basic scroll-button support for plan9 andrey Reference: /n/sources/patch/applied/scroll-mouse Date: Tue Oct 19 16:29:46 CES 2004 --- /sys/src/9/pc/mouse.c Tue Oct 19 16:29:46 2004 +++ /sys/src/9/pc/mouse.c Tue Oct 19 16:29:46 2004 @@ -129,10 +129,16 @@ /* fall through to emit previous packet */ }else{ /* the AccuPoint on the Toshiba 34[48]0CT encodes extra buttons as 4 and 5 */ - /* they repeat and don't release, however, so user-level timing code is required */ - if(msg[3] == 0xFF) + /* they repeat and don't release, however, so user-level timing code is required + * furthermore, intellimice with 3buttons + scroll give a two's complement + * number in the lower 4 bytes (byte 4 is sign extension) that describes + * the amount the scroll wheel has moved during the last sample. here we use only + * the sign to decide whether the wheel is moving up or down and generate + * a single button 4 or 5 click accordingly. + */ + if((msg[3] >> 3) & 1) buttons |= 1<<3; - if(msg[3] == 0x01) + else if(msg[3] & 0x7) buttons |= 1<<4; } }