diff options
author | Jason Downs <downsj@cvs.openbsd.org> | 1996-10-13 00:55:51 +0000 |
---|---|---|
committer | Jason Downs <downsj@cvs.openbsd.org> | 1996-10-13 00:55:51 +0000 |
commit | cb87ad0a2e91f474ae7c5cef2d3d4db3c88c9d50 (patch) | |
tree | fb3fd2d35f4f63e4295737ece7ee2eb37037a50c /sys/arch/i386 | |
parent | 2791bcbb96fbc04f3d2cd70d211169ad78efaee9 (diff) |
provide split raw/cooked (translated) input modes. cooked mode is default,
raw mode is set by using an ioctl or opening minor dev 1.
MAKEDEV created pms0r with minor dev 1.
Diffstat (limited to 'sys/arch/i386')
-rw-r--r-- | sys/arch/i386/include/mouse.h | 4 | ||||
-rw-r--r-- | sys/arch/i386/isa/pms.c | 138 |
2 files changed, 99 insertions, 43 deletions
diff --git a/sys/arch/i386/include/mouse.h b/sys/arch/i386/include/mouse.h index 2d4a16c27d7..6ed881d6cea 100644 --- a/sys/arch/i386/include/mouse.h +++ b/sys/arch/i386/include/mouse.h @@ -1,6 +1,8 @@ +/* $OpenBSD: mouse.h,v 1.2 1996/10/13 00:55:50 downsj Exp $ */ /* $NetBSD: mouse.h,v 1.4 1994/10/27 04:16:10 cgd Exp $ */ /*- + * Copyright (c) 1996, Jason Downs. * Copyright (c) 1992, 1993 Erik Forsberg. * All rights reserved. * @@ -45,5 +47,7 @@ struct mouseinfo { #define MOUSEIOC ('M'<<8) #define MOUSEIOCREAD (MOUSEIOC|60) +#define MOUSEIOCSRAW (MOUSEIOC|61) +#define MOUSEIOCSCOOKED (MOUSEIOC|62) #endif /* !_I386_MOUSE_H_ */ diff --git a/sys/arch/i386/isa/pms.c b/sys/arch/i386/isa/pms.c index 6dafcc4512d..eccfe6671c1 100644 --- a/sys/arch/i386/isa/pms.c +++ b/sys/arch/i386/isa/pms.c @@ -1,7 +1,8 @@ -/* $OpenBSD: pms.c,v 1.10 1996/08/17 05:57:23 deraadt Exp $ */ +/* $OpenBSD: pms.c,v 1.11 1996/10/13 00:55:49 downsj Exp $ */ /* $NetBSD: pms.c,v 1.29 1996/05/12 23:12:42 mycroft Exp $ */ /*- + * Copyright (c) 1996, Jason Downs. * Copyright (c) 1994 Charles Hannum. * Copyright (c) 1992, 1993 Erik Forsberg. * All rights reserved. @@ -99,6 +100,8 @@ struct pms_softc { /* driver status information */ u_char sc_state; /* mouse driver state */ #define PMS_OPEN 0x01 /* device is open */ #define PMS_ASLP 0x02 /* waiting for mouse data */ + u_char sc_flags; /* mouse driver flags */ +#define PMS_RAW 0x01 /* device is in raw mode */ u_char sc_status; /* mouse button status */ int sc_x, sc_y; /* accumulated motion in the X,Y axis */ }; @@ -115,7 +118,8 @@ struct cfdriver pms_cd = { NULL, "pms", DV_TTY }; -#define PMSUNIT(dev) (minor(dev)) +#define PMSUNIT(dev) (minor(dev) / 2) +#define PMSTYPE(dev) (minor(dev) % 2) static __inline void pms_flush __P((void)); static __inline void pms_dev_cmd __P((u_char)); @@ -246,6 +250,7 @@ pmsopen(dev, flag, mode, p) sc->sc_state |= PMS_OPEN; sc->sc_status = 0; + sc->sc_flags = (PMSTYPE(dev) ? PMS_RAW : 0); sc->sc_x = sc->sc_y = 0; /* Enable interrupts. */ @@ -377,7 +382,12 @@ pmsioctl(dev, cmd, addr, flag, p) splx(s); error = copyout(&info, addr, sizeof(struct mouseinfo)); break; - + case MOUSEIOCSRAW: + sc->sc_flags |= PMS_RAW; + break; + case MOUSEIOCSCOOKED: + sc->sc_flags &= ~PMS_RAW; + break; default: error = EINVAL; break; @@ -408,51 +418,93 @@ pmsintr(arg) return 0; } - switch (state) { - - case 0: - buttons = inb(PMS_DATA); - if ((buttons & 0xc0) == 0) + if (!(sc->sc_flags & PMS_RAW)) { + switch (state) { + case 0: + buttons = inb(PMS_DATA); + if ((buttons & 0xc0) == 0) + ++state; + break; + case 1: + dx = inb(PMS_DATA); + /* Bounding at -127 avoids a bug in XFree86. */ + dx = (dx == -128) ? -127 : dx; ++state; - break; - - case 1: - dx = inb(PMS_DATA); - /* Bounding at -127 avoids a bug in XFree86. */ - dx = (dx == -128) ? -127 : dx; - ++state; - break; + break; + case 2: + dy = inb(PMS_DATA); + dy = (dy == -128) ? -127 : dy; + state = 0; + + buttons = ((buttons & PS2LBUTMASK) << 2) | + ((buttons & (PS2RBUTMASK | PS2MBUTMASK)) >> 1); + changed = ((buttons ^ sc->sc_status) & BUTSTATMASK) << 3; + sc->sc_status = buttons | (sc->sc_status & ~BUTSTATMASK) | changed; + + if (dx || dy || changed) { + /* Update accumulated movements. */ + sc->sc_x += dx; + sc->sc_y += dy; + + /* Add this event to the queue. */ + buffer[0] = 0x80 | (buttons ^ BUTSTATMASK); + buffer[1] = dx; + buffer[2] = dy; + buffer[3] = buffer[4] = 0; + (void) b_to_q(buffer, sizeof buffer, &sc->sc_q); + + if (sc->sc_state & PMS_ASLP) { + sc->sc_state &= ~PMS_ASLP; + wakeup((caddr_t)sc); + } + selwakeup(&sc->sc_rsel); + } - case 2: - dy = inb(PMS_DATA); - dy = (dy == -128) ? -127 : dy; - state = 0; - - buttons = ((buttons & PS2LBUTMASK) << 2) | - ((buttons & (PS2RBUTMASK | PS2MBUTMASK)) >> 1); - changed = ((buttons ^ sc->sc_status) & BUTSTATMASK) << 3; - sc->sc_status = buttons | (sc->sc_status & ~BUTSTATMASK) | changed; - - if (dx || dy || changed) { - /* Update accumulated movements. */ - sc->sc_x += dx; - sc->sc_y += dy; - - /* Add this event to the queue. */ - buffer[0] = 0x80 | (buttons ^ BUTSTATMASK); - buffer[1] = dx; - buffer[2] = dy; - buffer[3] = buffer[4] = 0; - (void) b_to_q(buffer, sizeof buffer, &sc->sc_q); - - if (sc->sc_state & PMS_ASLP) { - sc->sc_state &= ~PMS_ASLP; - wakeup((caddr_t)sc); + break; + } + } else { + /* read data port */ + buffer[0] = inb(PMS_DATA); + + /* emulate old state machine for the ioctl's sake. */ + switch (state) { + case 0: + buttons = buffer[0]; + if ((buttons & 0xc0) == 0) + ++state; + break; + case 1: + dx = buffer[0]; + /* Bounding at -127 avoids a bug in XFree86. */ + dx = (dx == -128) ? -127 : dx; + ++state; + break; + case 2: + dy = buffer[0]; + dy = (dy == -128) ? -127 : dy; + state = 0; + + buttons = ((buttons & PS2LBUTMASK) << 2) | + ((buttons & (PS2RBUTMASK | PS2MBUTMASK)) >> 1); + changed = ((buttons ^ sc->sc_status) & BUTSTATMASK) << 3; + sc->sc_status = buttons | (sc->sc_status & ~BUTSTATMASK) | changed; + + if (dx || dy || changed) { + /* Update accumulated movements. */ + sc->sc_x += dx; + sc->sc_y += dy; } - selwakeup(&sc->sc_rsel); + break; } - break; + /* add raw data to the queue. */ + (void) b_to_q(buffer, 1, &sc->sc_q); + + if (sc->sc_state & PMS_ASLP) { + sc->sc_state &= ~PMS_ASLP; + wakeup((caddr_t)sc); + } + selwakeup(&sc->sc_rsel); } return -1; |