Subject: MicroSpeed mouse fixes.
To: None <port-mac68k@NetBSD.ORG>
From: Taras Ivanenko <ivanenko@ctpa03.mit.edu>
List: port-mac68k
Date: 04/30/1996 12:18:40
I downloaded a bunch of ADB tools yesterday and cracked (partially)
MicroSpeed 3-button mouse protocol. It is as follows:
Setup:
The handler_id field for this mouse is 47. I took it as a
"signature" and use this number to distinguish that type of a mouse.
First send "listen 1" command with the data:
buffer[1] -- not significant (?), i put 0x3 there
buffer[2] -- speed, 00 is the default(?), 01 if the min
buffer[3] -- 0x10 , magic flag to enable extended protocol
buffer[4] -- first 4 bits = lock flags, if 1 the mouse sends the
button-down signal on the first click, button-up on the
second
last 4 bits = button enable bits. if 1, the button works.
After that the mouse return data in the form:
buffer[0] = 4 (bytes)
buffer[1], buffer[2] = as the standard mouse
buffer[3]==buffer[4] = 0xFF when no buttons are down. When the button
N is down, bit N is cleared.
So, here is the patch to implement this protocol. There are no changes
to ADB code, only some additions with comparasion devType==47.
I checked that this patch works for X.
Taras Ivanenko.
*** /usr/users/ivanenko/work/arch/mac68k/dev/adb.c Tue Apr 30 10:03:46 1996
--- arch/mac68k/dev/adb.c Tue Apr 30 09:44:29 1996
***************
*** 312,317 ****
--- 312,318 ----
*/
max_byte = event->byte_count;
button_bit = 1;
+ if(event->hand_id != 47) {
/* Classic Mouse Protocol (up to 2 buttons) */
for (i = 0; i < 2; i++, button_bit <<= 1)
/* 0 when button down */
***************
*** 329,334 ****
--- 330,343 ----
buttons &= ~button_bit;
mask = ((mask >> 4) & 0xf) | ((mask & 0xf) << 4);
}
+ } else {
+ /* MicroSpeed mouse */
+ if(max_byte==4) {
+ buttons = (~event->bytes[2])&0xFF;
+ } else {
+ buttons = (event->bytes[0]&0x80)?0:1;
+ }
+ }
new_event.u.m.buttons = adb_ms_buttons | buttons;
new_event.u.m.dx = ((signed int) (event->bytes[1] & 0x3f)) -
((event->bytes[1] & 0x40) ? 64 : 0);
*** /usr/users/ivanenko/work/arch/mac68k/dev/adbsys.c Tue Apr 30 10:03:57 1996
--- arch/mac68k/dev/adbsys.c Mon Apr 29 23:13:33 1996
***************
*** 107,112 ****
--- 113,139 ----
for (adbindex = 1; adbindex <= totaladbs; adbindex++) {
/* Get the ADB information */
adbaddr = GetIndADB(&adbdata, adbindex);
+ #if defined(MICROSPEED_MOUSE) || 1
+ if (adbdata.origADBAddr == ADBADDR_MS &&
+ (adbdata.devType == 47)) {
+ /* found MicroSpeed Mouse Deluxe Mac */
+ cmd = 0x39; /* listen 1 */
+
+ buffer[0]=4;
+ buffer[1]=0x03; /* ??? */
+ buffer[2]=0x00; /* speed = maximum */
+ buffer[3]=0x10; /* enable extended protocol */
+ buffer[4]=0x07; /* Locking mask = 0000b,
+ enable buttons = 0111b */
+
+ extdms_done = 0;
+ ADBOp((Ptr)buffer, (Ptr)extdms_complete,
+ (Ptr)&extdms_done, cmd);
+ while (!extdms_done)
+ /* busy wait until done */;
+
+ }
+ #endif
if (adbdata.origADBAddr == ADBADDR_MS &&
(adbdata.devType == 1 || adbdata.devType == 2)) {
/* found a mouse */
***************
*** 213,218 ****
--- 241,249 ----
case 2:
printf("200 dpi mouse");
break;
+ case 47:
+ printf("MicroSpeed mouse, default parameters");
+ break;
case 4:
extdms_done = 0;
/* talk register 1 */