9front - general discussion about 9front
 help / color / mirror / Atom feed
* nusb/kb screwing up trackball button state
@ 2020-11-08  5:18 umbraticus
  2020-11-08  5:29 ` [9front] " umbraticus
  0 siblings, 1 reply; 2+ messages in thread
From: umbraticus @ 2020-11-08  5:18 UTC (permalink / raw)
  To: 9front

diff -r eef7bc730924 sys/src/cmd/nusb/kb/kb.c
--- a/sys/src/cmd/nusb/kb/kb.c	Fri Nov 06 18:15:15 2020 -0800
+++ b/sys/src/cmd/nusb/kb/kb.c	Sun Nov 08 17:56:48 2020 +1300
@@ -65,6 +65,7 @@
 	int	y;
 	int	z;
 
+	int	binfo;
 	int	b;
 	int	m;
 
@@ -602,6 +603,7 @@
 		case 0x090008:
 			m = 1<<(l[Usage] - 0x090001);
 		Button:
+			s->binfo = 1;
 			s->m |= m;
 			s->b &= ~m;
 			if(v != 0)
@@ -629,7 +631,7 @@
 			s->h = v;
 			break;
 
-		case 0x0D0051:	/* Conteact identifier */
+		case 0x0D0051:	/* Contact identifier */
 			s->id = v;
 			break;
 
@@ -677,7 +679,7 @@
 	char	err[ERRMAX], mbuf[80];
 	uchar	lastk[64], uk, dk;
 	int	i, c, nerrs, lastb, nlastk;
-	int	abs, x, y, z, b;
+	int	abs, x, y, z, b, binfo;
 	Hidreport p;
 	Hidslot lasts[nelem(p.s)], *s, *l;
 	Hiddev *f = a;
@@ -766,7 +768,7 @@
 			continue;
 
 		/* combine all the slots */
-		abs = x = y = z = b = 0;
+		abs = x = y = z = b = binfo = 0;
 		for(i=0; i<p.ns; *l = *s, i++){
 			s = &p.s[i];
 
@@ -777,7 +779,7 @@
 			if(l == &lasts[nelem(lasts)-1] || !l->valid)
 				*l = *s;
 
-			/* convet absolute z to relative */
+			/* convert absolute z to relative */
 			z += s->z;
 			if(s->abs & 4)
 				z -= l->z;
@@ -795,8 +797,9 @@
 			}
 
 			/* map to mouse buttons */
-			b |= s->b & 1;
-			if(s->b & (4|8))
+			binfo |= s->binfo;
+			b |= s->b & ~6;
+			if(s->b & 4)
 				b |= 2;
 			if(s->b & 2)
 				b |= 4;
@@ -818,6 +821,7 @@
 			}
 		}
 	
+		if(binfo == 0) b = lastb;
 		if(z != 0)
 			b |= z > 0 ? 8 : 16;


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

end of thread, other threads:[~2020-11-08  5:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-08  5:18 nusb/kb screwing up trackball button state umbraticus
2020-11-08  5:29 ` [9front] " umbraticus

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).