shithub: riscv

Download patch

ref: 07805ac8927ca8034a2e1bc39ef1b6a20f80806c
parent: 3d9abd96aea42e7e1134e0f241cb57275a29bc71
author: Sigrid <ftrvxmtrx@gmail.com>
date: Tue Dec 8 06:47:15 EST 2020

nusb/kb: update button state if event was actually received, fix typos (thanks umbraticus)

--- a/sys/src/cmd/nusb/kb/kb.c
+++ b/sys/src/cmd/nusb/kb/kb.c
@@ -637,7 +637,7 @@
 			s->h = v;
 			break;
 
-		case 0x0D0051:	/* Conteact identifier */
+		case 0x0D0051:	/* Contact identifier */
 			s->id = v;
 			break;
 
@@ -684,7 +684,7 @@
 {
 	char	err[ERRMAX], mbuf[80];
 	uchar	lastk[64], uk, dk;
-	int	i, c, nerrs, lastb, nlastk;
+	int	i, c, nerrs, bpress, lastb, nlastk;
 	int	abs, x, y, z, b;
 	Hidreport p;
 	Hidslot lasts[nelem(p.s)], *s, *l;
@@ -774,7 +774,7 @@
 			continue;
 
 		/* combine all the slots */
-		abs = x = y = z = b = 0;
+		bpress = abs = x = y = z = b = 0;
 		for(i=0; i<p.ns; *l = *s, i++){
 			s = &p.s[i];
 
@@ -785,7 +785,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;
@@ -808,6 +808,7 @@
 				b |= 2;
 			if(s->b & 2)
 				b |= 4;
+			bpress |= s->m;
 
 			/* X/Y are absolute? */
 			if((s->abs & 3) == 3){
@@ -825,7 +826,9 @@
 				y += s->y;
 			}
 		}
-	
+
+		if(bpress == 0)
+			b = lastb & 7;
 		if(z != 0)
 			b |= z > 0 ? 8 : 16;