]> git.lizzy.rs Git - plan9front.git/commitdiff
nusb/kb: add quirks for Elecom HUGE trackball
authorkvik <kvik@a-b.xyz>
Fri, 8 May 2020 18:49:11 +0000 (20:49 +0200)
committerkvik <kvik@a-b.xyz>
Fri, 8 May 2020 18:49:11 +0000 (20:49 +0200)
As said in the code comment:

Elecom trackball report descriptor lies by
omission, failing to mention all its buttons.
We patch the descriptor with a correct count
which lets us parse full reports. Tested with:
Elecom HUGE (M-HT1DRBK, M-HT1URBK)

The descriptor fixup is adapted from Linux kernel:
drivers/hid/hid-elecom.c
in which a more detailed account of why and how this
works may be found.

A followup change to nusb/kb will be needed to expose
these additional events for potential remapping.

sys/src/cmd/nusb/kb/kb.c

index 8d481aaee52e4df2fda57a8747bbf9acd8b2efc1..3e2913e34dc947be85e5b6acbf4196e0d84672b0 100644 (file)
@@ -835,6 +835,33 @@ readerproc(void* a)
        }
 }
 
+static void
+quirks(Hiddev *f)
+{
+       Dev *d;
+       
+       d = f->dev;
+       
+       /* Elecom trackball report descriptor lies by
+        * omission, failing to mention all its buttons.
+        * We patch the descriptor with a correct count
+        * which lets us parse full reports. Tested with:
+        *   Elecom HUGE (M-HT1DRBK, M-HT1URBK) */
+       if(d->usb->vid == 0x056e && d->usb->did == 0x010c){
+               if(f->nrep < 32
+               || f->rep[12] != 0x95
+               || f->rep[14] != 0x75
+               || f->rep[15] != 0x01
+               || f->rep[20] != 0x29
+               || f->rep[30] != 0x75)
+               return;
+
+               f->rep[13] = 8;
+               f->rep[21] = 8;
+               f->rep[31] = 0;
+       }
+}
+
 static void
 hdsetup(Dev *d, Ep *ep)
 {
@@ -858,6 +885,7 @@ hdsetup(Dev *d, Ep *ep)
                fprint(2, "%s: %s: opendevdata: %r\n", argv0, f->ep->dir);
                goto Err;
        }
+       quirks(f);
        procrfork(readerproc, f, Stack, RFNOTEG);
        return;
 Err: