diff options
author | fauxpark <fauxpark@gmail.com> | 2020-02-12 17:19:39 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-12 17:19:39 +1100 |
commit | eaf32621aa0c067b2cab203e5e8e58c7c07a4ff4 (patch) | |
tree | 11220345d3692208129d317097af6d18c07afb78 /tmk_core/protocol/vusb | |
parent | f318d6fffcda102b9063effb5403598d4bbf1213 (diff) |
Align VUSB HID descriptors with LUFA/ChibiOS (#7675)
* Align VUSB HID descriptors with LUFA/ChibiOS
* Wrap send_system and send_consumer in ifdefs too
* Offset system usages to match LUFA/ChibiOS
Diffstat (limited to 'tmk_core/protocol/vusb')
-rw-r--r-- | tmk_core/protocol/vusb/vusb.c | 247 |
1 files changed, 127 insertions, 120 deletions
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c index 110b3069bd..7c1f4ca7f0 100644 --- a/tmk_core/protocol/vusb/vusb.c +++ b/tmk_core/protocol/vusb/vusb.c @@ -112,6 +112,7 @@ static void send_mouse(report_mouse_t *report) { } } +#ifdef EXTRAKEY_ENABLE static void send_extra(uint8_t report_id, uint16_t data) { static uint8_t last_id = 0; static uint16_t last_data = 0; @@ -124,10 +125,19 @@ static void send_extra(uint8_t report_id, uint16_t data) { usbSetInterrupt3((void *)&report, sizeof(report)); } } +#endif -static void send_system(uint16_t data) { send_extra(REPORT_ID_SYSTEM, data); } +static void send_system(uint16_t data) { +#ifdef EXTRAKEY_ENABLE + send_extra(REPORT_ID_SYSTEM, data - SYSTEM_POWER_DOWN + 1); +#endif +} -static void send_consumer(uint16_t data) { send_extra(REPORT_ID_CONSUMER, data); } +static void send_consumer(uint16_t data) { +#ifdef EXTRAKEY_ENABLE + send_extra(REPORT_ID_CONSUMER, data); +#endif +} /*------------------------------------------------------------------* * Request from host * @@ -200,128 +210,125 @@ uchar usbFunctionWrite(uchar *data, uchar len) { * Descriptors * *------------------------------------------------------------------*/ -/* - * Report Descriptor for keyboard - * - * from an example in HID spec appendix - */ const PROGMEM uchar keyboard_hid_report[] = { - 0x05, 0x01, // Usage Page (Generic Desktop), - 0x09, 0x06, // Usage (Keyboard), - 0xA1, 0x01, // Collection (Application), - 0x75, 0x01, // Report Size (1), - 0x95, 0x08, // Report Count (8), - 0x05, 0x07, // Usage Page (Key Codes), - 0x19, 0xE0, // Usage Minimum (224), - 0x29, 0xE7, // Usage Maximum (231), - 0x15, 0x00, // Logical Minimum (0), - 0x25, 0x01, // Logical Maximum (1), - 0x81, 0x02, // Input (Data, Variable, Absolute), ;Modifier byte - 0x95, 0x01, // Report Count (1), - 0x75, 0x08, // Report Size (8), - 0x81, 0x03, // Input (Constant), ;Reserved byte - 0x95, 0x05, // Report Count (5), - 0x75, 0x01, // Report Size (1), - 0x05, 0x08, // Usage Page (LEDs), - 0x19, 0x01, // Usage Minimum (1), - 0x29, 0x05, // Usage Maximum (5), - 0x91, 0x02, // Output (Data, Variable, Absolute), ;LED report - 0x95, 0x01, // Report Count (1), - 0x75, 0x03, // Report Size (3), - 0x91, 0x03, // Output (Constant), ;LED report padding - 0x95, 0x06, // Report Count (6), - 0x75, 0x08, // Report Size (8), - 0x15, 0x00, // Logical Minimum (0), - 0x26, 0xFF, 0x00, // Logical Maximum(255), - 0x05, 0x07, // Usage Page (Key Codes), - 0x19, 0x00, // Usage Minimum (0), - 0x29, 0xFF, // Usage Maximum (255), - 0x81, 0x00, // Input (Data, Array), - 0xc0 // End Collection + 0x05, 0x01, // Usage Page (Generic Desktop) + 0x09, 0x06, // Usage (Keyboard) + 0xA1, 0x01, // Collection (Application) + // Modifiers (8 bits) + 0x05, 0x07, // Usage Page (Keyboard/Keypad) + 0x19, 0xE0, // Usage Minimum (Keyboard Left Control) + 0x29, 0xE7, // Usage Maximum (Keyboard Right GUI) + 0x15, 0x00, // Logical Minimum (0) + 0x25, 0x01, // Logical Maximum (1) + 0x95, 0x08, // Report Count (8) + 0x75, 0x01, // Report Size (1) + 0x81, 0x02, // Input (Data, Variable, Absolute) + // Reserved (1 byte) + 0x95, 0x01, // Report Count (1) + 0x75, 0x08, // Report Size (8) + 0x81, 0x03, // Input (Constant) + // Keycodes (6 bytes) + 0x05, 0x07, // Usage Page (Keyboard/Keypad) + 0x19, 0x00, // Usage Minimum (0) + 0x29, 0xFF, // Usage Maximum (255) + 0x15, 0x00, // Logical Minimum (0) + 0x26, 0xFF, 0x00, // Logical Maximum (255) + 0x95, 0x06, // Report Count (6) + 0x75, 0x08, // Report Size (8) + 0x81, 0x00, // Input (Data, Array, Absolute) + + // Status LEDs (5 bits) + 0x05, 0x08, // Usage Page (LED) + 0x19, 0x01, // Usage Minimum (Num Lock) + 0x29, 0x05, // Usage Maximum (Kana) + 0x95, 0x05, // Report Count (5) + 0x75, 0x01, // Report Size (1) + 0x91, 0x02, // Output (Data, Variable, Absolute) + // LED padding (3 bits) + 0x95, 0x01, // Report Count (1) + 0x75, 0x03, // Report Size (3) + 0x91, 0x03, // Output (Constant) + 0xC0 // End Collection }; -/* - * Report Descriptor for mouse - * - * Mouse Protocol 1, HID 1.11 spec, Appendix B, page 59-60, with wheel extension - * http://www.microchip.com/forums/tm.aspx?high=&m=391435&mpage=1#391521 - * http://www.keil.com/forum/15671/ - * http://www.microsoft.com/whdc/device/input/wheel.mspx - */ const PROGMEM uchar mouse_hid_report[] = { - /* mouse */ - 0x05, 0x01, // USAGE_PAGE (Generic Desktop) - 0x09, 0x02, // USAGE (Mouse) - 0xa1, 0x01, // COLLECTION (Application) - 0x85, REPORT_ID_MOUSE, // REPORT_ID (1) - 0x09, 0x01, // USAGE (Pointer) - 0xa1, 0x00, // COLLECTION (Physical) - // ---------------------------- Buttons - 0x05, 0x09, // USAGE_PAGE (Button) - 0x19, 0x01, // USAGE_MINIMUM (Button 1) - 0x29, 0x05, // USAGE_MAXIMUM (Button 5) - 0x15, 0x00, // LOGICAL_MINIMUM (0) - 0x25, 0x01, // LOGICAL_MAXIMUM (1) - 0x75, 0x01, // REPORT_SIZE (1) - 0x95, 0x05, // REPORT_COUNT (5) - 0x81, 0x02, // INPUT (Data,Var,Abs) - 0x75, 0x03, // REPORT_SIZE (3) - 0x95, 0x01, // REPORT_COUNT (1) - 0x81, 0x03, // INPUT (Cnst,Var,Abs) - // ---------------------------- X,Y position - 0x05, 0x01, // USAGE_PAGE (Generic Desktop) - 0x09, 0x30, // USAGE (X) - 0x09, 0x31, // USAGE (Y) - 0x15, 0x81, // LOGICAL_MINIMUM (-127) - 0x25, 0x7f, // LOGICAL_MAXIMUM (127) - 0x75, 0x08, // REPORT_SIZE (8) - 0x95, 0x02, // REPORT_COUNT (2) - 0x81, 0x06, // INPUT (Data,Var,Rel) - // ---------------------------- Vertical wheel - 0x09, 0x38, // USAGE (Wheel) - 0x15, 0x81, // LOGICAL_MINIMUM (-127) - 0x25, 0x7f, // LOGICAL_MAXIMUM (127) - 0x35, 0x00, // PHYSICAL_MINIMUM (0) - reset physical - 0x45, 0x00, // PHYSICAL_MAXIMUM (0) - 0x75, 0x08, // REPORT_SIZE (8) - 0x95, 0x01, // REPORT_COUNT (1) - 0x81, 0x06, // INPUT (Data,Var,Rel) - // ---------------------------- Horizontal wheel - 0x05, 0x0c, // USAGE_PAGE (Consumer Devices) - 0x0a, 0x38, 0x02, // USAGE (AC Pan) - 0x15, 0x81, // LOGICAL_MINIMUM (-127) - 0x25, 0x7f, // LOGICAL_MAXIMUM (127) - 0x75, 0x08, // REPORT_SIZE (8) - 0x95, 0x01, // REPORT_COUNT (1) - 0x81, 0x06, // INPUT (Data,Var,Rel) - 0xc0, // END_COLLECTION - 0xc0, // END_COLLECTION - /* system control */ - 0x05, 0x01, // USAGE_PAGE (Generic Desktop) - 0x09, 0x80, // USAGE (System Control) - 0xa1, 0x01, // COLLECTION (Application) - 0x85, REPORT_ID_SYSTEM, // REPORT_ID (2) - 0x15, 0x01, // LOGICAL_MINIMUM (0x1) - 0x26, 0xb7, 0x00, // LOGICAL_MAXIMUM (0xb7) - 0x19, 0x01, // USAGE_MINIMUM (0x1) - 0x29, 0xb7, // USAGE_MAXIMUM (0xb7) - 0x75, 0x10, // REPORT_SIZE (16) - 0x95, 0x01, // REPORT_COUNT (1) - 0x81, 0x00, // INPUT (Data,Array,Abs) - 0xc0, // END_COLLECTION - /* consumer */ - 0x05, 0x0c, // USAGE_PAGE (Consumer Devices) - 0x09, 0x01, // USAGE (Consumer Control) - 0xa1, 0x01, // COLLECTION (Application) - 0x85, REPORT_ID_CONSUMER, // REPORT_ID (3) - 0x15, 0x01, // LOGICAL_MINIMUM (0x1) - 0x26, 0x9c, 0x02, // LOGICAL_MAXIMUM (0x29c) - 0x19, 0x01, // USAGE_MINIMUM (0x1) - 0x2a, 0x9c, 0x02, // USAGE_MAXIMUM (0x29c) - 0x75, 0x10, // REPORT_SIZE (16) - 0x95, 0x01, // REPORT_COUNT (1) - 0x81, 0x00, // INPUT (Data,Array,Abs) - 0xc0, // END_COLLECTION + // Mouse report descriptor + 0x05, 0x01, // Usage Page (Generic Desktop) + 0x09, 0x02, // Usage (Mouse) + 0xA1, 0x01, // Collection (Application) + 0x85, REPORT_ID_MOUSE, // Report ID + 0x09, 0x01, // Usage (Pointer) + 0xA1, 0x00, // Collection (Physical) + // Buttons (5 bits) + 0x05, 0x09, // Usage Page (Button) + 0x19, 0x01, // Usage Minimum (Button 1) + 0x29, 0x05, // Usage Maximum (Button 5) + 0x15, 0x00, // Logical Minimum (0) + 0x25, 0x01, // Logical Maximum (1) + 0x95, 0x05, // Report Count (5) + 0x75, 0x01, // Report Size (1) + 0x81, 0x02, // Input (Data, Variable, Absolute) + // Button padding (3 bits) + 0x95, 0x01, // Report Count (1) + 0x75, 0x03, // Report Size (3) + 0x81, 0x03, // Input (Constant) + + // X/Y position (2 bytes) + 0x05, 0x01, // Usage Page (Generic Desktop) + 0x09, 0x30, // Usage (X) + 0x09, 0x31, // Usage (Y) + 0x15, 0x81, // Logical Minimum (-127) + 0x25, 0x7F, // Logical Maximum (127) + 0x95, 0x02, // Report Count (2) + 0x75, 0x08, // Report Size (8) + 0x81, 0x06, // Input (Data, Variable, Relative) + + // Vertical wheel (1 byte) + 0x09, 0x38, // Usage (Wheel) + 0x15, 0x81, // Logical Minimum (-127) + 0x25, 0x7F, // Logical Maximum (127) + 0x95, 0x01, // Report Count (1) + 0x75, 0x08, // Report Size (8) + 0x81, 0x06, // Input (Data, Variable, Relative) + // Horizontal wheel (1 byte) + 0x05, 0x0C, // Usage Page (Consumer) + 0x0A, 0x38, 0x02, // Usage (AC Pan) + 0x15, 0x81, // Logical Minimum (-127) + 0x25, 0x7F, // Logical Maximum (127) + 0x95, 0x01, // Report Count (1) + 0x75, 0x08, // Report Size (8) + 0x81, 0x06, // Input (Data, Variable, Relative) + 0xC0, // End Collection + 0xC0, // End Collection + +#ifdef EXTRAKEY_ENABLE + // Extrakeys report descriptor + 0x05, 0x01, // Usage Page (Generic Desktop) + 0x09, 0x80, // Usage (System Control) + 0xA1, 0x01, // Collection (Application) + 0x85, REPORT_ID_SYSTEM, // Report ID + 0x1A, 0x81, 0x00, // Usage Minimum (System Power Down) + 0x2A, 0x83, 0x00, // Usage Maximum (System Wake Up) + 0x16, 0x01, 0x00, // Logical Minimum + 0x26, 0x03, 0x00, // Logical Maximum + 0x95, 0x01, // Report Count (1) + 0x75, 0x10, // Report Size (16) + 0x81, 0x00, // Input (Data, Array, Absolute) + 0xC0, // End Collection + + 0x05, 0x0C, // Usage Page (Consumer) + 0x09, 0x01, // Usage (Consumer Control) + 0xA1, 0x01, // Collection (Application) + 0x85, REPORT_ID_CONSUMER, // Report ID + 0x1A, 0x01, 0x00, // Usage Minimum (Consumer Control) + 0x2A, 0x9C, 0x02, // Usage Maximum (AC Distribute Vertically) + 0x16, 0x01, 0x00, // Logical Minimum + 0x26, 0x9C, 0x02, // Logical Maximum + 0x95, 0x01, // Report Count (1) + 0x75, 0x10, // Report Size (16) + 0x81, 0x00, // Input (Data, Array, Absolute) + 0xC0 // End Collection +#endif }; #ifndef USB_MAX_POWER_CONSUMPTION |