Serial Mouse Data Formats

The Microsoft Serial Mouse format is the defacto standard for serial mice. The Microsoft mouse format allows for only two buttons. Three button mice working in Microsoft mode ignore the middle button.

The data packets are sent at 1200 baud with 1 stop bit and no parity. Each packet consists of 3 bytes. It is sent to the computer every time the mouse changes state (ie. the mouse is moved or the buttons are pressed/released).

                    D6    D5    D4    D3    D2    D1    D0
                 -----------------------------------------
       1st byte  |  1     LB    RB    Y7    Y6    X7    X6
       2nd byte  |  0     X5    X4    X3    X2    X1    X0
       3rd byte  |  0     Y5    Y4    Y3    Y2    Y1    Y0

     LB is the state of the left  button, 1 = pressed, 0 = released.
     RB is the state of the right button, 1 = pressed, 0 = released
     X0-7 is movement of the mouse in the X direction since the
          last packet.  Positive movement is toward the right.
     Y0-7 is movement of the mouse in the Y direction since the
          last packet.  Positive movement is back, toward the user.
The mouse driver software collects the X and Y movement bits from the different bytes in the packet. All moves are sent as two's complement binary numbers.

Although the Microsoft format only requires 7 data bits per byte, most mice actually send 8-bit data with the most significant bit set to 1. Since the most-significant-bit (D7) is last in the serial data stream, this is the same as sending two stop bits instead of one. The Joymouse sends data packets as shown below.

                    D7    D6    D5    D4    D3    D2    D1    D0
                 -----------------------------------------------
       1st byte  |  1     1     LB    RB    Y7    Y6    X7    X6
       2nd byte  |  1     0     X5    X4    X3    X2    X1    X0
       3rd byte  |  1     0     Y5    Y4    Y3    Y2    Y1    Y0

[ Back to Data & Documentation ] [ Home ]