]> git.donarmstrong.com Git - kiibohd-controller.git/blob - Output/pjrcUSB/arm/usb_desc.c
Fixing NKRO for Windows.
[kiibohd-controller.git] / Output / pjrcUSB / arm / usb_desc.c
1 /* Teensyduino Core Library
2  * http://www.pjrc.com/teensy/
3  * Copyright (c) 2013 PJRC.COM, LLC.
4  * Modified by Jacob Alexander (2013-2014)
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining
7  * a copy of this software and associated documentation files (the
8  * "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sublicense, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  *
14  * 1. The above copyright notice and this permission notice shall be
15  * included in all copies or substantial portions of the Software.
16  *
17  * 2. If the Software is incorporated into a build system that allows
18  * selection among a list of target devices, then similar target
19  * devices manufactured by PJRC.COM must be included in the list of
20  * target devices and selectable in the same manner.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
26  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
27  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
28  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29  * SOFTWARE.
30  */
31
32 // ----- Includes -----
33
34 // Local Includes
35 #include "usb_desc.h"
36
37
38
39 // ----- Macros -----
40
41 #define LSB(n) ((n) & 255)
42 #define MSB(n) (((n) >> 8) & 255)
43
44
45
46 // ----- USB Device Descriptor -----
47
48 // USB Device Descriptor.  The USB host reads this first, to learn
49 // what type of device is connected.
50 static uint8_t device_descriptor[] = {
51         18,                                     // bLength
52         1,                                      // bDescriptorType
53         0x00, 0x02,                             // bcdUSB
54         DEVICE_CLASS,                           // bDeviceClass
55         DEVICE_SUBCLASS,                        // bDeviceSubClass
56         DEVICE_PROTOCOL,                        // bDeviceProtocol
57         EP0_SIZE,                               // bMaxPacketSize0
58         LSB(VENDOR_ID), MSB(VENDOR_ID),         // idVendor
59         LSB(PRODUCT_ID), MSB(PRODUCT_ID),       // idProduct
60         0x00, 0x01,                             // bcdDevice
61         1,                                      // iManufacturer
62         2,                                      // iProduct
63         3,                                      // iSerialNumber
64         1                                       // bNumConfigurations
65 };
66
67 // USB Device Qualifier Descriptor
68 static uint8_t device_qualifier_descriptor[] = {
69         0                                       // Indicate only single speed
70         /* Device qualifier example (used for specifying multiple USB speeds)
71         10,                                     // bLength
72         6,                                      // bDescriptorType
73         0x00, 0x02,                             // bcdUSB
74         DEVICE_CLASS,                           // bDeviceClass
75         DEVICE_SUBCLASS,                        // bDeviceSubClass
76         DEVICE_PROTOCOL,                        // bDeviceProtocol
77         EP0_SIZE,                               // bMaxPacketSize0
78         0,                                      // bNumOtherSpeedConfigurations
79         0                                       // bReserved
80         */
81 };
82
83 // USB Debug Descriptor
84 // XXX Not sure of exact use, lsusb requests it
85 static uint8_t usb_debug_descriptor[] = {
86         0
87 };
88
89 // XXX
90 // These descriptors must NOT be "const", because the USB DMA
91 // has trouble accessing flash memory with enough bandwidth
92 // while the processor is executing from flash.
93 // XXX
94
95
96
97 // ----- USB HID Report Descriptsors -----
98
99 // Each HID interface needs a special report descriptor that tells
100 // the meaning and format of the data.
101
102 // Keyboard Protocol 1, HID 1.11 spec, Appendix B, page 59-60
103 static uint8_t keyboard_report_desc[] = {
104         // Keyboard Collection
105         0x05, 0x01,          // Usage Page (Generic Desktop),
106         0x09, 0x06,          // Usage (Keyboard),
107         0xA1, 0x01,          // Collection (Application) - Keyboard,
108
109         // Modifier Byte
110         0x75, 0x01,          //   Report Size (1),
111         0x95, 0x08,          //   Report Count (8),
112         0x05, 0x07,          //   Usage Page (Key Codes),
113         0x19, 0xE0,          //   Usage Minimum (224),
114         0x29, 0xE7,          //   Usage Maximum (231),
115         0x15, 0x00,          //   Logical Minimum (0),
116         0x25, 0x01,          //   Logical Maximum (1),
117         0x81, 0x02,          //   Input (Data, Variable, Absolute),
118
119         // Reserved Byte
120         0x75, 0x08,          //   Report Size (8),
121         0x95, 0x01,          //   Report Count (1),
122         0x81, 0x03,          //   Output (Constant),
123
124         // LED Report
125         0x75, 0x01,          //   Report Size (1),
126         0x95, 0x05,          //   Report Count (5),
127         0x05, 0x08,          //   Usage Page (LEDs),
128         0x19, 0x01,          //   Usage Minimum (1),
129         0x29, 0x05,          //   Usage Maximum (5),
130         0x91, 0x02,          //   Output (Data, Variable, Absolute),
131
132         // LED Report Padding
133         0x75, 0x03,          //   Report Size (3),
134         0x95, 0x01,          //   Report Count (1),
135         0x91, 0x03,          //   Output (Constant),
136
137         // Normal Keys
138         0x75, 0x08,          //   Report Size (8),
139         0x95, 0x06,          //   Report Count (6),
140         0x15, 0x00,          //   Logical Minimum (0),
141         0x25, 0x7F,          //   Logical Maximum(104),
142         0x05, 0x07,          //   Usage Page (Key Codes),
143         0x19, 0x00,          //   Usage Minimum (0),
144         0x29, 0x7F,          //   Usage Maximum (104),
145         0x81, 0x00,          //   Input (Data, Array),
146         0xc0,                // End Collection - Keyboard
147 };
148
149 // Keyboard Protocol 1, HID 1.11 spec, Appendix B, page 59-60
150 static uint8_t nkro_keyboard_report_desc[] = {
151         // Keyboard Collection
152         0x05, 0x01,          // Usage Page (Generic Desktop),
153         0x09, 0x06,          // Usage (Keyboard),
154         0xA1, 0x01,          // Collection (Application) - Keyboard,
155
156         // Modifier Byte
157         0x85, 0x01,          //   Report ID (1),
158         0x75, 0x01,          //   Report Size (1),
159         0x95, 0x08,          //   Report Count (8),
160         0x15, 0x00,          //   Logical Minimum (0),
161         0x25, 0x01,          //   Logical Maximum (1),
162         0x05, 0x07,          //   Usage Page (Key Codes),
163         0x19, 0xE0,          //   Usage Minimum (224),
164         0x29, 0xE7,          //   Usage Maximum (231),
165         0x81, 0x02,          //   Input (Data, Variable, Absolute),
166
167         // LED Report
168         0x85, 0x02,          //   Report ID (2),
169         0x75, 0x01,          //   Report Size (1),
170         0x95, 0x05,          //   Report Count (5),
171         0x05, 0x08,          //   Usage Page (LEDs),
172         0x19, 0x01,          //   Usage Minimum (1),
173         0x29, 0x05,          //   Usage Maximum (5),
174         0x91, 0x02,          //   Output (Data, Variable, Absolute),
175
176         // LED Report Padding
177         0x75, 0x03,          //   Report Size (3),
178         0x95, 0x01,          //   Report Count (1),
179         0x91, 0x03,          //   Output (Constant),
180
181         // Normal Keys - Using an NKRO Bitmap
182         //
183         // NOTES:
184         // Supports all keys defined by the spec, except 1-3 which define error events
185         //  and 0 which is "no keys pressed"
186         // See http://www.usb.org/developers/hidpage/Hut1_12v2.pdf Chapter 10
187         // Or Macros/PartialMap/usb_hid.h
188         //
189         // 165-175 are reserved/unused as well as 222-223 and 232-65535
190         // 224-231 are used for modifiers (see above)
191         //
192         // Packing of bitmaps are as follows:
193         //   4-164 : 20 bytes + 1 Report ID byte (0x04-0xA4)
194         // 176-221 :  6 bytes + 1 Report ID byte (0xB0-0xDD) (45 bits + 3 padding bits for 6 bytes total)
195         //
196         // 4-164 (20 bytes/160 bits)
197         0x85, 0x03,          //   Report ID (3),
198         0x75, 0x01,          //   Report Size (1),
199         0x95, 0xA0,          //   Report Count (160),
200         0x15, 0x00,          //   Logical Minimum (0),
201         0x25, 0x01,          //   Logical Maximum (1),
202         0x05, 0x07,          //   Usage Page (Key Codes),
203         0x19, 0x04,          //   Usage Minimum (4),
204         0x29, 0xA4,          //   Usage Maximum (164),
205         0x81, 0x02,          //   Input (Data, Variable, Absolute, Bitfield),
206
207         // 176-221 (45 bits)
208         0x85, 0x04,          //   Report ID (4),
209         0x75, 0x01,          //   Report Size (1),
210         0x95, 0x2D,          //   Report Count (45),
211         0x15, 0x00,          //   Logical Minimum (0),
212         0x25, 0x01,          //   Logical Maximum (1),
213         0x05, 0x07,          //   Usage Page (Key Codes),
214         0x19, 0xB0,          //   Usage Minimum (176),
215         0x29, 0xDD,          //   Usage Maximum (221),
216         0x81, 0x02,          //   Input (Data, Variable, Absolute, Bitfield),
217
218         // 176-221 Padding (3 bits)
219         0x75, 0x03,          //   Report Size (3),
220         0x95, 0x01,          //   Report Count (1),
221         0x81, 0x03,          //   Input (Constant),
222         0xc0,                // End Collection - Keyboard
223
224         // System Control Collection
225         //
226         // NOTES:
227         // Not bothering with NKRO for this table. If there's need, I can implement it. -HaaTa
228         // Using a 1KRO scheme
229         0x05, 0x01,          // Usage Page (Generic Desktop),
230         0x09, 0x80,          // Usage (System Control),
231         0xA1, 0x01,          // Collection (Application),
232         0x85, 0x05,          //   Report ID (5),
233         0x75, 0x08,          //   Report Size (8),
234         0x95, 0x01,          //   Report Count (1),
235         0x16, 0x81, 0x00,    //   Logical Minimum (129),
236         0x26, 0xB7, 0x00,    //   Logical Maximum (183),
237         0x19, 0x81,          //   Usage Minimum (129),
238         0x29, 0xB7,          //   Usage Maximum (183),
239         0x81, 0x00,          //   Input (Data, Array),
240         0xc0,                // End Collection - System Control
241
242         // Consumer Control Collection - Media Keys
243         //
244         // NOTES:
245         // Not bothering with NKRO for this table. If there's a need, I can implement it. -HaaTa
246         // Using a 1KRO scheme
247         0x05, 0x0c,          // Usage Page (Consumer),
248         0x09, 0x01,          // Usage (Consumer Control),
249         0xA1, 0x01,          // Collection (Application),
250         0x85, 0x06,          //   Report ID (6),
251         0x75, 0x10,          //   Report Size (16),
252         0x95, 0x01,          //   Report Count (1),
253         0x16, 0x20, 0x00,    //   Logical Minimum (32),
254         0x26, 0x9C, 0x02,    //   Logical Maximum (668),
255         0x05, 0x0C,          //   Usage Page (Consumer),
256         0x19, 0x20,          //   Usage Minimum (32),
257         0x2A, 0x9C, 0x02,    //   Usage Maximum (668),
258         0x81, 0x00,          //   Input (Data, Array),
259         0xc0,                // End Collection - Consumer Control
260 };
261
262 /* MOUSE
263 // Mouse Protocol 1, HID 1.11 spec, Appendix B, page 59-60, with wheel extension
264 static uint8_t mouse_report_desc[] = {
265         0x05, 0x01,                     // Usage Page (Generic Desktop)
266         0x09, 0x02,                     // Usage (Mouse)
267         0xA1, 0x01,                     // Collection (Application)
268         0x05, 0x09,                     //   Usage Page (Button)
269         0x19, 0x01,                     //   Usage Minimum (Button #1)
270         0x29, 0x03,                     //   Usage Maximum (Button #3)
271         0x15, 0x00,                     //   Logical Minimum (0)
272         0x25, 0x01,                     //   Logical Maximum (1)
273         0x95, 0x03,                     //   Report Count (3)
274         0x75, 0x01,                     //   Report Size (1)
275         0x81, 0x02,                     //   Input (Data, Variable, Absolute)
276         0x95, 0x01,                     //   Report Count (1)
277         0x75, 0x05,                     //   Report Size (5)
278         0x81, 0x03,                     //   Input (Constant)
279         0x05, 0x01,                     //   Usage Page (Generic Desktop)
280         0x09, 0x30,                     //   Usage (X)
281         0x09, 0x31,                     //   Usage (Y)
282         0x15, 0x00,                     //   Logical Minimum (0)
283         0x26, 0xFF, 0x7F,               //   Logical Maximum (32767)
284         0x75, 0x10,                     //   Report Size (16),
285         0x95, 0x02,                     //   Report Count (2),
286         0x81, 0x02,                     //   Input (Data, Variable, Absolute)
287         0x09, 0x38,                     //   Usage (Wheel)
288         0x15, 0x81,                     //   Logical Minimum (-127)
289         0x25, 0x7F,                     //   Logical Maximum (127)
290         0x75, 0x08,                     //   Report Size (8),
291         0x95, 0x01,                     //   Report Count (1),
292         0x81, 0x06,                     //   Input (Data, Variable, Relative)
293         0xC0                            // End Collection
294 };
295 */
296
297
298
299 // ----- USB Configuration -----
300
301 // USB Configuration Descriptor.  This huge descriptor tells all
302 // of the devices capbilities.
303 static uint8_t config_descriptor[CONFIG_DESC_SIZE] = {
304 // --- Configuration ---
305 // - 9 bytes -
306         // configuration descriptor, USB spec 9.6.3, page 264-266, Table 9-10
307         9,                                      // bLength;
308         2,                                      // bDescriptorType;
309         LSB(CONFIG_DESC_SIZE),                  // wTotalLength
310         MSB(CONFIG_DESC_SIZE),
311         NUM_INTERFACE,                          // bNumInterfaces
312         1,                                      // bConfigurationValue
313         0,                                      // iConfiguration
314         0xA0,                                   // bmAttributes
315         250,                                    // bMaxPower
316
317 // --- Keyboard HID --- Boot Mode Keyboard Interface
318 // - 9 bytes -
319         // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
320         9,                                      // bLength
321         4,                                      // bDescriptorType
322         KEYBOARD_INTERFACE,                     // bInterfaceNumber
323         0,                                      // bAlternateSetting
324         1,                                      // bNumEndpoints
325         0x03,                                   // bInterfaceClass (0x03 = HID)
326         0x01,                                   // bInterfaceSubClass (0x00 = Non-Boot, 0x01 = Boot)
327         0x01,                                   // bInterfaceProtocol (0x01 = Keyboard)
328         0,                                      // iInterface
329 // - 9 bytes -
330         // HID interface descriptor, HID 1.11 spec, section 6.2.1
331         9,                                      // bLength
332         0x21,                                   // bDescriptorType
333         0x11, 0x01,                             // bcdHID
334         0,                                      // bCountryCode
335         1,                                      // bNumDescriptors
336         0x22,                                   // bDescriptorType
337         LSB(sizeof(keyboard_report_desc)),      // wDescriptorLength
338         MSB(sizeof(keyboard_report_desc)),
339 // - 7 bytes -
340         // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
341         7,                                      // bLength
342         5,                                      // bDescriptorType
343         KEYBOARD_ENDPOINT | 0x80,               // bEndpointAddress
344         0x03,                                   // bmAttributes (0x03=intr)
345         KEYBOARD_SIZE, 0,                       // wMaxPacketSize
346         KEYBOARD_INTERVAL,                      // bInterval
347
348 // --- NKRO Keyboard HID --- OS Mode Keyboard Interface
349 // - 9 bytes -
350         // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
351         9,                                      // bLength
352         4,                                      // bDescriptorType
353         NKRO_KEYBOARD_INTERFACE,                // bInterfaceNumber
354         0,                                      // bAlternateSetting
355         1,                                      // bNumEndpoints
356         0x03,                                   // bInterfaceClass (0x03 = HID)
357         0x00,                                   // bInterfaceSubClass (0x00 = Non-Boot, 0x01 = Boot)
358         0x01,                                   // bInterfaceProtocol (0x01 = Keyboard)
359         0,                                      // iInterface
360 // - 9 bytes -
361         // HID interface descriptor, HID 1.11 spec, section 6.2.1
362         9,                                      // bLength
363         0x21,                                   // bDescriptorType
364         0x11, 0x01,                             // bcdHID
365         0,                                      // bCountryCode
366         1,                                      // bNumDescriptors
367         0x22,                                   // bDescriptorType
368         LSB(sizeof(nkro_keyboard_report_desc)), // wDescriptorLength
369         MSB(sizeof(nkro_keyboard_report_desc)),
370 // - 7 bytes -
371         // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
372         7,                                      // bLength
373         5,                                      // bDescriptorType
374         NKRO_KEYBOARD_ENDPOINT | 0x80,          // bEndpointAddress
375         0x03,                                   // bmAttributes (0x03=intr)
376         NKRO_KEYBOARD_SIZE, 0,                  // wMaxPacketSize
377         NKRO_KEYBOARD_INTERVAL,                 // bInterval
378
379 // --- Serial CDC --- CDC IAD Descriptor
380 // - 8 bytes -
381         // interface association descriptor, USB ECN, Table 9-Z
382         8,                                      // bLength
383         11,                                     // bDescriptorType
384         CDC_STATUS_INTERFACE,                   // bFirstInterface
385         2,                                      // bInterfaceCount
386         0x02,                                   // bFunctionClass
387         0x02,                                   // bFunctionSubClass
388         0x01,                                   // bFunctionProtocol
389         0,                                      // iFunction
390
391 // --- Serial CDC --- CDC Data Interface
392 // - 9 bytes -
393         // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
394         9,                                      // bLength
395         4,                                      // bDescriptorType
396         CDC_STATUS_INTERFACE,                   // bInterfaceNumber
397         0,                                      // bAlternateSetting
398         1,                                      // bNumEndpoints
399         0x02,                                   // bInterfaceClass
400         0x02,                                   // bInterfaceSubClass
401         0x01,                                   // bInterfaceProtocol
402         0,                                      // iInterface
403 // - 5 bytes -
404         // CDC Header Functional Descriptor, CDC Spec 5.2.3.1, Table 26
405         5,                                      // bFunctionLength
406         0x24,                                   // bDescriptorType
407         0x00,                                   // bDescriptorSubtype
408         0x10, 0x01,                             // bcdCDC
409 // - 5 bytes -
410         // Call Management Functional Descriptor, CDC Spec 5.2.3.2, Table 27
411         5,                                      // bFunctionLength
412         0x24,                                   // bDescriptorType
413         0x01,                                   // bDescriptorSubtype
414         0x01,                                   // bmCapabilities
415         1,                                      // bDataInterface
416 // - 4 bytes -
417         // Abstract Control Management Functional Descriptor, CDC Spec 5.2.3.3, Table 28
418         4,                                      // bFunctionLength
419         0x24,                                   // bDescriptorType
420         0x02,                                   // bDescriptorSubtype
421         0x06,                                   // bmCapabilities
422 // - 5 bytes -
423         // Union Functional Descriptor, CDC Spec 5.2.3.8, Table 33
424         5,                                      // bFunctionLength
425         0x24,                                   // bDescriptorType
426         0x06,                                   // bDescriptorSubtype
427         CDC_STATUS_INTERFACE,                   // bMasterInterface
428         CDC_DATA_INTERFACE,                     // bSlaveInterface0
429 // - 7 bytes -
430         // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
431         7,                                      // bLength
432         5,                                      // bDescriptorType
433         CDC_ACM_ENDPOINT | 0x80,                // bEndpointAddress
434         0x03,                                   // bmAttributes (0x03=intr)
435         CDC_ACM_SIZE, 0,                        // wMaxPacketSize
436         64,                                     // bInterval
437 // - 9 bytes -
438         // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
439         9,                                      // bLength
440         4,                                      // bDescriptorType
441         CDC_DATA_INTERFACE,                     // bInterfaceNumber
442         0,                                      // bAlternateSetting
443         2,                                      // bNumEndpoints
444         0x0A,                                   // bInterfaceClass
445         0x00,                                   // bInterfaceSubClass
446         0x00,                                   // bInterfaceProtocol
447         0,                                      // iInterface
448 // - 7 bytes -
449         // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
450         7,                                      // bLength
451         5,                                      // bDescriptorType
452         CDC_RX_ENDPOINT,                        // bEndpointAddress
453         0x02,                                   // bmAttributes (0x02=bulk)
454         CDC_RX_SIZE, 0,                         // wMaxPacketSize
455         0,                                      // bInterval
456 // - 7 bytes -
457         // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
458         7,                                      // bLength
459         5,                                      // bDescriptorType
460         CDC_TX_ENDPOINT | 0x80,                 // bEndpointAddress
461         0x02,                                   // bmAttributes (0x02=bulk)
462         CDC_TX_SIZE, 0,                         // wMaxPacketSize
463         0,                                      // bInterval
464
465 /*
466 // Mouse Interface
467 // - 9 bytes -
468         // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
469         9,                                      // bLength
470         4,                                      // bDescriptorType
471         MOUSE_INTERFACE,                        // bInterfaceNumber
472         0,                                      // bAlternateSetting
473         1,                                      // bNumEndpoints
474         0x03,                                   // bInterfaceClass (0x03 = HID)
475         0x00,                                   // bInterfaceSubClass (0x01 = Boot)
476         0x00,                                   // bInterfaceProtocol (0x02 = Mouse)
477         0,                                      // iInterface
478 // - 9 bytes -
479         // HID interface descriptor, HID 1.11 spec, section 6.2.1
480         9,                                      // bLength
481         0x21,                                   // bDescriptorType
482         0x11, 0x01,                             // bcdHID
483         0,                                      // bCountryCode
484         1,                                      // bNumDescriptors
485         0x22,                                   // bDescriptorType
486         LSB(sizeof(mouse_report_desc)),         // wDescriptorLength
487         MSB(sizeof(mouse_report_desc)),
488 // - 7 bytes -
489         // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
490         7,                                      // bLength
491         5,                                      // bDescriptorType
492         MOUSE_ENDPOINT | 0x80,                  // bEndpointAddress
493         0x03,                                   // bmAttributes (0x03=intr)
494         MOUSE_SIZE, 0,                          // wMaxPacketSize
495         MOUSE_INTERVAL,                         // bInterval
496 #endif // MOUSE_INTERFACE
497 */
498 };
499
500
501
502 // ----- String Descriptors -----
503
504 // The descriptors above can provide human readable strings,
505 // referenced by index numbers.  These descriptors are the
506 // actual string data
507
508 struct usb_string_descriptor_struct {
509         uint8_t bLength;
510         uint8_t bDescriptorType;
511         uint16_t wString[];
512 };
513
514 extern struct usb_string_descriptor_struct usb_string_manufacturer_name
515         __attribute__ ((weak, alias("usb_string_manufacturer_name_default")));
516 extern struct usb_string_descriptor_struct usb_string_product_name
517         __attribute__ ((weak, alias("usb_string_product_name_default")));
518 extern struct usb_string_descriptor_struct usb_string_serial_number
519         __attribute__ ((weak, alias("usb_string_serial_number_default")));
520
521 struct usb_string_descriptor_struct string0 = {
522         4,
523         3,
524         {0x0409}
525 };
526
527 struct usb_string_descriptor_struct usb_string_manufacturer_name_default = {
528         sizeof(STR_MANUFACTURER),
529         3,
530         STR_MANUFACTURER
531 };
532 struct usb_string_descriptor_struct usb_string_product_name_default = {
533         sizeof(STR_PRODUCT),
534         3,
535         STR_PRODUCT
536 };
537 struct usb_string_descriptor_struct usb_string_serial_number_default = {
538         sizeof(STR_SERIAL),
539         3,
540         STR_SERIAL
541 };
542
543
544
545 // ----- Descriptors List -----
546
547 // This table provides access to all the descriptor data above.
548
549 const usb_descriptor_list_t usb_descriptor_list[] = {
550         //wValue, wIndex, address,          length
551         {0x0100, 0x0000, device_descriptor, sizeof(device_descriptor)},
552         {0x0200, 0x0000, config_descriptor, sizeof(config_descriptor)},
553         {0x0600, 0x0000, device_qualifier_descriptor, sizeof(device_qualifier_descriptor)},
554         {0x0A00, 0x0000, usb_debug_descriptor, sizeof(usb_debug_descriptor)},
555         {0x2200, KEYBOARD_INTERFACE, keyboard_report_desc, sizeof(keyboard_report_desc)},
556         {0x2100, KEYBOARD_INTERFACE, config_descriptor + KEYBOARD_DESC_OFFSET, 9},
557         {0x2200, NKRO_KEYBOARD_INTERFACE, nkro_keyboard_report_desc, sizeof(nkro_keyboard_report_desc)},
558         {0x2100, NKRO_KEYBOARD_INTERFACE, config_descriptor + NKRO_KEYBOARD_DESC_OFFSET, 9},
559 /* MOUSE
560         {0x2200, MOUSE_INTERFACE, mouse_report_desc, sizeof(mouse_report_desc)},
561         {0x2100, MOUSE_INTERFACE, config_descriptor+MOUSE_DESC_OFFSET, 9},
562 */
563         {0x0300, 0x0000, (const uint8_t *)&string0, 0},
564         {0x0301, 0x0409, (const uint8_t *)&usb_string_manufacturer_name, 0},
565         {0x0302, 0x0409, (const uint8_t *)&usb_string_product_name, 0},
566         {0x0303, 0x0409, (const uint8_t *)&usb_string_serial_number, 0},
567         {0, 0, NULL, 0}
568 };
569
570
571
572 // ----- Endpoint Configuration -----
573
574 // See usb_desc.h for Endpoint configuration
575 // 0x00 = not used
576 // 0x19 = Recieve only
577 // 0x15 = Transmit only
578 // 0x1D = Transmit & Recieve
579 //
580 const uint8_t usb_endpoint_config_table[NUM_ENDPOINTS] =
581 {
582 #if (defined(ENDPOINT1_CONFIG) && NUM_ENDPOINTS >= 1)
583         ENDPOINT1_CONFIG,
584 #elif (NUM_ENDPOINTS >= 1)
585         ENDPOINT_UNUSED,
586 #endif
587 #if (defined(ENDPOINT2_CONFIG) && NUM_ENDPOINTS >= 2)
588         ENDPOINT2_CONFIG,
589 #elif (NUM_ENDPOINTS >= 2)
590         ENDPOINT_UNUSED,
591 #endif
592 #if (defined(ENDPOINT3_CONFIG) && NUM_ENDPOINTS >= 3)
593         ENDPOINT3_CONFIG,
594 #elif (NUM_ENDPOINTS >= 3)
595         ENDPOINT_UNUSED,
596 #endif
597 #if (defined(ENDPOINT4_CONFIG) && NUM_ENDPOINTS >= 4)
598         ENDPOINT4_CONFIG,
599 #elif (NUM_ENDPOINTS >= 4)
600         ENDPOINT_UNUSED,
601 #endif
602 #if (defined(ENDPOINT5_CONFIG) && NUM_ENDPOINTS >= 5)
603         ENDPOINT5_CONFIG,
604 #elif (NUM_ENDPOINTS >= 5)
605         ENDPOINT_UNUSED,
606 #endif
607 #if (defined(ENDPOINT6_CONFIG) && NUM_ENDPOINTS >= 6)
608         ENDPOINT6_CONFIG,
609 #elif (NUM_ENDPOINTS >= 6)
610         ENDPOINT_UNUSED,
611 #endif
612 #if (defined(ENDPOINT7_CONFIG) && NUM_ENDPOINTS >= 7)
613         ENDPOINT7_CONFIG,
614 #elif (NUM_ENDPOINTS >= 7)
615         ENDPOINT_UNUSED,
616 #endif
617 #if (defined(ENDPOINT8_CONFIG) && NUM_ENDPOINTS >= 8)
618         ENDPOINT8_CONFIG,
619 #elif (NUM_ENDPOINTS >= 8)
620         ENDPOINT_UNUSED,
621 #endif
622 #if (defined(ENDPOINT9_CONFIG) && NUM_ENDPOINTS >= 9)
623         ENDPOINT9_CONFIG,
624 #elif (NUM_ENDPOINTS >= 9)
625         ENDPOINT_UNUSED,
626 #endif
627 #if (defined(ENDPOINT10_CONFIG) && NUM_ENDPOINTS >= 10)
628         ENDPOINT10_CONFIG,
629 #elif (NUM_ENDPOINTS >= 10)
630         ENDPOINT_UNUSED,
631 #endif
632 #if (defined(ENDPOINT11_CONFIG) && NUM_ENDPOINTS >= 11)
633         ENDPOINT11_CONFIG,
634 #elif (NUM_ENDPOINTS >= 11)
635         ENDPOINT_UNUSED,
636 #endif
637 #if (defined(ENDPOINT12_CONFIG) && NUM_ENDPOINTS >= 12)
638         ENDPOINT12_CONFIG,
639 #elif (NUM_ENDPOINTS >= 12)
640         ENDPOINT_UNUSED,
641 #endif
642 #if (defined(ENDPOINT13_CONFIG) && NUM_ENDPOINTS >= 13)
643         ENDPOINT13_CONFIG,
644 #elif (NUM_ENDPOINTS >= 13)
645         ENDPOINT_UNUSED,
646 #endif
647 #if (defined(ENDPOINT14_CONFIG) && NUM_ENDPOINTS >= 14)
648         ENDPOINT14_CONFIG,
649 #elif (NUM_ENDPOINTS >= 14)
650         ENDPOINT_UNUSED,
651 #endif
652 #if (defined(ENDPOINT15_CONFIG) && NUM_ENDPOINTS >= 15)
653         ENDPOINT15_CONFIG,
654 #elif (NUM_ENDPOINTS >= 15)
655         ENDPOINT_UNUSED,
656 #endif
657 };
658