Index: arch/ppc/config.in =================================================================== RCS file: /cvs/linux/linux/arch/ppc/config.in,v retrieving revision 1.92.2.2 diff -u -r1.92.2.2 config.in --- arch/ppc/config.in 1999/06/17 01:19:06 1.92.2.2 +++ arch/ppc/config.in 1999/06/21 02:31:48 @@ -88,7 +88,10 @@ if [ "$CONFIG_MAC_SERIAL" = "y" ]; then bool ' Support for console on serial port' CONFIG_SERIAL_CONSOLE fi bool 'Support for PowerMac ADB mouse' CONFIG_ADBMOUSE +if [ "$CONFIG_ADBMOUSE" != "n" ]; then + bool ' Support for PowerMac MacX 3 btn. mouse' CONFIG_MACX_MOUSE +fi bool 'Support for Open Firmware device tree in /proc' CONFIG_PROC_DEVICETREE bool 'Support for TotalImpact TotalMP' CONFIG_TOTALMP bool 'Support for early boot text console (BootX only)' CONFIG_BOOTX_TEXT Index: drivers/macintosh/mac_keyb.c =================================================================== RCS file: /cvs/linux/linux/drivers/macintosh/mac_keyb.c,v retrieving revision 1.27 diff -u -r1.27 mac_keyb.c --- drivers/macintosh/mac_keyb.c 1999/04/28 11:55:00 1.27 +++ drivers/macintosh/mac_keyb.c 1999/06/21 02:32:22 @@ -250,6 +250,11 @@ extern int console_loglevel; +#ifdef CONFIG_MACX_MOUSE +/* DKH:9/98 -- Fake packet for the mouse data / also button state*/ +static unsigned char fake_mouse_packet[4] = { 0x3c, 0x80, 0x80, 0x80 }; +#endif /*CONFIG_MACX_MOUSE*/ + extern struct kbd_struct kbd_table[]; extern struct wait_queue * keypress_wait; @@ -308,13 +313,70 @@ static void keyboard_input(unsigned char *data, int nb, struct pt_regs *regs, int apoll) { + +#ifdef CONFIG_MACX_MOUSE + /* Treat all ADB devices as _potential_ MacX mice, + then determine later which ones aren't based on data */ + /* XXX: Can 0 ever be a device? */ + static char mice[16] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}; + char button_state; + struct kbd_struct *kbd; + + kbd = kbd_table + fg_console; +#endif + /* first check this is from register 0 */ if (nb != 3 || (data[0] & 3) != KEYB_KEYREG) return; /* ignore it */ + +#ifdef CONFIG_MACX_MOUSE + if ( !mice[ data[0]>>4 ]){ /* A _known_ keyboard */ +regular_keyboard: +#endif + kbd_pt_regs = regs; input_keycode(data[1], 0); if (!(data[2] == 0xff || (data[2] == 0x7f && data[1] == 0x7f))) input_keycode(data[2], 0); + +#ifdef CONFIG_MACX_MOUSE + } else { + /* This _could_ be a MacX mouse. If it is then send + the data to the X server and possibly FB, else + pass it back to the keyboard code and mark this + device as a known keyboard. (HACK) */ + + switch(data[1]){ + case 0x3b: + fake_mouse_packet[2] = 0; + button_state = 0x3f; + break; + case 0xbb: + fake_mouse_packet[2] = 0x80; + button_state = 0xbf; + break; + case 0x3c: + fake_mouse_packet[3] = 0; + button_state = 0x40; + break; + case 0xbc: + fake_mouse_packet[3] = 0x80; + button_state = 0xc0; + break; + default: + mice[ data[0]>>4 ] = 0; /* Nope, not a mouse */ + goto regular_keyboard; + } + + /* XXX Wont this loose the first button state? */ + + if (adb_mouse_interrupt_hook) /* New style */ + adb_mouse_interrupt_hook(fake_mouse_packet,4); + + if (kbd->kbdmode == VC_RAW) /* Old style */ + mac_put_queue( button_state ); + } +#endif } static void @@ -616,6 +678,33 @@ } } +#ifdef CONFIG_MACX_MOUSE +static void +macx_mouse_input(unsigned char *data, int nb, struct pt_regs *regs, int autopoll) +{ + /* It would be nice if this would check to see if we have mouse data from + a real three button mouse and then re-register the real handler + function. */ + + struct kbd_struct *kbd; + /* Store the button states in data (nuking extranious button info)*/ + data[2] = ( data[2] & 0x7f) | fake_mouse_packet[2]; + data[3] = ( data[3] & 0x7f) | fake_mouse_packet[3]; + + if (adb_mouse_interrupt_hook) + adb_mouse_interrupt_hook(data, nb); + kbd = kbd_table + fg_console; + + /* Only send mouse codes when keyboard is in raw mode. */ + if (kbd->kbdmode == VC_RAW) { + mac_put_queue( 0x7e ); + mac_put_queue( data[1] ); + mac_put_queue( data[2] ); + } + +} +#endif /*CONFIG_MACX_MOUSE*/ + /* Map led flags as defined in kbd_kern.h to bits for Apple keyboard. */ static unsigned char mac_ledmap[8] = { 0, /* none */ @@ -725,7 +814,11 @@ int i; #ifdef CONFIG_ADBMOUSE +#ifdef CONFIG_MACX_MOUSE + adb_register(ADB_MOUSE, 3, &mouse_ids, macx_mouse_input); +#else adb_register(ADB_MOUSE, 0, &mouse_ids, mouse_input); +#endif #endif /* CONFIG_ADBMOUSE */ adb_register(ADB_KEYBOARD, 0, &keyboard_ids, keyboard_input);