diff options
| author | fauxpark <fauxpark@gmail.com> | 2019-07-10 05:34:17 +1000 |
|---|---|---|
| committer | skullydazed <skullydazed@users.noreply.github.com> | 2019-08-30 15:01:52 -0700 |
| commit | ac1672689599ff7180b3baaaa9a1356e0e23021e (patch) | |
| tree | 64a564592c5eaf239e99ca3a78c5576c391425b1 | |
| parent | 21df614a8ebf216f65822a28e319a05360f5244d (diff) | |
| download | qmk_firmware-ac1672689599ff7180b3baaaa9a1356e0e23021e.tar.gz qmk_firmware-ac1672689599ff7180b3baaaa9a1356e0e23021e.zip | |
LUFA USB descriptor cleanup (#4871)
* Fix indentation
* Fix braces
* Expand descriptor headers
* Align descriptor elements
* Nicer formatting
* Tidy up preprocessor statements
* Remove VERSION_BCD redefine - LUFA_VERSION_INTEGER is currently 0x170418
* Tidy up comments
* Tweak ordering of HID report elements (no functional changes)
* We don't need all of these newlines
* Move default USB_MAX_POWER_CONSUMPTION closer to where it makes sense
* Ask nicely
* Add some more comments
* Change indentation back to 4 spaces
* Add changelog entry
| -rw-r--r-- | docs/ChangeLog/20190830/PR4871.md | 4 | ||||
| -rw-r--r-- | tmk_core/protocol/usb_descriptor.c | 1403 | ||||
| -rw-r--r-- | tmk_core/protocol/usb_descriptor.h | 347 |
3 files changed, 879 insertions, 875 deletions
diff --git a/docs/ChangeLog/20190830/PR4871.md b/docs/ChangeLog/20190830/PR4871.md new file mode 100644 index 000000000..e4ea171d7 --- /dev/null +++ b/docs/ChangeLog/20190830/PR4871.md | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | * LUFA USB descriptor cleanup | ||
| 2 | * Some code cleanups related to the USB HID descriptors on AVR keyboards, to make them easier to read and understand | ||
| 3 | * More information: see https://github.com/qmk/qmk_firmware/pull/4871 | ||
| 4 | * No behaviour changes anticipated and no keymaps modified | ||
diff --git a/tmk_core/protocol/usb_descriptor.c b/tmk_core/protocol/usb_descriptor.c index 589ad23cd..fb280f947 100644 --- a/tmk_core/protocol/usb_descriptor.c +++ b/tmk_core/protocol/usb_descriptor.c | |||
| @@ -6,238 +6,242 @@ | |||
| 6 | */ | 6 | */ |
| 7 | 7 | ||
| 8 | /* | 8 | /* |
| 9 | LUFA Library | 9 | LUFA Library |
| 10 | Copyright (C) Dean Camera, 2012. | 10 | Copyright (C) Dean Camera, 2012. |
| 11 | 11 | ||
| 12 | dean [at] fourwalledcubicle [dot] com | 12 | dean [at] fourwalledcubicle [dot] com |
| 13 | www.lufa-lib.org | 13 | www.lufa-lib.org |
| 14 | */ | 14 | */ |
| 15 | 15 | ||
| 16 | /* | 16 | /* |
| 17 | Copyright 2012 Dean Camera (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) | 18 | Copyright 2010 Denver Gingerich (denver [at] ossguy [dot] com) |
| 19 | 19 | ||
| 20 | Permission to use, copy, modify, distribute, and sell this | 20 | Permission to use, copy, modify, distribute, and sell this |
| 21 | software and its documentation for any purpose is hereby granted | 21 | software and its documentation for any purpose is hereby granted |
| 22 | without fee, provided that the above copyright notice appear in | 22 | without fee, provided that the above copyright notice appear in |
| 23 | all copies and that both that the copyright notice and this | 23 | all copies and that both that the copyright notice and this |
| 24 | permission notice and warranty disclaimer appear in supporting | 24 | permission notice and warranty disclaimer appear in supporting |
| 25 | documentation, and that the name of the author not be used in | 25 | documentation, and that the name of the author not be used in |
| 26 | advertising or publicity pertaining to distribution of the | 26 | advertising or publicity pertaining to distribution of the |
| 27 | software without specific, written prior permission. | 27 | software without specific, written prior permission. |
| 28 | 28 | ||
| 29 | The author disclaim all warranties with regard to this | 29 | The author disclaim all warranties with regard to this |
| 30 | software, including all implied warranties of merchantability | 30 | software, including all implied warranties of merchantability |
| 31 | and fitness. In no event shall the author be liable for any | 31 | and fitness. In no event shall the author be liable for any |
| 32 | special, indirect or consequential damages or any damages | 32 | special, indirect or consequential damages or any damages |
| 33 | whatsoever resulting from loss of use, data or profits, whether | 33 | whatsoever resulting from loss of use, data or profits, whether |
| 34 | in an action of contract, negligence or other tortious action, | 34 | in an action of contract, negligence or other tortious action, |
| 35 | arising out of or in connection with the use or performance of | 35 | arising out of or in connection with the use or performance of |
| 36 | this software. | 36 | this software. |
| 37 | */ | 37 | */ |
| 38 | 38 | ||
| 39 | #include "util.h" | 39 | #include "util.h" |
| 40 | #include "report.h" | 40 | #include "report.h" |
| 41 | #include "usb_descriptor.h" | 41 | #include "usb_descriptor.h" |
| 42 | 42 | ||
| 43 | #ifndef USB_MAX_POWER_CONSUMPTION | 43 | /* |
| 44 | #define USB_MAX_POWER_CONSUMPTION 500 | 44 | * HID report descriptors |
| 45 | #endif | 45 | */ |
| 46 | |||
| 47 | /******************************************************************************* | ||
| 48 | * HID Report Descriptors | ||
| 49 | ******************************************************************************/ | ||
| 50 | #ifdef KEYBOARD_SHARED_EP | 46 | #ifdef KEYBOARD_SHARED_EP |
| 51 | const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = { | 47 | const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = { |
| 52 | #define SHARED_REPORT_STARTED | 48 | #define SHARED_REPORT_STARTED |
| 53 | #else | 49 | #else |
| 54 | const USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] = { | 50 | const USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] = { |
| 55 | #endif | 51 | #endif |
| 56 | HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */ | 52 | HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop |
| 57 | HID_RI_USAGE(8, 0x06), /* Keyboard */ | 53 | HID_RI_USAGE(8, 0x06), // Keyboard |
| 58 | HID_RI_COLLECTION(8, 0x01), /* Application */ | 54 | HID_RI_COLLECTION(8, 0x01), // Application |
| 59 | # ifdef KEYBOARD_SHARED_EP | 55 | #ifdef KEYBOARD_SHARED_EP |
| 60 | HID_RI_REPORT_ID(8, REPORT_ID_KEYBOARD), | 56 | HID_RI_REPORT_ID(8, REPORT_ID_KEYBOARD), |
| 61 | # endif | 57 | #endif |
| 62 | HID_RI_USAGE_PAGE(8, 0x07), /* Key Codes */ | 58 | // Modifiers (8 bits) |
| 63 | HID_RI_USAGE_MINIMUM(8, 0xE0), /* Keyboard Left Control */ | 59 | HID_RI_USAGE_PAGE(8, 0x07), // Keyboard/Keypad |
| 64 | HID_RI_USAGE_MAXIMUM(8, 0xE7), /* Keyboard Right GUI */ | 60 | HID_RI_USAGE_MINIMUM(8, 0xE0), // Keyboard Left Control |
| 61 | HID_RI_USAGE_MAXIMUM(8, 0xE7), // Keyboard Right GUI | ||
| 65 | HID_RI_LOGICAL_MINIMUM(8, 0x00), | 62 | HID_RI_LOGICAL_MINIMUM(8, 0x00), |
| 66 | HID_RI_LOGICAL_MAXIMUM(8, 0x01), | 63 | HID_RI_LOGICAL_MAXIMUM(8, 0x01), |
| 67 | HID_RI_REPORT_COUNT(8, 0x08), | 64 | HID_RI_REPORT_COUNT(8, 0x08), |
| 68 | HID_RI_REPORT_SIZE(8, 0x01), | 65 | HID_RI_REPORT_SIZE(8, 0x01), |
| 69 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), | 66 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), |
| 70 | 67 | // Reserved (1 byte) | |
| 71 | HID_RI_REPORT_COUNT(8, 0x01), | 68 | HID_RI_REPORT_COUNT(8, 0x01), |
| 72 | HID_RI_REPORT_SIZE(8, 0x08), | 69 | HID_RI_REPORT_SIZE(8, 0x08), |
| 73 | HID_RI_INPUT(8, HID_IOF_CONSTANT), /* reserved */ | 70 | HID_RI_INPUT(8, HID_IOF_CONSTANT), |
| 71 | // Keycodes (6 bytes) | ||
| 72 | HID_RI_USAGE_PAGE(8, 0x07), // Keyboard/Keypad | ||
| 73 | HID_RI_USAGE_MINIMUM(8, 0x00), | ||
| 74 | HID_RI_USAGE_MAXIMUM(8, 0xFF), | ||
| 75 | HID_RI_LOGICAL_MINIMUM(8, 0x00), | ||
| 76 | HID_RI_LOGICAL_MAXIMUM(16, 0x00FF), | ||
| 77 | HID_RI_REPORT_COUNT(8, 0x06), | ||
| 78 | HID_RI_REPORT_SIZE(8, 0x08), | ||
| 79 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE), | ||
| 74 | 80 | ||
| 75 | HID_RI_USAGE_PAGE(8, 0x08), /* LEDs */ | 81 | // Status LEDs (5 bits) |
| 76 | HID_RI_USAGE_MINIMUM(8, 0x01), /* Num Lock */ | 82 | HID_RI_USAGE_PAGE(8, 0x08), // LED |
| 77 | HID_RI_USAGE_MAXIMUM(8, 0x05), /* Kana */ | 83 | HID_RI_USAGE_MINIMUM(8, 0x01), // Num Lock |
| 84 | HID_RI_USAGE_MAXIMUM(8, 0x05), // Kana | ||
| 78 | HID_RI_REPORT_COUNT(8, 0x05), | 85 | HID_RI_REPORT_COUNT(8, 0x05), |
| 79 | HID_RI_REPORT_SIZE(8, 0x01), | 86 | HID_RI_REPORT_SIZE(8, 0x01), |
| 80 | HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), | 87 | HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), |
| 88 | // LED padding (3 bits) | ||
| 81 | HID_RI_REPORT_COUNT(8, 0x01), | 89 | HID_RI_REPORT_COUNT(8, 0x01), |
| 82 | HID_RI_REPORT_SIZE(8, 0x03), | 90 | HID_RI_REPORT_SIZE(8, 0x03), |
| 83 | HID_RI_OUTPUT(8, HID_IOF_CONSTANT), | 91 | HID_RI_OUTPUT(8, HID_IOF_CONSTANT), |
| 84 | |||
| 85 | HID_RI_USAGE_PAGE(8, 0x07), /* Keyboard */ | ||
| 86 | HID_RI_USAGE_MINIMUM(8, 0x00), /* Reserved (no event indicated) */ | ||
| 87 | HID_RI_USAGE_MAXIMUM(8, 0xFF), /* Keyboard Application */ | ||
| 88 | HID_RI_LOGICAL_MINIMUM(8, 0x00), | ||
| 89 | HID_RI_LOGICAL_MAXIMUM(16, 0x00FF), | ||
| 90 | HID_RI_REPORT_COUNT(8, 0x06), | ||
| 91 | HID_RI_REPORT_SIZE(8, 0x08), | ||
| 92 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE), | ||
| 93 | HID_RI_END_COLLECTION(0), | 92 | HID_RI_END_COLLECTION(0), |
| 94 | |||
| 95 | #ifndef KEYBOARD_SHARED_EP | 93 | #ifndef KEYBOARD_SHARED_EP |
| 96 | }; | 94 | }; |
| 97 | #endif | 95 | #endif |
| 98 | 96 | ||
| 99 | #if defined(MOUSE_ENABLE) | 97 | #ifdef MOUSE_ENABLE |
| 100 | 98 | #ifndef MOUSE_SHARED_EP | |
| 101 | # if !defined(MOUSE_SHARED_EP) | ||
| 102 | const USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] = { | 99 | const USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] = { |
| 103 | # elif !defined(SHARED_REPORT_STARTED) | 100 | #elif !defined(SHARED_REPORT_STARTED) |
| 104 | const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = { | 101 | const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = { |
| 105 | #define SHARED_REPORT_STARTED | 102 | #define SHARED_REPORT_STARTED |
| 106 | # endif | 103 | #endif |
| 107 | HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */ | 104 | HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop |
| 108 | HID_RI_USAGE(8, 0x02), /* Mouse */ | 105 | HID_RI_USAGE(8, 0x02), // Mouse |
| 109 | HID_RI_COLLECTION(8, 0x01), /* Application */ | 106 | HID_RI_COLLECTION(8, 0x01), // Application |
| 110 | # ifdef MOUSE_SHARED_EP | 107 | #ifdef MOUSE_SHARED_EP |
| 111 | HID_RI_REPORT_ID(8, REPORT_ID_MOUSE), | 108 | HID_RI_REPORT_ID(8, REPORT_ID_MOUSE), |
| 112 | # endif | 109 | #endif |
| 113 | HID_RI_USAGE(8, 0x01), /* Pointer */ | 110 | HID_RI_USAGE(8, 0x01), // Pointer |
| 114 | HID_RI_COLLECTION(8, 0x00), /* Physical */ | 111 | HID_RI_COLLECTION(8, 0x00), // Physical |
| 115 | 112 | // Buttons (5 bits) | |
| 116 | HID_RI_USAGE_PAGE(8, 0x09), /* Button */ | 113 | HID_RI_USAGE_PAGE(8, 0x09), // Button |
| 117 | HID_RI_USAGE_MINIMUM(8, 0x01), /* Button 1 */ | 114 | HID_RI_USAGE_MINIMUM(8, 0x01), // Button 1 |
| 118 | HID_RI_USAGE_MAXIMUM(8, 0x05), /* Button 5 */ | 115 | HID_RI_USAGE_MAXIMUM(8, 0x05), // Button 5 |
| 119 | HID_RI_LOGICAL_MINIMUM(8, 0x00), | 116 | HID_RI_LOGICAL_MINIMUM(8, 0x00), |
| 120 | HID_RI_LOGICAL_MAXIMUM(8, 0x01), | 117 | HID_RI_LOGICAL_MAXIMUM(8, 0x01), |
| 121 | HID_RI_REPORT_COUNT(8, 0x05), | 118 | HID_RI_REPORT_COUNT(8, 0x05), |
| 122 | HID_RI_REPORT_SIZE(8, 0x01), | 119 | HID_RI_REPORT_SIZE(8, 0x01), |
| 123 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), | 120 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), |
| 121 | // Button padding (3 bits) | ||
| 124 | HID_RI_REPORT_COUNT(8, 0x01), | 122 | HID_RI_REPORT_COUNT(8, 0x01), |
| 125 | HID_RI_REPORT_SIZE(8, 0x03), | 123 | HID_RI_REPORT_SIZE(8, 0x03), |
| 126 | HID_RI_INPUT(8, HID_IOF_CONSTANT), | 124 | HID_RI_INPUT(8, HID_IOF_CONSTANT), |
| 127 | 125 | ||
| 128 | HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */ | 126 | // X/Y position (2 bytes) |
| 129 | HID_RI_USAGE(8, 0x30), /* Usage X */ | 127 | HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop |
| 130 | HID_RI_USAGE(8, 0x31), /* Usage Y */ | 128 | HID_RI_USAGE(8, 0x30), // X |
| 129 | HID_RI_USAGE(8, 0x31), // Y | ||
| 131 | HID_RI_LOGICAL_MINIMUM(8, -127), | 130 | HID_RI_LOGICAL_MINIMUM(8, -127), |
| 132 | HID_RI_LOGICAL_MAXIMUM(8, 127), | 131 | HID_RI_LOGICAL_MAXIMUM(8, 127), |
| 133 | HID_RI_REPORT_COUNT(8, 0x02), | 132 | HID_RI_REPORT_COUNT(8, 0x02), |
| 134 | HID_RI_REPORT_SIZE(8, 0x08), | 133 | HID_RI_REPORT_SIZE(8, 0x08), |
| 135 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE), | 134 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE), |
| 136 | 135 | ||
| 137 | HID_RI_USAGE(8, 0x38), /* Wheel */ | 136 | // Vertical wheel (1 byte) |
| 137 | HID_RI_USAGE(8, 0x38), // Wheel | ||
| 138 | HID_RI_LOGICAL_MINIMUM(8, -127), | 138 | HID_RI_LOGICAL_MINIMUM(8, -127), |
| 139 | HID_RI_LOGICAL_MAXIMUM(8, 127), | 139 | HID_RI_LOGICAL_MAXIMUM(8, 127), |
| 140 | HID_RI_REPORT_COUNT(8, 0x01), | 140 | HID_RI_REPORT_COUNT(8, 0x01), |
| 141 | HID_RI_REPORT_SIZE(8, 0x08), | 141 | HID_RI_REPORT_SIZE(8, 0x08), |
| 142 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE), | 142 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE), |
| 143 | 143 | // Horizontal wheel (1 byte) | |
| 144 | HID_RI_USAGE_PAGE(8, 0x0C), /* Consumer */ | 144 | HID_RI_USAGE_PAGE(8, 0x0C), // Consumer |
| 145 | HID_RI_USAGE(16, 0x0238), /* AC Pan (Horizontal wheel) */ | 145 | HID_RI_USAGE(16, 0x0238), // AC Pan |
| 146 | HID_RI_LOGICAL_MINIMUM(8, -127), | 146 | HID_RI_LOGICAL_MINIMUM(8, -127), |
| 147 | HID_RI_LOGICAL_MAXIMUM(8, 127), | 147 | HID_RI_LOGICAL_MAXIMUM(8, 127), |
| 148 | HID_RI_REPORT_COUNT(8, 0x01), | 148 | HID_RI_REPORT_COUNT(8, 0x01), |
| 149 | HID_RI_REPORT_SIZE(8, 0x08), | 149 | HID_RI_REPORT_SIZE(8, 0x08), |
| 150 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE), | 150 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE), |
| 151 | |||
| 152 | HID_RI_END_COLLECTION(0), | 151 | HID_RI_END_COLLECTION(0), |
| 153 | HID_RI_END_COLLECTION(0), | 152 | HID_RI_END_COLLECTION(0), |
| 154 | # ifndef MOUSE_SHARED_EP | 153 | #ifndef MOUSE_SHARED_EP |
| 155 | }; | 154 | }; |
| 156 | # endif | 155 | #endif |
| 157 | #endif | 156 | #endif |
| 158 | 157 | ||
| 159 | #if defined(SHARED_EP_ENABLE) && !defined(SHARED_REPORT_STARTED) | 158 | #if defined(SHARED_EP_ENABLE) && !defined(SHARED_REPORT_STARTED) |
| 160 | const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = { | 159 | const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = { |
| 161 | #endif | 160 | #endif |
| 162 | # ifdef EXTRAKEY_ENABLE | 161 | |
| 163 | HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */ | 162 | #ifdef EXTRAKEY_ENABLE |
| 164 | HID_RI_USAGE(8, 0x80), /* System Control */ | 163 | HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop |
| 165 | HID_RI_COLLECTION(8, 0x01), /* Application */ | 164 | HID_RI_USAGE(8, 0x80), // System Control |
| 165 | HID_RI_COLLECTION(8, 0x01), // Application | ||
| 166 | HID_RI_REPORT_ID(8, REPORT_ID_SYSTEM), | 166 | HID_RI_REPORT_ID(8, REPORT_ID_SYSTEM), |
| 167 | HID_RI_USAGE_MINIMUM(16, 0x0081), // System Power Down | ||
| 168 | HID_RI_USAGE_MAXIMUM(16, 0x0083), // System Wake Up | ||
| 167 | HID_RI_LOGICAL_MINIMUM(16, 0x0001), | 169 | HID_RI_LOGICAL_MINIMUM(16, 0x0001), |
| 168 | HID_RI_LOGICAL_MAXIMUM(16, 0x0003), | 170 | HID_RI_LOGICAL_MAXIMUM(16, 0x0003), |
| 169 | HID_RI_USAGE_MINIMUM(16, 0x0081), /* System Power Down */ | ||
| 170 | HID_RI_USAGE_MAXIMUM(16, 0x0083), /* System Wake Up */ | ||
| 171 | HID_RI_REPORT_SIZE(8, 16), | ||
| 172 | HID_RI_REPORT_COUNT(8, 1), | 171 | HID_RI_REPORT_COUNT(8, 1), |
| 172 | HID_RI_REPORT_SIZE(8, 16), | ||
| 173 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE), | 173 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE), |
| 174 | HID_RI_END_COLLECTION(0), | 174 | HID_RI_END_COLLECTION(0), |
| 175 | 175 | ||
| 176 | HID_RI_USAGE_PAGE(8, 0x0C), /* Consumer */ | 176 | HID_RI_USAGE_PAGE(8, 0x0C), // Consumer |
| 177 | HID_RI_USAGE(8, 0x01), /* Consumer Control */ | 177 | HID_RI_USAGE(8, 0x01), // Consumer Control |
| 178 | HID_RI_COLLECTION(8, 0x01), /* Application */ | 178 | HID_RI_COLLECTION(8, 0x01), // Application |
| 179 | HID_RI_REPORT_ID(8, REPORT_ID_CONSUMER), | 179 | HID_RI_REPORT_ID(8, REPORT_ID_CONSUMER), |
| 180 | HID_RI_USAGE_MINIMUM(16, 0x0001), // Consumer Control | ||
| 181 | HID_RI_USAGE_MAXIMUM(16, 0x029C), // AC Distribute Vertically | ||
| 180 | HID_RI_LOGICAL_MINIMUM(16, 0x0001), | 182 | HID_RI_LOGICAL_MINIMUM(16, 0x0001), |
| 181 | HID_RI_LOGICAL_MAXIMUM(16, 0x029C), | 183 | HID_RI_LOGICAL_MAXIMUM(16, 0x029C), |
| 182 | HID_RI_USAGE_MINIMUM(16, 0x0001), /* +10 */ | ||
| 183 | HID_RI_USAGE_MAXIMUM(16, 0x029C), /* AC Distribute Vertically */ | ||
| 184 | HID_RI_REPORT_SIZE(8, 16), | ||
| 185 | HID_RI_REPORT_COUNT(8, 1), | 184 | HID_RI_REPORT_COUNT(8, 1), |
| 185 | HID_RI_REPORT_SIZE(8, 16), | ||
| 186 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE), | 186 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE), |
| 187 | HID_RI_END_COLLECTION(0), | 187 | HID_RI_END_COLLECTION(0), |
| 188 | # endif | 188 | #endif |
| 189 | 189 | ||
| 190 | # ifdef NKRO_ENABLE | 190 | #ifdef NKRO_ENABLE |
| 191 | HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */ | 191 | HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop |
| 192 | HID_RI_USAGE(8, 0x06), /* Keyboard */ | 192 | HID_RI_USAGE(8, 0x06), // Keyboard |
| 193 | HID_RI_COLLECTION(8, 0x01), /* Application */ | 193 | HID_RI_COLLECTION(8, 0x01), // Application |
| 194 | HID_RI_REPORT_ID(8, REPORT_ID_NKRO), | 194 | HID_RI_REPORT_ID(8, REPORT_ID_NKRO), |
| 195 | HID_RI_USAGE_PAGE(8, 0x07), /* Key Codes */ | 195 | // Modifiers (8 bits) |
| 196 | HID_RI_USAGE_MINIMUM(8, 0xE0), /* Keyboard Left Control */ | 196 | HID_RI_USAGE_PAGE(8, 0x07), // Keyboard/Keypad |
| 197 | HID_RI_USAGE_MAXIMUM(8, 0xE7), /* Keyboard Right GUI */ | 197 | HID_RI_USAGE_MINIMUM(8, 0xE0), // Keyboard Left Control |
| 198 | HID_RI_USAGE_MAXIMUM(8, 0xE7), // Keyboard Right GUI | ||
| 198 | HID_RI_LOGICAL_MINIMUM(8, 0x00), | 199 | HID_RI_LOGICAL_MINIMUM(8, 0x00), |
| 199 | HID_RI_LOGICAL_MAXIMUM(8, 0x01), | 200 | HID_RI_LOGICAL_MAXIMUM(8, 0x01), |
| 200 | HID_RI_REPORT_COUNT(8, 0x08), | 201 | HID_RI_REPORT_COUNT(8, 0x08), |
| 201 | HID_RI_REPORT_SIZE(8, 0x01), | 202 | HID_RI_REPORT_SIZE(8, 0x01), |
| 202 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), | 203 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), |
| 204 | // Keycodes | ||
| 205 | HID_RI_USAGE_PAGE(8, 0x07), // Keyboard/Keypad | ||
| 206 | HID_RI_USAGE_MINIMUM(8, 0x00), | ||
| 207 | HID_RI_USAGE_MAXIMUM(8, KEYBOARD_REPORT_BITS * 8 - 1), | ||
| 208 | HID_RI_LOGICAL_MINIMUM(8, 0x00), | ||
| 209 | HID_RI_LOGICAL_MAXIMUM(8, 0x01), | ||
| 210 | HID_RI_REPORT_COUNT(8, KEYBOARD_REPORT_BITS * 8), | ||
| 211 | HID_RI_REPORT_SIZE(8, 0x01), | ||
| 212 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), | ||
| 203 | 213 | ||
| 204 | HID_RI_USAGE_PAGE(8, 0x08), /* LEDs */ | 214 | // Status LEDs (5 bits) |
| 205 | HID_RI_USAGE_MINIMUM(8, 0x01), /* Num Lock */ | 215 | HID_RI_USAGE_PAGE(8, 0x08), // LED |
| 206 | HID_RI_USAGE_MAXIMUM(8, 0x05), /* Kana */ | 216 | HID_RI_USAGE_MINIMUM(8, 0x01), // Num Lock |
| 217 | HID_RI_USAGE_MAXIMUM(8, 0x05), // Kana | ||
| 207 | HID_RI_REPORT_COUNT(8, 0x05), | 218 | HID_RI_REPORT_COUNT(8, 0x05), |
| 208 | HID_RI_REPORT_SIZE(8, 0x01), | 219 | HID_RI_REPORT_SIZE(8, 0x01), |
| 209 | HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), | 220 | HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), |
| 221 | // LED padding (3 bits) | ||
| 210 | HID_RI_REPORT_COUNT(8, 0x01), | 222 | HID_RI_REPORT_COUNT(8, 0x01), |
| 211 | HID_RI_REPORT_SIZE(8, 0x03), | 223 | HID_RI_REPORT_SIZE(8, 0x03), |
| 212 | HID_RI_OUTPUT(8, HID_IOF_CONSTANT), | 224 | HID_RI_OUTPUT(8, HID_IOF_CONSTANT), |
| 213 | |||
| 214 | HID_RI_USAGE_PAGE(8, 0x07), /* Key Codes */ | ||
| 215 | HID_RI_USAGE_MINIMUM(8, 0x00), /* Keyboard 0 */ | ||
| 216 | HID_RI_USAGE_MAXIMUM(8, KEYBOARD_REPORT_BITS*8-1), | ||
| 217 | HID_RI_LOGICAL_MINIMUM(8, 0x00), | ||
| 218 | HID_RI_LOGICAL_MAXIMUM(8, 0x01), | ||
| 219 | HID_RI_REPORT_COUNT(8, KEYBOARD_REPORT_BITS*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), | 225 | HID_RI_END_COLLECTION(0), |
| 223 | # endif | 226 | #endif |
| 224 | #ifdef SHARED_EP_ENABLE | 227 | #ifdef SHARED_EP_ENABLE |
| 225 | }; | 228 | }; |
| 226 | #endif | 229 | #endif |
| 227 | 230 | ||
| 228 | #ifdef RAW_ENABLE | 231 | #ifdef RAW_ENABLE |
| 229 | const USB_Descriptor_HIDReport_Datatype_t PROGMEM RawReport[] = | 232 | const USB_Descriptor_HIDReport_Datatype_t PROGMEM RawReport[] = { |
| 230 | { | 233 | HID_RI_USAGE_PAGE(16, 0xFF60), // Vendor Defined |
| 231 | HID_RI_USAGE_PAGE(16, 0xFF60), /* Vendor Page 0xFF60 */ | 234 | HID_RI_USAGE(8, 0x61), // Vendor Defined |
| 232 | HID_RI_USAGE(8, 0x61), /* Vendor Usage 0x61 */ | 235 | HID_RI_COLLECTION(8, 0x01), // Application |
| 233 | HID_RI_COLLECTION(8, 0x01), /* Application */ | 236 | // Data to host |
| 234 | HID_RI_USAGE(8, 0x62), /* Vendor Usage 0x62 */ | 237 | HID_RI_USAGE(8, 0x62), // Vendor Defined |
| 235 | HID_RI_LOGICAL_MINIMUM(8, 0x00), | 238 | HID_RI_LOGICAL_MINIMUM(8, 0x00), |
| 236 | HID_RI_LOGICAL_MAXIMUM(16, 0x00FF), | 239 | HID_RI_LOGICAL_MAXIMUM(16, 0x00FF), |
| 237 | HID_RI_REPORT_COUNT(8, RAW_EPSIZE), | 240 | HID_RI_REPORT_COUNT(8, RAW_EPSIZE), |
| 238 | HID_RI_REPORT_SIZE(8, 0x08), | 241 | HID_RI_REPORT_SIZE(8, 0x08), |
| 239 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), | 242 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), |
| 240 | HID_RI_USAGE(8, 0x63), /* Vendor Usage 0x63 */ | 243 | // Data from host |
| 244 | HID_RI_USAGE(8, 0x63), // Vendor Defined | ||
| 241 | HID_RI_LOGICAL_MINIMUM(8, 0x00), | 245 | HID_RI_LOGICAL_MINIMUM(8, 0x00), |
| 242 | HID_RI_LOGICAL_MAXIMUM(16, 0x00FF), | 246 | HID_RI_LOGICAL_MAXIMUM(16, 0x00FF), |
| 243 | HID_RI_REPORT_COUNT(8, RAW_EPSIZE), | 247 | HID_RI_REPORT_COUNT(8, RAW_EPSIZE), |
| @@ -248,18 +252,19 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM RawReport[] = | |||
| 248 | #endif | 252 | #endif |
| 249 | 253 | ||
| 250 | #ifdef CONSOLE_ENABLE | 254 | #ifdef CONSOLE_ENABLE |
| 251 | const USB_Descriptor_HIDReport_Datatype_t PROGMEM ConsoleReport[] = | 255 | const USB_Descriptor_HIDReport_Datatype_t PROGMEM ConsoleReport[] = { |
| 252 | { | 256 | HID_RI_USAGE_PAGE(16, 0xFF31), // Vendor Defined (PJRC Teensy compatible) |
| 253 | HID_RI_USAGE_PAGE(16, 0xFF31), /* Vendor Page(PJRC Teensy compatible) */ | 257 | HID_RI_USAGE(8, 0x74), // Vendor Defined (PJRC Teensy compatible) |
| 254 | HID_RI_USAGE(8, 0x74), /* Vendor Usage(PJRC Teensy compatible) */ | 258 | HID_RI_COLLECTION(8, 0x01), // Application |
| 255 | HID_RI_COLLECTION(8, 0x01), /* Application */ | 259 | // Data to host |
| 256 | HID_RI_USAGE(8, 0x75), /* Vendor Usage 0x75 */ | 260 | HID_RI_USAGE(8, 0x75), // Vendor Defined |
| 257 | HID_RI_LOGICAL_MINIMUM(8, 0x00), | 261 | HID_RI_LOGICAL_MINIMUM(8, 0x00), |
| 258 | HID_RI_LOGICAL_MAXIMUM(16, 0x00FF), | 262 | HID_RI_LOGICAL_MAXIMUM(16, 0x00FF), |
| 259 | HID_RI_REPORT_COUNT(8, CONSOLE_EPSIZE), | 263 | HID_RI_REPORT_COUNT(8, CONSOLE_EPSIZE), |
| 260 | HID_RI_REPORT_SIZE(8, 0x08), | 264 | HID_RI_REPORT_SIZE(8, 0x08), |
| 261 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), | 265 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), |
| 262 | HID_RI_USAGE(8, 0x76), /* Vendor Usage 0x76 */ | 266 | // Data from host |
| 267 | HID_RI_USAGE(8, 0x76), // Vendor Defined | ||
| 263 | HID_RI_LOGICAL_MINIMUM(8, 0x00), | 268 | HID_RI_LOGICAL_MINIMUM(8, 0x00), |
| 264 | HID_RI_LOGICAL_MAXIMUM(16, 0x00FF), | 269 | HID_RI_LOGICAL_MAXIMUM(16, 0x00FF), |
| 265 | HID_RI_REPORT_COUNT(8, CONSOLE_EPSIZE), | 270 | HID_RI_REPORT_COUNT(8, CONSOLE_EPSIZE), |
| @@ -269,15 +274,15 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM ConsoleReport[] = | |||
| 269 | }; | 274 | }; |
| 270 | #endif | 275 | #endif |
| 271 | 276 | ||
| 272 | 277 | /* | |
| 273 | /******************************************************************************* | 278 | * Device descriptor |
| 274 | * Device Descriptors | 279 | */ |
| 275 | ******************************************************************************/ | 280 | const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = { |
| 276 | const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = | 281 | .Header = { |
| 277 | { | 282 | .Size = sizeof(USB_Descriptor_Device_t), |
| 278 | .Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, | 283 | .Type = DTYPE_Device |
| 279 | 284 | }, | |
| 280 | .USBSpecification = VERSION_BCD(1,1,0), | 285 | .USBSpecification = VERSION_BCD(1, 1, 0), |
| 281 | #if VIRTSER_ENABLE | 286 | #if VIRTSER_ENABLE |
| 282 | .Class = USB_CSCP_IADDeviceClass, | 287 | .Class = USB_CSCP_IADDeviceClass, |
| 283 | .SubClass = USB_CSCP_IADDeviceSubclass, | 288 | .SubClass = USB_CSCP_IADDeviceSubclass, |
| @@ -287,710 +292,698 @@ const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = | |||
| 287 | .SubClass = USB_CSCP_NoDeviceSubclass, | 292 | .SubClass = USB_CSCP_NoDeviceSubclass, |
| 288 | .Protocol = USB_CSCP_NoDeviceProtocol, | 293 | .Protocol = USB_CSCP_NoDeviceProtocol, |
| 289 | #endif | 294 | #endif |
| 290 | |||
| 291 | .Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE, | 295 | .Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE, |
| 292 | 296 | // Specified in config.h | |
| 293 | /* specified in config.h */ | ||
| 294 | .VendorID = VENDOR_ID, | 297 | .VendorID = VENDOR_ID, |
| 295 | .ProductID = PRODUCT_ID, | 298 | .ProductID = PRODUCT_ID, |
| 296 | .ReleaseNumber = DEVICE_VER, | 299 | .ReleaseNumber = DEVICE_VER, |
| 297 | |||
| 298 | .ManufacturerStrIndex = 0x01, | 300 | .ManufacturerStrIndex = 0x01, |
| 299 | .ProductStrIndex = 0x02, | 301 | .ProductStrIndex = 0x02, |
| 300 | .SerialNumStrIndex = 0x03, | 302 | .SerialNumStrIndex = 0x03, |
| 301 | |||
| 302 | .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS | 303 | .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS |
| 303 | }; | 304 | }; |
| 304 | 305 | ||
| 305 | /******************************************************************************* | 306 | #ifndef USB_MAX_POWER_CONSUMPTION |
| 306 | * Configuration Descriptors | 307 | #define USB_MAX_POWER_CONSUMPTION 500 |
| 307 | ******************************************************************************/ | 308 | #endif |
| 308 | const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = | ||
| 309 | { | ||
| 310 | .Config = | ||
| 311 | { | ||
| 312 | .Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, | ||
| 313 | |||
| 314 | .TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), | ||
| 315 | .TotalInterfaces = TOTAL_INTERFACES, | ||
| 316 | |||
| 317 | .ConfigurationNumber = 1, | ||
| 318 | .ConfigurationStrIndex = NO_DESCRIPTOR, | ||
| 319 | |||
| 320 | .ConfigAttributes = (USB_CONFIG_ATTR_RESERVED | USB_CONFIG_ATTR_REMOTEWAKEUP), | ||
| 321 | 309 | ||
| 322 | .MaxPowerConsumption = USB_CONFIG_POWER_MA(USB_MAX_POWER_CONSUMPTION) | 310 | /* |
| 311 | * Configuration descriptors | ||
| 312 | */ | ||
| 313 | const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = { | ||
| 314 | .Config = { | ||
| 315 | .Header = { | ||
| 316 | .Size = sizeof(USB_Descriptor_Configuration_Header_t), | ||
| 317 | .Type = DTYPE_Configuration | ||
| 323 | }, | 318 | }, |
| 319 | .TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), | ||
| 320 | .TotalInterfaces = TOTAL_INTERFACES, | ||
| 321 | .ConfigurationNumber = 1, | ||
| 322 | .ConfigurationStrIndex = NO_DESCRIPTOR, | ||
| 323 | .ConfigAttributes = (USB_CONFIG_ATTR_RESERVED | USB_CONFIG_ATTR_REMOTEWAKEUP), | ||
| 324 | .MaxPowerConsumption = USB_CONFIG_POWER_MA(USB_MAX_POWER_CONSUMPTION) | ||
| 325 | }, | ||
| 324 | 326 | ||
| 327 | #ifndef KEYBOARD_SHARED_EP | ||
| 325 | /* | 328 | /* |
| 326 | * Keyboard | 329 | * Keyboard |
| 327 | */ | 330 | */ |
| 328 | #ifndef KEYBOARD_SHARED_EP | 331 | .Keyboard_Interface = { |
| 329 | .Keyboard_Interface = | 332 | .Header = { |
| 330 | { | 333 | .Size = sizeof(USB_Descriptor_Interface_t), |
| 331 | .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | 334 | .Type = DTYPE_Interface |
| 332 | |||
| 333 | .InterfaceNumber = KEYBOARD_INTERFACE, | ||
| 334 | .AlternateSetting = 0x00, | ||
| 335 | |||
| 336 | .TotalEndpoints = 1, | ||
| 337 | |||
| 338 | .Class = HID_CSCP_HIDClass, | ||
| 339 | .SubClass = HID_CSCP_BootSubclass, | ||
| 340 | .Protocol = HID_CSCP_KeyboardBootProtocol, | ||
| 341 | |||
| 342 | .InterfaceStrIndex = NO_DESCRIPTOR | ||
| 343 | }, | 335 | }, |
| 344 | 336 | .InterfaceNumber = KEYBOARD_INTERFACE, | |
| 345 | .Keyboard_HID = | 337 | .AlternateSetting = 0x00, |
| 346 | { | 338 | .TotalEndpoints = 1, |
| 347 | .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, | 339 | .Class = HID_CSCP_HIDClass, |
| 348 | 340 | .SubClass = HID_CSCP_BootSubclass, | |
| 349 | .HIDSpec = VERSION_BCD(1,1,1), | 341 | .Protocol = HID_CSCP_KeyboardBootProtocol, |
| 350 | .CountryCode = 0x00, | 342 | |
| 351 | .TotalReportDescriptors = 1, | 343 | .InterfaceStrIndex = NO_DESCRIPTOR |
| 352 | .HIDReportType = HID_DTYPE_Report, | 344 | }, |
| 353 | .HIDReportLength = sizeof(KeyboardReport) | 345 | .Keyboard_HID = { |
| 346 | .Header = { | ||
| 347 | .Size = sizeof(USB_HID_Descriptor_HID_t), | ||
| 348 | .Type = HID_DTYPE_HID | ||
| 354 | }, | 349 | }, |
| 355 | 350 | .HIDSpec = VERSION_BCD(1, 1, 1), | |
| 356 | .Keyboard_INEndpoint = | 351 | .CountryCode = 0x00, |
| 357 | { | 352 | .TotalReportDescriptors = 1, |
| 358 | .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | 353 | .HIDReportType = HID_DTYPE_Report, |
| 359 | 354 | .HIDReportLength = sizeof(KeyboardReport) | |
| 360 | .EndpointAddress = (ENDPOINT_DIR_IN | KEYBOARD_IN_EPNUM), | 355 | }, |
| 361 | .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | 356 | .Keyboard_INEndpoint = { |
| 362 | .EndpointSize = KEYBOARD_EPSIZE, | 357 | .Header = { |
| 363 | .PollingIntervalMS = 0x0A | 358 | .Size = sizeof(USB_Descriptor_Endpoint_t), |
| 359 | .Type = DTYPE_Endpoint | ||
| 364 | }, | 360 | }, |
| 361 | .EndpointAddress = (ENDPOINT_DIR_IN | KEYBOARD_IN_EPNUM), | ||
| 362 | .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||
| 363 | .EndpointSize = KEYBOARD_EPSIZE, | ||
| 364 | .PollingIntervalMS = 0x0A | ||
| 365 | }, | ||
| 365 | #endif | 366 | #endif |
| 366 | 367 | ||
| 368 | #if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP) | ||
| 367 | /* | 369 | /* |
| 368 | * Mouse | 370 | * Mouse |
| 369 | */ | 371 | */ |
| 370 | #if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP) | 372 | .Mouse_Interface = { |
| 371 | .Mouse_Interface = | 373 | .Header = { |
| 372 | { | 374 | .Size = sizeof(USB_Descriptor_Interface_t), |
| 373 | .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | 375 | .Type = DTYPE_Interface |
| 374 | |||
| 375 | .InterfaceNumber = MOUSE_INTERFACE, | ||
| 376 | .AlternateSetting = 0x00, | ||
| 377 | |||
| 378 | .TotalEndpoints = 1, | ||
| 379 | |||
| 380 | .Class = HID_CSCP_HIDClass, | ||
| 381 | .SubClass = HID_CSCP_BootSubclass, | ||
| 382 | .Protocol = HID_CSCP_MouseBootProtocol, | ||
| 383 | |||
| 384 | .InterfaceStrIndex = NO_DESCRIPTOR | ||
| 385 | }, | 376 | }, |
| 386 | 377 | .InterfaceNumber = MOUSE_INTERFACE, | |
| 387 | .Mouse_HID = | 378 | .AlternateSetting = 0x00, |
| 388 | { | 379 | .TotalEndpoints = 1, |
| 389 | .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, | 380 | .Class = HID_CSCP_HIDClass, |
| 390 | 381 | .SubClass = HID_CSCP_BootSubclass, | |
| 391 | .HIDSpec = VERSION_BCD(1,1,1), | 382 | .Protocol = HID_CSCP_MouseBootProtocol, |
| 392 | .CountryCode = 0x00, | 383 | .InterfaceStrIndex = NO_DESCRIPTOR |
| 393 | .TotalReportDescriptors = 1, | 384 | }, |
| 394 | .HIDReportType = HID_DTYPE_Report, | 385 | .Mouse_HID = { |
| 395 | .HIDReportLength = sizeof(MouseReport) | 386 | .Header = { |
| 387 | .Size = sizeof(USB_HID_Descriptor_HID_t), | ||
| 388 | .Type = HID_DTYPE_HID | ||
| 396 | }, | 389 | }, |
| 397 | 390 | .HIDSpec = VERSION_BCD(1, 1, 1), | |
| 398 | .Mouse_INEndpoint = | 391 | .CountryCode = 0x00, |
| 399 | { | 392 | .TotalReportDescriptors = 1, |
| 400 | .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | 393 | .HIDReportType = HID_DTYPE_Report, |
| 401 | 394 | .HIDReportLength = sizeof(MouseReport) | |
| 402 | .EndpointAddress = (ENDPOINT_DIR_IN | MOUSE_IN_EPNUM), | 395 | }, |
| 403 | .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | 396 | .Mouse_INEndpoint = { |
| 404 | .EndpointSize = MOUSE_EPSIZE, | 397 | .Header = { |
| 405 | .PollingIntervalMS = 0x0A | 398 | .Size = sizeof(USB_Descriptor_Endpoint_t), |
| 399 | .Type = DTYPE_Endpoint | ||
| 406 | }, | 400 | }, |
| 401 | .EndpointAddress = (ENDPOINT_DIR_IN | MOUSE_IN_EPNUM), | ||
| 402 | .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||
| 403 | .EndpointSize = MOUSE_EPSIZE, | ||
| 404 | .PollingIntervalMS = 0x0A | ||
| 405 | }, | ||
| 407 | #endif | 406 | #endif |
| 408 | 407 | ||
| 408 | #ifdef SHARED_EP_ENABLE | ||
| 409 | /* | 409 | /* |
| 410 | * Shared | 410 | * Shared |
| 411 | */ | 411 | */ |
| 412 | #ifdef SHARED_EP_ENABLE | 412 | .Shared_Interface = { |
| 413 | .Shared_Interface = | 413 | .Header = { |
| 414 | { | 414 | .Size = sizeof(USB_Descriptor_Interface_t), |
| 415 | .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | 415 | .Type = DTYPE_Interface |
| 416 | 416 | }, | |
| 417 | .InterfaceNumber = SHARED_INTERFACE, | 417 | .InterfaceNumber = SHARED_INTERFACE, |
| 418 | .AlternateSetting = 0x00, | 418 | .AlternateSetting = 0x00, |
| 419 | 419 | .TotalEndpoints = 1, | |
| 420 | .TotalEndpoints = 1, | 420 | .Class = HID_CSCP_HIDClass, |
| 421 | 421 | #ifdef KEYBOARD_SHARED_EP | |
| 422 | .Class = HID_CSCP_HIDClass, | 422 | .SubClass = HID_CSCP_BootSubclass, |
| 423 | # ifdef KEYBOARD_SHARED_EP | 423 | .Protocol = HID_CSCP_KeyboardBootProtocol, |
| 424 | .SubClass = HID_CSCP_BootSubclass, | 424 | #else |
| 425 | .Protocol = HID_CSCP_KeyboardBootProtocol, | 425 | .SubClass = HID_CSCP_NonBootSubclass, |
| 426 | # else | 426 | .Protocol = HID_CSCP_NonBootProtocol, |
| 427 | .SubClass = HID_CSCP_NonBootSubclass, | ||
| 428 | .Protocol = HID_CSCP_NonBootProtocol, | ||
| 429 | #endif | 427 | #endif |
| 430 | 428 | .InterfaceStrIndex = NO_DESCRIPTOR | |
| 431 | .InterfaceStrIndex = NO_DESCRIPTOR | 429 | }, |
| 430 | .Shared_HID = { | ||
| 431 | .Header = { | ||
| 432 | .Size = sizeof(USB_HID_Descriptor_HID_t), | ||
| 433 | .Type = HID_DTYPE_HID | ||
| 432 | }, | 434 | }, |
| 433 | 435 | .HIDSpec = VERSION_BCD(1, 1, 1), | |
| 434 | .Shared_HID = | 436 | .CountryCode = 0x00, |
| 435 | { | 437 | .TotalReportDescriptors = 1, |
| 436 | .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, | 438 | .HIDReportType = HID_DTYPE_Report, |
| 437 | 439 | .HIDReportLength = sizeof(SharedReport) | |
| 438 | .HIDSpec = VERSION_BCD(1,1,1), | 440 | }, |
| 439 | .CountryCode = 0x00, | 441 | .Shared_INEndpoint = { |
| 440 | .TotalReportDescriptors = 1, | 442 | .Header = { |
| 441 | .HIDReportType = HID_DTYPE_Report, | 443 | .Size = sizeof(USB_Descriptor_Endpoint_t), |
| 442 | .HIDReportLength = sizeof(SharedReport) | 444 | .Type = DTYPE_Endpoint |
| 443 | }, | 445 | }, |
| 446 | .EndpointAddress = (ENDPOINT_DIR_IN | SHARED_IN_EPNUM), | ||
| 447 | .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||
| 448 | .EndpointSize = SHARED_EPSIZE, | ||
| 449 | .PollingIntervalMS = 0x0A | ||
| 450 | }, | ||
| 451 | #endif | ||
| 444 | 452 | ||
| 445 | .Shared_INEndpoint = | 453 | #ifdef RAW_ENABLE |
| 446 | { | 454 | /* |
| 447 | .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | 455 | * Raw HID |
| 448 | 456 | */ | |
| 449 | .EndpointAddress = (ENDPOINT_DIR_IN | SHARED_IN_EPNUM), | 457 | .Raw_Interface = { |
| 450 | .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | 458 | .Header = { |
| 451 | .EndpointSize = SHARED_EPSIZE, | 459 | .Size = sizeof(USB_Descriptor_Interface_t), |
| 452 | .PollingIntervalMS = 0x0A | 460 | .Type = DTYPE_Interface |
| 461 | }, | ||
| 462 | .InterfaceNumber = RAW_INTERFACE, | ||
| 463 | .AlternateSetting = 0x00, | ||
| 464 | .TotalEndpoints = 2, | ||
| 465 | .Class = HID_CSCP_HIDClass, | ||
| 466 | .SubClass = HID_CSCP_NonBootSubclass, | ||
| 467 | .Protocol = HID_CSCP_NonBootProtocol, | ||
| 468 | .InterfaceStrIndex = NO_DESCRIPTOR | ||
| 469 | }, | ||
| 470 | .Raw_HID = { | ||
| 471 | .Header = { | ||
| 472 | .Size = sizeof(USB_HID_Descriptor_HID_t), | ||
| 473 | .Type = HID_DTYPE_HID | ||
| 474 | }, | ||
| 475 | .HIDSpec = VERSION_BCD(1, 1, 1), | ||
| 476 | .CountryCode = 0x00, | ||
| 477 | .TotalReportDescriptors = 1, | ||
| 478 | .HIDReportType = HID_DTYPE_Report, | ||
| 479 | .HIDReportLength = sizeof(RawReport) | ||
| 480 | }, | ||
| 481 | .Raw_INEndpoint = { | ||
| 482 | .Header = { | ||
| 483 | .Size = sizeof(USB_Descriptor_Endpoint_t), | ||
| 484 | .Type = DTYPE_Endpoint | ||
| 485 | }, | ||
| 486 | .EndpointAddress = (ENDPOINT_DIR_IN | RAW_IN_EPNUM), | ||
| 487 | .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||
| 488 | .EndpointSize = RAW_EPSIZE, | ||
| 489 | .PollingIntervalMS = 0x01 | ||
| 490 | }, | ||
| 491 | .Raw_OUTEndpoint = { | ||
| 492 | .Header = { | ||
| 493 | .Size = sizeof(USB_Descriptor_Endpoint_t), | ||
| 494 | .Type = DTYPE_Endpoint | ||
| 453 | }, | 495 | }, |
| 496 | .EndpointAddress = (ENDPOINT_DIR_OUT | RAW_OUT_EPNUM), | ||
| 497 | .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||
| 498 | .EndpointSize = RAW_EPSIZE, | ||
| 499 | .PollingIntervalMS = 0x01 | ||
| 500 | }, | ||
| 454 | #endif | 501 | #endif |
| 455 | 502 | ||
| 456 | /* | 503 | #ifdef CONSOLE_ENABLE |
| 457 | * Raw | ||
| 458 | */ | ||
| 459 | #ifdef RAW_ENABLE | ||
| 460 | .Raw_Interface = | ||
| 461 | { | ||
| 462 | .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||
| 463 | |||
| 464 | .InterfaceNumber = RAW_INTERFACE, | ||
| 465 | .AlternateSetting = 0x00, | ||
| 466 | |||
| 467 | .TotalEndpoints = 2, | ||
| 468 | |||
| 469 | .Class = HID_CSCP_HIDClass, | ||
| 470 | .SubClass = HID_CSCP_NonBootSubclass, | ||
| 471 | .Protocol = HID_CSCP_NonBootProtocol, | ||
| 472 | |||
| 473 | .InterfaceStrIndex = NO_DESCRIPTOR | ||
| 474 | }, | ||
| 475 | |||
| 476 | .Raw_HID = | ||
| 477 | { | ||
| 478 | .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, | ||
| 479 | |||
| 480 | .HIDSpec = VERSION_BCD(1,1,1), | ||
| 481 | .CountryCode = 0x00, | ||
| 482 | .TotalReportDescriptors = 1, | ||
| 483 | .HIDReportType = HID_DTYPE_Report, | ||
| 484 | .HIDReportLength = sizeof(RawReport) | ||
| 485 | }, | ||
| 486 | |||
| 487 | .Raw_INEndpoint = | ||
| 488 | { | ||
| 489 | .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||
| 490 | |||
| 491 | .EndpointAddress = (ENDPOINT_DIR_IN | RAW_IN_EPNUM), | ||
| 492 | .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||
| 493 | .EndpointSize = RAW_EPSIZE, | ||
| 494 | .PollingIntervalMS = 0x01 | ||
| 495 | }, | ||
| 496 | |||
| 497 | .Raw_OUTEndpoint = | ||
| 498 | { | ||
| 499 | .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||
| 500 | |||
| 501 | .EndpointAddress = (ENDPOINT_DIR_OUT | RAW_OUT_EPNUM), | ||
| 502 | .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||
| 503 | .EndpointSize = RAW_EPSIZE, | ||
| 504 | .PollingIntervalMS = 0x01 | ||
| 505 | }, | ||
| 506 | #endif | ||
| 507 | |||
| 508 | /* | 504 | /* |
| 509 | * Console | 505 | * Console |
| 510 | */ | 506 | */ |
| 511 | #ifdef CONSOLE_ENABLE | 507 | .Console_Interface = { |
| 512 | .Console_Interface = | 508 | .Header = { |
| 513 | { | 509 | .Size = sizeof(USB_Descriptor_Interface_t), |
| 514 | .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | 510 | .Type = DTYPE_Interface |
| 515 | |||
| 516 | .InterfaceNumber = CONSOLE_INTERFACE, | ||
| 517 | .AlternateSetting = 0x00, | ||
| 518 | |||
| 519 | .TotalEndpoints = 2, | ||
| 520 | |||
| 521 | .Class = HID_CSCP_HIDClass, | ||
| 522 | .SubClass = HID_CSCP_NonBootSubclass, | ||
| 523 | .Protocol = HID_CSCP_NonBootProtocol, | ||
| 524 | |||
| 525 | .InterfaceStrIndex = NO_DESCRIPTOR | ||
| 526 | }, | 511 | }, |
| 527 | 512 | .InterfaceNumber = CONSOLE_INTERFACE, | |
| 528 | .Console_HID = | 513 | .AlternateSetting = 0x00, |
| 529 | { | 514 | .TotalEndpoints = 2, |
| 530 | .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, | 515 | .Class = HID_CSCP_HIDClass, |
| 531 | 516 | .SubClass = HID_CSCP_NonBootSubclass, | |
| 532 | .HIDSpec = VERSION_BCD(1,1,1), | 517 | .Protocol = HID_CSCP_NonBootProtocol, |
| 533 | .CountryCode = 0x00, | 518 | .InterfaceStrIndex = NO_DESCRIPTOR |
| 534 | .TotalReportDescriptors = 1, | 519 | }, |
| 535 | .HIDReportType = HID_DTYPE_Report, | 520 | .Console_HID = { |
| 536 | .HIDReportLength = sizeof(ConsoleReport) | 521 | .Header = { |
| 522 | .Size = sizeof(USB_HID_Descriptor_HID_t), | ||
| 523 | .Type = HID_DTYPE_HID | ||
| 537 | }, | 524 | }, |
| 538 | 525 | .HIDSpec = VERSION_BCD(1, 1, 1), | |
| 539 | .Console_INEndpoint = | 526 | .CountryCode = 0x00, |
| 540 | { | 527 | .TotalReportDescriptors = 1, |
| 541 | .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | 528 | .HIDReportType = HID_DTYPE_Report, |
| 542 | 529 | .HIDReportLength = sizeof(ConsoleReport) | |
| 543 | .EndpointAddress = (ENDPOINT_DIR_IN | CONSOLE_IN_EPNUM), | 530 | }, |
| 544 | .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | 531 | .Console_INEndpoint = { |
| 545 | .EndpointSize = CONSOLE_EPSIZE, | 532 | .Header = { |
| 546 | .PollingIntervalMS = 0x01 | 533 | .Size = sizeof(USB_Descriptor_Endpoint_t), |
| 534 | .Type = DTYPE_Endpoint | ||
| 547 | }, | 535 | }, |
| 548 | 536 | .EndpointAddress = (ENDPOINT_DIR_IN | CONSOLE_IN_EPNUM), | |
| 549 | .Console_OUTEndpoint = | 537 | .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), |
| 550 | { | 538 | .EndpointSize = CONSOLE_EPSIZE, |
| 551 | .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | 539 | .PollingIntervalMS = 0x01 |
| 552 | 540 | }, | |
| 553 | .EndpointAddress = (ENDPOINT_DIR_OUT | CONSOLE_OUT_EPNUM), | 541 | .Console_OUTEndpoint = { |
| 554 | .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | 542 | .Header = { |
| 555 | .EndpointSize = CONSOLE_EPSIZE, | 543 | .Size = sizeof(USB_Descriptor_Endpoint_t), |
| 556 | .PollingIntervalMS = 0x01 | 544 | .Type = DTYPE_Endpoint |
| 557 | }, | 545 | }, |
| 546 | .EndpointAddress = (ENDPOINT_DIR_OUT | CONSOLE_OUT_EPNUM), | ||
| 547 | .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||
| 548 | .EndpointSize = CONSOLE_EPSIZE, | ||
| 549 | .PollingIntervalMS = 0x01 | ||
| 550 | }, | ||
| 558 | #endif | 551 | #endif |
| 559 | 552 | ||
| 560 | #ifdef MIDI_ENABLE | 553 | #ifdef MIDI_ENABLE |
| 561 | .Audio_Interface_Association = | 554 | /* |
| 562 | { | 555 | * MIDI |
| 563 | .Header = {.Size = sizeof(USB_Descriptor_Interface_Association_t), .Type = DTYPE_InterfaceAssociation}, | 556 | */ |
| 564 | 557 | .Audio_Interface_Association = { | |
| 565 | .FirstInterfaceIndex = AC_INTERFACE, | 558 | .Header = { |
| 566 | .TotalInterfaces = 2, | 559 | .Size = sizeof(USB_Descriptor_Interface_Association_t), |
| 567 | 560 | .Type = DTYPE_InterfaceAssociation | |
| 568 | .Class = AUDIO_CSCP_AudioClass, | ||
| 569 | .SubClass = AUDIO_CSCP_ControlSubclass, | ||
| 570 | .Protocol = AUDIO_CSCP_ControlProtocol, | ||
| 571 | |||
| 572 | .IADStrIndex = NO_DESCRIPTOR, | ||
| 573 | }, | 561 | }, |
| 574 | .Audio_ControlInterface = | 562 | .FirstInterfaceIndex = AC_INTERFACE, |
| 575 | { | 563 | .TotalInterfaces = 2, |
| 576 | .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | 564 | .Class = AUDIO_CSCP_AudioClass, |
| 577 | 565 | .SubClass = AUDIO_CSCP_ControlSubclass, | |
| 578 | .InterfaceNumber = AC_INTERFACE, | 566 | .Protocol = AUDIO_CSCP_ControlProtocol, |
| 579 | .AlternateSetting = 0, | 567 | .IADStrIndex = NO_DESCRIPTOR, |
| 580 | 568 | }, | |
| 581 | .TotalEndpoints = 0, | 569 | .Audio_ControlInterface = { |
| 582 | 570 | .Header = { | |
| 583 | .Class = AUDIO_CSCP_AudioClass, | 571 | .Size = sizeof(USB_Descriptor_Interface_t), |
| 584 | .SubClass = AUDIO_CSCP_ControlSubclass, | 572 | .Type = DTYPE_Interface |
| 585 | .Protocol = AUDIO_CSCP_ControlProtocol, | ||
| 586 | |||
| 587 | .InterfaceStrIndex = NO_DESCRIPTOR | ||
| 588 | }, | 573 | }, |
| 589 | 574 | .InterfaceNumber = AC_INTERFACE, | |
| 590 | .Audio_ControlInterface_SPC = | 575 | .AlternateSetting = 0, |
| 591 | { | 576 | .TotalEndpoints = 0, |
| 592 | .Header = {.Size = sizeof(USB_Audio_Descriptor_Interface_AC_t), .Type = DTYPE_CSInterface}, | 577 | .Class = AUDIO_CSCP_AudioClass, |
| 593 | .Subtype = AUDIO_DSUBTYPE_CSInterface_Header, | 578 | .SubClass = AUDIO_CSCP_ControlSubclass, |
| 594 | 579 | .Protocol = AUDIO_CSCP_ControlProtocol, | |
| 595 | .ACSpecification = VERSION_BCD(1,0,0), | 580 | .InterfaceStrIndex = NO_DESCRIPTOR |
| 596 | .TotalLength = sizeof(USB_Audio_Descriptor_Interface_AC_t), | 581 | }, |
| 597 | 582 | .Audio_ControlInterface_SPC = { | |
| 598 | .InCollection = 1, | 583 | .Header = { |
| 599 | .InterfaceNumber = AS_INTERFACE, | 584 | .Size = sizeof(USB_Audio_Descriptor_Interface_AC_t), |
| 585 | .Type = DTYPE_CSInterface | ||
| 600 | }, | 586 | }, |
| 601 | 587 | .Subtype = AUDIO_DSUBTYPE_CSInterface_Header, | |
| 602 | .Audio_StreamInterface = | 588 | .ACSpecification = VERSION_BCD(1, 0, 0), |
| 603 | { | 589 | .TotalLength = sizeof(USB_Audio_Descriptor_Interface_AC_t), |
| 604 | .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | 590 | .InCollection = 1, |
| 605 | 591 | .InterfaceNumber = AS_INTERFACE, | |
| 606 | .InterfaceNumber = AS_INTERFACE, | 592 | }, |
| 607 | .AlternateSetting = 0, | 593 | .Audio_StreamInterface = { |
| 608 | 594 | .Header = { | |
| 609 | .TotalEndpoints = 2, | 595 | .Size = sizeof(USB_Descriptor_Interface_t), |
| 610 | 596 | .Type = DTYPE_Interface | |
| 611 | .Class = AUDIO_CSCP_AudioClass, | ||
| 612 | .SubClass = AUDIO_CSCP_MIDIStreamingSubclass, | ||
| 613 | .Protocol = AUDIO_CSCP_StreamingProtocol, | ||
| 614 | |||
| 615 | .InterfaceStrIndex = NO_DESCRIPTOR | ||
| 616 | }, | 597 | }, |
| 617 | 598 | .InterfaceNumber = AS_INTERFACE, | |
| 618 | .Audio_StreamInterface_SPC = | 599 | .AlternateSetting = 0, |
| 619 | { | 600 | .TotalEndpoints = 2, |
| 620 | .Header = {.Size = sizeof(USB_MIDI_Descriptor_AudioInterface_AS_t), .Type = DTYPE_CSInterface}, | 601 | .Class = AUDIO_CSCP_AudioClass, |
| 621 | .Subtype = AUDIO_DSUBTYPE_CSInterface_General, | 602 | .SubClass = AUDIO_CSCP_MIDIStreamingSubclass, |
| 622 | 603 | .Protocol = AUDIO_CSCP_StreamingProtocol, | |
| 623 | .AudioSpecification = VERSION_BCD(1,0,0), | 604 | .InterfaceStrIndex = NO_DESCRIPTOR |
| 624 | 605 | }, | |
| 625 | .TotalLength = offsetof(USB_Descriptor_Configuration_t, MIDI_Out_Jack_Endpoint_SPC) | 606 | .Audio_StreamInterface_SPC = { |
| 626 | + sizeof(USB_MIDI_Descriptor_Jack_Endpoint_t) | 607 | .Header = { |
| 627 | - offsetof(USB_Descriptor_Configuration_t, Audio_StreamInterface_SPC) | 608 | .Size = sizeof(USB_MIDI_Descriptor_AudioInterface_AS_t), |
| 609 | .Type = DTYPE_CSInterface | ||
| 628 | }, | 610 | }, |
| 629 | 611 | .Subtype = AUDIO_DSUBTYPE_CSInterface_General, | |
| 630 | .MIDI_In_Jack_Emb = | 612 | .AudioSpecification = VERSION_BCD(1, 0, 0), |
| 631 | { | 613 | .TotalLength = offsetof(USB_Descriptor_Configuration_t, MIDI_Out_Jack_Endpoint_SPC) + sizeof(USB_MIDI_Descriptor_Jack_Endpoint_t) - offsetof(USB_Descriptor_Configuration_t, Audio_StreamInterface_SPC) |
| 632 | .Header = {.Size = sizeof(USB_MIDI_Descriptor_InputJack_t), .Type = DTYPE_CSInterface}, | 614 | }, |
| 633 | .Subtype = AUDIO_DSUBTYPE_CSInterface_InputTerminal, | 615 | .MIDI_In_Jack_Emb = { |
| 634 | 616 | .Header = { | |
| 635 | .JackType = MIDI_JACKTYPE_Embedded, | 617 | .Size = sizeof(USB_MIDI_Descriptor_InputJack_t), |
| 636 | .JackID = 0x01, | 618 | .Type = DTYPE_CSInterface |
| 637 | |||
| 638 | .JackStrIndex = NO_DESCRIPTOR | ||
| 639 | }, | 619 | }, |
| 640 | 620 | .Subtype = AUDIO_DSUBTYPE_CSInterface_InputTerminal, | |
| 641 | .MIDI_In_Jack_Ext = | 621 | .JackType = MIDI_JACKTYPE_Embedded, |
| 642 | { | 622 | .JackID = 0x01, |
| 643 | .Header = {.Size = sizeof(USB_MIDI_Descriptor_InputJack_t), .Type = DTYPE_CSInterface}, | 623 | .JackStrIndex = NO_DESCRIPTOR |
| 644 | .Subtype = AUDIO_DSUBTYPE_CSInterface_InputTerminal, | 624 | }, |
| 645 | 625 | .MIDI_In_Jack_Ext = { | |
| 646 | .JackType = MIDI_JACKTYPE_External, | 626 | .Header = { |
| 647 | .JackID = 0x02, | 627 | .Size = sizeof(USB_MIDI_Descriptor_InputJack_t), |
| 648 | 628 | .Type = DTYPE_CSInterface | |
| 649 | .JackStrIndex = NO_DESCRIPTOR | ||
| 650 | }, | 629 | }, |
| 651 | 630 | .Subtype = AUDIO_DSUBTYPE_CSInterface_InputTerminal, | |
| 652 | .MIDI_Out_Jack_Emb = | 631 | .JackType = MIDI_JACKTYPE_External, |
| 653 | { | 632 | .JackID = 0x02, |
| 654 | .Header = {.Size = sizeof(USB_MIDI_Descriptor_OutputJack_t), .Type = DTYPE_CSInterface}, | 633 | .JackStrIndex = NO_DESCRIPTOR |
| 655 | .Subtype = AUDIO_DSUBTYPE_CSInterface_OutputTerminal, | 634 | }, |
| 656 | 635 | .MIDI_Out_Jack_Emb = { | |
| 657 | .JackType = MIDI_JACKTYPE_Embedded, | 636 | .Header = { |
| 658 | .JackID = 0x03, | 637 | .Size = sizeof(USB_MIDI_Descriptor_OutputJack_t), |
| 659 | 638 | .Type = DTYPE_CSInterface | |
| 660 | .NumberOfPins = 1, | ||
| 661 | .SourceJackID = {0x02}, | ||
| 662 | .SourcePinID = {0x01}, | ||
| 663 | |||
| 664 | .JackStrIndex = NO_DESCRIPTOR | ||
| 665 | }, | 639 | }, |
| 666 | 640 | .Subtype = AUDIO_DSUBTYPE_CSInterface_OutputTerminal, | |
| 667 | .MIDI_Out_Jack_Ext = | 641 | .JackType = MIDI_JACKTYPE_Embedded, |
| 668 | { | 642 | .JackID = 0x03, |
| 669 | .Header = {.Size = sizeof(USB_MIDI_Descriptor_OutputJack_t), .Type = DTYPE_CSInterface}, | 643 | .NumberOfPins = 1, |
| 670 | .Subtype = AUDIO_DSUBTYPE_CSInterface_OutputTerminal, | 644 | .SourceJackID = {0x02}, |
| 671 | 645 | .SourcePinID = {0x01}, | |
| 672 | .JackType = MIDI_JACKTYPE_External, | 646 | .JackStrIndex = NO_DESCRIPTOR |
| 673 | .JackID = 0x04, | 647 | }, |
| 674 | 648 | .MIDI_Out_Jack_Ext = { | |
| 675 | .NumberOfPins = 1, | 649 | .Header = { |
| 676 | .SourceJackID = {0x01}, | 650 | .Size = sizeof(USB_MIDI_Descriptor_OutputJack_t), |
| 677 | .SourcePinID = {0x01}, | 651 | .Type = DTYPE_CSInterface |
| 678 | |||
| 679 | .JackStrIndex = NO_DESCRIPTOR | ||
| 680 | }, | 652 | }, |
| 681 | 653 | .Subtype = AUDIO_DSUBTYPE_CSInterface_OutputTerminal, | |
| 682 | .MIDI_In_Jack_Endpoint = | 654 | .JackType = MIDI_JACKTYPE_External, |
| 683 | { | 655 | .JackID = 0x04, |
| 684 | .Endpoint = | 656 | .NumberOfPins = 1, |
| 685 | { | 657 | .SourceJackID = {0x01}, |
| 686 | .Header = {.Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t), .Type = DTYPE_Endpoint}, | 658 | .SourcePinID = {0x01}, |
| 687 | 659 | .JackStrIndex = NO_DESCRIPTOR | |
| 688 | .EndpointAddress = MIDI_STREAM_OUT_EPADDR, | 660 | }, |
| 689 | .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | 661 | .MIDI_In_Jack_Endpoint = { |
| 690 | .EndpointSize = MIDI_STREAM_EPSIZE, | 662 | .Endpoint = { |
| 691 | .PollingIntervalMS = 0x05 | 663 | .Header = { |
| 692 | }, | 664 | .Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t), |
| 693 | 665 | .Type = DTYPE_Endpoint | |
| 694 | .Refresh = 0, | 666 | }, |
| 695 | .SyncEndpointNumber = 0 | 667 | .EndpointAddress = MIDI_STREAM_OUT_EPADDR, |
| 668 | .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||
| 669 | .EndpointSize = MIDI_STREAM_EPSIZE, | ||
| 670 | .PollingIntervalMS = 0x05 | ||
| 696 | }, | 671 | }, |
| 697 | 672 | .Refresh = 0, | |
| 698 | .MIDI_In_Jack_Endpoint_SPC = | 673 | .SyncEndpointNumber = 0 |
| 699 | { | 674 | }, |
| 700 | .Header = {.Size = sizeof(USB_MIDI_Descriptor_Jack_Endpoint_t), .Type = DTYPE_CSEndpoint}, | 675 | .MIDI_In_Jack_Endpoint_SPC = { |
| 701 | .Subtype = AUDIO_DSUBTYPE_CSEndpoint_General, | 676 | .Header = { |
| 702 | 677 | .Size = sizeof(USB_MIDI_Descriptor_Jack_Endpoint_t), | |
| 703 | .TotalEmbeddedJacks = 0x01, | 678 | .Type = DTYPE_CSEndpoint |
| 704 | .AssociatedJackID = {0x01} | ||
| 705 | }, | 679 | }, |
| 706 | 680 | .Subtype = AUDIO_DSUBTYPE_CSEndpoint_General, | |
| 707 | .MIDI_Out_Jack_Endpoint = | 681 | .TotalEmbeddedJacks = 0x01, |
| 708 | { | 682 | .AssociatedJackID = {0x01} |
| 709 | .Endpoint = | 683 | }, |
| 710 | { | 684 | .MIDI_Out_Jack_Endpoint = { |
| 711 | .Header = {.Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t), .Type = DTYPE_Endpoint}, | 685 | .Endpoint = { |
| 712 | 686 | .Header = { | |
| 713 | .EndpointAddress = MIDI_STREAM_IN_EPADDR, | 687 | .Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t), |
| 714 | .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | 688 | .Type = DTYPE_Endpoint |
| 715 | .EndpointSize = MIDI_STREAM_EPSIZE, | 689 | }, |
| 716 | .PollingIntervalMS = 0x05 | 690 | .EndpointAddress = MIDI_STREAM_IN_EPADDR, |
| 717 | }, | 691 | .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), |
| 718 | 692 | .EndpointSize = MIDI_STREAM_EPSIZE, | |
| 719 | .Refresh = 0, | 693 | .PollingIntervalMS = 0x05 |
| 720 | .SyncEndpointNumber = 0 | ||
| 721 | }, | 694 | }, |
| 722 | 695 | .Refresh = 0, | |
| 723 | .MIDI_Out_Jack_Endpoint_SPC = | 696 | .SyncEndpointNumber = 0 |
| 724 | { | 697 | }, |
| 725 | .Header = {.Size = sizeof(USB_MIDI_Descriptor_Jack_Endpoint_t), .Type = DTYPE_CSEndpoint}, | 698 | .MIDI_Out_Jack_Endpoint_SPC = { |
| 726 | .Subtype = AUDIO_DSUBTYPE_CSEndpoint_General, | 699 | .Header = { |
| 727 | 700 | .Size = sizeof(USB_MIDI_Descriptor_Jack_Endpoint_t), | |
| 728 | .TotalEmbeddedJacks = 0x01, | 701 | .Type = DTYPE_CSEndpoint |
| 729 | .AssociatedJackID = {0x03} | ||
| 730 | }, | 702 | }, |
| 703 | .Subtype = AUDIO_DSUBTYPE_CSEndpoint_General, | ||
| 704 | .TotalEmbeddedJacks = 0x01, | ||
| 705 | .AssociatedJackID = {0x03} | ||
| 706 | }, | ||
| 731 | #endif | 707 | #endif |
| 732 | 708 | ||
| 733 | #ifdef VIRTSER_ENABLE | 709 | #ifdef VIRTSER_ENABLE |
| 734 | .CDC_Interface_Association = | 710 | /* |
| 735 | { | 711 | * Virtual Serial |
| 736 | .Header = {.Size = sizeof(USB_Descriptor_Interface_Association_t), .Type = DTYPE_InterfaceAssociation}, | 712 | */ |
| 737 | 713 | .CDC_Interface_Association = { | |
| 738 | .FirstInterfaceIndex = CCI_INTERFACE, | 714 | .Header = { |
| 739 | .TotalInterfaces = 2, | 715 | .Size = sizeof(USB_Descriptor_Interface_Association_t), |
| 740 | 716 | .Type = DTYPE_InterfaceAssociation | |
| 741 | .Class = CDC_CSCP_CDCClass, | 717 | }, |
| 742 | .SubClass = CDC_CSCP_ACMSubclass, | 718 | .FirstInterfaceIndex = CCI_INTERFACE, |
| 743 | .Protocol = CDC_CSCP_ATCommandProtocol, | 719 | .TotalInterfaces = 2, |
| 744 | 720 | .Class = CDC_CSCP_CDCClass, | |
| 745 | .IADStrIndex = NO_DESCRIPTOR, | 721 | .SubClass = CDC_CSCP_ACMSubclass, |
| 746 | }, | 722 | .Protocol = CDC_CSCP_ATCommandProtocol, |
| 747 | 723 | .IADStrIndex = NO_DESCRIPTOR, | |
| 748 | .CDC_CCI_Interface = | 724 | }, |
| 749 | { | 725 | .CDC_CCI_Interface = { |
| 750 | .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | 726 | .Header = { |
| 751 | 727 | .Size = sizeof(USB_Descriptor_Interface_t), | |
| 752 | .InterfaceNumber = CCI_INTERFACE, | 728 | .Type = DTYPE_Interface |
| 753 | .AlternateSetting = 0, | 729 | }, |
| 754 | 730 | .InterfaceNumber = CCI_INTERFACE, | |
| 755 | .TotalEndpoints = 1, | 731 | .AlternateSetting = 0, |
| 756 | 732 | .TotalEndpoints = 1, | |
| 757 | .Class = CDC_CSCP_CDCClass, | 733 | .Class = CDC_CSCP_CDCClass, |
| 758 | .SubClass = CDC_CSCP_ACMSubclass, | 734 | .SubClass = CDC_CSCP_ACMSubclass, |
| 759 | .Protocol = CDC_CSCP_ATCommandProtocol, | 735 | .Protocol = CDC_CSCP_ATCommandProtocol, |
| 760 | 736 | .InterfaceStrIndex = NO_DESCRIPTOR | |
| 761 | .InterfaceStrIndex = NO_DESCRIPTOR | 737 | }, |
| 762 | }, | 738 | .CDC_Functional_Header = { |
| 763 | 739 | .Header = { | |
| 764 | .CDC_Functional_Header = | 740 | .Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t), |
| 765 | { | 741 | .Type = DTYPE_CSInterface |
| 766 | .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t), .Type = DTYPE_CSInterface}, | 742 | }, |
| 767 | .Subtype = 0x00, | 743 | .Subtype = 0x00, |
| 768 | 744 | .CDCSpecification = VERSION_BCD(1, 1, 0), | |
| 769 | .CDCSpecification = VERSION_BCD(1,1,0), | 745 | }, |
| 770 | }, | 746 | .CDC_Functional_ACM = { |
| 771 | 747 | .Header = { | |
| 772 | .CDC_Functional_ACM = | 748 | .Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), |
| 773 | { | 749 | .Type = DTYPE_CSInterface |
| 774 | .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface}, | 750 | }, |
| 775 | .Subtype = 0x02, | 751 | .Subtype = 0x02, |
| 776 | 752 | .Capabilities = 0x02, | |
| 777 | .Capabilities = 0x02, | 753 | }, |
| 778 | }, | 754 | .CDC_Functional_Union = { |
| 779 | 755 | .Header = { | |
| 780 | .CDC_Functional_Union = | 756 | .Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t), |
| 781 | { | 757 | .Type = DTYPE_CSInterface |
| 782 | .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t), .Type = DTYPE_CSInterface}, | 758 | }, |
| 783 | .Subtype = 0x06, | 759 | .Subtype = 0x06, |
| 784 | 760 | .MasterInterfaceNumber = CCI_INTERFACE, | |
| 785 | .MasterInterfaceNumber = CCI_INTERFACE, | 761 | .SlaveInterfaceNumber = CDI_INTERFACE, |
| 786 | .SlaveInterfaceNumber = CDI_INTERFACE, | 762 | }, |
| 787 | }, | 763 | .CDC_NotificationEndpoint = { |
| 788 | 764 | .Header = { | |
| 789 | .CDC_NotificationEndpoint = | 765 | .Size = sizeof(USB_Descriptor_Endpoint_t), |
| 790 | { | 766 | .Type = DTYPE_Endpoint |
| 791 | .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | 767 | }, |
| 792 | 768 | .EndpointAddress = CDC_NOTIFICATION_EPADDR, | |
| 793 | .EndpointAddress = CDC_NOTIFICATION_EPADDR, | 769 | .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), |
| 794 | .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | 770 | .EndpointSize = CDC_NOTIFICATION_EPSIZE, |
| 795 | .EndpointSize = CDC_NOTIFICATION_EPSIZE, | 771 | .PollingIntervalMS = 0xFF |
| 796 | .PollingIntervalMS = 0xFF | 772 | }, |
| 797 | }, | 773 | .CDC_DCI_Interface = { |
| 798 | 774 | .Header = { | |
| 799 | .CDC_DCI_Interface = | 775 | .Size = sizeof(USB_Descriptor_Interface_t), |
| 800 | { | 776 | .Type = DTYPE_Interface |
| 801 | .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | 777 | }, |
| 802 | 778 | .InterfaceNumber = CDI_INTERFACE, | |
| 803 | .InterfaceNumber = CDI_INTERFACE, | 779 | .AlternateSetting = 0, |
| 804 | .AlternateSetting = 0, | 780 | .TotalEndpoints = 2, |
| 805 | 781 | .Class = CDC_CSCP_CDCDataClass, | |
| 806 | .TotalEndpoints = 2, | 782 | .SubClass = CDC_CSCP_NoDataSubclass, |
| 807 | 783 | .Protocol = CDC_CSCP_NoDataProtocol, | |
| 808 | .Class = CDC_CSCP_CDCDataClass, | 784 | .InterfaceStrIndex = NO_DESCRIPTOR |
| 809 | .SubClass = CDC_CSCP_NoDataSubclass, | 785 | }, |
| 810 | .Protocol = CDC_CSCP_NoDataProtocol, | 786 | .CDC_DataOutEndpoint = { |
| 811 | 787 | .Header = { | |
| 812 | .InterfaceStrIndex = NO_DESCRIPTOR | 788 | .Size = sizeof(USB_Descriptor_Endpoint_t), |
| 813 | }, | 789 | .Type = DTYPE_Endpoint |
| 814 | 790 | }, | |
| 815 | .CDC_DataOutEndpoint = | 791 | .EndpointAddress = CDC_OUT_EPADDR, |
| 816 | { | 792 | .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), |
| 817 | .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | 793 | .EndpointSize = CDC_EPSIZE, |
| 818 | 794 | .PollingIntervalMS = 0x05 | |
| 819 | .EndpointAddress = CDC_OUT_EPADDR, | 795 | }, |
| 820 | .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | 796 | .CDC_DataInEndpoint = { |
| 821 | .EndpointSize = CDC_EPSIZE, | 797 | .Header = { |
| 822 | .PollingIntervalMS = 0x05 | 798 | .Size = sizeof(USB_Descriptor_Endpoint_t), |
| 823 | }, | 799 | .Type = DTYPE_Endpoint |
| 824 | 800 | }, | |
| 825 | .CDC_DataInEndpoint = | 801 | .EndpointAddress = CDC_IN_EPADDR, |
| 826 | { | 802 | .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), |
| 827 | .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | 803 | .EndpointSize = CDC_EPSIZE, |
| 828 | 804 | .PollingIntervalMS = 0x05 | |
| 829 | .EndpointAddress = CDC_IN_EPADDR, | 805 | }, |
| 830 | .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||
| 831 | .EndpointSize = CDC_EPSIZE, | ||
| 832 | .PollingIntervalMS = 0x05 | ||
| 833 | }, | ||
| 834 | #endif | 806 | #endif |
| 835 | }; | 807 | }; |
| 836 | 808 | ||
| 837 | 809 | /* | |
| 838 | /******************************************************************************* | 810 | * String descriptors |
| 839 | * String Descriptors | 811 | */ |
| 840 | ******************************************************************************/ | 812 | const USB_Descriptor_String_t PROGMEM LanguageString = { |
| 841 | const USB_Descriptor_String_t PROGMEM LanguageString = | 813 | .Header = { |
| 842 | { | 814 | .Size = USB_STRING_LEN(1), |
| 843 | .Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String}, | 815 | .Type = DTYPE_String |
| 844 | 816 | }, | |
| 845 | .UnicodeString = {LANGUAGE_ID_ENG} | 817 | .UnicodeString = {LANGUAGE_ID_ENG} |
| 846 | }; | 818 | }; |
| 847 | 819 | ||
| 848 | const USB_Descriptor_String_t PROGMEM ManufacturerString = | 820 | const USB_Descriptor_String_t PROGMEM ManufacturerString = { |
| 849 | { | 821 | .Header = { |
| 850 | /* subtract 1 for null terminator */ | 822 | .Size = USB_STRING_LEN(sizeof(STR(MANUFACTURER)) - 1), // Subtract 1 for null terminator |
| 851 | .Header = {.Size = USB_STRING_LEN(sizeof(STR(MANUFACTURER))-1), .Type = DTYPE_String}, | 823 | .Type = DTYPE_String |
| 852 | 824 | }, | |
| 853 | .UnicodeString = LSTR(MANUFACTURER) | 825 | .UnicodeString = LSTR(MANUFACTURER) |
| 854 | }; | 826 | }; |
| 855 | 827 | ||
| 856 | const USB_Descriptor_String_t PROGMEM ProductString = | 828 | const USB_Descriptor_String_t PROGMEM ProductString = { |
| 857 | { | 829 | .Header = { |
| 858 | /* subtract 1 for null terminator */ | 830 | .Size = USB_STRING_LEN(sizeof(STR(PRODUCT)) - 1), // Subtract 1 for null terminator |
| 859 | .Header = {.Size = USB_STRING_LEN(sizeof(STR(PRODUCT))-1), .Type = DTYPE_String}, | 831 | .Type = DTYPE_String |
| 860 | 832 | }, | |
| 861 | .UnicodeString = LSTR(PRODUCT) | 833 | .UnicodeString = LSTR(PRODUCT) |
| 862 | }; | 834 | }; |
| 863 | 835 | ||
| 864 | #ifndef SERIAL_NUMBER | 836 | #ifndef SERIAL_NUMBER |
| 865 | #define SERIAL_NUMBER 0 | 837 | #define SERIAL_NUMBER 0 |
| 866 | #endif | 838 | #endif |
| 867 | 839 | ||
| 868 | const USB_Descriptor_String_t PROGMEM SerialNumberString = | 840 | const USB_Descriptor_String_t PROGMEM SerialNumberString = { |
| 869 | { | 841 | .Header = { |
| 870 | /* subtract 1 for null terminator */ | 842 | .Size = USB_STRING_LEN(sizeof(STR(SERIAL_NUMBER)) - 1), // Subtract 1 for null terminator |
| 871 | .Header = {.Size = USB_STRING_LEN(sizeof(STR(SERIAL_NUMBER))-1), .Type = DTYPE_String}, | 843 | .Type = DTYPE_String |
| 872 | 844 | }, | |
| 873 | .UnicodeString = LSTR(SERIAL_NUMBER) | 845 | .UnicodeString = LSTR(SERIAL_NUMBER) |
| 874 | }; | 846 | }; |
| 875 | 847 | ||
| 876 | 848 | /** | |
| 877 | /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" | 849 | * This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" |
| 878 | * documentation) by the application code so that the address and size of a requested descriptor can be given | 850 | * documentation) by the application code so that the address and size of a requested descriptor can be given |
| 879 | * to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function | 851 | * to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function |
| 880 | * is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the | 852 | * is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the |
| 881 | * USB host. | 853 | * USB host. |
| 882 | */ | 854 | */ |
| 883 | uint16_t get_usb_descriptor(const uint16_t wValue, | 855 | uint16_t get_usb_descriptor(const uint16_t wValue, const uint16_t wIndex, const void** const DescriptorAddress) { |
| 884 | const uint16_t wIndex, | 856 | const uint8_t DescriptorType = (wValue >> 8); |
| 885 | const void** const DescriptorAddress) | 857 | const uint8_t DescriptorIndex = (wValue & 0xFF); |
| 886 | { | 858 | const void* Address = NULL; |
| 887 | const uint8_t DescriptorType = (wValue >> 8); | 859 | uint16_t Size = NO_DESCRIPTOR; |
| 888 | const uint8_t DescriptorIndex = (wValue & 0xFF); | 860 | |
| 889 | 861 | switch (DescriptorType) { | |
| 890 | const void* Address = NULL; | ||
| 891 | uint16_t Size = NO_DESCRIPTOR; | ||
| 892 | |||
| 893 | switch (DescriptorType) | ||
| 894 | { | ||
| 895 | case DTYPE_Device: | 862 | case DTYPE_Device: |
| 896 | Address = &DeviceDescriptor; | 863 | Address = &DeviceDescriptor; |
| 897 | Size = sizeof(USB_Descriptor_Device_t); | 864 | Size = sizeof(USB_Descriptor_Device_t); |
| 865 | |||
| 898 | break; | 866 | break; |
| 899 | case DTYPE_Configuration: | 867 | case DTYPE_Configuration: |
| 900 | Address = &ConfigurationDescriptor; | 868 | Address = &ConfigurationDescriptor; |
| 901 | Size = sizeof(USB_Descriptor_Configuration_t); | 869 | Size = sizeof(USB_Descriptor_Configuration_t); |
| 870 | |||
| 902 | break; | 871 | break; |
| 903 | case DTYPE_String: | 872 | case DTYPE_String: |
| 904 | switch (DescriptorIndex ) | 873 | switch (DescriptorIndex) { |
| 905 | { | ||
| 906 | case 0x00: | 874 | case 0x00: |
| 907 | Address = &LanguageString; | 875 | Address = &LanguageString; |
| 908 | Size = pgm_read_byte(&LanguageString.Header.Size); | 876 | Size = pgm_read_byte(&LanguageString.Header.Size); |
| 877 | |||
| 909 | break; | 878 | break; |
| 910 | case 0x01: | 879 | case 0x01: |
| 911 | Address = &ManufacturerString; | 880 | Address = &ManufacturerString; |
| 912 | Size = pgm_read_byte(&ManufacturerString.Header.Size); | 881 | Size = pgm_read_byte(&ManufacturerString.Header.Size); |
| 882 | |||
| 913 | break; | 883 | break; |
| 914 | case 0x02: | 884 | case 0x02: |
| 915 | Address = &ProductString; | 885 | Address = &ProductString; |
| 916 | Size = pgm_read_byte(&ProductString.Header.Size); | 886 | Size = pgm_read_byte(&ProductString.Header.Size); |
| 887 | |||
| 917 | break; | 888 | break; |
| 918 | case 0x03: | 889 | case 0x03: |
| 919 | Address = &SerialNumberString; | 890 | Address = &SerialNumberString; |
| 920 | Size = pgm_read_byte(&SerialNumberString.Header.Size); | 891 | Size = pgm_read_byte(&SerialNumberString.Header.Size); |
| 892 | |||
| 921 | break; | 893 | break; |
| 922 | } | 894 | } |
| 895 | |||
| 923 | break; | 896 | break; |
| 924 | case HID_DTYPE_HID: | 897 | case HID_DTYPE_HID: |
| 925 | switch (wIndex) { | 898 | switch (wIndex) { |
| 926 | #ifndef KEYBOARD_SHARED_EP | 899 | #ifndef KEYBOARD_SHARED_EP |
| 927 | case KEYBOARD_INTERFACE: | 900 | case KEYBOARD_INTERFACE: |
| 928 | Address = &ConfigurationDescriptor.Keyboard_HID; | 901 | Address = &ConfigurationDescriptor.Keyboard_HID; |
| 929 | Size = sizeof(USB_HID_Descriptor_HID_t); | 902 | Size = sizeof(USB_HID_Descriptor_HID_t); |
| 930 | break; | 903 | break; |
| 931 | #endif | 904 | #endif |
| 905 | |||
| 932 | #if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP) | 906 | #if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP) |
| 933 | case MOUSE_INTERFACE: | 907 | case MOUSE_INTERFACE: |
| 934 | Address = &ConfigurationDescriptor.Mouse_HID; | 908 | Address = &ConfigurationDescriptor.Mouse_HID; |
| 935 | Size = sizeof(USB_HID_Descriptor_HID_t); | 909 | Size = sizeof(USB_HID_Descriptor_HID_t); |
| 936 | break; | 910 | |
| 911 | break; | ||
| 937 | #endif | 912 | #endif |
| 913 | |||
| 938 | #ifdef SHARED_EP_ENABLE | 914 | #ifdef SHARED_EP_ENABLE |
| 939 | case SHARED_INTERFACE: | 915 | case SHARED_INTERFACE: |
| 940 | Address = &ConfigurationDescriptor.Shared_HID; | 916 | Address = &ConfigurationDescriptor.Shared_HID; |
| 941 | Size = sizeof(USB_HID_Descriptor_HID_t); | 917 | Size = sizeof(USB_HID_Descriptor_HID_t); |
| 942 | break; | 918 | |
| 919 | break; | ||
| 943 | #endif | 920 | #endif |
| 921 | |||
| 944 | #ifdef RAW_ENABLE | 922 | #ifdef RAW_ENABLE |
| 945 | case RAW_INTERFACE: | 923 | case RAW_INTERFACE: |
| 946 | Address = &ConfigurationDescriptor.Raw_HID; | 924 | Address = &ConfigurationDescriptor.Raw_HID; |
| 947 | Size = sizeof(USB_HID_Descriptor_HID_t); | 925 | Size = sizeof(USB_HID_Descriptor_HID_t); |
| 948 | break; | 926 | |
| 927 | break; | ||
| 949 | #endif | 928 | #endif |
| 929 | |||
| 950 | #ifdef CONSOLE_ENABLE | 930 | #ifdef CONSOLE_ENABLE |
| 951 | case CONSOLE_INTERFACE: | 931 | case CONSOLE_INTERFACE: |
| 952 | Address = &ConfigurationDescriptor.Console_HID; | 932 | Address = &ConfigurationDescriptor.Console_HID; |
| 953 | Size = sizeof(USB_HID_Descriptor_HID_t); | 933 | Size = sizeof(USB_HID_Descriptor_HID_t); |
| 954 | break; | 934 | |
| 935 | break; | ||
| 955 | #endif | 936 | #endif |
| 956 | } | 937 | } |
| 938 | |||
| 957 | break; | 939 | break; |
| 958 | case HID_DTYPE_Report: | 940 | case HID_DTYPE_Report: |
| 959 | switch (wIndex) { | 941 | switch (wIndex) { |
| 960 | #ifndef KEYBOARD_SHARED_EP | 942 | #ifndef KEYBOARD_SHARED_EP |
| 961 | case KEYBOARD_INTERFACE: | 943 | case KEYBOARD_INTERFACE: |
| 962 | Address = &KeyboardReport; | 944 | Address = &KeyboardReport; |
| 963 | Size = sizeof(KeyboardReport); | 945 | Size = sizeof(KeyboardReport); |
| 964 | break; | 946 | |
| 947 | break; | ||
| 965 | #endif | 948 | #endif |
| 949 | |||
| 966 | #if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP) | 950 | #if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP) |
| 967 | case MOUSE_INTERFACE: | 951 | case MOUSE_INTERFACE: |
| 968 | Address = &MouseReport; | 952 | Address = &MouseReport; |
| 969 | Size = sizeof(MouseReport); | 953 | Size = sizeof(MouseReport); |
| 970 | break; | 954 | |
| 955 | break; | ||
| 971 | #endif | 956 | #endif |
| 957 | |||
| 972 | #ifdef SHARED_EP_ENABLE | 958 | #ifdef SHARED_EP_ENABLE |
| 973 | case SHARED_INTERFACE: | 959 | case SHARED_INTERFACE: |
| 974 | Address = &SharedReport; | 960 | Address = &SharedReport; |
| 975 | Size = sizeof(SharedReport); | 961 | Size = sizeof(SharedReport); |
| 976 | break; | 962 | |
| 963 | break; | ||
| 977 | #endif | 964 | #endif |
| 965 | |||
| 978 | #ifdef RAW_ENABLE | 966 | #ifdef RAW_ENABLE |
| 979 | case RAW_INTERFACE: | 967 | case RAW_INTERFACE: |
| 980 | Address = &RawReport; | 968 | Address = &RawReport; |
| 981 | Size = sizeof(RawReport); | 969 | Size = sizeof(RawReport); |
| 982 | break; | 970 | |
| 971 | break; | ||
| 983 | #endif | 972 | #endif |
| 973 | |||
| 984 | #ifdef CONSOLE_ENABLE | 974 | #ifdef CONSOLE_ENABLE |
| 985 | case CONSOLE_INTERFACE: | 975 | case CONSOLE_INTERFACE: |
| 986 | Address = &ConsoleReport; | 976 | Address = &ConsoleReport; |
| 987 | Size = sizeof(ConsoleReport); | 977 | Size = sizeof(ConsoleReport); |
| 988 | break; | 978 | |
| 979 | break; | ||
| 989 | #endif | 980 | #endif |
| 990 | } | 981 | } |
| 982 | |||
| 991 | break; | 983 | break; |
| 992 | } | 984 | } |
| 993 | 985 | ||
| 994 | *DescriptorAddress = Address; | 986 | *DescriptorAddress = Address; |
| 987 | |||
| 995 | return Size; | 988 | return Size; |
| 996 | } | 989 | } |
diff --git a/tmk_core/protocol/usb_descriptor.h b/tmk_core/protocol/usb_descriptor.h index 3ca0c00b3..d41956803 100644 --- a/tmk_core/protocol/usb_descriptor.h +++ b/tmk_core/protocol/usb_descriptor.h | |||
| @@ -6,95 +6,97 @@ | |||
| 6 | */ | 6 | */ |
| 7 | 7 | ||
| 8 | /* | 8 | /* |
| 9 | LUFA Library | 9 | LUFA Library |
| 10 | Copyright (C) Dean Camera, 2012. | 10 | Copyright (C) Dean Camera, 2012. |
| 11 | 11 | ||
| 12 | dean [at] fourwalledcubicle [dot] com | 12 | dean [at] fourwalledcubicle [dot] com |
| 13 | www.lufa-lib.org | 13 | www.lufa-lib.org |
| 14 | */ | 14 | */ |
| 15 | 15 | ||
| 16 | /* | 16 | /* |
| 17 | Copyright 2012 Dean Camera (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) | 18 | Copyright 2010 Denver Gingerich (denver [at] ossguy [dot] com) |
| 19 | 19 | ||
| 20 | Permission to use, copy, modify, distribute, and sell this | 20 | Permission to use, copy, modify, distribute, and sell this |
| 21 | software and its documentation for any purpose is hereby granted | 21 | software and its documentation for any purpose is hereby granted |
| 22 | without fee, provided that the above copyright notice appear in | 22 | without fee, provided that the above copyright notice appear in |
| 23 | all copies and that both that the copyright notice and this | 23 | all copies and that both that the copyright notice and this |
| 24 | permission notice and warranty disclaimer appear in supporting | 24 | permission notice and warranty disclaimer appear in supporting |
| 25 | documentation, and that the name of the author not be used in | 25 | documentation, and that the name of the author not be used in |
| 26 | advertising or publicity pertaining to distribution of the | 26 | advertising or publicity pertaining to distribution of the |
| 27 | software without specific, written prior permission. | 27 | software without specific, written prior permission. |
| 28 | 28 | ||
| 29 | The author disclaim all warranties with regard to this | 29 | The author disclaim all warranties with regard to this |
| 30 | software, including all implied warranties of merchantability | 30 | software, including all implied warranties of merchantability |
| 31 | and fitness. In no event shall the author be liable for any | 31 | and fitness. In no event shall the author be liable for any |
| 32 | special, indirect or consequential damages or any damages | 32 | special, indirect or consequential damages or any damages |
| 33 | whatsoever resulting from loss of use, data or profits, whether | 33 | whatsoever resulting from loss of use, data or profits, whether |
| 34 | in an action of contract, negligence or other tortious action, | 34 | in an action of contract, negligence or other tortious action, |
| 35 | arising out of or in connection with the use or performance of | 35 | arising out of or in connection with the use or performance of |
| 36 | this software. | 36 | this software. |
| 37 | */ | 37 | */ |
| 38 | 38 | ||
| 39 | /** \file | 39 | /** \file |
| 40 | * | 40 | * |
| 41 | * Header file for Descriptors.c. | 41 | * Header file for Descriptors.c. |
| 42 | */ | 42 | */ |
| 43 | |||
| 44 | #ifndef _DESCRIPTORS_H_ | 43 | #ifndef _DESCRIPTORS_H_ |
| 45 | #define _DESCRIPTORS_H_ | 44 | #define _DESCRIPTORS_H_ |
| 46 | 45 | ||
| 47 | #include <LUFA/Drivers/USB/USB.h> | 46 | #include <LUFA/Drivers/USB/USB.h> |
| 48 | #ifdef PROTOCOL_CHIBIOS | ||
| 49 | #include "hal.h" | ||
| 50 | #endif | ||
| 51 | 47 | ||
| 52 | typedef struct | 48 | #ifdef PROTOCOL_CHIBIOS |
| 53 | { | 49 | #include "hal.h" |
| 54 | USB_Descriptor_Configuration_Header_t Config; | 50 | #endif |
| 51 | |||
| 52 | /* | ||
| 53 | * USB descriptor structure | ||
| 54 | */ | ||
| 55 | typedef struct { | ||
| 56 | USB_Descriptor_Configuration_Header_t Config; | ||
| 55 | 57 | ||
| 56 | #ifndef KEYBOARD_SHARED_EP | 58 | #ifndef KEYBOARD_SHARED_EP |
| 57 | // Keyboard HID Interface | 59 | // Keyboard HID Interface |
| 58 | USB_Descriptor_Interface_t Keyboard_Interface; | 60 | USB_Descriptor_Interface_t Keyboard_Interface; |
| 59 | USB_HID_Descriptor_HID_t Keyboard_HID; | 61 | USB_HID_Descriptor_HID_t Keyboard_HID; |
| 60 | USB_Descriptor_Endpoint_t Keyboard_INEndpoint; | 62 | USB_Descriptor_Endpoint_t Keyboard_INEndpoint; |
| 61 | #endif | 63 | #endif |
| 62 | 64 | ||
| 63 | #if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP) | 65 | #if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP) |
| 64 | // Mouse HID Interface | 66 | // Mouse HID Interface |
| 65 | USB_Descriptor_Interface_t Mouse_Interface; | 67 | USB_Descriptor_Interface_t Mouse_Interface; |
| 66 | USB_HID_Descriptor_HID_t Mouse_HID; | 68 | USB_HID_Descriptor_HID_t Mouse_HID; |
| 67 | USB_Descriptor_Endpoint_t Mouse_INEndpoint; | 69 | USB_Descriptor_Endpoint_t Mouse_INEndpoint; |
| 68 | #endif | 70 | #endif |
| 69 | 71 | ||
| 70 | #if defined(SHARED_EP_ENABLE) | 72 | #ifdef SHARED_EP_ENABLE |
| 71 | USB_Descriptor_Interface_t Shared_Interface; | 73 | // Shared Interface |
| 72 | USB_HID_Descriptor_HID_t Shared_HID; | 74 | USB_Descriptor_Interface_t Shared_Interface; |
| 73 | USB_Descriptor_Endpoint_t Shared_INEndpoint; | 75 | USB_HID_Descriptor_HID_t Shared_HID; |
| 74 | #endif | 76 | USB_Descriptor_Endpoint_t Shared_INEndpoint; |
| 75 | 77 | #endif | |
| 76 | #if defined(RAW_ENABLE) | 78 | |
| 79 | #ifdef RAW_ENABLE | ||
| 77 | // Raw HID Interface | 80 | // Raw HID Interface |
| 78 | USB_Descriptor_Interface_t Raw_Interface; | 81 | USB_Descriptor_Interface_t Raw_Interface; |
| 79 | USB_HID_Descriptor_HID_t Raw_HID; | 82 | USB_HID_Descriptor_HID_t Raw_HID; |
| 80 | USB_Descriptor_Endpoint_t Raw_INEndpoint; | 83 | USB_Descriptor_Endpoint_t Raw_INEndpoint; |
| 81 | USB_Descriptor_Endpoint_t Raw_OUTEndpoint; | 84 | USB_Descriptor_Endpoint_t Raw_OUTEndpoint; |
| 82 | #endif | 85 | #endif |
| 83 | 86 | ||
| 84 | #ifdef CONSOLE_ENABLE | 87 | #ifdef CONSOLE_ENABLE |
| 85 | // Console HID Interface | 88 | // Console HID Interface |
| 86 | USB_Descriptor_Interface_t Console_Interface; | 89 | USB_Descriptor_Interface_t Console_Interface; |
| 87 | USB_HID_Descriptor_HID_t Console_HID; | 90 | USB_HID_Descriptor_HID_t Console_HID; |
| 88 | USB_Descriptor_Endpoint_t Console_INEndpoint; | 91 | USB_Descriptor_Endpoint_t Console_INEndpoint; |
| 89 | USB_Descriptor_Endpoint_t Console_OUTEndpoint; | 92 | USB_Descriptor_Endpoint_t Console_OUTEndpoint; |
| 90 | #endif | 93 | #endif |
| 91 | 94 | ||
| 92 | #ifdef MIDI_ENABLE | 95 | #ifdef MIDI_ENABLE |
| 93 | USB_Descriptor_Interface_Association_t Audio_Interface_Association; | 96 | USB_Descriptor_Interface_Association_t Audio_Interface_Association; |
| 94 | // MIDI Audio Control Interface | 97 | // MIDI Audio Control Interface |
| 95 | USB_Descriptor_Interface_t Audio_ControlInterface; | 98 | USB_Descriptor_Interface_t Audio_ControlInterface; |
| 96 | USB_Audio_Descriptor_Interface_AC_t Audio_ControlInterface_SPC; | 99 | USB_Audio_Descriptor_Interface_AC_t Audio_ControlInterface_SPC; |
| 97 | |||
| 98 | // MIDI Audio Streaming Interface | 100 | // MIDI Audio Streaming Interface |
| 99 | USB_Descriptor_Interface_t Audio_StreamInterface; | 101 | USB_Descriptor_Interface_t Audio_StreamInterface; |
| 100 | USB_MIDI_Descriptor_AudioInterface_AS_t Audio_StreamInterface_SPC; | 102 | USB_MIDI_Descriptor_AudioInterface_AS_t Audio_StreamInterface_SPC; |
| @@ -106,141 +108,146 @@ typedef struct | |||
| 106 | USB_MIDI_Descriptor_Jack_Endpoint_t MIDI_In_Jack_Endpoint_SPC; | 108 | USB_MIDI_Descriptor_Jack_Endpoint_t MIDI_In_Jack_Endpoint_SPC; |
| 107 | USB_Audio_Descriptor_StreamEndpoint_Std_t MIDI_Out_Jack_Endpoint; | 109 | USB_Audio_Descriptor_StreamEndpoint_Std_t MIDI_Out_Jack_Endpoint; |
| 108 | USB_MIDI_Descriptor_Jack_Endpoint_t MIDI_Out_Jack_Endpoint_SPC; | 110 | USB_MIDI_Descriptor_Jack_Endpoint_t MIDI_Out_Jack_Endpoint_SPC; |
| 109 | #endif | 111 | #endif |
| 110 | 112 | ||
| 111 | #ifdef VIRTSER_ENABLE | 113 | #ifdef VIRTSER_ENABLE |
| 112 | USB_Descriptor_Interface_Association_t CDC_Interface_Association; | 114 | USB_Descriptor_Interface_Association_t CDC_Interface_Association; |
| 113 | 115 | // CDC Control Interface | |
| 114 | // CDC Control Interface | 116 | USB_Descriptor_Interface_t CDC_CCI_Interface; |
| 115 | USB_Descriptor_Interface_t CDC_CCI_Interface; | 117 | USB_CDC_Descriptor_FunctionalHeader_t CDC_Functional_Header; |
| 116 | USB_CDC_Descriptor_FunctionalHeader_t CDC_Functional_Header; | 118 | USB_CDC_Descriptor_FunctionalACM_t CDC_Functional_ACM; |
| 117 | USB_CDC_Descriptor_FunctionalACM_t CDC_Functional_ACM; | 119 | USB_CDC_Descriptor_FunctionalUnion_t CDC_Functional_Union; |
| 118 | USB_CDC_Descriptor_FunctionalUnion_t CDC_Functional_Union; | 120 | USB_Descriptor_Endpoint_t CDC_NotificationEndpoint; |
| 119 | USB_Descriptor_Endpoint_t CDC_NotificationEndpoint; | 121 | // CDC Data Interface |
| 120 | 122 | USB_Descriptor_Interface_t CDC_DCI_Interface; | |
| 121 | // CDC Data Interface | 123 | USB_Descriptor_Endpoint_t CDC_DataOutEndpoint; |
| 122 | USB_Descriptor_Interface_t CDC_DCI_Interface; | 124 | USB_Descriptor_Endpoint_t CDC_DataInEndpoint; |
| 123 | USB_Descriptor_Endpoint_t CDC_DataOutEndpoint; | 125 | #endif |
| 124 | USB_Descriptor_Endpoint_t CDC_DataInEndpoint; | ||
| 125 | #endif | ||
| 126 | } USB_Descriptor_Configuration_t; | 126 | } USB_Descriptor_Configuration_t; |
| 127 | 127 | ||
| 128 | 128 | /* | |
| 129 | /* index of interface */ | 129 | * Interface indexes |
| 130 | */ | ||
| 130 | enum usb_interfaces { | 131 | enum usb_interfaces { |
| 131 | #if !defined(KEYBOARD_SHARED_EP) | 132 | #ifndef KEYBOARD_SHARED_EP |
| 132 | KEYBOARD_INTERFACE, | 133 | KEYBOARD_INTERFACE, |
| 133 | #else | 134 | #else |
| 134 | # define KEYBOARD_INTERFACE SHARED_INTERFACE | 135 | #define KEYBOARD_INTERFACE SHARED_INTERFACE |
| 135 | #endif | 136 | #endif |
| 136 | // It is important that the Raw HID interface is at a constant | 137 | |
| 137 | // interface number, to support Linux/OSX platforms and chrome.hid | 138 | // It is important that the Raw HID interface is at a constant |
| 138 | // If Raw HID is enabled, let it be always 1. | 139 | // interface number, to support Linux/OSX platforms and chrome.hid |
| 139 | #if defined(RAW_ENABLE) | 140 | // If Raw HID is enabled, let it be always 1. |
| 141 | #ifdef RAW_ENABLE | ||
| 140 | RAW_INTERFACE, | 142 | RAW_INTERFACE, |
| 141 | #endif | 143 | #endif |
| 142 | #if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP) | 144 | |
| 145 | #if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP) | ||
| 143 | MOUSE_INTERFACE, | 146 | MOUSE_INTERFACE, |
| 144 | #endif | 147 | #endif |
| 145 | #if defined(SHARED_EP_ENABLE) | 148 | |
| 149 | #ifdef SHARED_EP_ENABLE | ||
| 146 | SHARED_INTERFACE, | 150 | SHARED_INTERFACE, |
| 147 | #endif | 151 | #endif |
| 148 | #if defined(CONSOLE_ENABLE) | 152 | |
| 153 | #ifdef CONSOLE_ENABLE | ||
| 149 | CONSOLE_INTERFACE, | 154 | CONSOLE_INTERFACE, |
| 150 | #endif | 155 | #endif |
| 151 | #if defined(MIDI_ENABLE) | 156 | |
| 157 | #ifdef MIDI_ENABLE | ||
| 152 | AC_INTERFACE, | 158 | AC_INTERFACE, |
| 153 | AS_INTERFACE, | 159 | AS_INTERFACE, |
| 154 | #endif | 160 | #endif |
| 155 | #if defined(VIRTSER_ENABLE) | 161 | |
| 162 | #ifdef VIRTSER_ENABLE | ||
| 156 | CCI_INTERFACE, | 163 | CCI_INTERFACE, |
| 157 | CDI_INTERFACE, | 164 | CDI_INTERFACE, |
| 158 | #endif | 165 | #endif |
| 166 | |||
| 159 | TOTAL_INTERFACES | 167 | TOTAL_INTERFACES |
| 160 | }; | 168 | }; |
| 161 | 169 | ||
| 162 | #define NEXT_EPNUM __COUNTER__ | 170 | #define NEXT_EPNUM __COUNTER__ |
| 163 | 171 | ||
| 172 | /* | ||
| 173 | * Endpoint numbers | ||
| 174 | */ | ||
| 164 | enum usb_endpoints { | 175 | enum usb_endpoints { |
| 165 | __unused_epnum__ = NEXT_EPNUM, /* EP numbering starts at 1 */ | 176 | __unused_epnum__ = NEXT_EPNUM, // Endpoint numbering starts at 1 |
| 166 | #if !defined(KEYBOARD_SHARED_EP) | 177 | |
| 178 | #ifndef KEYBOARD_SHARED_EP | ||
| 167 | KEYBOARD_IN_EPNUM = NEXT_EPNUM, | 179 | KEYBOARD_IN_EPNUM = NEXT_EPNUM, |
| 168 | #else | 180 | #else |
| 169 | # define KEYBOARD_IN_EPNUM SHARED_IN_EPNUM | 181 | #define KEYBOARD_IN_EPNUM SHARED_IN_EPNUM |
| 170 | #endif | 182 | #endif |
| 171 | #if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP) | 183 | |
| 184 | #if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP) | ||
| 172 | MOUSE_IN_EPNUM = NEXT_EPNUM, | 185 | MOUSE_IN_EPNUM = NEXT_EPNUM, |
| 173 | #else | 186 | #else |
| 174 | # define MOUSE_IN_EPNUM SHARED_IN_EPNUM | 187 | #define MOUSE_IN_EPNUM SHARED_IN_EPNUM |
| 175 | #endif | 188 | #endif |
| 176 | #if defined(RAW_ENABLE) | 189 | |
| 190 | #ifdef RAW_ENABLE | ||
| 177 | RAW_IN_EPNUM = NEXT_EPNUM, | 191 | RAW_IN_EPNUM = NEXT_EPNUM, |
| 178 | RAW_OUT_EPNUM = NEXT_EPNUM, | 192 | RAW_OUT_EPNUM = NEXT_EPNUM, |
| 179 | #endif | 193 | #endif |
| 180 | #if defined(SHARED_EP_ENABLE) | 194 | |
| 195 | #ifdef SHARED_EP_ENABLE | ||
| 181 | SHARED_IN_EPNUM = NEXT_EPNUM, | 196 | SHARED_IN_EPNUM = NEXT_EPNUM, |
| 182 | #endif | 197 | #endif |
| 183 | #if defined(CONSOLE_ENABLE) | 198 | |
| 199 | #ifdef CONSOLE_ENABLE | ||
| 184 | CONSOLE_IN_EPNUM = NEXT_EPNUM, | 200 | CONSOLE_IN_EPNUM = NEXT_EPNUM, |
| 185 | #ifdef PROTOCOL_CHIBIOS | 201 | |
| 186 | // ChibiOS has enough memory and descriptor to actually enable the endpoint | 202 | #ifdef PROTOCOL_CHIBIOS |
| 187 | // It could use the same endpoint numbers, as that's supported by ChibiOS | 203 | // ChibiOS has enough memory and descriptor to actually enable the endpoint |
| 188 | // But the QMK code currently assumes that the endpoint numbers are different | 204 | // It could use the same endpoint numbers, as that's supported by ChibiOS |
| 205 | // But the QMK code currently assumes that the endpoint numbers are different | ||
| 189 | CONSOLE_OUT_EPNUM = NEXT_EPNUM, | 206 | CONSOLE_OUT_EPNUM = NEXT_EPNUM, |
| 190 | #else | 207 | #else |
| 191 | #define CONSOLE_OUT_EPNUM CONSOLE_IN_EPNUM | 208 | #define CONSOLE_OUT_EPNUM CONSOLE_IN_EPNUM |
| 192 | #endif | 209 | #endif |
| 193 | #endif | 210 | #endif |
| 194 | #ifdef MIDI_ENABLE | 211 | |
| 212 | #ifdef MIDI_ENABLE | ||
| 195 | MIDI_STREAM_IN_EPNUM = NEXT_EPNUM, | 213 | MIDI_STREAM_IN_EPNUM = NEXT_EPNUM, |
| 196 | MIDI_STREAM_OUT_EPNUM = NEXT_EPNUM, | 214 | MIDI_STREAM_OUT_EPNUM = NEXT_EPNUM, |
| 197 | # define MIDI_STREAM_IN_EPADDR (ENDPOINT_DIR_IN | MIDI_STREAM_IN_EPNUM) | 215 | #define MIDI_STREAM_IN_EPADDR (ENDPOINT_DIR_IN | MIDI_STREAM_IN_EPNUM) |
| 198 | # define MIDI_STREAM_OUT_EPADDR (ENDPOINT_DIR_OUT | MIDI_STREAM_OUT_EPNUM) | 216 | #define MIDI_STREAM_OUT_EPADDR (ENDPOINT_DIR_OUT | MIDI_STREAM_OUT_EPNUM) |
| 199 | #endif | 217 | #endif |
| 200 | #ifdef VIRTSER_ENABLE | 218 | |
| 219 | #ifdef VIRTSER_ENABLE | ||
| 201 | CDC_NOTIFICATION_EPNUM = NEXT_EPNUM, | 220 | CDC_NOTIFICATION_EPNUM = NEXT_EPNUM, |
| 202 | CDC_IN_EPNUM = NEXT_EPNUM, | 221 | CDC_IN_EPNUM = NEXT_EPNUM, |
| 203 | CDC_OUT_EPNUM = NEXT_EPNUM, | 222 | CDC_OUT_EPNUM = NEXT_EPNUM, |
| 204 | # define CDC_NOTIFICATION_EPADDR (ENDPOINT_DIR_IN | CDC_NOTIFICATION_EPNUM) | 223 | #define CDC_NOTIFICATION_EPADDR (ENDPOINT_DIR_IN | CDC_NOTIFICATION_EPNUM) |
| 205 | # define CDC_IN_EPADDR (ENDPOINT_DIR_IN | CDC_IN_EPNUM) | 224 | #define CDC_IN_EPADDR (ENDPOINT_DIR_IN | CDC_IN_EPNUM) |
| 206 | # define CDC_OUT_EPADDR (ENDPOINT_DIR_OUT | CDC_OUT_EPNUM) | 225 | #define CDC_OUT_EPADDR (ENDPOINT_DIR_OUT | CDC_OUT_EPNUM) |
| 207 | #endif | 226 | #endif |
| 208 | }; | 227 | }; |
| 209 | 228 | ||
| 210 | #if defined(PROTOCOL_LUFA) | 229 | #ifdef PROTOCOL_LUFA |
| 211 | /* LUFA tells us total endpoints including control */ | 230 | // LUFA tells us total endpoints including control |
| 212 | #define MAX_ENDPOINTS (ENDPOINT_TOTAL_ENDPOINTS - 1) | 231 | #define MAX_ENDPOINTS (ENDPOINT_TOTAL_ENDPOINTS - 1) |
| 213 | #elif defined(PROTOCOL_CHIBIOS) | 232 | #elif defined(PROTOCOL_CHIBIOS) |
| 214 | /* ChibiOS gives us number of available user endpoints, not control */ | 233 | // ChibiOS gives us number of available user endpoints, not control |
| 215 | #define MAX_ENDPOINTS USB_MAX_ENDPOINTS | 234 | #define MAX_ENDPOINTS USB_MAX_ENDPOINTS |
| 216 | #endif | 235 | #endif |
| 217 | /* TODO - ARM_ATSAM */ | 236 | |
| 218 | 237 | // TODO - ARM_ATSAM | |
| 219 | 238 | ||
| 220 | #if (NEXT_EPNUM - 1) > MAX_ENDPOINTS | 239 | #if (NEXT_EPNUM - 1) > MAX_ENDPOINTS |
| 221 | # error There are not enough available endpoints to support all functions. Remove some in the rules.mk file. (MOUSEKEY, EXTRAKEY, CONSOLE, NKRO, MIDI, SERIAL, STENO) | 240 | #error There are not enough available endpoints to support all functions. Please disable one or more of the following: Mouse Keys, Extra Keys, Console, NKRO, MIDI, Serial, Steno |
| 222 | #endif | 241 | #endif |
| 223 | 242 | ||
| 224 | #define KEYBOARD_EPSIZE 8 | 243 | #define KEYBOARD_EPSIZE 8 |
| 225 | #define SHARED_EPSIZE 32 | 244 | #define SHARED_EPSIZE 32 |
| 226 | #define MOUSE_EPSIZE 8 | 245 | #define MOUSE_EPSIZE 8 |
| 227 | #define RAW_EPSIZE 32 | 246 | #define RAW_EPSIZE 32 |
| 228 | #define CONSOLE_EPSIZE 32 | 247 | #define CONSOLE_EPSIZE 32 |
| 229 | #define MIDI_STREAM_EPSIZE 64 | 248 | #define MIDI_STREAM_EPSIZE 64 |
| 230 | #define CDC_NOTIFICATION_EPSIZE 8 | 249 | #define CDC_NOTIFICATION_EPSIZE 8 |
| 231 | #define CDC_EPSIZE 16 | 250 | #define CDC_EPSIZE 16 |
| 232 | 251 | ||
| 233 | uint16_t get_usb_descriptor(const uint16_t wValue, | 252 | uint16_t get_usb_descriptor(const uint16_t wValue, const uint16_t wIndex, const void** const DescriptorAddress); |
| 234 | const uint16_t wIndex, | ||
| 235 | const void** const DescriptorAddress); | ||
| 236 | |||
| 237 | /* new API */ | ||
| 238 | #if LUFA_VERSION_INTEGER < 0x140302 | ||
| 239 | #undef VERSION_BCD | ||
| 240 | #define VERSION_BCD(Major, Minor, Revision) \ | ||
| 241 | CPU_TO_LE16( ((Major & 0xFF) << 8) | \ | ||
| 242 | ((Minor & 0x0F) << 4) | \ | ||
| 243 | (Revision & 0x0F) ) | ||
| 244 | #endif | ||
| 245 | |||
| 246 | #endif | 253 | #endif |
