31
31
32
32
from adafruit_usb_descriptor import hid
33
33
34
- class HIDReportDescriptors :
35
- pass
36
-
37
- HIDReportDescriptors .REPORT_IDS = {
34
+ REPORT_IDS = {
38
35
"KEYBOARD" : 1 ,
39
36
"MOUSE" : 2 ,
40
37
"CONSUMER" : 3 ,
@@ -44,7 +41,7 @@ class HIDReportDescriptors:
44
41
}
45
42
46
43
# Byte count for each kind of report. Length does not include report ID in first byte.
47
- HIDReportDescriptors . REPORT_LENGTHS = {
44
+ REPORT_LENGTHS = {
48
45
"KEYBOARD" : 8 ,
49
46
"MOUSE" : 4 ,
50
47
"CONSUMER" : 2 ,
@@ -53,14 +50,14 @@ class HIDReportDescriptors:
53
50
"DIGITIZER" : 5 ,
54
51
}
55
52
56
- HIDReportDescriptors . KEYBOARD_WITH_ID = hid .ReportDescriptor (
53
+ KEYBOARD_WITH_ID = hid .ReportDescriptor (
57
54
description = "KEYBOARD" ,
58
55
report_descriptor = bytes ([
59
56
# Regular keyboard
60
57
0x05 , 0x01 , # Usage Page (Generic Desktop)
61
58
0x09 , 0x06 , # Usage (Keyboard)
62
59
0xA1 , 0x01 , # Collection (Application)
63
- 0x85 , HIDReportDescriptors . REPORT_IDS ["KEYBOARD" ], # Report ID (1)
60
+ 0x85 , REPORT_IDS ["KEYBOARD" ], # Report ID (1)
64
61
0x05 , 0x07 , # Usage Page (Keyboard)
65
62
0x19 , 224 , # Usage Minimum (224)
66
63
0x29 , 231 , # Usage Maximum (231)
@@ -90,7 +87,7 @@ class HIDReportDescriptors:
90
87
0xC0 , # End Collection
91
88
]))
92
89
93
- HIDReportDescriptors . MOUSE_WITH_ID = hid .ReportDescriptor (
90
+ MOUSE_WITH_ID = hid .ReportDescriptor (
94
91
description = "MOUSE" ,
95
92
report_descriptor = bytes ([
96
93
# Regular mouse
@@ -99,7 +96,7 @@ class HIDReportDescriptors:
99
96
0xA1 , 0x01 , # Collection (Application)
100
97
0x09 , 0x01 , # Usage (Pointer)
101
98
0xA1 , 0x00 , # Collection (Physical)
102
- 0x85 , HIDReportDescriptors . REPORT_IDS ["MOUSE" ], # Report ID (n)
99
+ 0x85 , REPORT_IDS ["MOUSE" ], # Report ID (n)
103
100
0x05 , 0x09 , # Usage Page (Button)
104
101
0x19 , 0x01 , # Usage Minimum (0x01)
105
102
0x29 , 0x05 , # Usage Maximum (0x05)
@@ -129,14 +126,14 @@ class HIDReportDescriptors:
129
126
0xC0 , # End Collection
130
127
]))
131
128
132
- HIDReportDescriptors . CONSUMER_WITH_ID = hid .ReportDescriptor (
129
+ CONSUMER_WITH_ID = hid .ReportDescriptor (
133
130
description = "CONSUMER" ,
134
131
report_descriptor = bytes ([
135
132
# Consumer ("multimedia") keys
136
133
0x05 , 0x0C , # Usage Page (Consumer)
137
134
0x09 , 0x01 , # Usage (Consumer Control)
138
135
0xA1 , 0x01 , # Collection (Application)
139
- 0x85 , HIDReportDescriptors . REPORT_IDS ["CONSUMER" ], # Report ID (n)
136
+ 0x85 , REPORT_IDS ["CONSUMER" ], # Report ID (n)
140
137
0x75 , 0x10 , # Report Size (16)
141
138
0x95 , 0x01 , # Report Count (1)
142
139
0x15 , 0x01 , # Logical Minimum (1)
@@ -147,14 +144,14 @@ class HIDReportDescriptors:
147
144
0xC0 , # End Collection
148
145
]))
149
146
150
- HIDReportDescriptors . SYS_CONTROL_WITH_ID = hid .ReportDescriptor (
147
+ SYS_CONTROL_WITH_ID = hid .ReportDescriptor (
151
148
description = "SYS_CONTROL" ,
152
149
report_descriptor = bytes ([
153
150
# Power controls
154
151
0x05 , 0x01 , # Usage Page (Generic Desktop Ctrls)
155
152
0x09 , 0x80 , # Usage (Sys Control)
156
153
0xA1 , 0x01 , # Collection (Application)
157
- 0x85 , HIDReportDescriptors . REPORT_IDS ["SYS_CONTROL" ], # Report ID (n)
154
+ 0x85 , REPORT_IDS ["SYS_CONTROL" ], # Report ID (n)
158
155
0x75 , 0x02 , # Report Size (2)
159
156
0x95 , 0x01 , # Report Count (1)
160
157
0x15 , 0x01 , # Logical Minimum (1)
@@ -168,14 +165,14 @@ class HIDReportDescriptors:
168
165
0xC0 , # End Collection
169
166
]))
170
167
171
- HIDReportDescriptors . GAMEPAD_WITH_ID = hid .ReportDescriptor (
168
+ GAMEPAD_WITH_ID = hid .ReportDescriptor (
172
169
description = "GAMEPAD" ,
173
170
report_descriptor = bytes ([
174
171
# Gamepad with 16 buttons and two joysticks
175
172
0x05 , 0x01 , # Usage Page (Generic Desktop Ctrls)
176
173
0x09 , 0x05 , # Usage (Game Pad)
177
174
0xA1 , 0x01 , # Collection (Application)
178
- 0x85 , HIDReportDescriptors . REPORT_IDS ["GAMEPAD" ], # Report ID (n)
175
+ 0x85 , REPORT_IDS ["GAMEPAD" ], # Report ID (n)
179
176
0x05 , 0x09 , # Usage Page (Button)
180
177
0x19 , 0x01 , # Usage Minimum (Button 1)
181
178
0x29 , 0x10 , # Usage Maximum (Button 16)
@@ -197,14 +194,14 @@ class HIDReportDescriptors:
197
194
0xC0 , # End Collection
198
195
]))
199
196
200
- HIDReportDescriptors . DIGITIZER_WITH_ID = hid .ReportDescriptor (
197
+ DIGITIZER_WITH_ID = hid .ReportDescriptor (
201
198
description = "DIGITIZER" ,
202
199
report_descriptor = bytes ([
203
200
# Digitizer (used as an absolute pointer)
204
201
0x05 , 0x0D , # Usage Page (Digitizers)
205
202
0x09 , 0x02 , # Usage (Pen)
206
203
0xA1 , 0x01 , # Collection (Application)
207
- 0x85 , HIDReportDescriptors . REPORT_IDS ["DIGITIZER" ], # Report ID (n)
204
+ 0x85 , REPORT_IDS ["DIGITIZER" ], # Report ID (n)
208
205
0x09 , 0x01 , # Usage (Stylus)
209
206
0xA1 , 0x00 , # Collection (Physical)
210
207
0x09 , 0x32 , # Usage (In-Range)
@@ -232,11 +229,11 @@ class HIDReportDescriptors:
232
229
]))
233
230
234
231
# Byte count for each kind of report. Length does not include report ID in first byte.
235
- HIDReportDescriptors . REPORT_DESCRIPTORS = {
236
- "KEYBOARD" : HIDReportDescriptors . KEYBOARD_WITH_ID ,
237
- "MOUSE" : HIDReportDescriptors . MOUSE_WITH_ID ,
238
- "CONSUMER" : HIDReportDescriptors . CONSUMER_WITH_ID ,
239
- "SYS_CONTROL" : HIDReportDescriptors . SYS_CONTROL_WITH_ID ,
240
- "GAMEPAD" : HIDReportDescriptors . GAMEPAD_WITH_ID ,
241
- "DIGITIZER" : HIDReportDescriptors . DIGITIZER_WITH_ID ,
232
+ REPORT_DESCRIPTORS = {
233
+ "KEYBOARD" : KEYBOARD_WITH_ID ,
234
+ "MOUSE" : MOUSE_WITH_ID ,
235
+ "CONSUMER" : CONSUMER_WITH_ID ,
236
+ "SYS_CONTROL" : SYS_CONTROL_WITH_ID ,
237
+ "GAMEPAD" : GAMEPAD_WITH_ID ,
238
+ "DIGITIZER" : DIGITIZER_WITH_ID ,
242
239
}
0 commit comments