summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2012-11-25 22:37:53 +0100
committercinap_lenrek <cinap_lenrek@gmx.de>2012-11-25 22:37:53 +0100
commit4260392749bb9f1092c537a3e02c720e4e43f31e (patch)
tree599838d85c8624ed481e5e198928f113d8eb6a2b
parentffa54947bc52cf9a09d3cee9780e6858792a8b9b (diff)
nusb/kb: skip 0x01 lead byte hack, you dont wanna know
apparently, some mouse send constant 0x01 byte before normal 4 byte mouse packet. this is known in openbsd/freebsd as UQ_MS_LEADING_BYTE quirk.
-rw-r--r--sys/src/cmd/nusb/kb/kb.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/sys/src/cmd/nusb/kb/kb.c b/sys/src/cmd/nusb/kb/kb.c
index 1a4634377..643078ef1 100644
--- a/sys/src/cmd/nusb/kb/kb.c
+++ b/sys/src/cmd/nusb/kb/kb.c
@@ -226,12 +226,13 @@ static void
ptrwork(void* a)
{
static char maptab[] = {0x0, 0x1, 0x4, 0x5, 0x2, 0x3, 0x6, 0x7};
- int x, y, b, c, nerrs;
+ int x, y, b, c, nerrs, skiplead;
char err[ERRMAX], buf[64];
char mbuf[80];
KDev* f = a;
sethipri();
+ skiplead = -1;
nerrs = 0;
for(;;){
if(f->ep == nil)
@@ -256,6 +257,21 @@ ptrwork(void* a)
nerrs = 0;
if(c < 3)
continue;
+
+ if(c > 4){
+ /*
+ * horrible horrible hack. some mouse send a
+ * constant 0x01 lead byte. stop the hack as
+ * soon as buf[0] changes.
+ */
+ if(skiplead == -1)
+ skiplead = buf[0] & 0xFF;
+ if(skiplead == 0x01 && skiplead == buf[0])
+ memmove(buf, buf+1, --c);
+ else
+ skiplead = 0;
+ }
+
if(f->accel){
x = scale(f, buf[1]);
y = scale(f, buf[2]);