Skip to content

Commit 48f595e

Browse files
committed
convert wrapper class to just a module
1 parent 9daa1a6 commit 48f595e

File tree

2 files changed

+25
-28
lines changed

2 files changed

+25
-28
lines changed

ports/atmel-samd/tools/gen_usb_descriptor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
sys.path.append("../../tools/usb_descriptor")
88

99
from adafruit_usb_descriptor import cdc, hid, msc, standard, util
10-
from hid_report_descriptors import HIDReportDescriptors
10+
import hid_report_descriptors
1111

1212
parser = argparse.ArgumentParser(description='Generate USB descriptors.')
1313
parser.add_argument('--manufacturer', type=str,
@@ -141,10 +141,10 @@ def strings_in_order(cls):
141141
combined_hid_report_descriptor = hid.ReportDescriptor(
142142
description="MULTIDEVICE",
143143
report_descriptor=b''.join(
144-
HIDReportDescriptors.REPORT_DESCRIPTORS[name].report_descriptor for name in hid_devices ))
144+
hid_report_descriptors.REPORT_DESCRIPTORS[name].report_descriptor for name in hid_devices ))
145145

146-
hid_report_ids_dict = { name: HIDReportDescriptors.REPORT_IDS[name] for name in hid_devices }
147-
hid_report_lengths_dict = { name: HIDReportDescriptors.REPORT_LENGTHS[name] for name in hid_devices }
146+
hid_report_ids_dict = { name: hid_report_descriptors.REPORT_IDS[name] for name in hid_devices }
147+
hid_report_lengths_dict = { name: hid_report_descriptors.REPORT_LENGTHS[name] for name in hid_devices }
148148
hid_max_report_length = max(hid_report_lengths_dict.values())
149149

150150
# ASF4 expects keyboard and generic devices to have both in and out endpoints,

ports/atmel-samd/tools/hid_report_descriptors.py

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@
3131

3232
from adafruit_usb_descriptor import hid
3333

34-
class HIDReportDescriptors:
35-
pass
36-
37-
HIDReportDescriptors.REPORT_IDS = {
34+
REPORT_IDS = {
3835
"KEYBOARD" : 1,
3936
"MOUSE" : 2,
4037
"CONSUMER" : 3,
@@ -44,7 +41,7 @@ class HIDReportDescriptors:
4441
}
4542

4643
# Byte count for each kind of report. Length does not include report ID in first byte.
47-
HIDReportDescriptors.REPORT_LENGTHS = {
44+
REPORT_LENGTHS = {
4845
"KEYBOARD" : 8,
4946
"MOUSE" : 4,
5047
"CONSUMER" : 2,
@@ -53,14 +50,14 @@ class HIDReportDescriptors:
5350
"DIGITIZER" : 5,
5451
}
5552

56-
HIDReportDescriptors.KEYBOARD_WITH_ID = hid.ReportDescriptor(
53+
KEYBOARD_WITH_ID = hid.ReportDescriptor(
5754
description="KEYBOARD",
5855
report_descriptor=bytes([
5956
# Regular keyboard
6057
0x05, 0x01, # Usage Page (Generic Desktop)
6158
0x09, 0x06, # Usage (Keyboard)
6259
0xA1, 0x01, # Collection (Application)
63-
0x85, HIDReportDescriptors.REPORT_IDS["KEYBOARD"], # Report ID (1)
60+
0x85, REPORT_IDS["KEYBOARD"], # Report ID (1)
6461
0x05, 0x07, # Usage Page (Keyboard)
6562
0x19, 224, # Usage Minimum (224)
6663
0x29, 231, # Usage Maximum (231)
@@ -90,7 +87,7 @@ class HIDReportDescriptors:
9087
0xC0, # End Collection
9188
]))
9289

93-
HIDReportDescriptors.MOUSE_WITH_ID = hid.ReportDescriptor(
90+
MOUSE_WITH_ID = hid.ReportDescriptor(
9491
description="MOUSE",
9592
report_descriptor=bytes([
9693
# Regular mouse
@@ -99,7 +96,7 @@ class HIDReportDescriptors:
9996
0xA1, 0x01, # Collection (Application)
10097
0x09, 0x01, # Usage (Pointer)
10198
0xA1, 0x00, # Collection (Physical)
102-
0x85, HIDReportDescriptors.REPORT_IDS["MOUSE"], # Report ID (n)
99+
0x85, REPORT_IDS["MOUSE"], # Report ID (n)
103100
0x05, 0x09, # Usage Page (Button)
104101
0x19, 0x01, # Usage Minimum (0x01)
105102
0x29, 0x05, # Usage Maximum (0x05)
@@ -129,14 +126,14 @@ class HIDReportDescriptors:
129126
0xC0, # End Collection
130127
]))
131128

132-
HIDReportDescriptors.CONSUMER_WITH_ID = hid.ReportDescriptor(
129+
CONSUMER_WITH_ID = hid.ReportDescriptor(
133130
description="CONSUMER",
134131
report_descriptor=bytes([
135132
# Consumer ("multimedia") keys
136133
0x05, 0x0C, # Usage Page (Consumer)
137134
0x09, 0x01, # Usage (Consumer Control)
138135
0xA1, 0x01, # Collection (Application)
139-
0x85, HIDReportDescriptors.REPORT_IDS["CONSUMER"], # Report ID (n)
136+
0x85, REPORT_IDS["CONSUMER"], # Report ID (n)
140137
0x75, 0x10, # Report Size (16)
141138
0x95, 0x01, # Report Count (1)
142139
0x15, 0x01, # Logical Minimum (1)
@@ -147,14 +144,14 @@ class HIDReportDescriptors:
147144
0xC0, # End Collection
148145
]))
149146

150-
HIDReportDescriptors.SYS_CONTROL_WITH_ID = hid.ReportDescriptor(
147+
SYS_CONTROL_WITH_ID = hid.ReportDescriptor(
151148
description="SYS_CONTROL",
152149
report_descriptor=bytes([
153150
# Power controls
154151
0x05, 0x01, # Usage Page (Generic Desktop Ctrls)
155152
0x09, 0x80, # Usage (Sys Control)
156153
0xA1, 0x01, # Collection (Application)
157-
0x85, HIDReportDescriptors.REPORT_IDS["SYS_CONTROL"], # Report ID (n)
154+
0x85, REPORT_IDS["SYS_CONTROL"], # Report ID (n)
158155
0x75, 0x02, # Report Size (2)
159156
0x95, 0x01, # Report Count (1)
160157
0x15, 0x01, # Logical Minimum (1)
@@ -168,14 +165,14 @@ class HIDReportDescriptors:
168165
0xC0, # End Collection
169166
]))
170167

171-
HIDReportDescriptors.GAMEPAD_WITH_ID = hid.ReportDescriptor(
168+
GAMEPAD_WITH_ID = hid.ReportDescriptor(
172169
description="GAMEPAD",
173170
report_descriptor=bytes([
174171
# Gamepad with 16 buttons and two joysticks
175172
0x05, 0x01, # Usage Page (Generic Desktop Ctrls)
176173
0x09, 0x05, # Usage (Game Pad)
177174
0xA1, 0x01, # Collection (Application)
178-
0x85, HIDReportDescriptors.REPORT_IDS["GAMEPAD"], # Report ID (n)
175+
0x85, REPORT_IDS["GAMEPAD"], # Report ID (n)
179176
0x05, 0x09, # Usage Page (Button)
180177
0x19, 0x01, # Usage Minimum (Button 1)
181178
0x29, 0x10, # Usage Maximum (Button 16)
@@ -197,14 +194,14 @@ class HIDReportDescriptors:
197194
0xC0, # End Collection
198195
]))
199196

200-
HIDReportDescriptors.DIGITIZER_WITH_ID = hid.ReportDescriptor(
197+
DIGITIZER_WITH_ID = hid.ReportDescriptor(
201198
description="DIGITIZER",
202199
report_descriptor=bytes([
203200
# Digitizer (used as an absolute pointer)
204201
0x05, 0x0D, # Usage Page (Digitizers)
205202
0x09, 0x02, # Usage (Pen)
206203
0xA1, 0x01, # Collection (Application)
207-
0x85, HIDReportDescriptors.REPORT_IDS["DIGITIZER"], # Report ID (n)
204+
0x85, REPORT_IDS["DIGITIZER"], # Report ID (n)
208205
0x09, 0x01, # Usage (Stylus)
209206
0xA1, 0x00, # Collection (Physical)
210207
0x09, 0x32, # Usage (In-Range)
@@ -232,11 +229,11 @@ class HIDReportDescriptors:
232229
]))
233230

234231
# 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,
242239
}

0 commit comments

Comments
 (0)