-
Notifications
You must be signed in to change notification settings - Fork 2
/
protocol.txt
225 lines (157 loc) · 7.42 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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
These are some notes I took on the protocol as I was reversing it. Some of the notes will be out-of-date.
The keyboard has three USB interfaces. The one of interest has the following description.
# 8BitDo 8BitDo Retro Keyboard
# 0x05, 0x8c, // Usage Page (Bar Code Scanner) 0
# 0x09, 0x01, // Usage (Vendor Usage 0x01) 2
# 0xa1, 0x01, // Collection (Application) 4
# 0x85, 0xb1, // Report ID (177) 6
# 0x09, 0x02, // Usage (Vendor Usage 0x02) 8
# 0x15, 0x00, // Logical Minimum (0) 10
# 0x26, 0xff, 0x00, // Logical Maximum (255) 12
# 0x75, 0x08, // Report Size (8) 15
# 0x95, 0x20, // Report Count (32) 17
# 0x81, 0x02, // Input (Data,Var,Abs) 19
# 0x85, 0xb2, // Report ID (178) 21
# 0x09, 0x03, // Usage (Vendor Usage 0x03) 23
# 0x95, 0x20, // Report Count (32) 25
# 0x75, 0x08, // Report Size (8) 27
# 0x15, 0x00, // Logical Minimum (0) 29
# 0x26, 0xff, 0x00, // Logical Maximum (255) 31
# 0x91, 0x02, // Output (Data,Var,Abs) 34
# 0x85, 0x54, // Report ID (84) 36
# 0x15, 0x00, // Logical Minimum (0) 38
# 0x26, 0xff, 0x00, // Logical Maximum (255) 40
# 0x09, 0x07, // Usage (Vendor Usage 0x07) 43
# 0x75, 0x08, // Report Size (8) 45
# 0x95, 0x20, // Report Count (32) 47
# 0x81, 0x02, // Input (Data,Var,Abs) 49
# 0x85, 0x51, // Report ID (81) 51
# 0x09, 0x08, // Usage (Vendor Usage 0x08) 53
# 0x95, 0x20, // Report Count (32) 55
# 0x75, 0x08, // Report Size (8) 57
# 0x15, 0x00, // Logical Minimum (0) 59
# 0x26, 0xff, 0x00, // Logical Maximum (255) 61
# 0x91, 0x02, // Output (Data,Var,Abs) 64
# 0x85, 0x52, // Report ID (82) 66
# 0x09, 0x09, // Usage (Vendor Usage 0x09) 68
# 0x95, 0x20, // Report Count (32) 70
# 0x75, 0x08, // Report Size (8) 72
# 0x15, 0x00, // Logical Minimum (0) 74
# 0x26, 0xff, 0x00, // Logical Maximum (255) 76
# 0x91, 0x02, // Output (Data,Var,Abs) 79
# 0xc0, // End Collection 81
-----
Map a key
---------
Send (attention?):
5276ff000000000000000000000000000000000000000000000000000000000000
Receive (nothing to report?):
548a07010000000000000000000000000000000000000000000000000000000000
Send:
52fa030c00aa0971 29 07 0004 000000000000000000000000000000000000000000
------fixed----- | | |
hardware key -/ | |
kbd(07) / mouse(01)-/ |
mapped key-/
Receive (ok?):
54e408000000000000000000000000000000000000000000000000000000000000
Send (not needed?):
5276a5000000000000000000000000000000000000000000000000000000000000
Receive (ok?):
54e408000000000000000000000000000000000000000000000000000000000000
Next reads will receive (nothing to report?):
548a07010000000000000000000000000000000000000000000000000000000000
Reset a key
-----------
Set it to it's default key (e.g. Esc to Esc).
Disable a key
-------------
Set it to 0000. Example, disable B super key:
52fa030c00aa0971 6c 07 0000000000000000000000000000000000000000000000
Load a profile in software
--------------------------
Send:
5276ff000000000000000000000000000000000000000000000000000000000000
Receive (ok):
54e408000000000000000000000000000000000000000000000000000000000000
Send:
528000000000000000000000000000000000000000000000000000000000000000
Receive profile name:
5480 1000 00700072006f00660069006c0065003100000000000000000000000000
| | --- profile name (UTF-16 ??) -----------------------------
fixd |
\- profile present (yes: 1000, no: 0000)
54 80 10 00 00 70 00 72 00 6f 00 66 00 69 00 6c T....p.r.o.f.i.l
00 65 00 31 00 00 00 00 00 00 00 00 00 00 00 00 .e.1............
00 .
Example no profile:
5480 0000 0000000000000000000000000000000000000000000000000000000000
Send (if profile present):
528100000000000000000000000000000000000000000000000000000000000000
Seems less than 1 ms (0.7 ms ok) must pass between previous message.
Receive which keys are mapped:
Example 1, only Esc (0x29) key mapped:
5481 29 07 0000000000000000000000000000000000000000000000000000000000
| | | \- terminator
fixd | |
key-/ |
delimit-/
Example 2, many mapped keys:
5481 04 07 07 07 08 0709070a070b070c070d070e070f0712071307140715071607 01
5481 17 07 18 07 1a 071c071e071f07200721072207230724072507260727072807 01
5481 29 07 2a 07 2b 072c072d072e072f073007310733073407350739073a073b07 01
5481 3c 07 3d 07 3e 073f0740074107420743074407450746074707480749074a07 01
5481 4b 07 4c 07 4d 074e074f07500751076407650766076707680769076a076c07 01
5481 6d 07 00 00 00 00000000000000000000000000000000000000000000000000 00
Get key mapping
---------------
Send (attention?):
5276ff000000000000000000000000000000000000000000000000000000000000
Receive (ok?):
54e408000000000000000000000000000000000000000000000000000000000000
Send:
5283 04 000000000000000000000000000000000000000000000000000000000000
| |
fixd |
hkey-/
Receive:
5483 04 07 0005 000000000000000000000000000000000000000000000000000000
| | | |
fixd | | |
hkey-/ | |
hid tab-/ |
mapped key-/
Delete/reset profile
--------------------
Send:
527000000000000000000000000000000000000000000000000000000000000000
Receive (ok?):
54e408000000000000000000000000000000000000000000000000000000000000
Create profile
--------------
Send (reset?):
527000000000000000000000000000000000000000000000000000000000000000
Receive (ok?):
54e408000000000000000000000000000000000000000000000000000000000000
Send (profile name, see rename):
5270100000700072006f00660069006c0065003100000000000000000000000000
Receive (ok?):
54e408000000000000000000000000000000000000000000000000000000000000
Rename profile
--------------
Send "attention"? Seemingly uneeded?
Send:
52701000 00700072006f00660069006c0065003100000000000000000000000000
-fixed-- --- profile name (UTF-16 ??) -----------------------------
52 70 10 00 00 70 00 72 00 6f 00 66 00 69 00 6c Rp...p.r.o.f.i.l
00 65 00 33 00 00 00 00 00 00 00 00 00 00 00 00 .e.3............
00 .
error ??
--------
receive:
0c00000000000000000000000000000000
report firmware version ??
--------------------------
b2aa5503fc01606000000000000000000000000000000000000000000000000000
- mapping keys in inactive profiles does not write them. unmapped profiles exist only on the PC
- protocol seems timing sensitive. some things work only if less than x time passes between messages