Detection of mouse packet did not work with my mouse. It only sends 6 bytes

instead of the 8 defined by struct dt_locator_msg.  Change the dectection
so we swap the mouse/keyboard addresses only if the packets don't match
what's expected (rather than on every packet).  My mouse now works, and
if a different mouse sends an 8 byte packet, it should also work.
This commit is contained in:
mhitch 2005-01-15 05:24:30 +00:00
parent 14eae77d98
commit 3eeb49f1f2
1 changed files with 22 additions and 27 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: dt.c,v 1.3 2003/12/23 09:39:46 ad Exp $ */
/* $NetBSD: dt.c,v 1.4 2005/01/15 05:24:30 mhitch Exp $ */
/*-
* Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
@ -140,7 +140,7 @@ SOFTWARE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: dt.c,v 1.3 2003/12/23 09:39:46 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: dt.c,v 1.4 2005/01/15 05:24:30 mhitch Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -326,26 +326,16 @@ dt_dispatch(void *cookie)
{
struct dt_softc *sc;
struct dt_msg *msg;
int s, other, mouse;
int s;
struct dt_device *dtdv;
sc = cookie;
msg = NULL;
other = DT_ADDR_KBD;
mouse = 0;
for (;;) {
s = spltty();
if (msg != NULL) {
if (msg != NULL)
SLIST_INSERT_HEAD(&sc->sc_free, msg, chain.slist);
if (mouse) {
dt_ms_addr = msg->src;
dt_kbd_addr = other;
} else {
dt_kbd_addr = msg->src;
dt_ms_addr = other;
}
}
msg = SIMPLEQ_FIRST(&sc->sc_queue);
if (msg != NULL)
SIMPLEQ_REMOVE_HEAD(&sc->sc_queue, chain.simpleq);
@ -353,11 +343,7 @@ dt_dispatch(void *cookie)
if (msg == NULL)
break;
if (msg->src == DT_ADDR_MOUSE)
other = DT_ADDR_KBD;
else if (msg->src == DT_ADDR_KBD)
other = DT_ADDR_MOUSE;
else {
if (msg->src != DT_ADDR_MOUSE && msg->src != DT_ADDR_KBD) {
printf("%s: message from unknown dev 0x%x\n",
sc->sc_dv.dv_xname, sc->sc_msg.src);
dt_msg_dump(msg);
@ -371,20 +357,29 @@ dt_dispatch(void *cookie)
}
/*
* 1. Mouse should have no more than eight buttons.
* 1. Mouse should have no more than eight buttons, so first
* 8 bits of body will be zero.
* 2. Mouse should always send full locator report.
* Note: my mouse does not send 'z' data, so the size
* did not match the size of struct dt_locator_msg - mhitch
* 3. Keyboard should never report all-up (0x00) in
* a packet with size > 1.
*/
if (DT_CTL_LEN(msg->ctl) == sizeof(struct dt_locator_msg) &&
msg->body[0] == 0) {
mouse = 1;
dtdv = &dt_ms_dv;
} else {
mouse = 0;
dtdv = &dt_kbd_dv;
if (DT_CTL_LEN(msg->ctl) >= 6 &&
msg->body[0] == 0 && msg->src != dt_ms_addr) {
dt_kbd_addr = dt_ms_addr;
dt_ms_addr = msg->src;
} else if (DT_CTL_LEN(msg->ctl) < 6 && msg->body[0] != 0 &&
msg->src != dt_kbd_addr) {
dt_ms_addr = dt_kbd_addr;
dt_kbd_addr = msg->src;
}
if (msg->src == dt_kbd_addr)
dtdv = &dt_kbd_dv;
else
dtdv = &dt_ms_dv;
if (dtdv->dtdv_handler != NULL)
(*dtdv->dtdv_handler)(dtdv->dtdv_dv, msg);
}