-
Notifications
You must be signed in to change notification settings - Fork 4
/
protocol.txt
207 lines (162 loc) · 8.91 KB
/
protocol.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
Serial mouse reset
------------------
1: Set UART to 'break line' state (set bit 6 in the LCR).
2: Clear the RTS and DTR (bits 0-1) in the MCR, wait a while.
3: Set the RTS and DTR bits again.
Serial mouse detection (identification bytes before optional PnP data)
----------------------------------------------------------------------
In Mouse Systems mode, mouse sends nothing.
In Microsoft mode, mouse sends 'M' after dropping and raising RTS.
In Logitech mode, mouse sends 'M3' after dropping and raising RTS.
In wheel mode, mouse sends 'MZ@',0,0,0 after dropping and raising RTS.
PS/2 pointing device ID (reported after 0F2h command)
-----------------------------------------------------
In standard mode, the device reports 0.
In wheel mode, the device reports 3. This mode is enabled by sending a
Select Report Rate 200, a Rate 100 and finally a Rate 80 command sequence.
In extended mode, the device reports 4. This mode is enabled by sending a
Select Report Rate 200, a Rate 200 and finally a Rate 80 command sequence.
===========================================================================
Serial Mouse Systems mode: 1200 bps, 8 data bits, 1 stop bit, no parity
1st byte 2nd byte 3rd byte
+---------------+ +---------------+ +---------------+
|1|0|0|0|0|L|M|R| |X|X|X|X|X|X|X|X| |Y|Y|Y|Y|Y|Y|Y|Y|
+---------------+ +---------------+ +---------------+
| | | Xa movement Ya movement
| | |
| | | 4th byte 5th byte
Left Button ------+ | | +---------------+ +---------------+
Middle Button --------+ | |X|X|X|X|X|X|X|X| |Y|Y|Y|Y|Y|Y|Y|Y|
Right Button ----------+ +---------------+ +---------------+
(0 if pressed) Xb movement Yb movement
Xa/Ya - movement of the mouse since last packet.
Xb/Yb - movement of the mouse since Xa/Ya.
Movement values are 8-bit signed twos complement integers.
Positive movement value indicates motion to the right/upward.
===========================================================================
Serial Microsoft mode: 1200 bps, 7 data bits, 1 stop bit, no parity
1st byte 2nd byte 3rd byte
+---------------+ +---------------+ +---------------+
|0|1|L|R|Y|Y|X|X| |0|0|X|X|X|X|X|X| |0|0|Y|Y|Y|Y|Y|Y|
+---------------+ +---------------+ +---------------+
| | \ / \ / \----+----/ \----+----/
| | | | | |
| | +---|-------------|---------+ |
| | +-----+ | | |
| | / \ /----+----\ / \ /----+----\
| | +---------------+ +---------------+
Left Button -+ | | | | | | | | | | | | | | | | | | |
Right Button ---+ +---------------+ +---------------+
(1 if pressed) X movement Y movement
Movement values are 8-bit signed twos complement integers.
Positive movement value indicates motion to the right/downward.
===========================================================================
Serial Logitech mode: 1200 bps, 7 data bits, 1 stop bit, no parity
1st byte 2nd byte 3rd byte
+---------------+ +---------------+ +---------------+
|0|1|L|R|Y|Y|X|X| |0|0|X|X|X|X|X|X| |0|0|Y|Y|Y|Y|Y|Y|
+---------------+ +---------------+ +---------------+
| | \ / \ / \----+----/ \----+----/
| | | | | |
| | +---|-------------|---------+ |
| | +-----+ | | |
| | / \ /----+----\ / \ /----+----\
| | +---------------+ +---------------+
Left Button -+ | | | | | | | | | | | | | | | | | | |
Right Button ---+ +---------------+ +---------------+
(1 if pressed) X movement Y movement
The extra byte (only when middle button is pressed)
---------------------------------------------------
4th byte
+---------------+
|0|0|M|0|0|0|0|0|
+---------------+
|
Middle Button (1 if pressed)
First three bytes are equal to Mouse mode packet.
Movement values are 8-bit signed twos complement integers.
Positive movement value indicates motion to the right/downward.
===========================================================================
Serial Microsoft wheel mode: 1200 bps, 7 data bits, 1 stop bit, no parity
1st byte 2nd byte 3rd byte 4th byte
+---------------+ +---------------+ +---------------+ +---------------+
|0|1|L|R|Y|Y|X|X| |0|0|X|X|X|X|X|X| |0|0|Y|Y|Y|Y|Y|Y| |0|0|0|M|w|w|w|w|
+---------------+ +---------------+ +---------------+ +---------------+
| | \ / \ / \----+----/ \----+----/ | \--+--/
| | | | | | | |
| | +---|-------------|---------+ | | |
| | +-----+ | | | | Wheel
| | / \ /----+----\ / \ /----+----\ | Movement
| | +---------------+ +---------------+ |
Left Button -+ | | | | | | | | | | | | | | | | | | | |
Right Button ---+ +---------------+ +---------------+ Middle Button
(1 if pressed) X movement Y movement (1 if pressed)
First three bytes are equal to Mouse mode packet.
Movement values are 8-bit signed twos complement integers.
Positive movement value indicates motion to the right/downward.
Wheel movement is a 4-bit signed twos complement integer.
Positive wheel movement value indicates rotation downward.
===========================================================================
PS/2 standard mode protocol:
1st byte 2nd byte 3rd byte
+---------------+ +---------------+ +---------------+
|?|?|Y|X|1|M|R|L| |X|X|X|X|X|X|X|X| |Y|Y|Y|Y|Y|Y|Y|Y|
+---------------+ +---------------+ +---------------+
| | | | | \------+------/ \------+------/
| | | | | | |
+-|---|-|-|----------|-----------+ |
+---|-|-|--+ | | |
| | | | /-----+-------\ | /---+---------\
Middle Button ------+ | | +-----------------+ +-----------------+
Right Button --------+ | | | | | | | | | | | | | | | | | | | | |
Left Button ----------+ +-----------------+ +-----------------+
(1 if pressed) X movement Y movement
Two most significant bits in first byte indicate overflow (more than 9 bits
of movement) in each direction. Usually ignored.
Movement values are 9-bit signed twos complement integers.
Positive movement value indicates motion to the right/upward.
===========================================================================
PS/2 wheel mode protocol:
1st byte 2nd byte 3rd byte 4th byte
+---------------+ +---------------+ +---------------+ +---------------+
|?|?|Y|X|1|M|R|L| |X|X|X|X|X|X|X|X| |Y|Y|Y|Y|Y|Y|Y|Y| |w|w|w|w|W|W|W|W|
+---------------+ +---------------+ +---------------+ +---------------+
| | | | | \------+------/ \------+------/ \-------+-----/
| | | | | | | |
+-|---|-|-|----------|-----------+ | |
+---|-|-|--+ | | | |
| | | | /-----+-------\ | /---+---------\ |
Middle Button ------+ | | +-----------------+ +-----------------+ |
Right Button --------+ | | | | | | | | | | | | | | | | | | | | | |
Left Button ----------+ +-----------------+ +-----------------+ Wheel
(1 if pressed) X movement Y movement Movement
First three bytes are equal to PS/2 standard mode packet.
Two most significant bits in first byte indicate overflow (more than 9 bits
of movement) in each direction. Usually ignored.
Movement values are 9-bit signed twos complement integers.
Positive movement value indicates motion to the right/upward.
Wheel movement is a 8-bit signed twos complement integer and usually
limited by -8..+7 range (4-bit value).
Positive wheel movement value indicates rotation downward.
===========================================================================
PS/2 extended mode protocol:
1st byte 2nd byte 3rd byte 4th byte
+---------------+ +---------------+ +---------------+ +---------------+
|?|?|Y|X|1|M|R|L| |X|X|X|X|X|X|X|X| |Y|Y|Y|Y|Y|Y|Y|Y| |0|0|B|F|W|W|W|W|
+---------------+ +---------------+ +---------------+ +---------------+
| | | | | \------+------/ \------+------/ | | \--+--/
| | | | | | | | | |
+-|---|-|-|----------|-----------+ | | | |
+---|-|-|--+ | | | | | Wheel
| | | | /-----+-------\ | /---+---------\ | | Movement
Middle Button ------+ | | +-----------------+ +-----------------+ | |
Right Button --------+ | | | | | | | | | | | | | | | | | | | | | | +- Forward Button
Left Button ----------+ +-----------------+ +-----------------+ +--- Back Button
(1 if pressed) X movement Y movement (1 if pressed)
First three bytes are equal to PS/2 standard mode packet.
Two most significant bits in first byte indicate overflow (more than 9 bits
of movement) in each direction. Usually ignored.
Movement values are 9-bit signed twos complement integers.
Positive movement value indicates motion to the right/upward.
Wheel movement is a 4-bit signed twos complement integer.
Positive wheel movement value indicates rotation downward.