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.
This commit is contained in:
cinap_lenrek 2012-11-25 22:37:53 +01:00
parent ffa54947bc
commit 4260392749

View file

@ -226,12 +226,13 @@ static void
ptrwork(void* a) ptrwork(void* a)
{ {
static char maptab[] = {0x0, 0x1, 0x4, 0x5, 0x2, 0x3, 0x6, 0x7}; 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 err[ERRMAX], buf[64];
char mbuf[80]; char mbuf[80];
KDev* f = a; KDev* f = a;
sethipri(); sethipri();
skiplead = -1;
nerrs = 0; nerrs = 0;
for(;;){ for(;;){
if(f->ep == nil) if(f->ep == nil)
@ -256,6 +257,21 @@ ptrwork(void* a)
nerrs = 0; nerrs = 0;
if(c < 3) if(c < 3)
continue; 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){ if(f->accel){
x = scale(f, buf[1]); x = scale(f, buf[1]);
y = scale(f, buf[2]); y = scale(f, buf[2]);