Navigation
Highlights

Release 0.0.5

The latest release, alpha testing, unstable. See "downloads".

2005-06-01

Links
Documentation

Serial Mouse driver

The FreeDOS-32 Serial Mouse Driver is a loadable driver which allows FreeDOS-32 to use a mouse connected to a serial port (only COM1 at present). This document is intended for those people who want to use its features and/or study the source code, in the hope it will be useful.

Mouse Reset

The serial mouse is reset by holding the RTS line low for at least 100 ms (200 ms according to the Plug'n'Play specification) and then raising it. RTS is used as the power source for the mouse. Right after reset, the mouse sends some identification bytes and is then ready for normal operation.

After a reset, the Serial Mouse Driver polls the serial port for identification bytes, that usually have the following form:

id [packet] [PnP data]
  • id is one or two bytes long, identifying the mouse protocol used:
    • M for the Microsoft (or MS) protocol, 2 buttons
    • M3 for the Extended Microsoft protocol, 3 buttons
    • MZ for the Extended Microsoft protocol, mouse wheel mode
    • for Mouse System protocol (3 buttons) some mice are reported to send H, whereas others report nothing. Hence, a serial mouse using the Mouse System protocol may not be autodetected, needing the user to force the protocol.
    • other values are not supported by the FD32 Serial Mouse Driver.
  • packet is an empty motion packet (see below, Mouse Protocols) usually sent after id and before PnP data. The FD32 Serial Mouse Driver ignores this packet.
  • PnP data is a Plug'n'Play identification string for the mouse, beginning with a PnP start mark (28h or 08h, the open round bracket) and ending with a PnP end mark (29h or 09h, the closed round bracket). This string includes things like the product name and serial number. The FD32 Serial Mouse Driver ignores the PnP data.

Mouse Protocols

Serial mice use several different protocols.

"M" Microsoft (or MS) protocol, 2 buttons

1200 bps, 7 data bits, 1 stop bit, no parity.

 bit 6bit 5bit 4bit 3bit 2bit 1bit 0
byte 1'1'LRY7Y6X7X6
byte 2'0'X5X4X3X2X1X0
byte 3'0'Y5Y4Y3Y2Y1Y0

Only the first byte has MSB set, for sequence identification.

  • L and R are left and right button status (1 = pressed).
  • X7..X0, packed to form an 8-bit integer (X0 is LSB), is the two's complement increment (in mouse unit) of the X axis.
  • Y7..Y0, packed to form an 8-bit integer (Y0 is LSB), is the two's complement increment (in mouse unit) of the Y axis.

"M3" Extended Microsoft protocol, 3 buttons

Same as "M" Mircosoft protocol for two buttons mice, but a fourth byte is sent if the middle button is being pressed or changing state:

  bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
byte 1 '1' L R Y7 Y6 X7 X6
byte 2 '0' X5 X4 X3 X2 X1 X0
byte 3 '0' Y5 Y4 Y3 Y2 Y1 Y0
byte 4 '0' M '0' '0' '0' '0' '0'
  • M is the middle button status (1 = pressed).

"MZ" Extended Microsoft protocol, mouse wheel mode

Same as "M" Microsoft protocol for two buttons mice, but a fourth byte is always sent, carrying informations about the middle button and the mouse wheel movement:

  bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
byte 1 '1' L R Y7 Y6 X7 X6
byte 2 '0' X5 X4 X3 X2 X1 X0
byte 3 '0' Y5 Y4 Y3 Y2 Y1 Y0
byte 4 '0' '0' M Z3 Z2 Z1 Z0
  • M is the button status (1 = pressed).
  • Z3..Z0, packed to form a 4-bit integer (Z0 is LSB), is the two's complement increment of the Z axis (mouse wheel).

Mouse System (or PC) protocol, 3 buttons

1200 bps, 8 data bits, 1 stop bit, no parity.

  bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
byte 1 '1' '0' '0' '0' '0' L M R
byte 2 X7 X6 X5 X4 X3 X2 X1 X0
byte 3 Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0
byte 4 X7' X6' X5' X4' X3' X2' X1' X0'
byte 5 Y7' Y6' Y5' Y4' Y3' Y2' Y1' Y0'

The most significant bits of the first byte are equal to '10000' for sequence identification.

  • L, M, and R are left, middle and right button status (0 = pressed).
  • X7..X0, a two's complement 8-bit integer (X0 is LSB), is the increment (in mouse unit) of the X axis since the last packet.
  • Y7..Y0, a two's complement 8-bit integer (Y0 is LSB), is the increment (in mouse unit) of the Y axis since the last packet.
  • X7'..X0', a two's complement 8-bit integer (X0' is LSB), is the increment of the X axis since X7..X0 was sent.
  • Y7'..Y0', a two's complement 8-bit integer (Y0' is LSB), is the increment of the Y axis since Y7..Y0 was sent.