From b6700f4a6dad1f781af611627f1b245f0bfcb1f2 Mon Sep 17 00:00:00 2001 From: briggs Date: Sun, 26 May 1996 18:14:44 +0000 Subject: Sync with NetBSD-current. --- sys/arch/mac68k/dev/adb.c | 68 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 21 deletions(-) (limited to 'sys/arch/mac68k/dev/adb.c') diff --git a/sys/arch/mac68k/dev/adb.c b/sys/arch/mac68k/dev/adb.c index 8e75d7df8ab..44e1f721d58 100644 --- a/sys/arch/mac68k/dev/adb.c +++ b/sys/arch/mac68k/dev/adb.c @@ -1,4 +1,4 @@ -/* $NetBSD: adb.c,v 1.5 1995/11/01 04:40:21 briggs Exp $ */ +/* $NetBSD: adb.c,v 1.9 1996/05/05 16:21:20 briggs Exp $ */ /*- * Copyright (C) 1994 Bradley A. Grantham @@ -35,18 +35,22 @@ e* notice, this list of conditions and the following disclaimer in the #include #include #include +#include #include #include +#include #include #include "adbvar.h" +#include "itevar.h" #include "../mac68k/macrom.h" /* * Function declarations. */ -static void adbattach __P((struct device *parent, struct device *dev, void *aux)); +static int adbmatch __P((struct device *, void *, void *)); +static void adbattach __P((struct device *, struct device *, void *)); /* * Global variables. @@ -80,13 +84,23 @@ static int adb_rptinterval = 6; /* ticks between auto-repeat */ static int adb_repeating = -1; /* key that is auto-repeating */ static adb_event_t adb_rptevent;/* event to auto-repeat */ -extern int matchbyname(); +/* Driver definition. -- This should probably be a bus... */ +struct cfattach adb_ca = { + sizeof(struct device), adbmatch, adbattach +}; -/* Driver definition. */ -struct cfdriver adbcd = { - NULL, "adb", matchbyname, adbattach, DV_DULL, sizeof(struct device), +struct cfdriver adb_cd = { + NULL, "adb", DV_DULL }; +static int +adbmatch(pdp, match, auxp) + struct device *pdp; + void *match, *auxp; +{ + return 1; +} + static void adbattach(parent, dev, aux) struct device *parent, *dev; @@ -308,22 +322,34 @@ adb_processevent(event) */ max_byte = event->byte_count; button_bit = 1; - /* Classic Mouse Protocol (up to 2 buttons) */ - for (i = 0; i < 2; i++, button_bit <<= 1) - /* 0 when button down */ - if (!(event->bytes[i] & 0x80)) - 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; + switch (event->hand_id) { + case ADBMS_USPEED: + /* MicroSpeed mouse */ + if (max_byte == 4) + buttons = (~event->bytes[2]) & 0xff; else - buttons &= ~button_bit; - mask = ((mask >> 4) & 0xf) | ((mask & 0xf) << 4); + buttons = (event->bytes[0] & 0x80) ? 0 : 1; + break; + default: + /* Classic Mouse Protocol (up to 2 buttons) */ + for (i = 0; i < 2; i++, button_bit <<= 1) + /* 0 when button down */ + if (!(event->bytes[i] & 0x80)) + 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); + } + break; } new_event.u.m.buttons = adb_ms_buttons | buttons; new_event.u.m.dx = ((signed int) (event->bytes[1] & 0x3f)) - -- cgit v1.2.3