-
Notifications
You must be signed in to change notification settings - Fork 1.7k
IBM PC Mouse
Set mouse sample rate in Hz.
Param: {10d, 20d, 40d, 60d, 80d, 100d, 200d}
This command is followed by a byte indicating the resolution (0, 1, 2, 3: 1, 2, 4, 8 units per mm, respectively).
Param: {00, 01, 02, 03}
Responds with 3-byte status report.
Byte0:
Bit | Description |
---|---|
Bit 7 | 0 = Always (Reserved for future use) |
Bit 6 | 0 = Stream mode / 1 = Remote mode |
Bit 5 | 0 = Disable / 1 = Enable |
Bit 4 | 0 = Scaling 1:1 / 1 = Scaling 2:1 |
Bit 3 | 0 = Always (Reserved for future use) |
Bit 2 | 1 = Left button depressed |
Bit 1 | 1 = Middle button depressed |
Bit 0 | 1 = Right button depressed |
Byte 1: Current resolution setting (Same format as second byte of ”E8” command)
Byte 2: Current sampling rate (Same format as second byte of ”F3” command)
/* Data format:
* byte|7 6 5 4 3 2 1 0
* ----+--------------------------------------------------------------
* 0|Yovflw Xovflw Ysign Xsign 1 Middle Right Left
* 1| X movement
* 2| Y movement
*/
https://www.win.tue.nl/~aeb/linux/kbd/scancodes-13.html
https://en.wikipedia.org/wiki/IntelliMouse
Logitech PS/2++ protocol
https://www.win.tue.nl/~aeb/linux/kbd/scancodes-13.html
https://web.archive.org/web/20030714000535/www.dqcs.com/logitech/ps2ppspec.htm
Logitech Mouse report consists of 3 bytes and reports following data.
- X: 9-bit, -255(0x101) to 255(0x0FF)
- Y: 9-bit, -255(0x101) to 255(0x0FF)
- Wheel: 5-bit, -15(0x11) to 15(0x0F)
- Buttons: Left, Right, Middle, Back, Forward, Up, Down, Task, ...
Standard PS/2 mouse data Byte0 looks like this. Logitech mouse never overflow on X and Y count, so the overflow bits are used to discriminate mouse report types.
Byte0:
Bit | Description |
---|---|
Bit 7 | Y-overflow (1 if report comes from an external device) |
Bit 6 | X-overflow (1 when Logitech specific report) |
Bit 5 | Y-sign |
Bit 4 | X-sign |
Bit 3 | 1 |
Bit 2 | Middle button |
Bit 1 | Right button |
Bit 0 | Left button |
This is normal report when Byte0 X-overflow bit is 0.
Byte0:
Bit | Description |
---|---|
Bit 7 | 0(Y-overflow) |
Bit 6 | 0(X-overflow) |
Bit 5 | Y-sign |
Bit 4 | X-sign |
Bit 3 | 1 |
Bit 2 | Middle button |
Bit 1 | Right button |
Bit 0 | Left button |
Byte1: X movement, 8-bit
Byte2: Y movement, 8-bit
When Byte0 X-overflow bit is 1, Byte0 both sign bits are 0 and Byte1 is 0xD2
Byte0:
Bit | Description |
---|---|
Bit 7 | -(Y-overflow) |
Bit 6 | 1(X-overflow) |
Bit 5 | 0(Y-sign) |
Bit 4 | 0(X-sign) |
Bit 3 | 1 |
Bit 2 | -(Middle button) |
Bit 1 | -(Right button) |
Bit 0 | -(Left button) |
Byte1:
Bit | Description |
---|---|
Bit 7 | 1 |
Bit 6 | 1 |
Bit 5 | 0 |
Bit 4 | 1 |
Bit 3 | - |
Bit 2 | - |
Bit 1 | - |
Bit 0 | - |
Byte2:
Bit | Description |
---|---|
Bit 7 | 0 |
Bit 6 | 0 |
Bit 5 | Forward button |
Bit 4 | Back button |
Bit 3 | 0 |
Bit 2 | 0 |
Bit 1 | 0 |
Bit 0 | 0 |
When Overflow bits(Bit7, Bit6) of Byte0 are x1 and Byte1 is 0xE2
Byte0:
Bit | Description |
---|---|
Bit 7 | -(Y-overflow) |
Bit 6 | 1(X-overflow) |
Bit 5 | 0(Y-sign) |
Bit 4 | 0(X-sign) |
Bit 3 | 1 |
Bit 2 | -(Middle button) |
Bit 1 | -(Right button) |
Bit 0 | -(Left button) |
Byte1:
Bit | Description |
---|---|
Bit 7 | 1 |
Bit 6 | 1 |
Bit 5 | 1 |
Bit 4 | 0 |
Bit 3 | - |
Bit 2 | - |
Bit 1 | - |
Bit 0 | - |
Byte2:
Bit | Description |
---|---|
Bit 7 | 0 |
Bit 6 | 0 |
Bit 5 | 0 |
Bit 4 | Down button |
Bit 3 | Up button |
Bit 2 | Task button |
Bit 1 | ??? button |
Bit 0 | ??? button |
When X-overflow bit is 1(Byte0 == 0xC8|3-buttons) and Byte1 is 0xD6 or 0xDE
Wheel movement: 5-bit, -1(0x1F) or 1(0x01) [-15(0x11) to 15(0x0F) in theory]
Byte1:
Bit | Description |
---|---|
Bit 7 | 1 |
Bit 6 | 1 |
Bit 5 | 0 |
Bit 4 | 1 |
Bit 3 | Wheel-Sign |
Bit 2 | 1 |
Bit 1 | 1 |
Bit 0 | 0 |
Byte2:
Bit | Description |
---|---|
Bit 7 | 0/1 (1 if horizontal) |
Bit 6 | 1 = virtual scroll by Up/Down button |
Bit 5 | 0 |
Bit 4 | 0 |
Bit 3 | Wheel-3 |
Bit 2 | Wheel-2 |
Bit 1 | Wheel-1 |
Bit 0 | Wheel-0 |