9front - general discussion about 9front
 help / color / mirror / Atom feed
* [PATCH] nusb/kb: Elecom HUGE quirks
@ 2020-05-07 14:23 kvik
  2020-05-08 16:07 ` [9front] " cinap_lenrek
  0 siblings, 1 reply; 2+ messages in thread
From: kvik @ 2020-05-07 14:23 UTC (permalink / raw)
  To: 9front

As said in the 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 report fixup is adapted from the Linux kernel:
	linux/drivers/hid/hid-elecom.c
which contains a more detailed comment about why and how this
works.  Should this be mentioned in a comment as well or is it
enough to do so in a commit message?

Pending OK to commit.

diff -r 0afc08d69aef sys/src/cmd/nusb/kb/kb.c
--- a/sys/src/cmd/nusb/kb/kb.c	Wed May 06 15:39:12 2020 -0700
+++ b/sys/src/cmd/nusb/kb/kb.c	Thu May 07 16:05:19 2020 +0200
@@ -836,6 +836,33 @@
 }
 
 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)
 {
 	Hiddev *f;
@@ -858,6 +885,7 @@
 		fprint(2, "%s: %s: opendevdata: %r\n", argv0, f->ep->dir);
 		goto Err;
 	}
+	quirks(f);
 	procrfork(readerproc, f, Stack, RFNOTEG);
 	return;
 Err:


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [9front] [PATCH] nusb/kb: Elecom HUGE quirks
  2020-05-07 14:23 [PATCH] nusb/kb: Elecom HUGE quirks kvik
@ 2020-05-08 16:07 ` cinap_lenrek
  0 siblings, 0 replies; 2+ messages in thread
From: cinap_lenrek @ 2020-05-08 16:07 UTC (permalink / raw)
  To: 9front

looks good to me.

--
cinap


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-08 16:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-07 14:23 [PATCH] nusb/kb: Elecom HUGE quirks kvik
2020-05-08 16:07 ` [9front] " cinap_lenrek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).