Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-6]: src/sys/dev/pckbc resolve 1.6 pullup ticket #17 from martin.
details: https://anonhg.NetBSD.org/src/rev/ad9ff6390f82
branches: netbsd-1-6
changeset: 527536:ad9ff6390f82
user: perry <perry%NetBSD.org@localhost>
date: Fri May 24 22:49:08 2002 +0000
description:
resolve 1.6 pullup ticket #17 from martin.
pulls up version 1.5
Original commit message:
> When using standard (no scroll wheel) protocol, ignore garbage between
> two packets (just like the old psm.c driver did). And don't insist on the
> first byte having bit 0x08 set.
>
> This makes some odd trackball device work.
>
> Thanks to Tyler Mitchell for reporting and testing.
diffstat:
sys/dev/pckbc/pms.c | 30 +++++++++++++++++++++++++-----
1 files changed, 25 insertions(+), 5 deletions(-)
diffs (86 lines):
diff -r d64386115529 -r ad9ff6390f82 sys/dev/pckbc/pms.c
--- a/sys/dev/pckbc/pms.c Fri May 24 22:37:40 2002 +0000
+++ b/sys/dev/pckbc/pms.c Fri May 24 22:49:08 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pms.c,v 1.4 2002/05/17 22:49:48 martin Exp $ */
+/* $NetBSD: pms.c,v 1.4.2.1 2002/05/24 22:49:08 perry Exp $ */
/*-
* Copyright (c) 1994 Charles M. Hannum.
@@ -24,7 +24,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pms.c,v 1.4 2002/05/17 22:49:48 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pms.c,v 1.4.2.1 2002/05/24 22:49:08 perry Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -75,7 +75,13 @@
#ifndef PMS_DISABLE_POWERHOOK
void *sc_powerhook; /* cookie from power hook */
#endif /* !PMS_DISABLE_POWERHOOK */
- int inputstate;
+ /*
+ * Some devices (trackballs) seem to use the standard 3 byte protocol,
+ * but send arbitrary (uninterpreted) bytes following the packet.
+ * We set inputstate to -1 to indicate we are looking for a start
+ * of packet (and discard input in this state).
+ */
+ int inputstate; /* number of bytes received for this packet */
u_int buttons; /* mouse button status */
enum pms_type protocol;
unsigned char packet[4];
@@ -269,6 +275,8 @@
sc->protocol = pms_protocol(sc->sc_kbctag, sc->sc_kbcslot);
DPRINTF(("pms_enable: using %s protocol\n",
pms_protocols[sc->protocol].name));
+ if (sc->protocol == PMS_STANDARD)
+ sc->inputstate = -1; /* need to sync */
#if 0
{
u_char scmd[2];
@@ -468,7 +476,7 @@
}
microtime(&sc->current);
- if (sc->inputstate != 0) {
+ if (sc->inputstate > 0) {
struct timeval diff;
timersub(&sc->current, &sc->last, &diff);
@@ -495,6 +503,13 @@
}
}
sc->last = sc->current;
+
+ if (sc->inputstate < 0) {
+ if ((data & 0xc0) != 0)
+ return; /* not in sync yet, discard input */
+ sc->inputstate = 0;
+ }
+
sc->packet[sc->inputstate++] = data & 0xff;
switch (sc->inputstate) {
case 0:
@@ -502,6 +517,8 @@
break;
case 1:
+ if (sc->protocol == PMS_STANDARD)
+ break;
if (!(sc->packet[0] & 0x8)) {
DPRINTF(("pmsinput: 0x8 not set in first byte "
"[0x%02x], resetting\n", sc->packet[0]));
@@ -560,7 +577,10 @@
if (dy == -128)
dy = -127;
- sc->inputstate = 0;
+ if (sc->protocol == PMS_STANDARD)
+ sc->inputstate = -1; /* may need to sync again */
+ else
+ sc->inputstate = 0;
changed = (sc->buttons ^ newbuttons);
sc->buttons = newbuttons;
Home |
Main Index |
Thread Index |
Old Index