Skip to content

IBM PC Mouse

hasu@tmk edited this page Jun 22, 2021 · 30 revisions

Commands

E6 - Set Scaling 1:1

E7 - Set Scaling 2:1

F3 - Set Sampling Rate

Set mouse sample rate in Hz.

Param: {10d, 20d, 40d, 60d, 80d, 100d, 200d}

E8 - Set Resolution

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}

E9 - Read Status

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 (TrackPoint system or external device)
Bit 1 1 = Middle button depressed (TrackPoint system or external device)
Bit 0 1 = Right button depressed (TrackPoint system or external device)

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)

Mouse Data

/* 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
 */

TrackPoint

https://web.archive.org/web/20100613123840/http://wwwcssrv.almaden.ibm.com/trackpoint/files/ykt3eext.pdf

Intellimouse Explorer

https://www.win.tue.nl/~aeb/linux/kbd/scancodes-13.html

https://en.wikipedia.org/wiki/IntelliMouse

Logitech

Logitech PS/2++ protocol

https://www.win.tue.nl/~aeb/linux/kbd/scancodes-13.html

https://github.com/torvalds/linux/blob/d2912cb15bdda8ba4a5dd73396ad62641af2f520/drivers/input/mouse/logips2pp.c#L41

Logitech 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, ...

Byte0:

Bit Description
Bit 7 Y-overflow
Bit 6 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

Logitech mouse doesn't overflow on X and Y count, the overflow bits are useded to discriminate data kind.

Cursor Data

When both Bit7 and Bit6 is 0(Byte0 == XY-sign | 0x08 | 3-buttons)

Byte0:

Bit Description
Bit 7 0
Bit 6 0
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

Extra Button Data 1

When Overflow bits are 1(Byte0 == 0xC8|3-buttons) and Byte1 is 0xD2 Byte2: Bit4: Back button, Bit5: Forward button

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

Extra Button Data 2

When Overflow bits are 1(Byte0 == 0xC8|3-buttons) and Byte1 is 0xE2

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

Wheel Data

When Overflow bits are 1(Byte0 == 0xC8|3-buttons), 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
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
Clone this wiki locally