diff -rup xc-orig/programs/Xserver/hw/xfree86/input/mouse/mouse.c xc/programs/Xserver/hw/xfree86/input/mouse/mouse.c --- xc-orig/programs/Xserver/hw/xfree86/input/mouse/mouse.c 2003-02-10 19:33:06.000000000 -0800 +++ xc/programs/Xserver/hw/xfree86/input/mouse/mouse.c 2003-03-05 13:52:30.000000000 -0800 @@ -189,6 +189,7 @@ typedef enum { OPTION_X_AXIS_MAPPING, OPTION_Y_AXIS_MAPPING, OPTION_AUTO_SOFT, + OPTION_LOGITECH_SMS, OPTION_CLEAR_DTR, OPTION_CLEAR_RTS, OPTION_BAUD_RATE, @@ -226,6 +227,7 @@ static const OptionInfoRec mouseOptions[ { OPTION_X_AXIS_MAPPING, "XAxisMapping", OPTV_STRING, {0}, FALSE }, { OPTION_Y_AXIS_MAPPING, "YAxisMapping", OPTV_STRING, {0}, FALSE }, { OPTION_AUTO_SOFT, "AutoSoft", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_LOGITECH_SMS, "SmartScroll", OPTV_INTEGER, {0}, FALSE }, /* serial options */ { OPTION_CLEAR_DTR, "ClearDTR", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_CLEAR_RTS, "ClearRTS", OPTV_BOOLEAN, {0}, FALSE }, @@ -700,6 +702,12 @@ MouseHWOptions(InputInfoPtr pInfo) = xf86SetBoolOption(pInfo->options, "AutoSoft", FALSE))) { xf86Msg(X_CONFIG, "Don't initialize mouse when auto-probing\n"); } + + pMse->smartScroll = xf86SetIntOption(pInfo->options, "SmartScroll", 1); + if (pMse->smartScroll) { + xf86Msg(X_CONFIG, "%s: SmartScroll: %d \n", pInfo->name, + pMse->smartScroll); + } pMse->sampleRate = xf86SetIntOption(pInfo->options, "SampleRate", 0); if (pMse->sampleRate) { xf86Msg(X_CONFIG, "%s: SampleRate: %d\n", pInfo->name, @@ -1381,20 +1389,36 @@ MouseReadInput(InputInfoPtr pInfo) buttons = (pBuf[0] & 0x04) >> 1 | /* Middle */ (pBuf[0] & 0x02) >> 1 | /* Right */ (pBuf[0] & 0x01) << 2; /* Left */ - dx = (pBuf[0] & 0x10) ? pBuf[1] - 256 : pBuf[1]; - if (((pBuf[0] & 0x48) == 0x48) && - (abs(dx) > 191) && - ((((pBuf[2] & 0x03) << 2) | 0x02) == (pBuf[1] & 0x0f))) { + + /* + * PS2++ now uses 6 bits for type, 8 for data + * 2 type bits were implied to be always-on + */ + if ( ((pBuf[0] & 0x48) == 0x48) && ((pBuf[1] & 0x02) == 0x02) ) + { /* extended data packet */ - switch ((((pBuf[0] & 0x30) >> 2) | ((pBuf[1] & 0x30) >> 4))) { - case 1: /* wheel data packet */ + switch ( (pBuf[0] & 0x30) | + ( (pBuf[1] & 0xf0) >> 4) ) { + case 0x0d: /* P1 - wheel data, buttons 4, 5 packet */ + buttons |= ( pMse->lastButtons & ~0x18); buttons |= ((pBuf[2] & 0x10) ? 0x08 : 0) | /* 4th button */ ((pBuf[2] & 0x20) ? 0x10 : 0); /* 5th button */ dx = dy = 0; dz = (pBuf[2] & 0x08) ? (pBuf[2] & 0x0f) - 16 : (pBuf[2] & 0x0f); break; - case 2: /* Logitech reserves this packet type */ + case 0x0e: /* P2 - buttons 4,5,6,7,8,9,10 info - NEW */ + buttons |= ( pMse->lastButtons & ~0x3f8); + buttons |= ((pBuf[2] & 0x7f) << 3); + break; +#if 0 + /* + * formerly case 2: Logitech updated PS/2++ (MMPS2), + * and I guess it broke compatibility with manufacturers + * that were latching onto it + * is this what PS2TPP I see in the Linux 2.5.x + * kernel source (psmouse.c) is for? + */ /* * IBM ScrollPoint uses this packet to encode its * stick movement. @@ -1405,7 +1429,7 @@ MouseReadInput(InputInfoPtr pInfo) ((pBuf[2] >> 4) & 0x0f); dw = (pBuf[2] & 0x08) ? (pBuf[2] & 0x0f) - 16 : (pBuf[2] & 0x0f); - break; +#endif case 0: /* device type packet - shouldn't happen */ default: buttons |= (pMse->lastButtons & ~0x07); @@ -2635,7 +2659,12 @@ initMouseHW(InputInfoPtr pInfo) pMse->resolution); } else { unsigned char c2[2]; - + unsigned char sms[] = { 0xe6, + 0xe8, 0, 0xe8, 3, + 0xe8, 0, 0xe8, 2, + 0xe8, 0, 0xe8, 0, + 0xe8, 0, 0xe8, 0 }; + c = 0xE6; /*230*/ /* 1:1 scaling */ if (!ps2SendPacket(pInfo,&c,1)) { if (!count--) @@ -2664,6 +2693,18 @@ initMouseHW(InputInfoPtr pInfo) return TRUE; goto REDO; } + /* + * this is on by default, but some users (me) + * like it off + */ + if (pMse->smartScroll) + sms[16] |= 1; + if (!ps2SendPacket(pInfo, sms, 17)) { + if (!count--) + return TRUE; + goto REDO; + } + c2[0] = 0xE8; /*232*/ /* set device resolution */ if (pMse->resolution > 0) { if (pMse->resolution >= 200) @@ -2677,11 +2718,20 @@ initMouseHW(InputInfoPtr pInfo) } else { c2[1] = 2; } - if (!ps2SendPacket(pInfo,c2,2)) { + if (pMse->resolution >= 800) { + /* for Logitech mice that support it */ + unsigned char cpi800[] = { 0xe6, 0xe6, 0xe6, 0xe8, 3 }; + if (!ps2SendPacket(pInfo, cpi800, 5)) { + if (!count--) + return TRUE; + goto REDO; + } + } else if (!ps2SendPacket(pInfo,c2,2)) { if (!count--) return TRUE; goto REDO; - } + } + usleep(30000); xf86FlushInput(pInfo->fd); if (!ps2EnableDataReporting(pInfo)) { --- xc/programs/Xserver/hw/xfree86/os-support/xf86OSmouse.h.orig 2004-08-11 15:06:24.000000000 -0400 +++ xc/programs/Xserver/hw/xfree86/os-support/xf86OSmouse.h 2004-08-11 15:07:13.000000000 -0400 @@ -268,6 +268,7 @@ dataGoodProc dataGood; int angleOffset; pointer pDragLock; /* drag lock area */ + int smartScroll; int xisbscale; /* buffer size for 1 event */ } MouseDevRec, *MouseDevPtr;