Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/adb actually support EMP
details: https://anonhg.NetBSD.org/src/rev/506f92078fc7
branches: trunk
changeset: 803452:506f92078fc7
user: macallan <macallan%NetBSD.org@localhost>
date: Wed Oct 29 00:48:12 2014 +0000
description:
actually support EMP
( as in, look for additional motion info bits, not just buttons )
diffstat:
sys/dev/adb/adb_ms.c | 38 ++++++++++++++++++++++++++++++++++----
1 files changed, 34 insertions(+), 4 deletions(-)
diffs (59 lines):
diff -r 090c54333c9e -r 506f92078fc7 sys/dev/adb/adb_ms.c
--- a/sys/dev/adb/adb_ms.c Tue Oct 28 23:48:03 2014 +0000
+++ b/sys/dev/adb/adb_ms.c Wed Oct 29 00:48:12 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: adb_ms.c,v 1.15 2013/11/18 11:02:34 nisimura Exp $ */
+/* $NetBSD: adb_ms.c,v 1.16 2014/10/29 00:48:12 macallan Exp $ */
/*
* Copyright (C) 1998 Colin Wood
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: adb_ms.c,v 1.15 2013/11/18 11:02:34 nisimura Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adb_ms.c,v 1.16 2014/10/29 00:48:12 macallan Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -564,8 +564,38 @@
break;
}
- dx = ((int)(buffer[1] & 0x3f)) - ((buffer[1] & 0x40) ? 64 : 0);
- dy = ((int)(buffer[0] & 0x3f)) - ((buffer[0] & 0x40) ? 64 : 0);
+ if (sc->sc_adbdev->handler_id != ADBMS_EXTENDED) {
+ dx = ((int)(buffer[1] & 0x3f)) - ((buffer[1] & 0x40) ? 64 : 0);
+ dy = ((int)(buffer[0] & 0x3f)) - ((buffer[0] & 0x40) ? 64 : 0);
+ } else {
+ /* EMP crap, additional motion bits */
+ int shift = 7, ddx, ddy, sign, smask;
+
+#ifdef ADBMS_DEBUG
+ printf("EMP packet:");
+ for (i = 0; i < len; i++)
+ printf(" %02x", buffer[i]);
+ printf("\n");
+#endif
+ dx = (int)buffer[1] & 0x7f;
+ dy = (int)buffer[0] & 0x7f;
+ for (i = 2; i < len; i++) {
+ ddx = (buffer[i] & 0x07);
+ ddy = (buffer[i] & 0x70) >> 4;
+ dx |= (ddx << shift);
+ dy |= (ddy << shift);
+ shift += 3;
+ }
+ sign = 1 << (shift - 1);
+ smask = 0xffffffff << shift;
+ if (dx & sign)
+ dx |= smask;
+ if (dy & sign)
+ dy |= smask;
+#ifdef ADBMS_DEBUG
+ printf("%d %d %08x %d\n", dx, dy, smask, shift);
+#endif
+ }
if (sc->sc_class == MSCLASS_TRACKPAD) {
Home |
Main Index |
Thread Index |
Old Index