patch-2.2.12 linux/drivers/macintosh/mac_keyb.c

Next file: linux/drivers/macintosh/via-pmu.c
Previous file: linux/drivers/macintosh/adb.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.2.11/linux/drivers/macintosh/mac_keyb.c linux/drivers/macintosh/mac_keyb.c
@@ -16,13 +16,14 @@
  *
  * - Standard 1 button mouse
  * - All standard Apple Extended protocol (handler ID 4)
- *   mice & trackballs
+ * - mouseman and trackman mice & trackballs 
  * - PowerBook Trackpad (default setup: enable tapping)
  * - MicroSpeed mouse & trackball (needs testing)
  * - CH Products Trackball Pro (needs testing)
  * - Contour Design (Contour Mouse)
  * - Hunter digital (NoHandsMouse)
  * - Kensignton TurboMouse 5 (needs testing)
+ * - Mouse Systems A3 mice and trackballs <aidan@kublai.com>
  *
  * To do:
  *
@@ -39,6 +40,7 @@
 #include <linux/init.h>
 #include <linux/tty_flip.h>
 #include <linux/config.h>
+#include <linux/notifier.h>
 
 #include <asm/bitops.h>
 #include <asm/adb.h>
@@ -66,10 +68,10 @@
 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 	0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,	/* esc...option */
-	0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, /* fn, num lock */
+	0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, /* fn, num lock */
 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, /* scroll lock */
-	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, /* R modifiers */
 };
 
 /* Simple translation table for the SysRq keys */
@@ -239,6 +241,7 @@
 static void init_trackball(int id);
 static void init_turbomouse(int id);
 static void init_microspeed(int id);
+static void init_ms_a3(int id);
 
 #ifdef CONFIG_ADBMOUSE
 /* XXX: Hook for mouse driver */
@@ -268,6 +271,7 @@
 #define ADBMOUSE_TURBOMOUSE5    5	/* Turbomouse 5 (previously req. mousehack) */
 #define ADBMOUSE_MICROSPEED	6	/* Microspeed mouse (&trackball ?), MacPoint */
 #define ADBMOUSE_TRACKBALLPRO	7	/* Trackball Pro (special buttons) */
+#define ADBMOUSE_MS_A3		8	/* Mouse systems A3 trackball (handler 3) */
 
 static int adb_mouse_kinds[16];
 
@@ -512,6 +516,11 @@
 		data[2] = (data[2] & 0x7f) | ((data[3] & 0x01) << 7);
 		data[3] = (data[3] & 0x77) | ((data[3] & 0x02) << 6);
 		break;
+	    case ADBMOUSE_MS_A3:
+		data[1] = (data[1] & 0x7f) | ((data[3] & 0x01) << 7);
+		data[2] = (data[2] & 0x7f) | ((data[3] & 0x02) << 6);
+		data[3] = ((data[3] & 0x04) << 5);
+		break;
 	}
 
 	if (adb_mouse_interrupt_hook)
@@ -741,9 +750,12 @@
 		/* Enable full feature set of the keyboard
 		   ->get it to send separate codes for left and right shift,
 		   control, option keys */
+#if 0		/* handler 5 doesn't send separate codes for R modifiers */
 		if (adb_try_handler_change(id, 5))
 			printk("ADB keyboard at %d, handler set to 5\n", id);
-		else if (adb_try_handler_change(id, 3))
+		else
+#endif
+		if (adb_try_handler_change(id, 3))
 			printk("ADB keyboard at %d, handler set to 3\n", id);
 		else
 			printk("ADB keyboard at %d, handler 1\n", id);
@@ -757,10 +769,6 @@
 			printk("ADB mouse at %d, handler set to 4", id);
 			adb_mouse_kinds[id] = ADBMOUSE_EXTENDED;
 		}
-		else if (adb_try_handler_change(id, 2)) {
-			printk("ADB mouse at %d, handler set to 2", id);
-			adb_mouse_kinds[id] = ADBMOUSE_STANDARD_200;
-		}
 		else if (adb_try_handler_change(id, 0x2F)) {
 			printk("ADB mouse at %d, handler set to 0x2F", id);
 			adb_mouse_kinds[id] = ADBMOUSE_MICROSPEED;
@@ -777,6 +785,14 @@
 			printk("ADB mouse at %d, handler set to 0x5F", id);
 			adb_mouse_kinds[id] = ADBMOUSE_MICROSPEED;
 		}
+		else if (adb_try_handler_change(id, 3)) {
+			printk("ADB mouse at %d, handler set to 3", id);
+			adb_mouse_kinds[id] = ADBMOUSE_MS_A3;
+		}
+		else if (adb_try_handler_change(id, 2)) {
+			printk("ADB mouse at %d, handler set to 2", id);
+			adb_mouse_kinds[id] = ADBMOUSE_STANDARD_200;
+		}
 		else {
 			printk("ADB mouse at %d, handler 1", id);
 			adb_mouse_kinds[id] = ADBMOUSE_STANDARD_100;
@@ -785,6 +801,8 @@
 		if ((adb_mouse_kinds[id] == ADBMOUSE_TRACKBALLPRO)
 		    || (adb_mouse_kinds[id] == ADBMOUSE_MICROSPEED)) {
 			init_microspeed(id);
+		} else if (adb_mouse_kinds[id] == ADBMOUSE_MS_A3) {
+			init_ms_a3(id);	
 		}  else if (adb_mouse_kinds[id] ==  ADBMOUSE_EXTENDED) {
 			/*
 			 * Register 1 is usually used for device
@@ -796,7 +814,8 @@
 				    ADB_READREG(id, 1));
 
 			if ((req.reply_len) &&
-			    (req.reply[1] == 0x9a) && (req.reply[2] == 0x21))
+			    (req.reply[1] == 0x9a) && ((req.reply[2] == 0x21)
+			    	|| (req.reply[2] == 0x20)))
 				init_trackball(id);
 			else if ((req.reply_len >= 4) &&
 			    (req.reply[1] == 0x74) && (req.reply[2] == 0x70) &&
@@ -868,7 +887,7 @@
 {
 	struct adb_request req;
 	
-	printk(" (trackball)");
+	printk(" (trackman/mouseman)");
 	
 	adb_mouse_kinds[id] = ADBMOUSE_TRACKBALL;
 
@@ -908,13 +927,10 @@
 	
 	adb_request(&req, NULL, ADBREQ_SYNC, 1, ADB_FLUSH(id));
 
-	adb_request(&req, NULL, ADBREQ_SYNC, 3,
-		ADB_WRITEREG(id,3), 0x20 | id, 4);
-
-	adb_request(&req, NULL, ADBREQ_SYNC, 1, ADB_FLUSH(id));
+	adb_request(&req, NULL, ADBREQ_SYNC, 1, ADB_FLUSH(3));
 
 	adb_request(&req, NULL, ADBREQ_SYNC, 9,
-	ADB_WRITEREG(id,2),
+	ADB_WRITEREG(3,2),
 	    0xe7,
 	    0x8c,
 	    0,
@@ -924,10 +940,10 @@
 	    0xff,
 	    0x94);
 
-	adb_request(&req, NULL, ADBREQ_SYNC, 1, ADB_FLUSH(id));
+	adb_request(&req, NULL, ADBREQ_SYNC, 1, ADB_FLUSH(3));
 
 	adb_request(&req, NULL, ADBREQ_SYNC, 9,
-	ADB_WRITEREG(id,2),
+	ADB_WRITEREG(3,2),
 	    0xa5,
 	    0x14,
 	    0,
@@ -977,4 +993,18 @@
 
 	adb_request(&req, NULL, ADBREQ_SYNC, 1, ADB_FLUSH(id));
 }
+
+static void
+init_ms_a3(int id)
+{
+	struct adb_request req;
+
+	printk(" (Mouse Systems A3 Mouse, or compatible)");
+	adb_request(&req, NULL, ADBREQ_SYNC, 3,
+	ADB_WRITEREG(id, 0x2),
+	    0x00,
+	    0x07);
+ 
+ 	adb_request(&req, NULL, ADBREQ_SYNC, 1, ADB_FLUSH(id));
+ }
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)