2 * Copyright 2012 Jun Wako <wakojun@gmail.com>
3 * This file is based on:
4 * LUFA-120219/Demos/Device/Lowlevel/KeyboardMouse
5 * LUFA-120219/Demos/Device/Lowlevel/GenericHID
10 Copyright (C) Dean Camera, 2012.
12 dean [at] fourwalledcubicle [dot] com
17 Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
18 Copyright 2010 Denver Gingerich (denver [at] ossguy [dot] com)
20 Permission to use, copy, modify, distribute, and sell this
21 software and its documentation for any purpose is hereby granted
22 without fee, provided that the above copyright notice appear in
23 all copies and that both that the copyright notice and this
24 permission notice and warranty disclaimer appear in supporting
25 documentation, and that the name of the author not be used in
26 advertising or publicity pertaining to distribution of the
27 software without specific, written prior permission.
29 The author disclaim all warranties with regard to this
30 software, including all implied warranties of merchantability
31 and fitness. In no event shall the author be liable for any
32 special, indirect or consequential damages or any damages
33 whatsoever resulting from loss of use, data or profits, whether
34 in an action of contract, negligence or other tortious action,
35 arising out of or in connection with the use or performance of
41 #include "descriptor.h"
44 /*******************************************************************************
45 * HID Report Descriptors
46 ******************************************************************************/
47 const USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] =
49 HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */
50 HID_RI_USAGE(8, 0x06), /* Keyboard */
51 HID_RI_COLLECTION(8, 0x01), /* Application */
52 HID_RI_USAGE_PAGE(8, 0x07), /* Key Codes */
53 HID_RI_USAGE_MINIMUM(8, 0xE0), /* Keyboard Left Control */
54 HID_RI_USAGE_MAXIMUM(8, 0xE7), /* Keyboard Right GUI */
55 HID_RI_LOGICAL_MINIMUM(8, 0x00),
56 HID_RI_LOGICAL_MAXIMUM(8, 0x01),
57 HID_RI_REPORT_COUNT(8, 0x08),
58 HID_RI_REPORT_SIZE(8, 0x01),
59 HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
61 HID_RI_REPORT_COUNT(8, 0x01),
62 HID_RI_REPORT_SIZE(8, 0x08),
63 HID_RI_INPUT(8, HID_IOF_CONSTANT), /* reserved */
65 HID_RI_USAGE_PAGE(8, 0x08), /* LEDs */
66 HID_RI_USAGE_MINIMUM(8, 0x01), /* Num Lock */
67 HID_RI_USAGE_MAXIMUM(8, 0x05), /* Kana */
68 HID_RI_REPORT_COUNT(8, 0x05),
69 HID_RI_REPORT_SIZE(8, 0x01),
70 HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
71 HID_RI_REPORT_COUNT(8, 0x01),
72 HID_RI_REPORT_SIZE(8, 0x03),
73 HID_RI_OUTPUT(8, HID_IOF_CONSTANT),
75 HID_RI_USAGE_PAGE(8, 0x07), /* Keyboard */
76 HID_RI_USAGE_MINIMUM(8, 0x00), /* Reserved (no event indicated) */
77 HID_RI_USAGE_MAXIMUM(8, 0xFF), /* Keyboard Application */
78 HID_RI_LOGICAL_MINIMUM(8, 0x00),
79 HID_RI_LOGICAL_MAXIMUM(16, 0x00FF),
80 HID_RI_REPORT_COUNT(8, 0x06),
81 HID_RI_REPORT_SIZE(8, 0x08),
82 HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE),
83 HID_RI_END_COLLECTION(0),
87 const USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] =
89 HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */
90 HID_RI_USAGE(8, 0x02), /* Mouse */
91 HID_RI_COLLECTION(8, 0x01), /* Application */
92 HID_RI_USAGE(8, 0x01), /* Pointer */
93 HID_RI_COLLECTION(8, 0x00), /* Physical */
95 HID_RI_USAGE_PAGE(8, 0x09), /* Button */
96 HID_RI_USAGE_MINIMUM(8, 0x01), /* Button 1 */
97 HID_RI_USAGE_MAXIMUM(8, 0x05), /* Button 5 */
98 HID_RI_LOGICAL_MINIMUM(8, 0x00),
99 HID_RI_LOGICAL_MAXIMUM(8, 0x01),
100 HID_RI_REPORT_COUNT(8, 0x05),
101 HID_RI_REPORT_SIZE(8, 0x01),
102 HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
103 HID_RI_REPORT_COUNT(8, 0x01),
104 HID_RI_REPORT_SIZE(8, 0x03),
105 HID_RI_INPUT(8, HID_IOF_CONSTANT),
107 HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */
108 HID_RI_USAGE(8, 0x30), /* Usage X */
109 HID_RI_USAGE(8, 0x31), /* Usage Y */
110 HID_RI_LOGICAL_MINIMUM(8, -127),
111 HID_RI_LOGICAL_MAXIMUM(8, 127),
112 HID_RI_REPORT_COUNT(8, 0x02),
113 HID_RI_REPORT_SIZE(8, 0x08),
114 HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE),
116 HID_RI_USAGE(8, 0x38), /* Wheel */
117 HID_RI_LOGICAL_MINIMUM(8, -127),
118 HID_RI_LOGICAL_MAXIMUM(8, 127),
119 HID_RI_REPORT_COUNT(8, 0x01),
120 HID_RI_REPORT_SIZE(8, 0x08),
121 HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE),
123 HID_RI_USAGE_PAGE(8, 0x0C), /* Consumer */
124 HID_RI_USAGE(16, 0x0238), /* AC Pan (Horizontal wheel) */
125 HID_RI_LOGICAL_MINIMUM(8, -127),
126 HID_RI_LOGICAL_MAXIMUM(8, 127),
127 HID_RI_REPORT_COUNT(8, 0x01),
128 HID_RI_REPORT_SIZE(8, 0x08),
129 HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE),
131 HID_RI_END_COLLECTION(0),
132 HID_RI_END_COLLECTION(0),
136 #ifdef EXTRAKEY_ENABLE
137 const USB_Descriptor_HIDReport_Datatype_t PROGMEM ExtrakeyReport[] =
139 HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */
140 HID_RI_USAGE(8, 0x80), /* System Control */
141 HID_RI_COLLECTION(8, 0x01), /* Application */
142 HID_RI_REPORT_ID(8, REPORT_ID_SYSTEM),
143 HID_RI_LOGICAL_MINIMUM(16, 0x0081),
144 HID_RI_LOGICAL_MAXIMUM(16, 0x00B7),
145 HID_RI_USAGE_MINIMUM(16, 0x0081), /* System Power Down */
146 HID_RI_USAGE_MAXIMUM(16, 0x00B7), /* System Display LCD Autoscale */
147 HID_RI_REPORT_SIZE(8, 16),
148 HID_RI_REPORT_COUNT(8, 1),
149 HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE),
150 HID_RI_END_COLLECTION(0),
152 HID_RI_USAGE_PAGE(8, 0x0C), /* Consumer */
153 HID_RI_USAGE(8, 0x01), /* Consumer Control */
154 HID_RI_COLLECTION(8, 0x01), /* Application */
155 HID_RI_REPORT_ID(8, REPORT_ID_CONSUMER),
156 HID_RI_LOGICAL_MINIMUM(16, 0x0001),
157 HID_RI_LOGICAL_MAXIMUM(16, 0x029C),
158 HID_RI_USAGE_MINIMUM(16, 0x0001), /* +10 */
159 HID_RI_USAGE_MAXIMUM(16, 0x029C), /* AC Distribute Vertically */
160 HID_RI_REPORT_SIZE(8, 16),
161 HID_RI_REPORT_COUNT(8, 1),
162 HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE),
163 HID_RI_END_COLLECTION(0),
167 #ifdef CONSOLE_ENABLE
168 const USB_Descriptor_HIDReport_Datatype_t PROGMEM ConsoleReport[] =
170 HID_RI_USAGE_PAGE(16, 0xFF31), /* Vendor Page(PJRC Teensy compatible) */
171 HID_RI_USAGE(8, 0x74), /* Vendor Usage(PJRC Teensy compatible) */
172 HID_RI_COLLECTION(8, 0x01), /* Application */
173 HID_RI_USAGE(8, 0x75), /* Vendor Usage 0x75 */
174 HID_RI_LOGICAL_MINIMUM(8, 0x00),
175 HID_RI_LOGICAL_MAXIMUM(16, 0x00FF),
176 HID_RI_REPORT_COUNT(8, CONSOLE_EPSIZE),
177 HID_RI_REPORT_SIZE(8, 0x08),
178 HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
179 HID_RI_USAGE(8, 0x76), /* Vendor Usage 0x76 */
180 HID_RI_LOGICAL_MINIMUM(8, 0x00),
181 HID_RI_LOGICAL_MAXIMUM(16, 0x00FF),
182 HID_RI_REPORT_COUNT(8, CONSOLE_EPSIZE),
183 HID_RI_REPORT_SIZE(8, 0x08),
184 HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
185 HID_RI_END_COLLECTION(0),
190 const USB_Descriptor_HIDReport_Datatype_t PROGMEM NKROReport[] =
192 HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */
193 HID_RI_USAGE(8, 0x06), /* Keyboard */
194 HID_RI_COLLECTION(8, 0x01), /* Application */
195 HID_RI_USAGE_PAGE(8, 0x07), /* Key Codes */
196 HID_RI_USAGE_MINIMUM(8, 0xE0), /* Keyboard Left Control */
197 HID_RI_USAGE_MAXIMUM(8, 0xE7), /* Keyboard Right GUI */
198 HID_RI_LOGICAL_MINIMUM(8, 0x00),
199 HID_RI_LOGICAL_MAXIMUM(8, 0x01),
200 HID_RI_REPORT_COUNT(8, 0x08),
201 HID_RI_REPORT_SIZE(8, 0x01),
202 HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
204 HID_RI_USAGE_PAGE(8, 0x08), /* LEDs */
205 HID_RI_USAGE_MINIMUM(8, 0x01), /* Num Lock */
206 HID_RI_USAGE_MAXIMUM(8, 0x05), /* Kana */
207 HID_RI_REPORT_COUNT(8, 0x05),
208 HID_RI_REPORT_SIZE(8, 0x01),
209 HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
210 HID_RI_REPORT_COUNT(8, 0x01),
211 HID_RI_REPORT_SIZE(8, 0x03),
212 HID_RI_OUTPUT(8, HID_IOF_CONSTANT),
214 HID_RI_USAGE_PAGE(8, 0x07), /* Key Codes */
215 HID_RI_USAGE_MINIMUM(8, 0x00), /* Keyboard 0 */
216 HID_RI_USAGE_MAXIMUM(8, (NKRO_EPSIZE-1)*8-1), /* Keyboard Right GUI */
217 HID_RI_LOGICAL_MINIMUM(8, 0x00),
218 HID_RI_LOGICAL_MAXIMUM(8, 0x01),
219 HID_RI_REPORT_COUNT(8, (NKRO_EPSIZE-1)*8),
220 HID_RI_REPORT_SIZE(8, 0x01),
221 HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
222 HID_RI_END_COLLECTION(0),
226 /*******************************************************************************
228 ******************************************************************************/
229 const USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
231 .Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
233 .USBSpecification = VERSION_BCD(1,1,0),
235 .Class = USB_CSCP_IADDeviceClass,
236 .SubClass = USB_CSCP_IADDeviceSubclass,
237 .Protocol = USB_CSCP_IADDeviceProtocol,
239 .Class = USB_CSCP_NoDeviceClass,
240 .SubClass = USB_CSCP_NoDeviceSubclass,
241 .Protocol = USB_CSCP_NoDeviceProtocol,
244 .Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
246 /* specified in config.h */
247 .VendorID = VENDOR_ID,
248 .ProductID = PRODUCT_ID,
249 .ReleaseNumber = DEVICE_VER,
251 .ManufacturerStrIndex = 0x01,
252 .ProductStrIndex = 0x02,
253 .SerialNumStrIndex = NO_DESCRIPTOR,
255 .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
258 /*******************************************************************************
259 * Configuration Descriptors
260 ******************************************************************************/
261 const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
265 .Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
267 .TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
268 .TotalInterfaces = TOTAL_INTERFACES,
270 .ConfigurationNumber = 1,
271 .ConfigurationStrIndex = NO_DESCRIPTOR,
273 .ConfigAttributes = (USB_CONFIG_ATTR_RESERVED | USB_CONFIG_ATTR_REMOTEWAKEUP),
275 .MaxPowerConsumption = USB_CONFIG_POWER_MA(500)
281 .Keyboard_Interface =
283 .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
285 .InterfaceNumber = KEYBOARD_INTERFACE,
286 .AlternateSetting = 0x00,
290 .Class = HID_CSCP_HIDClass,
291 .SubClass = HID_CSCP_BootSubclass,
292 .Protocol = HID_CSCP_KeyboardBootProtocol,
294 .InterfaceStrIndex = NO_DESCRIPTOR
299 .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
301 .HIDSpec = VERSION_BCD(1,1,1),
303 .TotalReportDescriptors = 1,
304 .HIDReportType = HID_DTYPE_Report,
305 .HIDReportLength = sizeof(KeyboardReport)
308 .Keyboard_INEndpoint =
310 .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
312 .EndpointAddress = (ENDPOINT_DIR_IN | KEYBOARD_IN_EPNUM),
313 .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
314 .EndpointSize = KEYBOARD_EPSIZE,
315 .PollingIntervalMS = 0x0A
324 .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
326 .InterfaceNumber = MOUSE_INTERFACE,
327 .AlternateSetting = 0x00,
331 .Class = HID_CSCP_HIDClass,
332 .SubClass = HID_CSCP_BootSubclass,
333 .Protocol = HID_CSCP_MouseBootProtocol,
335 .InterfaceStrIndex = NO_DESCRIPTOR
340 .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
342 .HIDSpec = VERSION_BCD(1,1,1),
344 .TotalReportDescriptors = 1,
345 .HIDReportType = HID_DTYPE_Report,
346 .HIDReportLength = sizeof(MouseReport)
351 .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
353 .EndpointAddress = (ENDPOINT_DIR_IN | MOUSE_IN_EPNUM),
354 .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
355 .EndpointSize = MOUSE_EPSIZE,
356 .PollingIntervalMS = 0x0A
363 #ifdef EXTRAKEY_ENABLE
364 .Extrakey_Interface =
366 .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
368 .InterfaceNumber = EXTRAKEY_INTERFACE,
369 .AlternateSetting = 0x00,
373 .Class = HID_CSCP_HIDClass,
374 .SubClass = HID_CSCP_NonBootSubclass,
375 .Protocol = HID_CSCP_NonBootProtocol,
377 .InterfaceStrIndex = NO_DESCRIPTOR
382 .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
384 .HIDSpec = VERSION_BCD(1,1,1),
386 .TotalReportDescriptors = 1,
387 .HIDReportType = HID_DTYPE_Report,
388 .HIDReportLength = sizeof(ExtrakeyReport)
391 .Extrakey_INEndpoint =
393 .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
395 .EndpointAddress = (ENDPOINT_DIR_IN | EXTRAKEY_IN_EPNUM),
396 .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
397 .EndpointSize = EXTRAKEY_EPSIZE,
398 .PollingIntervalMS = 0x0A
405 #ifdef CONSOLE_ENABLE
408 .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
410 .InterfaceNumber = CONSOLE_INTERFACE,
411 .AlternateSetting = 0x00,
415 .Class = HID_CSCP_HIDClass,
416 .SubClass = HID_CSCP_NonBootSubclass,
417 .Protocol = HID_CSCP_NonBootProtocol,
419 .InterfaceStrIndex = NO_DESCRIPTOR
424 .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
426 .HIDSpec = VERSION_BCD(1,1,1),
428 .TotalReportDescriptors = 1,
429 .HIDReportType = HID_DTYPE_Report,
430 .HIDReportLength = sizeof(ConsoleReport)
433 .Console_INEndpoint =
435 .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
437 .EndpointAddress = (ENDPOINT_DIR_IN | CONSOLE_IN_EPNUM),
438 .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
439 .EndpointSize = CONSOLE_EPSIZE,
440 .PollingIntervalMS = 0x01
443 .Console_OUTEndpoint =
445 .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
447 .EndpointAddress = (ENDPOINT_DIR_OUT | CONSOLE_OUT_EPNUM),
448 .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
449 .EndpointSize = CONSOLE_EPSIZE,
450 .PollingIntervalMS = 0x01
460 .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
462 .InterfaceNumber = NKRO_INTERFACE,
463 .AlternateSetting = 0x00,
467 .Class = HID_CSCP_HIDClass,
468 .SubClass = HID_CSCP_NonBootSubclass,
469 .Protocol = HID_CSCP_NonBootProtocol,
471 .InterfaceStrIndex = NO_DESCRIPTOR
476 .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
478 .HIDSpec = VERSION_BCD(1,1,1),
480 .TotalReportDescriptors = 1,
481 .HIDReportType = HID_DTYPE_Report,
482 .HIDReportLength = sizeof(NKROReport)
487 .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
489 .EndpointAddress = (ENDPOINT_DIR_IN | NKRO_IN_EPNUM),
490 .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
491 .EndpointSize = NKRO_EPSIZE,
492 .PollingIntervalMS = 0x01
497 .Audio_ControlInterface =
499 .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
501 .InterfaceNumber = AC_INTERFACE,
502 .AlternateSetting = 0,
506 .Class = AUDIO_CSCP_AudioClass,
507 .SubClass = AUDIO_CSCP_ControlSubclass,
508 .Protocol = AUDIO_CSCP_ControlProtocol,
510 .InterfaceStrIndex = NO_DESCRIPTOR
513 .Audio_ControlInterface_SPC =
515 .Header = {.Size = sizeof(USB_Audio_Descriptor_Interface_AC_t), .Type = DTYPE_CSInterface},
516 .Subtype = AUDIO_DSUBTYPE_CSInterface_Header,
518 .ACSpecification = VERSION_BCD(1,0,0),
519 .TotalLength = sizeof(USB_Audio_Descriptor_Interface_AC_t),
522 .InterfaceNumber = AS_INTERFACE,
525 .Audio_StreamInterface =
527 .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
529 .InterfaceNumber = AS_INTERFACE,
530 .AlternateSetting = 0,
534 .Class = AUDIO_CSCP_AudioClass,
535 .SubClass = AUDIO_CSCP_MIDIStreamingSubclass,
536 .Protocol = AUDIO_CSCP_StreamingProtocol,
538 .InterfaceStrIndex = NO_DESCRIPTOR
541 .Audio_StreamInterface_SPC =
543 .Header = {.Size = sizeof(USB_MIDI_Descriptor_AudioInterface_AS_t), .Type = DTYPE_CSInterface},
544 .Subtype = AUDIO_DSUBTYPE_CSInterface_General,
546 .AudioSpecification = VERSION_BCD(1,0,0),
548 .TotalLength = (sizeof(USB_Descriptor_Configuration_t) -
549 offsetof(USB_Descriptor_Configuration_t, Audio_StreamInterface_SPC))
554 .Header = {.Size = sizeof(USB_MIDI_Descriptor_InputJack_t), .Type = DTYPE_CSInterface},
555 .Subtype = AUDIO_DSUBTYPE_CSInterface_InputTerminal,
557 .JackType = MIDI_JACKTYPE_Embedded,
560 .JackStrIndex = NO_DESCRIPTOR
565 .Header = {.Size = sizeof(USB_MIDI_Descriptor_InputJack_t), .Type = DTYPE_CSInterface},
566 .Subtype = AUDIO_DSUBTYPE_CSInterface_InputTerminal,
568 .JackType = MIDI_JACKTYPE_External,
571 .JackStrIndex = NO_DESCRIPTOR
576 .Header = {.Size = sizeof(USB_MIDI_Descriptor_OutputJack_t), .Type = DTYPE_CSInterface},
577 .Subtype = AUDIO_DSUBTYPE_CSInterface_OutputTerminal,
579 .JackType = MIDI_JACKTYPE_Embedded,
583 .SourceJackID = {0x02},
584 .SourcePinID = {0x01},
586 .JackStrIndex = NO_DESCRIPTOR
591 .Header = {.Size = sizeof(USB_MIDI_Descriptor_OutputJack_t), .Type = DTYPE_CSInterface},
592 .Subtype = AUDIO_DSUBTYPE_CSInterface_OutputTerminal,
594 .JackType = MIDI_JACKTYPE_External,
598 .SourceJackID = {0x01},
599 .SourcePinID = {0x01},
601 .JackStrIndex = NO_DESCRIPTOR
604 .MIDI_In_Jack_Endpoint =
608 .Header = {.Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t), .Type = DTYPE_Endpoint},
610 .EndpointAddress = MIDI_STREAM_OUT_EPADDR,
611 .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
612 .EndpointSize = MIDI_STREAM_EPSIZE,
613 .PollingIntervalMS = 0x05
617 .SyncEndpointNumber = 0
620 .MIDI_In_Jack_Endpoint_SPC =
622 .Header = {.Size = sizeof(USB_MIDI_Descriptor_Jack_Endpoint_t), .Type = DTYPE_CSEndpoint},
623 .Subtype = AUDIO_DSUBTYPE_CSEndpoint_General,
625 .TotalEmbeddedJacks = 0x01,
626 .AssociatedJackID = {0x01}
629 .MIDI_Out_Jack_Endpoint =
633 .Header = {.Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t), .Type = DTYPE_Endpoint},
635 .EndpointAddress = MIDI_STREAM_IN_EPADDR,
636 .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
637 .EndpointSize = MIDI_STREAM_EPSIZE,
638 .PollingIntervalMS = 0x05
642 .SyncEndpointNumber = 0
645 .MIDI_Out_Jack_Endpoint_SPC =
647 .Header = {.Size = sizeof(USB_MIDI_Descriptor_Jack_Endpoint_t), .Type = DTYPE_CSEndpoint},
648 .Subtype = AUDIO_DSUBTYPE_CSEndpoint_General,
650 .TotalEmbeddedJacks = 0x01,
651 .AssociatedJackID = {0x03}
655 #ifdef VIRTSER_ENABLE
656 .CDC_Interface_Association =
658 .Header = {.Size = sizeof(USB_Descriptor_Interface_Association_t), .Type = DTYPE_InterfaceAssociation},
660 .FirstInterfaceIndex = CCI_INTERFACE,
661 .TotalInterfaces = 2,
663 .Class = CDC_CSCP_CDCClass,
664 .SubClass = CDC_CSCP_ACMSubclass,
665 .Protocol = CDC_CSCP_ATCommandProtocol,
667 .IADStrIndex = NO_DESCRIPTOR,
672 .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
674 .InterfaceNumber = CCI_INTERFACE,
675 .AlternateSetting = 0,
679 .Class = CDC_CSCP_CDCClass,
680 .SubClass = CDC_CSCP_ACMSubclass,
681 .Protocol = CDC_CSCP_ATCommandProtocol,
683 .InterfaceStrIndex = NO_DESCRIPTOR
686 .CDC_Functional_Header =
688 .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t), .Type = DTYPE_CSInterface},
691 .CDCSpecification = VERSION_BCD(1,1,0),
694 .CDC_Functional_ACM =
696 .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface},
699 .Capabilities = 0x02,
702 .CDC_Functional_Union =
704 .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t), .Type = DTYPE_CSInterface},
707 .MasterInterfaceNumber = CCI_INTERFACE,
708 .SlaveInterfaceNumber = CDI_INTERFACE,
711 .CDC_NotificationEndpoint =
713 .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
715 .EndpointAddress = CDC_NOTIFICATION_EPADDR,
716 .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
717 .EndpointSize = CDC_NOTIFICATION_EPSIZE,
718 .PollingIntervalMS = 0xFF
723 .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
725 .InterfaceNumber = CDI_INTERFACE,
726 .AlternateSetting = 0,
730 .Class = CDC_CSCP_CDCDataClass,
731 .SubClass = CDC_CSCP_NoDataSubclass,
732 .Protocol = CDC_CSCP_NoDataProtocol,
734 .InterfaceStrIndex = NO_DESCRIPTOR
737 .CDC_DataOutEndpoint =
739 .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
741 .EndpointAddress = CDC_OUT_EPADDR,
742 .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
743 .EndpointSize = CDC_EPSIZE,
744 .PollingIntervalMS = 0x05
747 .CDC_DataInEndpoint =
749 .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
751 .EndpointAddress = CDC_IN_EPADDR,
752 .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
753 .EndpointSize = CDC_EPSIZE,
754 .PollingIntervalMS = 0x05
761 /*******************************************************************************
763 ******************************************************************************/
764 const USB_Descriptor_String_t PROGMEM LanguageString =
766 .Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
768 .UnicodeString = {LANGUAGE_ID_ENG}
771 const USB_Descriptor_String_t PROGMEM ManufacturerString =
773 /* subtract 1 for null terminator */
774 .Header = {.Size = USB_STRING_LEN(sizeof(STR(MANUFACTURER))-1), .Type = DTYPE_String},
776 .UnicodeString = LSTR(MANUFACTURER)
779 const USB_Descriptor_String_t PROGMEM ProductString =
781 /* subtract 1 for null terminator */
782 .Header = {.Size = USB_STRING_LEN(sizeof(STR(PRODUCT))-1), .Type = DTYPE_String},
784 .UnicodeString = LSTR(PRODUCT)
788 /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors"
789 * documentation) by the application code so that the address and size of a requested descriptor can be given
790 * to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function
791 * is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the
794 uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
795 const uint8_t wIndex,
796 const void** const DescriptorAddress)
798 const uint8_t DescriptorType = (wValue >> 8);
799 const uint8_t DescriptorIndex = (wValue & 0xFF);
801 const void* Address = NULL;
802 uint16_t Size = NO_DESCRIPTOR;
804 switch (DescriptorType)
807 Address = &DeviceDescriptor;
808 Size = sizeof(USB_Descriptor_Device_t);
810 case DTYPE_Configuration:
811 Address = &ConfigurationDescriptor;
812 Size = sizeof(USB_Descriptor_Configuration_t);
815 switch (DescriptorIndex )
818 Address = &LanguageString;
819 Size = pgm_read_byte(&LanguageString.Header.Size);
822 Address = &ManufacturerString;
823 Size = pgm_read_byte(&ManufacturerString.Header.Size);
826 Address = &ProductString;
827 Size = pgm_read_byte(&ProductString.Header.Size);
833 case KEYBOARD_INTERFACE:
834 Address = &ConfigurationDescriptor.Keyboard_HID;
835 Size = sizeof(USB_HID_Descriptor_HID_t);
838 case MOUSE_INTERFACE:
839 Address = &ConfigurationDescriptor.Mouse_HID;
840 Size = sizeof(USB_HID_Descriptor_HID_t);
843 #ifdef EXTRAKEY_ENABLE
844 case EXTRAKEY_INTERFACE:
845 Address = &ConfigurationDescriptor.Extrakey_HID;
846 Size = sizeof(USB_HID_Descriptor_HID_t);
849 #ifdef CONSOLE_ENABLE
850 case CONSOLE_INTERFACE:
851 Address = &ConfigurationDescriptor.Console_HID;
852 Size = sizeof(USB_HID_Descriptor_HID_t);
857 Address = &ConfigurationDescriptor.NKRO_HID;
858 Size = sizeof(USB_HID_Descriptor_HID_t);
863 case HID_DTYPE_Report:
865 case KEYBOARD_INTERFACE:
866 Address = &KeyboardReport;
867 Size = sizeof(KeyboardReport);
870 case MOUSE_INTERFACE:
871 Address = &MouseReport;
872 Size = sizeof(MouseReport);
875 #ifdef EXTRAKEY_ENABLE
876 case EXTRAKEY_INTERFACE:
877 Address = &ExtrakeyReport;
878 Size = sizeof(ExtrakeyReport);
881 #ifdef CONSOLE_ENABLE
882 case CONSOLE_INTERFACE:
883 Address = &ConsoleReport;
884 Size = sizeof(ConsoleReport);
889 Address = &NKROReport;
890 Size = sizeof(NKROReport);
897 *DescriptorAddress = Address;