diff options
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/amiga/amiga/autoconf.c | 3 | ||||
-rw-r--r-- | sys/arch/amiga/amiga/conf.c | 12 | ||||
-rw-r--r-- | sys/arch/amiga/conf/GENERIC | 3 | ||||
-rw-r--r-- | sys/arch/amiga/conf/files.amiga | 7 | ||||
-rw-r--r-- | sys/arch/amiga/dev/joy.c | 132 | ||||
-rw-r--r-- | sys/arch/amiga/include/conf.h | 4 | ||||
-rw-r--r-- | sys/arch/amiga/include/joystick.h | 12 |
7 files changed, 167 insertions, 6 deletions
diff --git a/sys/arch/amiga/amiga/autoconf.c b/sys/arch/amiga/amiga/autoconf.c index 3a1e9962a4c..64664d3b99c 100644 --- a/sys/arch/amiga/amiga/autoconf.c +++ b/sys/arch/amiga/amiga/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.12 1998/04/09 07:34:00 niklas Exp $ */ +/* $OpenBSD: autoconf.c,v 1.13 2000/09/02 13:45:38 espie Exp $ */ /* $NetBSD: autoconf.c,v 1.59 1998/01/15 21:55:51 is Exp $ */ /* @@ -271,6 +271,7 @@ mbattach(pdp, dp, auxp) } else #endif { + config_found(dp, "joy", simple_devprint); config_found(dp, "ser", simple_devprint); config_found(dp, "par", simple_devprint); config_found(dp, "kbd", simple_devprint); diff --git a/sys/arch/amiga/amiga/conf.c b/sys/arch/amiga/amiga/conf.c index 9332a08f9e4..fc6ee3feb29 100644 --- a/sys/arch/amiga/amiga/conf.c +++ b/sys/arch/amiga/amiga/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.26 1999/07/30 19:41:29 deraadt Exp $ */ +/* $OpenBSD: conf.c,v 1.27 2000/09/02 13:45:38 espie Exp $ */ /* $NetBSD: conf.c,v 1.42 1997/01/07 11:35:03 mrg Exp $ */ /*- @@ -108,6 +108,14 @@ dev_decl(filedesc,open); #include "audio.h" cdev_decl(audio); +/* open, close, read */ +#define cdev_joy_init(c,n) { \ + dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \ + (dev_type_write((*)))enodev, (dev_type_ioctl((*)))enodev, \ + (dev_type_stop((*)))enodev, 0, seltrue, \ + (dev_type_mmap((*)))enodev } + + struct cdevsw cdevsw[] = { cdev_cn_init(1,cn), /* 0: virtual console */ @@ -153,7 +161,7 @@ struct cdevsw cdevsw[] = cdev_ch_init(NCH,ch), /* 40: SCSI autochanger */ cdev_disk_init(NRD,rd), /* 41: RAM disk */ cdev_ksyms_init(NKSYMS,ksyms), /* 42: Kernel symbols device */ - cdev_notdef(), /* 43 */ + cdev_joy_init(1,joy), /* 43: Joystick */ cdev_notdef(), /* 44 */ cdev_notdef(), /* 45 */ cdev_notdef(), /* 46 */ diff --git a/sys/arch/amiga/conf/GENERIC b/sys/arch/amiga/conf/GENERIC index 06eb6c7620a..5c10bd268a4 100644 --- a/sys/arch/amiga/conf/GENERIC +++ b/sys/arch/amiga/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.31 2000/07/20 15:28:52 espie Exp $ +# $OpenBSD: GENERIC,v 1.32 2000/09/02 13:45:39 espie Exp $ # $NetBSD: GENERIC,v 1.85 1997/08/27 19:32:49 is Exp $ # @@ -149,6 +149,7 @@ com* at drsupio? port ? # DraCo serial a2kbbc0 at mainbus0 # A2000 battery backed clock a34kbbc0 at mainbus0 # A3000/A4000 battery backed clock +joy0 at mainbus0 aucc* at mainbus0 # Amiga CC audio audio* at aucc? diff --git a/sys/arch/amiga/conf/files.amiga b/sys/arch/amiga/conf/files.amiga index c3b81dfec9f..4cef7ce777d 100644 --- a/sys/arch/amiga/conf/files.amiga +++ b/sys/arch/amiga/conf/files.amiga @@ -1,4 +1,4 @@ -# $OpenBSD: files.amiga,v 1.37 2000/06/05 16:37:17 art Exp $ +# $OpenBSD: files.amiga,v 1.38 2000/09/02 13:45:39 espie Exp $ # $NetBSD: files.amiga,v 1.62 1997/08/27 19:32:47 is Exp $ @@ -26,6 +26,11 @@ attach clock at mainbus file arch/amiga/dev/clock.c file dev/clock_subr.c +# joystick +device joy +attach joy at mainbus +file arch/amiga/dev/joy.c joy + # A2000 internal hwc device a2kbbc attach a2kbbc at mainbus diff --git a/sys/arch/amiga/dev/joy.c b/sys/arch/amiga/dev/joy.c new file mode 100644 index 00000000000..a37ddce8e25 --- /dev/null +++ b/sys/arch/amiga/dev/joy.c @@ -0,0 +1,132 @@ +/* $OpenBSD: joy.c,v 1.1 2000/09/02 13:45:40 espie Exp $ */ + +/* + * Copyright (c) 2000 Marc Espie. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD + * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/param.h> +#include <sys/kernel.h> +#include <sys/device.h> +#include <sys/systm.h> +#include <machine/joystick.h> +#include <sys/conf.h> +#include <machine/conf.h> +#include <amiga/amiga/device.h> +#include <amiga/amiga/custom.h> +#include <amiga/amiga/cia.h> + + + +int joymatch __P((struct device *, void *, void *)); +void joyattach __P((struct device *, struct device *, void *)); + +struct cfattach joy_ca = { + sizeof(struct device), joymatch, joyattach +}; + +struct cfdriver joy_cd = { + NULL, "joy", DV_DULL, NULL, 0 }; + + +/* + * We assume the joysticks are always there. + * They share the mouse ports, and there is no way to + * distinguish what is connected. So what ? + */ +int +joymatch(pdp, match, auxp) + struct device *pdp; + void *match, *auxp; +{ + if (matchname("joy", auxp)) + return(1); + return(0); +} + +void +joyattach(pdp, dp, auxp) + struct device *pdp, *dp; + void *auxp; +{ + printf(": 2 ports\n"); +} + +int +joyopen(dev, flags, mode, p) + dev_t dev; + int flags, mode; + struct proc *p; +{ + int unit = minor(dev); + if (unit == 0 || unit == 1) + return(0); + else + return(ENXIO); +} + +int +joyclose(dev, flags, mode, p) + dev_t dev; + int flags, mode; + struct proc *p; +{ + return(0); +} + +int +joyread(dev, uio, flags) + dev_t dev; + struct uio *uio; + int flags; +{ + int unit = minor(dev); + unsigned short w, x; + unsigned char r; + + r = JOYSTICK_NONE; + + if (unit == 0) { + w = custom.joy0dat; + if ((ciaa.pra & 64) == 0) + r = JOYSTICK_FIRE; + } else { + w = custom.joy1dat; + if ((ciaa.pra & 128) == 0) + r = JOYSTICK_FIRE; + } + + + x = (w>>1) ^ w; + + if (w & 2) + r |= JOYSTICK_RIGHT; + if (x & 1) + r |= JOYSTICK_DOWN; + if (w & 512) + r |= JOYSTICK_LEFT; + if (x & 256) + r |= JOYSTICK_UP; + + return uiomove((caddr_t)&r, 1, uio); +} diff --git a/sys/arch/amiga/include/conf.h b/sys/arch/amiga/include/conf.h index 593d93bd001..3b0f2a76fad 100644 --- a/sys/arch/amiga/include/conf.h +++ b/sys/arch/amiga/include/conf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.h,v 1.11 1999/07/30 20:19:04 deraadt Exp $ */ +/* $OpenBSD: conf.h,v 1.12 2000/09/02 13:45:40 espie Exp $ */ /* $NetBSD: conf.h,v 1.4 1996/11/30 01:13:07 is Exp $ */ /* @@ -74,6 +74,8 @@ cdev_decl(wd); cdev_decl(ksyms); +cdev_decl(joy); + /* open, close, ioctl, select, mmap -- XXX should be a map device */ #define cdev_grf_init(c,n) { \ dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) nullop, \ diff --git a/sys/arch/amiga/include/joystick.h b/sys/arch/amiga/include/joystick.h new file mode 100644 index 00000000000..faafcd0d0d6 --- /dev/null +++ b/sys/arch/amiga/include/joystick.h @@ -0,0 +1,12 @@ +/* $OpenBSD: joystick.h,v 1.1 2000/09/02 13:45:40 espie Exp $ */ +#ifndef _AMIGA_JOYSTICK_H +#define _AMIGA_JOYSTICK_H + +#define JOYSTICK_NONE 0 +#define JOYSTICK_RIGHT 1 +#define JOYSTICK_DOWN 2 +#define JOYSTICK_LEFT 4 +#define JOYSTICK_UP 8 +#define JOYSTICK_FIRE 16 + +#endif |