88from adafruit_usb_descriptor import audio , audio10 , cdc , hid , midi , msc , standard , util
99import hid_report_descriptors
1010
11+ DEFAULT_INTERFACE_NAME = 'CircuitPython'
1112ALL_DEVICES = 'CDC,MSC,AUDIO,HID'
1213ALL_DEVICES_SET = frozenset (ALL_DEVICES .split (',' ))
1314DEFAULT_DEVICES = 'CDC,MSC,AUDIO,HID'
3233 help = 'devices to include in descriptor (AUDIO includes MIDI support)' )
3334parser .add_argument ('--hid_devices' , type = lambda l : tuple (l .split (',' )), default = DEFAULT_HID_DEVICES ,
3435 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 )
3539parser .add_argument ('--msc_max_packet_size' , type = int , default = 64 ,
3640 help = 'Max packet size for MSC' )
3741parser .add_argument ('--no-renumber_endpoints' , dest = 'renumber_endpoints' , action = 'store_false' ,
@@ -151,7 +155,7 @@ def strings_in_order(cls):
151155 bInterfaceClass = cdc .CDC_CLASS_COMM , # Communications Device Class
152156 bInterfaceSubClass = cdc .CDC_SUBCLASS_ACM , # Abstract control model
153157 bInterfaceProtocol = cdc .CDC_PROTOCOL_NONE ,
154- iInterface = StringIndex .index ("CircuitPython CDC control" ),
158+ iInterface = StringIndex .index ("{} CDC control" . format ( args . interface_name ) ),
155159 subdescriptors = [
156160 cdc .Header (
157161 description = "CDC comm" ,
@@ -172,7 +176,7 @@ def strings_in_order(cls):
172176cdc_data_interface = standard .InterfaceDescriptor (
173177 description = "CDC data" ,
174178 bInterfaceClass = cdc .CDC_CLASS_DATA ,
175- iInterface = StringIndex .index ("CircuitPython CDC data" ),
179+ iInterface = StringIndex .index ("{} CDC data" . format ( args . interface_name ) ),
176180 subdescriptors = [
177181 standard .EndpointDescriptor (
178182 description = "CDC data out" ,
@@ -192,7 +196,7 @@ def strings_in_order(cls):
192196 bInterfaceClass = msc .MSC_CLASS ,
193197 bInterfaceSubClass = msc .MSC_SUBCLASS_TRANSPARENT ,
194198 bInterfaceProtocol = msc .MSC_PROTOCOL_BULK ,
195- iInterface = StringIndex .index ("CircuitPython Mass Storage" ),
199+ iInterface = StringIndex .index ("{} Mass Storage" . format ( args . interface_name ) ),
196200 subdescriptors = [
197201 standard .EndpointDescriptor (
198202 description = "MSC in" ,
@@ -256,7 +260,7 @@ def strings_in_order(cls):
256260 bInterfaceClass = hid .HID_CLASS ,
257261 bInterfaceSubClass = hid .HID_SUBCLASS_NOBOOT ,
258262 bInterfaceProtocol = hid .HID_PROTOCOL_NONE ,
259- iInterface = StringIndex .index ("CircuitPython HID" ),
263+ iInterface = StringIndex .index ("{} HID" . format ( args . interface_name ) ),
260264 subdescriptors = [
261265 hid .HIDDescriptor (
262266 description = "HID" ,
@@ -272,9 +276,9 @@ def strings_in_order(cls):
272276
273277# USB OUT -> midi_in_jack_emb -> midi_out_jack_ext -> CircuitPython
274278midi_in_jack_emb = midi .InJackDescriptor (
275- description = "MIDI PC -> CircuitPython" ,
279+ description = "MIDI PC -> {}" . format ( args . interface_name ) ,
276280 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 ) ))
278282midi_out_jack_ext = midi .OutJackDescriptor (
279283 description = "MIDI data out to user code." ,
280284 bJackType = midi .JACK_TYPE_EXTERNAL ,
@@ -287,18 +291,18 @@ def strings_in_order(cls):
287291 bJackType = midi .JACK_TYPE_EXTERNAL ,
288292 iJack = 0 )
289293midi_out_jack_emb = midi .OutJackDescriptor (
290- description = "MIDI PC <- CircuitPython" ,
294+ description = "MIDI PC <- {}" . format ( args . interface_name ) ,
291295 bJackType = midi .JACK_TYPE_EMBEDDED ,
292296 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 ) ))
294298
295299
296300audio_midi_interface = standard .InterfaceDescriptor (
297301 description = "Midi goodness" ,
298302 bInterfaceClass = audio .AUDIO_CLASS_DEVICE ,
299303 bInterfaceSubClass = audio .AUDIO_SUBCLASS_MIDI_STREAMING ,
300304 bInterfaceProtocol = audio .AUDIO_PROTOCOL_V1 ,
301- iInterface = StringIndex .index ("CircuitPython MIDI" ),
305+ iInterface = StringIndex .index ("{} MIDI" . format ( args . interface_name ) ),
302306 subdescriptors = [
303307 midi .Header (
304308 jacks_and_elements = [
@@ -309,12 +313,12 @@ def strings_in_order(cls):
309313 ],
310314 ),
311315 standard .EndpointDescriptor (
312- description = "MIDI data out to CircuitPython" ,
316+ description = "MIDI data out to {}" . format ( args . interface_name ) ,
313317 bEndpointAddress = args .midi_ep_num_out | standard .EndpointDescriptor .DIRECTION_OUT ,
314318 bmAttributes = standard .EndpointDescriptor .TYPE_BULK ),
315319 midi .DataEndpointDescriptor (baAssocJack = [midi_in_jack_emb ]),
316320 standard .EndpointDescriptor (
317- description = "MIDI data in from CircuitPython" ,
321+ description = "MIDI data in from {}" . format ( args . interface_name ) ,
318322 bEndpointAddress = args .midi_ep_num_in | standard .EndpointDescriptor .DIRECTION_IN ,
319323 bmAttributes = standard .EndpointDescriptor .TYPE_BULK ,
320324 bInterval = 0x0 ),
@@ -334,7 +338,7 @@ def strings_in_order(cls):
334338 bInterfaceClass = audio .AUDIO_CLASS_DEVICE ,
335339 bInterfaceSubClass = audio .AUDIO_SUBCLASS_CONTROL ,
336340 bInterfaceProtocol = audio .AUDIO_PROTOCOL_V1 ,
337- iInterface = StringIndex .index ("CircuitPython Audio" ),
341+ iInterface = StringIndex .index ("{} Audio" . format ( args . interface_name ) ),
338342 subdescriptors = [
339343 cs_ac_interface ,
340344 ])
0 commit comments