diff options
| author | cinap_lenrek <cinap_lenrek@gmx.de> | 2012-11-30 04:02:03 +0100 |
|---|---|---|
| committer | cinap_lenrek <cinap_lenrek@gmx.de> | 2012-11-30 04:02:03 +0100 |
| commit | 3f25f69718756a7a5f64acc35ac9478b5eb9cefd (patch) | |
| tree | 8ff291068093c351b5f8661c8f8bcc455384dee3 | |
| parent | 8b7897b57a0df3e2f6f50ae866f1ab829322387a (diff) | |
| download | plan9front-3f25f69718756a7a5f64acc35ac9478b5eb9cefd.tar.xz | |
nusb/kb: add support for evoluent vertical mouse
| -rw-r--r-- | sys/src/cmd/nusb/kb/kb.c | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/sys/src/cmd/nusb/kb/kb.c b/sys/src/cmd/nusb/kb/kb.c index 643078ef1..c5d59425e 100644 --- a/sys/src/cmd/nusb/kb/kb.c +++ b/sys/src/cmd/nusb/kb/kb.c @@ -222,11 +222,18 @@ sethipri(void) close(fd); } +static short +s16(void *p) +{ + uchar *b = p; + return b[0] | b[1]<<8; +} + static void ptrwork(void* a) { static char maptab[] = {0x0, 0x1, 0x4, 0x5, 0x2, 0x3, 0x6, 0x7}; - int x, y, b, c, nerrs, skiplead; + int x, y, z, b, c, nerrs, skiplead; char err[ERRMAX], buf[64]; char mbuf[80]; KDev* f = a; @@ -272,20 +279,27 @@ ptrwork(void* a) skiplead = 0; } - if(f->accel){ - x = scale(f, buf[1]); - y = scale(f, buf[2]); - }else{ + z = 0; + if(c == 6 && f->dev->usb->vid == 0x1a7c){ + /* Evoluent vertical mouse */ + x = s16(&buf[1]); + y = s16(&buf[3]); + z = buf[5]; + } else { x = buf[1]; y = buf[2]; + if(c > 3) + z = buf[3]; + } + if(f->accel){ + x = scale(f, x); + y = scale(f, y); } b = maptab[buf[0] & 0x7]; - if(c > 3 && buf[3] > 0){ /* up */ + if(z > 0) /* up */ b |= 0x08; - } - if(c > 3 && buf[3] < 0){ /* down */ + if(z < 0) /* down */ b |= 0x10; - } if(kbdebug > 1) fprint(2, "%s: m%11d %11d %11d\n", argv0, x, y, b); seprint(mbuf, mbuf+sizeof(mbuf), "m%11d %11d %11d", x, y,b); |
