aboutsummaryrefslogtreecommitdiff
path: root/tmk_core
diff options
context:
space:
mode:
authorfauxpark <fauxpark@gmail.com>2020-02-02 13:10:57 +1100
committerGitHub <noreply@github.com>2020-02-02 13:10:57 +1100
commite036b94a215157bb45913a22267d709ec5c6ef5f (patch)
tree4f42dee141ef0b024e2a1fe29c117d6008e4dc61 /tmk_core
parent1a79f14e4390d088fcf6b26fe3b62549875c3e71 (diff)
downloadqmk_firmware-e036b94a215157bb45913a22267d709ec5c6ef5f.tar.gz
qmk_firmware-e036b94a215157bb45913a22267d709ec5c6ef5f.zip
Align ATSAM HID descriptors with LUFA/ChibiOS (#7651)
* Align ATSAM HID descriptors with LUFA/ChibiOS * Don't hardcode raw endpoint size
Diffstat (limited to 'tmk_core')
-rw-r--r--tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c301
1 files changed, 154 insertions, 147 deletions
diff --git a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c
index c3952d50c..ace7c2108 100644
--- a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c
+++ b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c
@@ -98,30 +98,36 @@ UDC_DESC_STORAGE udi_hid_kbd_report_desc_t udi_hid_kbd_report_desc = {{
98 0x05, 0x01, // Usage Page (Generic Desktop) 98 0x05, 0x01, // Usage Page (Generic Desktop)
99 0x09, 0x06, // Usage (Keyboard) 99 0x09, 0x06, // Usage (Keyboard)
100 0xA1, 0x01, // Collection (Application) 100 0xA1, 0x01, // Collection (Application)
101 // Modifiers (8 bits)
101 0x05, 0x07, // Usage Page (Keyboard) 102 0x05, 0x07, // Usage Page (Keyboard)
102 0x19, 0xE0, // Usage Minimum (224) 103 0x19, 0xE0, // Usage Minimum (Keyboard Left Control)
103 0x29, 0xE7, // Usage Maximum (231) 104 0x29, 0xE7, // Usage Maximum (Keyboard Right GUI)
104 0x15, 0x00, // Logical Minimum (0) 105 0x15, 0x00, // Logical Minimum (0)
105 0x25, 0x01, // Logical Maximum (1) 106 0x25, 0x01, // Logical Maximum (1)
106 0x75, 0x01, // Report Size (1)
107 0x95, 0x08, // Report Count (8) 107 0x95, 0x08, // Report Count (8)
108 0x75, 0x01, // Report Size (1)
108 0x81, 0x02, // Input (Data, Variable, Absolute) 109 0x81, 0x02, // Input (Data, Variable, Absolute)
110 // Reserved (1 byte)
109 0x81, 0x01, // Input (Constant) 111 0x81, 0x01, // Input (Constant)
112 // Keycodes (6 bytes)
110 0x19, 0x00, // Usage Minimum (0) 113 0x19, 0x00, // Usage Minimum (0)
111 0x29, 0xFF, // Usage Maximum (255) 114 0x29, 0xFF, // Usage Maximum (255)
112 0x15, 0x00, // Logical Minimum (0) 115 0x15, 0x00, // Logical Minimum (0)
113 0x25, 0xFF, // Logical Maximum (255) 116 0x25, 0xFF, // Logical Maximum (255)
114 0x75, 0x08, // Report Size (8)
115 0x95, 0x06, // Report Count (6) 117 0x95, 0x06, // Report Count (6)
116 0x81, 0x00, // Input (Data, Array) 118 0x75, 0x08, // Report Size (8)
119 0x81, 0x00, // Input (Data, Array, Absolute)
120
121 // Status LEDs (5 bits)
117 0x05, 0x08, // Usage Page (LED) 122 0x05, 0x08, // Usage Page (LED)
118 0x19, 0x01, // Usage Minimum (1) 123 0x19, 0x01, // Usage Minimum (Num Lock)
119 0x29, 0x05, // Usage Maximum (5) 124 0x29, 0x05, // Usage Maximum (Kana)
120 0x15, 0x00, // Logical Minimum (0) 125 0x15, 0x00, // Logical Minimum (0)
121 0x25, 0x01, // Logical Maximum (1) 126 0x25, 0x01, // Logical Maximum (1)
122 0x75, 0x01, // Report Size (1)
123 0x95, 0x05, // Report Count (5) 127 0x95, 0x05, // Report Count (5)
128 0x75, 0x01, // Report Size (1)
124 0x91, 0x02, // Output (Data, Variable, Absolute) 129 0x91, 0x02, // Output (Data, Variable, Absolute)
130 // LED padding (3 bits)
125 0x95, 0x03, // Report Count (3) 131 0x95, 0x03, // Report Count (3)
126 0x91, 0x01, // Output (Constant) 132 0x91, 0x01, // Output (Constant)
127 0xC0 // End Collection 133 0xC0 // End Collection
@@ -231,43 +237,41 @@ static uint8_t udi_hid_nkro_report_trans[UDI_HID_NKRO_REPORT_SIZE];
231 237
232COMPILER_WORD_ALIGNED 238COMPILER_WORD_ALIGNED
233UDC_DESC_STORAGE udi_hid_nkro_report_desc_t udi_hid_nkro_report_desc = {{ 239UDC_DESC_STORAGE udi_hid_nkro_report_desc_t udi_hid_nkro_report_desc = {{
234 0x05, 0x01, // Usage Page (Generic Desktop), 240 0x05, 0x01, // Usage Page (Generic Desktop)
235 0x09, 0x06, // Usage (Keyboard), 241 0x09, 0x06, // Usage (Keyboard)
236 0xA1, 0x01, // Collection (Application) - Keyboard, 242 0xA1, 0x01, // Collection (Application)
237 243
238 // Mods 244 // Modifiers (8 bits)
239 0x75, 0x01, // Report Size (1), 245 0x05, 0x07, // Usage Page (Keyboard/Keypad)
240 0x95, 0x08, // Report Count (8), 246 0x19, 0xE0, // Usage Minimum (Keyboard Left Control)
241 0x15, 0x00, // Logical Minimum (0), 247 0x29, 0xE7, // Usage Maximum (Keyboard Right GUI)
242 0x25, 0x01, // Logical Maximum (1), 248 0x15, 0x00, // Logical Minimum (0)
243 0x05, 0x07, // Usage Page (Key Codes), 249 0x25, 0x01, // Logical Maximum (1)
244 0x19, 0xE0, // Usage Minimum (224), 250 0x95, 0x08, // Report Count (8)
245 0x29, 0xE7, // Usage Maximum (231), 251 0x75, 0x01, // Report Size (1)
246 0x81, 0x02, // Input (Data, Variable, Absolute), 252 0x81, 0x02, // Input (Data, Variable, Absolute)
247 253 // Keycodes
248 // LED Report 254 0x05, 0x07, // Usage Page (Keyboard/Keypad)
249 0x75, 0x01, // Report Size (1), 255 0x19, 0x00, // Usage Minimum (0)
250 0x95, 0x05, // Report Count (5), 256 0x29, 0xF7, // Usage Maximum (247)
251 0x05, 0x08, // Usage Page (LEDs), 257 0x15, 0x00, // Logical Minimum (0)
252 0x19, 0x01, // Usage Minimum (1), 258 0x25, 0x01, // Logical Maximum (1)
253 0x29, 0x05, // Usage Maximum (5), 259 0x95, 0xF8, // Report Count (248)
254 0x91, 0x02, // Output (Data, Variable, Absolute), 260 0x75, 0x01, // Report Size (1)
255 261 0x81, 0x02, // Input (Data, Variable, Absolute, Bitfield)
256 // LED Report Padding 262
257 0x75, 0x03, // Report Size (3), 263 // Status LEDs (5 bits)
258 0x95, 0x01, // Report Count (1), 264 0x05, 0x08, // Usage Page (LED)
259 0x91, 0x03, // Output (Constant), 265 0x19, 0x01, // Usage Minimum (Num Lock)
260 266 0x29, 0x05, // Usage Maximum (Kana)
261 // Main keys 267 0x95, 0x05, // Report Count (5)
262 0x75, 0x01, // Report Size (1), 268 0x75, 0x01, // Report Size (1)
263 0x95, 0xF8, // Report Count (248), 269 0x91, 0x02, // Output (Data, Variable, Absolute)
264 0x15, 0x00, // Logical Minimum (0), 270 // LED padding (3 bits)
265 0x25, 0x01, // Logical Maximum (1), 271 0x95, 0x01, // Report Count (1)
266 0x05, 0x07, // Usage Page (Key Codes), 272 0x75, 0x03, // Report Size (3)
267 0x19, 0x00, // Usage Minimum (0), 273 0x91, 0x03, // Output (Constant)
268 0x29, 0xF7, // Usage Maximum (247), 274 0xC0 // End Collection
269 0x81, 0x02, // Input (Data, Variable, Absolute, Bitfield),
270 0xc0, // End Collection - Keyboard
271}}; 275}};
272 276
273static bool udi_hid_nkro_setreport(void); 277static bool udi_hid_nkro_setreport(void);
@@ -373,35 +377,31 @@ static uint8_t udi_hid_exk_report_trans[UDI_HID_EXK_REPORT_SIZE];
373 377
374COMPILER_WORD_ALIGNED 378COMPILER_WORD_ALIGNED
375UDC_DESC_STORAGE udi_hid_exk_report_desc_t udi_hid_exk_report_desc = {{ 379UDC_DESC_STORAGE udi_hid_exk_report_desc_t udi_hid_exk_report_desc = {{
376 // System Control Collection (8 bits) 380 0x05, 0x01, // Usage Page (Generic Desktop)
377 381 0x09, 0x80, // Usage (System Control)
378 0x05, 0x01, // Usage Page (Generic Desktop), 382 0xA1, 0x01, // Collection (Application)
379 0x09, 0x80, // Usage (System Control), 383 0x85, REPORT_ID_SYSTEM, // Report ID
380 0xA1, 0x01, // Collection (Application), 384 0x1A, 0x81, 0x00, // Usage Minimum (81) (System Power Down)
381 0x85, REPORT_ID_SYSTEM, // Report ID (2) (System), 385 0x2A, 0x83, 0x00, // Usage Maximum (83) (System Wake Up)
382 0x16, 0x01, 0x00, // Logical Minimum (1), 386 0x16, 0x01, 0x00, // Logical Minimum (1)
383 0x26, 0x03, 0x00, // Logical Maximum (3), 387 0x26, 0x03, 0x00, // Logical Maximum (3)
384 0x1A, 0x81, 0x00, // Usage Minimum (81) (System Power Down), 388 0x95, 0x01, // Report Count (1)
385 0x2A, 0x83, 0x00, // Usage Maximum (83) (System Wake Up), 389 0x75, 0x10, // Report Size (16)
386 0x75, 0x10, // Report Size (16), 390 0x81, 0x00, // Input (Data, Array, Absolute)
387 0x95, 0x01, // Report Count (1), 391 0xC0, // End Collection
388 0x81, 0x00, // Input (Data, Array), 392
389 0xC0, // End Collection - System Control 393 0x05, 0x0C, // Usage Page (Consumer)
390 394 0x09, 0x01, // Usage (Consumer Control)
391 // Consumer Control Collection - Media Keys (16 bits) 395 0xA1, 0x01, // Collection (Application)
392 396 0x85, REPORT_ID_CONSUMER, // Report ID
393 0x05, 0x0C, // Usage Page (Consumer), 397 0x1A, 0x01, 0x00, // Usage Minimum (Consumer Control)
394 0x09, 0x01, // Usage (Consumer Control), 398 0x2A, 0x9C, 0x02, // Usage Maximum (AC Distribute Vertically)
395 0xA1, 0x01, // Collection (Application), 399 0x16, 0x01, 0x00, // Logical Minimum
396 0x85, REPORT_ID_CONSUMER, // Report ID (3) (Consumer), 400 0x26, 0x9C, 0x02, // Logical Maximum
397 0x16, 0x01, 0x00, // Logical Minimum (1), 401 0x95, 0x01, // Report Count (1)
398 0x26, 0x9C, 0x02, // Logical Maximum (668), 402 0x75, 0x10, // Report Size (16)
399 0x1A, 0x01, 0x00, // Usage Minimum (1), 403 0x81, 0x00, // Input (Data, Array, Absolute)
400 0x2A, 0x9C, 0x02, // Usage Maximum (668), 404 0xC0 // End Collection
401 0x75, 0x10, // Report Size (16),
402 0x95, 0x01, // Report Count (1),
403 0x81, 0x00, // Input (Data, Array),
404 0xC0, // End Collection - Consumer Control
405}}; 405}};
406 406
407static bool udi_hid_exk_setreport(void); 407static bool udi_hid_exk_setreport(void);
@@ -506,49 +506,53 @@ static uint8_t udi_hid_mou_report_trans[UDI_HID_MOU_REPORT_SIZE];
506 506
507COMPILER_WORD_ALIGNED 507COMPILER_WORD_ALIGNED
508UDC_DESC_STORAGE udi_hid_mou_report_desc_t udi_hid_mou_report_desc = {{ 508UDC_DESC_STORAGE udi_hid_mou_report_desc_t udi_hid_mou_report_desc = {{
509 0x05, 0x01, // Usage Page (Generic Desktop), 509 0x05, 0x01, // Usage Page (Generic Desktop)
510 0x09, 0x02, // Usage (Mouse), 510 0x09, 0x02, // Usage (Mouse)
511 0xA1, 0x01, // Collection (Application), 511 0xA1, 0x01, // Collection (Application)
512 0x09, 0x01, // Usage (Pointer), 512 0x09, 0x01, // Usage (Pointer)
513 0xA1, 0x00, // Collection (Physical), 513 0xA1, 0x00, // Collection (Physical)
514 0x05, 0x09, // Usage Page (Buttons), 514 // Buttons (5 bits)
515 0x19, 0x01, // Usage Minimum (01), 515 0x05, 0x09, // Usage Page (Button)
516 0x29, 0x05, // Usage Maximun (05), 516 0x19, 0x01, // Usage Minimum (Button 1)
517 0x15, 0x00, // Logical Minimum (0), 517 0x29, 0x05, // Usage Maximun (Button 5)
518 0x25, 0x01, // Logical Maximum (1), 518 0x15, 0x00, // Logical Minimum (0)
519 0x95, 0x05, // Report Count (5), 519 0x25, 0x01, // Logical Maximum (1)
520 0x75, 0x01, // Report Size (1), 520 0x95, 0x05, // Report Count (5)
521 0x81, 0x02, // Input (Data, Variable, Absolute), ;5 button bits 521 0x75, 0x01, // Report Size (1)
522 0x95, 0x01, // Report Count (1), 522 0x81, 0x02, // Input (Data, Variable, Absolute)
523 0x75, 0x03, // Report Size (3), 523 // Button padding (3 bits)
524 0x81, 0x01, // Input (Constant), ;3 bit padding, 524 0x95, 0x01, // Report Count (1)
525 525 0x75, 0x03, // Report Size (3)
526 0x05, 0x01, // Usage Page (Generic Desktop), 526 0x81, 0x01, // Input (Constant)
527 0x09, 0x30, // Usage (X), 527
528 0x09, 0x31, // Usage (Y), 528 // X/Y position (2 bytes)
529 0x15, 0x81, // Logical Minimum (-127), 529 0x05, 0x01, // Usage Page (Generic Desktop)
530 0x25, 0x7F, // Logical Maximum (127), 530 0x09, 0x30, // Usage (X)
531 0x95, 0x02, // Report Count (2), 531 0x09, 0x31, // Usage (Y)
532 0x75, 0x08, // Report Size (8), 532 0x15, 0x81, // Logical Minimum (-127)
533 0x81, 0x06, // Input (Data, Variable, Relative), ;2 position bytes (X & Y), 533 0x25, 0x7F, // Logical Maximum (127)
534 534 0x95, 0x02, // Report Count (2)
535 0x09, 0x38, // Usage (Wheel), 535 0x75, 0x08, // Report Size (8)
536 0x15, 0x81, // Logical Minimum (-127), 536 0x81, 0x06, // Input (Data, Variable, Relative)
537 0x25, 0x7F, // Logical Maximum (127), 537
538 0x95, 0x01, // Report Count (1), 538 // Vertical wheel (1 byte)
539 0x75, 0x08, // Report Size (8), 539 0x09, 0x38, // Usage (Wheel)
540 0x81, 0x06, // Input (Data, Variable, Relative), 540 0x15, 0x81, // Logical Minimum (-127)
541 541 0x25, 0x7F, // Logical Maximum (127)
542 0x05, 0x0C, // Usage Page (Consumer), 542 0x95, 0x01, // Report Count (1)
543 0x0A, 0x38, 0x02, // Usage (AC Pan (Horizontal wheel)), 543 0x75, 0x08, // Report Size (8)
544 0x15, 0x81, // Logical Minimum (-127), 544 0x81, 0x06, // Input (Data, Variable, Relative)
545 0x25, 0x7F, // Logical Maximum (127), 545
546 0x95, 0x01, // Report Count (1), 546 // Horizontal wheel (1 byte)
547 0x75, 0x08, // Report Size (8), 547 0x05, 0x0C, // Usage Page (Consumer)
548 0x81, 0x06, // Input (Data, Variable, Relative), 548 0x0A, 0x38, 0x02, // Usage (AC Pan)
549 549 0x15, 0x81, // Logical Minimum (-127)
550 0xC0, // End Collection, 550 0x25, 0x7F, // Logical Maximum (127)
551 0xC0, // End Collection 551 0x95, 0x01, // Report Count (1)
552 0x75, 0x08, // Report Size (8)
553 0x81, 0x06, // Input (Data, Variable, Relative)
554 0xC0, // End Collection
555 0xC0 // End Collection
552}}; 556}};
553 557
554static void udi_hid_mou_report_sent(udd_ep_status_t status, iram_size_t nb_sent, udd_ep_id_t ep); 558static void udi_hid_mou_report_sent(udd_ep_status_t status, iram_size_t nb_sent, udd_ep_id_t ep);
@@ -636,20 +640,21 @@ static uint8_t udi_hid_raw_report_trans[UDI_HID_RAW_REPORT_SIZE];
636 640
637COMPILER_WORD_ALIGNED 641COMPILER_WORD_ALIGNED
638UDC_DESC_STORAGE udi_hid_raw_report_desc_t udi_hid_raw_report_desc = {{ 642UDC_DESC_STORAGE udi_hid_raw_report_desc_t udi_hid_raw_report_desc = {{
639 0x06, // Usage Page (Vendor Defined) 643 0x06, 0x60, 0xFF, // Usage Page (Vendor Defined)
640 0xFF, 0xFF, 644 0x09, 0x61, // Usage (Vendor Defined)
641 0x0A, // Usage (Mouse) 645 0xA1, 0x01, // Collection (Application)
642 0xFF, 0xFF, 0xA1, 0x01, // Collection (Application) 646 0x75, 0x08, // Report Size (8)
643 0x75, 0x08, // Report Size (8) 647 0x15, 0x00, // Logical Minimum (0)
644 0x15, 0x00, // Logical Minimum (0) 648 0x25, 0xFF, // Logical Maximum (255)
645 0x25, 0xFF, // Logical Maximum (255) 649 // Data to host
646 0x95, 0x40, // Report Count 650 0x09, 0x62, // Usage (Vendor Defined)
647 0x09, 0x01, // Usage (Input) 651 0x95, RAW_EPSIZE, // Report Count
648 0x81, 0x02, // Input (Data 652 0x81, 0x02, // Input (Data, Variable, Absolute)
649 0x95, 0x40, // Report Count 653 // Data from host
650 0x09, 0x02, // Usage (Output) 654 0x09, 0x63, // Usage (Vendor Defined)
651 0x91, 0x02, // Output (Data 655 0x95, RAW_EPSIZE, // Report Count
652 0xC0, // End Collection - Consumer Control 656 0x91, 0x02, // Output (Data, Variable, Absolute)
657 0xC0 // End Collection
653}}; 658}};
654 659
655static bool udi_hid_raw_setreport(void); 660static bool udi_hid_raw_setreport(void);
@@ -753,22 +758,24 @@ static uint8_t udi_hid_con_report_trans[UDI_HID_CON_REPORT_SIZE];
753 758
754COMPILER_WORD_ALIGNED 759COMPILER_WORD_ALIGNED
755UDC_DESC_STORAGE udi_hid_con_report_desc_t udi_hid_con_report_desc = {{ 760UDC_DESC_STORAGE udi_hid_con_report_desc_t udi_hid_con_report_desc = {{
756 0x06, 0x31, 0xFF, // Vendor Page (PJRC Teensy compatible) 761 0x06, 0x31, 0xFF, // Usage Page (Vendor Defined - PJRC Teensy compatible)
757 0x09, 0x74, // Vendor Usage (PJRC Teensy compatible) 762 0x09, 0x74, // Usage (Vendor Defined - PJRC Teensy compatible)
758 0xA1, 0x01, // Collection (Application) 763 0xA1, 0x01, // Collection (Application)
759 0x09, 0x75, // Usage (Vendor) 764 // Data to host
760 0x15, 0x00, // Logical Minimum (0x00) 765 0x09, 0x75, // Usage (Vendor Defined)
761 0x26, 0xFF, 0x00, // Logical Maximum (0x00FF) 766 0x15, 0x00, // Logical Minimum (0x00)
762 0x95, CONSOLE_EPSIZE, // Report Count 767 0x26, 0xFF, 0x00, // Logical Maximum (0x00FF)
763 0x75, 0x08, // Report Size (8) 768 0x95, CONSOLE_EPSIZE, // Report Count
764 0x81, 0x02, // Input (Data) 769 0x75, 0x08, // Report Size (8)
765 0x09, 0x76, // Usage (Vendor) 770 0x81, 0x02, // Input (Data, Variable, Absolute)
766 0x15, 0x00, // Logical Minimum (0x00) 771 // Data from host
767 0x26, 0xFF, 0x00, // Logical Maximum (0x00FF) 772 0x09, 0x76, // Usage (Vendor Defined)
768 0x95, CONSOLE_EPSIZE, // Report Count 773 0x15, 0x00, // Logical Minimum (0x00)
769 0x75, 0x08, // Report Size (8) 774 0x26, 0xFF, 0x00, // Logical Maximum (0x00FF)
770 0x91, 0x02, // Output (Data) 775 0x95, CONSOLE_EPSIZE, // Report Count
771 0xC0, // End Collection 776 0x75, 0x08, // Report Size (8)
777 0x91, 0x02, // Output (Data)
778 0xC0 // End Collection
772}}; 779}};
773 780
774static bool udi_hid_con_setreport(void); 781static bool udi_hid_con_setreport(void);