ref: 9b012b437445ad722d7b2c0fbc88fd04b4eb0ac2
parent: 90506cfeed5aedc3799a60ef0248ce6857970082
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Sat Aug 10 03:59:54 EDT 2013
nusb/kb: only send to mousein when mouse state actually changes
--- a/sys/src/cmd/nusb/kb/kb.c
+++ b/sys/src/cmd/nusb/kb/kb.c
@@ -460,6 +460,7 @@
char err[ERRMAX];
char mbuf[80];
int c, b, nerrs;
+ int lastx, lasty, lastb;
KDev* f = a;
Ptr p;
@@ -467,6 +468,7 @@
sethipri();
memset(&p, 0, sizeof(p));
+ lastx = lasty = lastb = 0;
nerrs = 0;
for(;;){@@ -508,7 +510,14 @@
if(p.z != 0)
b |= (p.z > 0) ? 8 : 16;
- seprint(mbuf, mbuf+sizeof(mbuf), "m%11d %11d %11d", p.x, p.y, b);
+ if(lastx == p.x && lasty == p.y && lastb == b)
+ continue;
+
+ lastx = p.x;
+ lasty = p.y;
+ lastb = b;
+
+ seprint(mbuf, mbuf+sizeof(mbuf), "m%11d %11d %11d", lastx, lasty, lastb);
if(write(f->infd, mbuf, strlen(mbuf)) < 0)
kbfatal(f, "mousein i/o");
}
--
⑨