Warning, /cpukit/libmisc/mouse/README.md is written in an unsupported language. File is not indexed.
0001 Mouse
0002 =====
0003
0004 SOURCE: http://www.kryslix.com/nsfaq/Q.12.html
0005
0006 Subject: What protocol do mice use?
0007 Date: 09/16/97
0008 Updated: 11/16/00 This document was adapated from a web page produced by
0009 Tomi Engdahl <then@delta.hut.fi>
0010 Microsoft serial mouse
0011 Description
0012
0013 The Microsoft serial mouse is the most popular 2 button mouse. It is
0014 supported by all major operating systems. The maximum tracking rate for
0015 a Microsoft mouse is 40 reports/second * 127 counts per report, in other
0016 words, 5080 counts per second. The most common range for mice is is 100
0017 to 400 CPI (counts per inch) but can be up to 1000 CPI. A 100CPI mouse
0018 can discriminate motion up to 50.8 inches/second while a 400 CPI mouse
0019 can only discriminate motion up to 12.7 inches/second.
0020 Pinout
0021
0022 ```
0023 9 pin 25 pin Line Comments
0024 shell 1 GND
0025 3 2 TD Serial data from host to mouse (only for power)
0026 2 3 RD Serial data from mouse to host
0027 7 4 RTS Positive voltage to mouse
0028 8 5 CTS
0029 6 6 DSR
0030 5 7 SGND
0031 4 20 DTR Positive voltage to mouse and reset/detection
0032 ```
0033
0034 RTS = Request to Send CTS = Clear to Send
0035 DSR = Data Set Ready DTR = Data Terminal Ready
0036 GND = Protective Ground SGND = Signal Ground
0037
0038 To function correctly, both the RTS and DTR lines must be
0039 positive. DTR/DSR and RTS/CTS must NOT be shorted. RTS may be toggled
0040 negative for at least 100ms to reset the mouse. (After a cold boot, the
0041 RTS line is usually negative. This provides an automatic toggle when
0042 RTS is brought positive). When DTR is toggled the mouse should send a
0043 single byte 0x45 (ASCII 'M').
0044
0045 Serial data parameters:
0046 1200bps, 7 databits, 1 stop-bit
0047
0048 Data packet format:
0049
0050 Data is sent in 3 byte packets for each event (a button is pressed or
0051 released or the mouse moves):
0052
0053 ```
0054 D7 D6 D5 D4 D3 D2 D1 D0
0055
0056 Byte 1 X 1 LB RB Y7 Y6 X7 X6
0057 Byte 2 X 0 X5 X4 X3 X2 X1 X0
0058 Byte 3 X 0 Y5 Y4 Y3 Y2 Y1 Y0
0059 ```
0060
0061 LB is the state of the left button (1 means down)
0062 RB is the state of the right button (1 means down)
0063 X7-X0 movement in X direction since last packet (signed byte)
0064 Y7-Y0 movement in Y direction since last packet (signed byte)
0065
0066 The high order bit of each byte (D7) is ignored. Bit D6 indicates the start of an event, which allows the software to synchronize with the mouse.
0067
0068 Graphical representation of a packet
0069
0070 ```
0071 1st byte 2nd byte 3rd byte
0072 ================ =============== ================
0073 - 1 ? ? Y Y X X - 0 X X X X X X - 0 Y Y Y Y Y Y
0074 ================ =============== ================
0075 | | \ / \ / \---------/ \---------/
0076 | | | | | |
0077 | | | \----\ | |
0078 | | \--------|-------|--------\ |
0079 | | / \ /---------\ / \ /---------\
0080 | | ================ =================
0081 | | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0082 Left Button --/ | ================ =================
0083 Right Button ----/ X increment Y increment
0084 ```
0085
0086 3 Button Logitech extension
0087
0088 Logitech extended the 2 button mouse protocol to support 3 button mice
0089 by adding a 4th byte when the middle button is pressed (and the first
0090 packet after it is released). If a 4th byte is encountered (i.e., an
0091 extra byte with D6 set to 0) then D5 of that byte (0x20) indicates the
0092 status of the middle mouse button.
0093
0094
0095 Mouse systems mouse
0096 -------------------
0097
0098 Serial data parameters:
0099 1200bps, 8 databits, 1 stop-bit
0100
0101 5 byte Mouse Systems packet
0102
0103 ```
0104 D7 D6 D5 D4 D3 D2 D1 D0
0105
0106 Byte 1 1 0 0 0 0 LB CB RB
0107 Byte 2 X7 X6 X5 X4 X3 X2 X1 X0
0108 Byte 3 Y7 Y6 Y5 Y4 Y3 Y4 Y1 Y0
0109 Byte 4 X7' X6' X5' X4' X3' X2' X1' X0'
0110 Byte 5 Y7' Y6' Y5' Y4' Y3' Y4' Y1' Y0'
0111 ```
0112
0113 LB is left button state (0=pressed, 1=released)
0114 CB is center button state (0=pressed, 1=released)
0115 RB is right button state (0=pressed, 1=released)
0116 X7-X0 movement in X direction since last packet in signed byte
0117 format (-128..+127), positive direction right
0118 Y7-Y0 movement in Y direction since last packet in signed byte
0119 format (-128..+127), positive direction up
0120 X7'-X0' movement in X direction since sending of X7-X0 packet in signed byte
0121 format (-128..+127), positive direction right
0122 Y7'-Y0' movement in Y direction since sending of Y7-Y0 in signed byte
0123 format (-128..+127), positive direction up
0124
0125 The last two bytes in the packet (bytes 4 and 5) contain information
0126 about movement data changes which have occured after data bytes 2 and
0127 3 have been sent.
0128
0129 PS/2 mouse
0130
0131 The standard PS/2 mouse (such as the Logitech mouse) defaults to 160 CPI
0132 and can be switched to 40, 80, 160 or 320 CPI via software. The Microsoft
0133 mouse driver for Windows 3.x and Windows 95 defaults to 160 counts per
0134 inch. The maximum tracking rate for PS/2 mouse is 40 reports/second *
0135 255 counts per report, or 10200 counts per second. A 100 CPI mouse could
0136 discriminate motion up to 102 inches per second while a 400 CPI mouse
0137 could discriminate motion up to 25.2 inches per second.
0138
0139
0140 Connector pinout
0141 ----------------
0142 ```
0143 Pin Wire Name
0144 1 DATA
0145 2 Reserved
0146 3 Ground
0147 4 +5V Supply
0148 5 CLK
0149 6 Reserved
0150 Shield Chassis
0151 ```
0152
0153 Packet Format
0154 -------------
0155 ```
0156 D7 D6 D5 D4 D3 D2 D1 D0
0157 Byte 1 XV XV YS XS 1 M R L
0158 Byte 2 X7 X6 X5 X4 X3 X2 X1 X0
0159 Byte 3 Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0
0160
0161 L Left button state (1 = pressed down)
0162 M Middle button state (1 = pressed down)
0163 R Right button state (1 = pressed down)
0164 X0-X7 Movement in X direction
0165 Y0-Y7 Movement in Y direction
0166 XS,YS Movement data sign bits (1 = negative)
0167 XV,YV Movement data overflow bits (1 = overflow has occured)
0168 ```
0169
0170 Physical connector
0171 ------------------
0172
0173 The PS/2 mouse connector has the following pinout when looking at the
0174 connector on the back of the computer:
0175
0176 ```
0177 4 u 6
0178 1 . 2
0179 3 5
0180
0181 1. GND
0182 2. +5V
0183 3. DATA
0184 4. CLOCK
0185 5. Not used
0186 6. Not used
0187 ```
0188
0189 Bi-directional transmission is controlled by the CLK and DATA lines. Both
0190 are fed by an open collector device which lets either host or mouse force
0191 the line to "0". During non-transmission, CLK is at "1" and DATA can be at
0192 "0" or "1".
0193
0194 The host can inhibit mouse transmission by forcing CLK to "0". If the
0195 host inhibits the mouse while it is transmitting, the byte must be
0196 retransmitted (if the inhibit state arrived before the 11th clock).
0197
0198 Receiving data: Check 'clock'. If inactive, there is a bit on the 'data'
0199 line. Each transmission unit is one start bit, eight data bits, odd
0200 parity and one stop bit. Start bits are low, stop bits high. Each clock
0201 active or inactive period is 30 to 50 microseconds. Data transition to
0202 falling edge of clock is 5 to 25 microseconds.
0203
0204 Sending: Check that both clock and data are high. Pull down data for
0205 start bit, and start clocking.
0206
0207 NOTE: Logitech has made the extension to this protocol to allow three
0208 buttons (the M bit is always 0 on 2 button mice).
0209
0210 References
0211
0212 * Original PC mouse info page by Tomi Engdahl
0213 http://www.hut.fi/~then/mytexts/mouse.html
0214
0215 * PC Magazine May 28, 1991
0216
0217 * Programmer's Reference to Genius Mouse
0218 ftp://x2ftp.oulu.fi/pub/msdos/programming/docs/gmouse.doc
0219
0220 * Logitech Pointing Device Hardware Information Product Support Document # 1410
0221 ftp://ftp.logitech.com/pub/TechSupport/MOUSE/HELP/1410.txt
0222
0223 * Mice: How do they work? by Richard Torrens
0224 http://box.argonet.co.uk/users/4qd/meece.html
0225
0226 * In Pursuit Of The Perfect Portable Pointer by Intelink Electronics
0227 from EDN Products Edition April 16, 1977 pages 43-45
0228
0229 * Programming the Microsoft Mouse
0230 http://www.geocities.com/SiliconValley/2151/mouse.html