patch-2.3.43 linux/drivers/macintosh/mac_keyb.c
Next file: linux/drivers/macintosh/macserial.c
Previous file: linux/drivers/macintosh/adb.c
Back to the patch index
Back to the overall index
- Lines: 243
- Date:
Wed Feb 9 19:43:47 2000
- Orig file:
v2.3.42/linux/drivers/macintosh/mac_keyb.c
- Orig date:
Fri Oct 15 15:25:13 1999
diff -u --recursive --new-file v2.3.42/linux/drivers/macintosh/mac_keyb.c linux/drivers/macintosh/mac_keyb.c
@@ -16,13 +16,15 @@
*
* - 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>
+ * - MacAlly 2-buttons mouse (needs testing) <pochini@denise.shiny.it>
*
* To do:
*
@@ -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,8 @@
#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) */
+#define ADBMOUSE_MACALLY2 9 /* MacAlly 2-button mouse */
static int adb_mouse_kinds[16];
@@ -484,6 +489,19 @@
data[3] = byyy bxxx Third button and fourth button. Y is additional
high bits of y-axis motion. XY is additional
high bits of x-axis motion.
+
+ MacAlly 2-button mouse protocol.
+
+ For MacAlly 2-button mouse protocol the data array will contain the
+ following values:
+
+ BITS COMMENTS
+ data[0] = dddd 1100 ADB command: Talk, register 0, for device dddd.
+ data[1] = bxxx xxxx Left button and x-axis motion.
+ data[2] = byyy yyyy Right button and y-axis motion.
+ data[3] = ???? ???? unknown
+ data[4] = ???? ???? unknown
+
*/
struct kbd_struct *kbd;
@@ -510,6 +528,16 @@
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;
+ case ADBMOUSE_MACALLY2:
+ data[3] = (data[2] & 0x80) ? 0x80 : 0x00;
+ data[2] |= 0x80; /* Right button is mapped as button 3 */
+ nb=4;
+ break;
}
if (adb_mouse_interrupt_hook)
@@ -642,7 +670,6 @@
static void real_mackbd_leds(unsigned char leds, int device)
{
-
if (led_request.complete) {
adb_request(&led_request, leds_done, 0, 3,
ADB_WRITEREG(device, KEYB_LEDREG), 0xff,
@@ -715,10 +742,18 @@
static int
adb_message_handler(struct notifier_block *this, unsigned long code, void *x)
{
+ unsigned long flags;
+
switch (code) {
case ADB_MSG_PRE_RESET:
case ADB_MSG_POWERDOWN:
- /* Add unregister_keyboard when merging with Paul Mackerras */
+ /* Stop the repeat timer. Autopoll is already off at this point */
+ save_flags(flags);
+ cli();
+ del_timer(&repeat_timer);
+ restore_flags(flags);
+
+ /* Stop pending led requests */
while(!led_request.complete)
adb_poll();
break;
@@ -753,9 +788,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);
@@ -769,10 +807,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;
@@ -789,6 +823,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;
@@ -797,6 +839,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
@@ -808,7 +852,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) &&
@@ -818,6 +863,14 @@
(req.reply[1] == 0x4b) && (req.reply[2] == 0x4d) &&
(req.reply[3] == 0x4c) && (req.reply[4] == 0x31))
init_turbomouse(id);
+ else if ((req.reply_len == 9) &&
+ (req.reply[1] == 0x4b) && (req.reply[2] == 0x4f) &&
+ (req.reply[3] == 0x49) && (req.reply[4] == 0x54)){
+ if (adb_try_handler_change(id, 0x42)) {
+ printk("\nADB MacAlly 2-button mouse at %d, handler set to 0x42", id);
+ adb_mouse_kinds[id] = ADBMOUSE_MACALLY2;
+ }
+ }
}
printk("\n");
}
@@ -880,7 +933,7 @@
{
struct adb_request req;
- printk(" (trackball)");
+ printk(" (trackman/mouseman)");
adb_mouse_kinds[id] = ADBMOUSE_TRACKBALL;
@@ -920,13 +973,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,
@@ -936,10 +986,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,
@@ -989,4 +1039,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)