8
8
from adafruit_usb_descriptor import audio , audio10 , cdc , hid , midi , msc , standard , util
9
9
import hid_report_descriptors
10
10
11
+ DEFAULT_INTERFACE_NAME = 'CircuitPython'
11
12
ALL_DEVICES = 'CDC,MSC,AUDIO,HID'
12
13
ALL_DEVICES_SET = frozenset (ALL_DEVICES .split (',' ))
13
14
DEFAULT_DEVICES = 'CDC,MSC,AUDIO,HID'
32
33
help = 'devices to include in descriptor (AUDIO includes MIDI support)' )
33
34
parser .add_argument ('--hid_devices' , type = lambda l : tuple (l .split (',' )), default = DEFAULT_HID_DEVICES ,
34
35
help = 'HID devices to include in HID report descriptor' )
36
+ parser .add_argument ('--interface_name' , type = str ,
37
+ help = 'The name/prefix to use in the interface descriptions' ,
38
+ default = DEFAULT_INTERFACE_NAME )
35
39
parser .add_argument ('--msc_max_packet_size' , type = int , default = 64 ,
36
40
help = 'Max packet size for MSC' )
37
41
parser .add_argument ('--no-renumber_endpoints' , dest = 'renumber_endpoints' , action = 'store_false' ,
@@ -151,7 +155,7 @@ def strings_in_order(cls):
151
155
bInterfaceClass = cdc .CDC_CLASS_COMM , # Communications Device Class
152
156
bInterfaceSubClass = cdc .CDC_SUBCLASS_ACM , # Abstract control model
153
157
bInterfaceProtocol = cdc .CDC_PROTOCOL_NONE ,
154
- iInterface = StringIndex .index ("CircuitPython CDC control" ),
158
+ iInterface = StringIndex .index ("{} CDC control" . format ( args . interface_name ) ),
155
159
subdescriptors = [
156
160
cdc .Header (
157
161
description = "CDC comm" ,
@@ -172,7 +176,7 @@ def strings_in_order(cls):
172
176
cdc_data_interface = standard .InterfaceDescriptor (
173
177
description = "CDC data" ,
174
178
bInterfaceClass = cdc .CDC_CLASS_DATA ,
175
- iInterface = StringIndex .index ("CircuitPython CDC data" ),
179
+ iInterface = StringIndex .index ("{} CDC data" . format ( args . interface_name ) ),
176
180
subdescriptors = [
177
181
standard .EndpointDescriptor (
178
182
description = "CDC data out" ,
@@ -192,7 +196,7 @@ def strings_in_order(cls):
192
196
bInterfaceClass = msc .MSC_CLASS ,
193
197
bInterfaceSubClass = msc .MSC_SUBCLASS_TRANSPARENT ,
194
198
bInterfaceProtocol = msc .MSC_PROTOCOL_BULK ,
195
- iInterface = StringIndex .index ("CircuitPython Mass Storage" ),
199
+ iInterface = StringIndex .index ("{} Mass Storage" . format ( args . interface_name ) ),
196
200
subdescriptors = [
197
201
standard .EndpointDescriptor (
198
202
description = "MSC in" ,
@@ -256,7 +260,7 @@ def strings_in_order(cls):
256
260
bInterfaceClass = hid .HID_CLASS ,
257
261
bInterfaceSubClass = hid .HID_SUBCLASS_NOBOOT ,
258
262
bInterfaceProtocol = hid .HID_PROTOCOL_NONE ,
259
- iInterface = StringIndex .index ("CircuitPython HID" ),
263
+ iInterface = StringIndex .index ("{} HID" . format ( args . interface_name ) ),
260
264
subdescriptors = [
261
265
hid .HIDDescriptor (
262
266
description = "HID" ,
@@ -272,9 +276,9 @@ def strings_in_order(cls):
272
276
273
277
# USB OUT -> midi_in_jack_emb -> midi_out_jack_ext -> CircuitPython
274
278
midi_in_jack_emb = midi .InJackDescriptor (
275
- description = "MIDI PC -> CircuitPython" ,
279
+ description = "MIDI PC -> {}" . format ( args . interface_name ) ,
276
280
bJackType = midi .JACK_TYPE_EMBEDDED ,
277
- iJack = StringIndex .index ("CircuitPython usb_midi.ports[0]" ))
281
+ iJack = StringIndex .index ("{} usb_midi.ports[0]" . format ( args . interface_name ) ))
278
282
midi_out_jack_ext = midi .OutJackDescriptor (
279
283
description = "MIDI data out to user code." ,
280
284
bJackType = midi .JACK_TYPE_EXTERNAL ,
@@ -287,18 +291,18 @@ def strings_in_order(cls):
287
291
bJackType = midi .JACK_TYPE_EXTERNAL ,
288
292
iJack = 0 )
289
293
midi_out_jack_emb = midi .OutJackDescriptor (
290
- description = "MIDI PC <- CircuitPython" ,
294
+ description = "MIDI PC <- {}" . format ( args . interface_name ) ,
291
295
bJackType = midi .JACK_TYPE_EMBEDDED ,
292
296
input_pins = [(midi_in_jack_ext , 1 )],
293
- iJack = StringIndex .index ("CircuitPython usb_midi.ports[1]" ))
297
+ iJack = StringIndex .index ("{} usb_midi.ports[1]" . format ( args . interface_name ) ))
294
298
295
299
296
300
audio_midi_interface = standard .InterfaceDescriptor (
297
301
description = "Midi goodness" ,
298
302
bInterfaceClass = audio .AUDIO_CLASS_DEVICE ,
299
303
bInterfaceSubClass = audio .AUDIO_SUBCLASS_MIDI_STREAMING ,
300
304
bInterfaceProtocol = audio .AUDIO_PROTOCOL_V1 ,
301
- iInterface = StringIndex .index ("CircuitPython MIDI" ),
305
+ iInterface = StringIndex .index ("{} MIDI" . format ( args . interface_name ) ),
302
306
subdescriptors = [
303
307
midi .Header (
304
308
jacks_and_elements = [
@@ -309,12 +313,12 @@ def strings_in_order(cls):
309
313
],
310
314
),
311
315
standard .EndpointDescriptor (
312
- description = "MIDI data out to CircuitPython" ,
316
+ description = "MIDI data out to {}" . format ( args . interface_name ) ,
313
317
bEndpointAddress = args .midi_ep_num_out | standard .EndpointDescriptor .DIRECTION_OUT ,
314
318
bmAttributes = standard .EndpointDescriptor .TYPE_BULK ),
315
319
midi .DataEndpointDescriptor (baAssocJack = [midi_in_jack_emb ]),
316
320
standard .EndpointDescriptor (
317
- description = "MIDI data in from CircuitPython" ,
321
+ description = "MIDI data in from {}" . format ( args . interface_name ) ,
318
322
bEndpointAddress = args .midi_ep_num_in | standard .EndpointDescriptor .DIRECTION_IN ,
319
323
bmAttributes = standard .EndpointDescriptor .TYPE_BULK ,
320
324
bInterval = 0x0 ),
@@ -334,7 +338,7 @@ def strings_in_order(cls):
334
338
bInterfaceClass = audio .AUDIO_CLASS_DEVICE ,
335
339
bInterfaceSubClass = audio .AUDIO_SUBCLASS_CONTROL ,
336
340
bInterfaceProtocol = audio .AUDIO_PROTOCOL_V1 ,
337
- iInterface = StringIndex .index ("CircuitPython Audio" ),
341
+ iInterface = StringIndex .index ("{} Audio" . format ( args . interface_name ) ),
338
342
subdescriptors = [
339
343
cs_ac_interface ,
340
344
])
0 commit comments