diff -ru linux-cvs/Documentation/Configure.help linux-cvs-macx/Documentation/Configure.help --- linux-cvs/Documentation/Configure.help Tue Oct 27 11:18:22 1998 +++ linux-cvs-macx/Documentation/Configure.help Fri Oct 30 21:33:58 1998 @@ -9088,6 +9088,14 @@ If you have an ADB mouse (4 pin connector) as is common on Macintoshes, say Y here. +Support for MacX mouse +CONFIG_MACX_MOUSE + If you have a 3 button ADB mouse that sends left and right + arrow keys as the middle and right buttons, then you probably + have a MacX compatible mouse. If so, say Y here to make + the middle and right buttons function properly. Do not + select this option if you have a normal multi-button ADB mouse. + Winbond SL82c105 support CONFIG_BLK_DEV_SL82C105 If you have a Winbond SL82c105 IDE controller, say Y here to diff -ru linux-cvs/arch/ppc/config.in linux-cvs-macx/arch/ppc/config.in --- linux-cvs/arch/ppc/config.in Thu Oct 22 20:08:48 1998 +++ linux-cvs-macx/arch/ppc/config.in Fri Oct 30 21:32:33 1998 @@ -80,6 +80,9 @@ bool 'Support for PowerMac floppy' CONFIG_MAC_FLOPPY bool 'Support for PowerMac serial ports' CONFIG_MAC_SERIAL bool 'Support for PowerMac ADB mouse' CONFIG_ADBMOUSE +if [ "$CONFIG_ADBMOUSE" = "y" ]; then + bool 'Support for PowerMac MacX mouse (READ HELP)' CONFIG_MACX_MOUSE +fi bool 'Support for PowerMac IDE devices (must also enable IDE)' CONFIG_BLK_DEV_IDE_PMAC bool 'Support for Open Firmware device tree in /proc' CONFIG_PROC_DEVICETREE bool 'Include kgdb kernel debugger' CONFIG_KGDB diff -ru linux-cvs/drivers/macintosh/mac_keyb.c linux-cvs-macx/drivers/macintosh/mac_keyb.c --- linux-cvs/drivers/macintosh/mac_keyb.c Thu Oct 22 20:10:34 1998 +++ linux-cvs-macx/drivers/macintosh/mac_keyb.c Fri Oct 30 23:01:59 1998 @@ -7,6 +7,9 @@ * (see that file for its authors and contributors). * * Copyright (C) 1996 Paul Mackerras. + * + * 981027 Support for MacX mice added by Daniel Hiltgen + * (dhiltgen@toocool.calpoly.edu) */ #include @@ -184,6 +187,11 @@ extern int console_loglevel; +#ifdef CONFIG_MACX_MOUSE +/* DKH:10/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; @@ -246,13 +254,72 @@ 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 This will forget the first button state. + * but how often will people click a second button + * while holding down the left one? */ + + 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 @@ -467,6 +534,52 @@ } #endif /* CONFIG_ADBMOUSE */ +#ifdef CONFIG_MACX_MOUSE +static void +macx_mouse_input(unsigned char *data, int nb, struct pt_regs *regs, int autopoll) +{ + struct kbd_struct *kbd; + + /* XXX If this works, it should detect a non MacX mouse + * and revert to the original mouse handler function. + * NOTE: This will not take into account multiple mice + * (Say one MacX and one normal mouse) but how often + * will that occur? We assume that if this option + * was compiled in, then we'll normally have a MacX mouse. + * The ifs are structured for gcc efficiency. + */ + static int macx = 1; /*Start out assuming MacX mice */ + + if ( macx ){ + if ( nb >= 4 ){ + /* Check for third or fourth button state. */ + if ( ! (( data[3] & 0x80 ) || ( data[3] & 0x08)) ){ + /* 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] ); + } + } else { /*Oops, looks like a normal mouse */ + macx = 0; /* Don't bother checking next time */ + printk(KERN_DEBUG "Non MacX mouse detected, reverting.\n"); + mouse_input(data,nb,regs,autopoll); + } + } else /* This shouldn't happen... maybe a 1 button mouse? */ + mouse_input(data,nb,regs,autopoll); + } else /* Dohp, this isn't a MacX mouse! */ + mouse_input(data,nb,regs,autopoll); +} +#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 */ @@ -546,7 +659,12 @@ /* initialize mouse interrupt hook */ adb_mouse_interrupt_hook = NULL; +#ifndef CONFIG_MACX_MOUSE /* Not sure if this is the best way */ adb_register(ADB_MOUSE, 1, &mouse_ids, mouse_input); +#else + adb_register(ADB_MOUSE, 3, &mouse_ids, macx_mouse_input); +#endif /* CONFIG_MACX_MOUSE */ + #endif /* CONFIG_ADBMOUSE */ adb_register(ADB_KEYBOARD, 5, &keyboard_ids, keyboard_input);