source: rtems/cpukit/libmisc/mouse/README @ 3d6c1bb

4.11
Last change on this file since 3d6c1bb was 3d6c1bb, checked in by Joel Sherrill <joel.sherrill@…>, on Mar 14, 2011 at 2:56:08 PM

2011-03-14 Joel Sherrill <joel.sherrill@…>

PR 1762/cpukit

  • Makefile.am, preinstall.am, libmisc/Makefile.am, wrapup/Makefile.am: Add generic serial mouse driver and mouse parser. The parser code was in the pc386 BSP but was generic so cleaned up and placed here. Serial mouse driver itself is new.
  • libmisc/mouse/README, libmisc/mouse/mouse_parser.c, libmisc/mouse/mouse_parser.h, libmisc/mouse/serial_mouse.c, libmisc/mouse/serial_mouse.h: New files.
  • Property mode set to 100644
File size: 7.9 KB
Line 
1#
2#  $Id$
3#
4
5SOURCE: http://www.kryslix.com/nsfaq/Q.12.html
6
7Subject: What protocol do mice use?
8Date: 09/16/97
9Updated: 11/16/00 This document was adapated from a web page produced by
10Tomi Engdahl <then@delta.hut.fi>
11Microsoft serial mouse
12Description
13
14The Microsoft serial mouse is the most popular 2 button mouse. It is
15supported by all major operating systems. The maximum tracking rate for
16a Microsoft mouse is 40 reports/second * 127 counts per report, in other
17words, 5080 counts per second. The most common range for mice is is 100
18to 400 CPI (counts per inch) but can be up to 1000 CPI. A 100CPI mouse
19can discriminate motion up to 50.8 inches/second while a 400 CPI mouse
20can only discriminate motion up to 12.7 inches/second.
21Pinout
22
239 pin  25 pin    Line    Comments
24shell  1         GND
253      2         TD      Serial data from host to mouse (only for power)
262      3         RD      Serial data from mouse to host
277      4         RTS     Positive voltage to mouse
288      5         CTS
296      6         DSR
305      7         SGND
314      20        DTR     Positive voltage to mouse and reset/detection
32
33RTS = Request to Send   CTS  = Clear to Send
34DSR = Data Set Ready    DTR  = Data Terminal Ready
35GND = Protective Ground SGND = Signal Ground
36
37To function correctly, both the RTS and DTR lines must be
38positive. DTR/DSR and RTS/CTS must NOT be shorted. RTS may be toggled
39negative for at least 100ms to reset the mouse. (After a cold boot, the
40RTS line is usually negative. This provides an automatic toggle when
41RTS is brought positive). When DTR is toggled the mouse should send a
42single byte 0x45 (ASCII 'M').
43
44Serial data parameters:
451200bps, 7 databits, 1 stop-bit
46
47Data packet format:
48
49Data is sent in 3 byte packets for each event (a button is pressed or
50released or the mouse moves):
51
52        D7      D6      D5      D4      D3      D2      D1      D0
53 
54Byte 1  X       1       LB      RB      Y7      Y6      X7      X6
55Byte 2  X       0       X5      X4      X3      X2      X1      X0     
56Byte 3  X       0       Y5      Y4      Y3      Y2      Y1      Y0
57
58LB is the state of the left button (1 means down)
59RB is the state of the right button (1 means down)
60X7-X0 movement in X direction since last packet (signed byte)
61Y7-Y0 movement in Y direction since last packet (signed byte)
62
63The 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.
64
65Graphical representation of a packet
66
67              1st byte        2nd byte         3rd byte
68          ================  ===============  ================
69           - 1 ? ? Y Y X X  - 0 X X X X X X  - 0 Y Y Y Y Y Y
70          ================  ===============  ================
71               | | \ / \ /      \---------/      \---------/
72               | |  |   |            |                |
73               | |  |   \----\       |                |
74               | |  \--------|-------|--------\       |
75               | |          / \ /---------\  / \ /---------\
76               | |         ================ =================
77               | |          0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0
78 Left Button --/ |         ================ =================
79Right Button ----/            X increment      Y increment
80
813 Button Logitech extension
82
83Logitech extended the 2 button mouse protocol to support 3 button mice
84by adding a 4th byte when the middle button is pressed (and the first
85packet after it is released). If a 4th byte is encountered (i.e., an
86extra byte with D6 set to 0) then D5 of that byte (0x20) indicates the
87status of the middle mouse button.
88
89Mouse systems mouse
90
91Serial data parameters:
92
931200bps, 8 databits, 1 stop-bit
94
955 byte Mouse Systems packet
96
97        D7      D6      D5      D4      D3      D2      D1      D0
98
99Byte 1  1       0       0       0       0       LB      CB      RB
100Byte 2  X7      X6      X5      X4      X3      X2      X1      X0
101Byte 3  Y7      Y6      Y5      Y4      Y3      Y4      Y1      Y0
102Byte 4  X7'     X6'     X5'     X4'     X3'     X2'     X1'     X0'
103Byte 5  Y7'     Y6'     Y5'     Y4'     Y3'     Y4'     Y1'     Y0'
104
105LB is left button state (0=pressed, 1=released)
106CB is center button state (0=pressed, 1=released)
107RB is right button state (0=pressed, 1=released)
108X7-X0 movement in X direction since last packet in signed byte
109      format (-128..+127), positive direction right
110Y7-Y0 movement in Y direction since last packet in signed byte
111      format (-128..+127), positive direction up
112X7'-X0' movement in X direction since sending of X7-X0 packet in signed byte
113      format (-128..+127), positive direction right
114Y7'-Y0' movement in Y direction since sending of Y7-Y0 in signed byte
115      format (-128..+127), positive direction up
116
117The last two bytes in the packet (bytes 4 and 5) contain information
118about movement data changes which have occured after data bytes 2 and
1193 have been sent.
120
121PS/2 mouse
122
123The standard PS/2 mouse (such as the Logitech mouse) defaults to 160 CPI
124and can be switched to 40, 80, 160 or 320 CPI via software. The Microsoft
125mouse driver for Windows 3.x and Windows 95 defaults to 160 counts per
126inch. The maximum tracking rate for PS/2 mouse is 40 reports/second *
127255 counts per report, or 10200 counts per second. A 100 CPI mouse could
128discriminate motion up to 102 inches per second while a 400 CPI mouse
129could discriminate motion up to 25.2 inches per second.
130
131Connector pinout
132
133Pin     Wire Name
1341       DATA
1352       Reserved
1363       Ground
1374       +5V Supply
1385       CLK
1396       Reserved
140Shield  Chassis
141
142Packet Format
143
144        D7      D6      D5      D4      D3      D2      D1      D0
145Byte 1  XV      XV      YS      XS       1       M       R       L
146Byte 2  X7      X6      X5      X4      X3      X2      X1      X0
147Byte 3  Y7      Y6      Y5      Y4      Y3      Y2      Y1      Y0
148
149L       Left button state (1 = pressed down)
150M       Middle button state (1 = pressed down)
151R       Right button state (1 = pressed down)
152X0-X7   Movement in X direction
153Y0-Y7   Movement in Y direction
154XS,YS   Movement data sign bits (1 = negative)
155XV,YV   Movement data overflow bits (1 = overflow has occured)
156
157Physical connector
158
159The PS/2 mouse connector has the following pinout when looking at the
160connector on the back of the computer:
161
162        4 u 6
163       1  .  2
164        3   5
165
1661.      GND
1672.      +5V
1683.      DATA
1694.      CLOCK
1705.      Not used
1716.      Not used
172
173Bi-directional transmission is controlled by the CLK and DATA lines. Both
174are fed by an open collector device which lets either host or mouse force
175the line to "0". During non-transmission, CLK is at "1" and DATA can be at
176"0" or "1".
177
178The host can inhibit mouse transmission by forcing CLK to "0". If the
179host inhibits the mouse while it is transmitting, the byte must be
180retransmitted (if the inhibit state arrived before the 11th clock).
181
182Receiving data: Check 'clock'. If inactive, there is a bit on the 'data'
183line. Each transmission unit is one start bit, eight data bits, odd
184parity and one stop bit. Start bits are low, stop bits high. Each clock
185active or inactive period is 30 to 50 microseconds. Data transition to
186falling edge of clock is 5 to 25 microseconds.
187
188Sending: Check that both clock and data are high. Pull down data for
189start bit, and start clocking.
190
191NOTE: Logitech has made the extension to this protocol to allow three
192buttons (the M bit is always 0 on 2 button mice).
193
194References
195
196* Original PC mouse info page by Tomi Engdahl
197  http://www.hut.fi/~then/mytexts/mouse.html
198
199* PC Magazine May 28, 1991
200
201* Programmer's Reference to Genius Mouse
202  ftp://x2ftp.oulu.fi/pub/msdos/programming/docs/gmouse.doc
203
204* Logitech Pointing Device Hardware Information Product Support Document # 1410
205  ftp://ftp.logitech.com/pub/TechSupport/MOUSE/HELP/1410.txt
206
207* Mice: How do they work? by Richard Torrens
208  http://box.argonet.co.uk/users/4qd/meece.html
209
210* In Pursuit Of The Perfect Portable Pointer by Intelink Electronics
211from EDN Products Edition April 16, 1977 pages 43-45
212
213* Programming the Microsoft Mouse
214  http://www.geocities.com/SiliconValley/2151/mouse.html
Note: See TracBrowser for help on using the repository browser.