shithub: riscv

Download patch

ref: bfe852b3a29799c8810c735acbeba907f02881f2
parent: 2012ba4d03039597b4eb7ad2174949ab666105f1
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Sat Aug 10 04:47:43 EDT 2013

nusb/kb: *really* only send to mousein when mouse state actually changes (zero detlas, same buttons)

--- a/sys/src/cmd/nusb/kb/kb.c
+++ b/sys/src/cmd/nusb/kb/kb.c
@@ -459,7 +459,7 @@
 {
 	char	err[ERRMAX];
 	char	mbuf[80];
-	int	c, b, nerrs;
+	int	c, b, nerrs, lastb;
 	KDev*	f = a;
 	Ptr	p;
 
@@ -467,6 +467,7 @@
 	sethipri();
 
 	memset(&p, 0, sizeof(p));
+	lastb = 0;
 
 	nerrs = 0;
 	for(;;){
@@ -507,6 +508,10 @@
 			b |= 4;
 		if(p.z != 0)
 			b |= (p.z > 0) ? 8 : 16;
+
+		if(p.x == 0 && p.y == 0 && p.z == 0 && b == lastb)
+			continue;
+		lastb = b;
 
 		seprint(mbuf, mbuf+sizeof(mbuf), "m%11d %11d %11d", p.x, p.y, b);
 		if(write(f->infd, mbuf, strlen(mbuf)) < 0)
--