From 41641016c7b0c5cedb23ad6def5d45e8c4638181 Mon Sep 17 00:00:00 2001 From: Matthieu Herrb Date: Sun, 28 Nov 2004 15:43:44 +0000 Subject: Prevent ADB devices other than mices of generating "extended" protocol events. This fixes a problem with some iBooks were the touchpad generates a button6 event everytime the pad is touched. Based on my observations and a similar patch from Aymeric Vincent for NetBSD. Enhancements and ok miod@ --- sys/arch/macppc/dev/ams.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'sys/arch/macppc/dev') diff --git a/sys/arch/macppc/dev/ams.c b/sys/arch/macppc/dev/ams.c index fab8a53ef9f..033c5c60141 100644 --- a/sys/arch/macppc/dev/ams.c +++ b/sys/arch/macppc/dev/ams.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ams.c,v 1.8 2003/10/16 03:54:48 deraadt Exp $ */ +/* $OpenBSD: ams.c,v 1.9 2004/11/28 15:43:43 matthieu Exp $ */ /* $NetBSD: ams.c,v 1.11 2000/12/19 03:13:40 tsubai Exp $ */ /* @@ -490,17 +490,18 @@ ms_processevent(adb_event_t *event, struct ams_softc *sc) buttons |= button_bit; else buttons &= ~button_bit; - /* Extended Protocol (up to 6 more buttons) */ - for (mask = 0x80; i < max_byte; - i += (mask == 0x80), button_bit <<= 1) { - /* 0 when button down */ - if (!(event->bytes[i] & mask)) - buttons |= button_bit; - else - buttons &= ~button_bit; - mask = ((mask >> 4) & 0xf) - | ((mask & 0xf) << 4); - } + if (sc->sc_class == MSCLASS_MOUSE) + /* Extended Protocol (up to 6 more buttons) */ + for (mask = 0x80; i < max_byte; + i += (mask == 0x80), button_bit <<= 1) { + /* 0 when button down */ + if (!(event->bytes[i] & mask)) + buttons |= button_bit; + else + buttons &= ~button_bit; + mask = ((mask >> 4) & 0xf) + | ((mask & 0xf) << 4); + } break; } new_event.u.m.buttons = sc->sc_mb | buttons; -- cgit v1.2.3