diff options
| author | Ryan <fauxpark@gmail.com> | 2020-02-25 12:18:11 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-25 12:18:11 +1100 |
| commit | 088b64ab3d598574244db5ac67fec889bdc58119 (patch) | |
| tree | 130709c89d516c3c91177ae0b310017c32b51ffb /tmk_core/protocol/vusb | |
| parent | ef8878fba5d3786e3f9c66436da63a560cd36ac9 (diff) | |
| download | qmk_firmware-088b64ab3d598574244db5ac67fec889bdc58119.tar.gz qmk_firmware-088b64ab3d598574244db5ac67fec889bdc58119.zip | |
Improvements to extrakey HID descriptors (#8156)
Diffstat (limited to 'tmk_core/protocol/vusb')
| -rw-r--r-- | tmk_core/protocol/vusb/vusb.c | 55 |
1 files changed, 37 insertions, 18 deletions
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c index 2d2e5ca5c..abf723952 100644 --- a/tmk_core/protocol/vusb/vusb.c +++ b/tmk_core/protocol/vusb/vusb.c | |||
| @@ -129,7 +129,7 @@ static void send_extra(uint8_t report_id, uint16_t data) { | |||
| 129 | 129 | ||
| 130 | static void send_system(uint16_t data) { | 130 | static void send_system(uint16_t data) { |
| 131 | #ifdef EXTRAKEY_ENABLE | 131 | #ifdef EXTRAKEY_ENABLE |
| 132 | send_extra(REPORT_ID_SYSTEM, data - SYSTEM_POWER_DOWN + 1); | 132 | send_extra(REPORT_ID_SYSTEM, data); |
| 133 | #endif | 133 | #endif |
| 134 | } | 134 | } |
| 135 | 135 | ||
| @@ -251,7 +251,9 @@ const PROGMEM uchar keyboard_hid_report[] = { | |||
| 251 | 0xC0 // End Collection | 251 | 0xC0 // End Collection |
| 252 | }; | 252 | }; |
| 253 | 253 | ||
| 254 | const PROGMEM uchar mouse_hid_report[] = { | 254 | #if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE) |
| 255 | const PROGMEM uchar mouse_extra_hid_report[] = { | ||
| 256 | # ifdef MOUSE_ENABLE | ||
| 255 | // Mouse report descriptor | 257 | // Mouse report descriptor |
| 256 | 0x05, 0x01, // Usage Page (Generic Desktop) | 258 | 0x05, 0x01, // Usage Page (Generic Desktop) |
| 257 | 0x09, 0x02, // Usage (Mouse) | 259 | 0x09, 0x02, // Usage (Mouse) |
| @@ -300,17 +302,18 @@ const PROGMEM uchar mouse_hid_report[] = { | |||
| 300 | 0x81, 0x06, // Input (Data, Variable, Relative) | 302 | 0x81, 0x06, // Input (Data, Variable, Relative) |
| 301 | 0xC0, // End Collection | 303 | 0xC0, // End Collection |
| 302 | 0xC0, // End Collection | 304 | 0xC0, // End Collection |
| 305 | # endif | ||
| 303 | 306 | ||
| 304 | #ifdef EXTRAKEY_ENABLE | 307 | # ifdef EXTRAKEY_ENABLE |
| 305 | // Extrakeys report descriptor | 308 | // Extrakeys report descriptor |
| 306 | 0x05, 0x01, // Usage Page (Generic Desktop) | 309 | 0x05, 0x01, // Usage Page (Generic Desktop) |
| 307 | 0x09, 0x80, // Usage (System Control) | 310 | 0x09, 0x80, // Usage (System Control) |
| 308 | 0xA1, 0x01, // Collection (Application) | 311 | 0xA1, 0x01, // Collection (Application) |
| 309 | 0x85, REPORT_ID_SYSTEM, // Report ID | 312 | 0x85, REPORT_ID_SYSTEM, // Report ID |
| 310 | 0x1A, 0x81, 0x00, // Usage Minimum (System Power Down) | 313 | 0x19, 0x01, // Usage Minimum (Pointer) |
| 311 | 0x2A, 0x83, 0x00, // Usage Maximum (System Wake Up) | 314 | 0x2A, 0xB7, 0x00, // Usage Maximum (System Display LCD Autoscale) |
| 312 | 0x16, 0x01, 0x00, // Logical Minimum | 315 | 0x15, 0x01, // Logical Minimum |
| 313 | 0x26, 0x03, 0x00, // Logical Maximum | 316 | 0x26, 0xB7, 0x00, // Logical Maximum |
| 314 | 0x95, 0x01, // Report Count (1) | 317 | 0x95, 0x01, // Report Count (1) |
| 315 | 0x75, 0x10, // Report Size (16) | 318 | 0x75, 0x10, // Report Size (16) |
| 316 | 0x81, 0x00, // Input (Data, Array, Absolute) | 319 | 0x81, 0x00, // Input (Data, Array, Absolute) |
| @@ -320,16 +323,17 @@ const PROGMEM uchar mouse_hid_report[] = { | |||
| 320 | 0x09, 0x01, // Usage (Consumer Control) | 323 | 0x09, 0x01, // Usage (Consumer Control) |
| 321 | 0xA1, 0x01, // Collection (Application) | 324 | 0xA1, 0x01, // Collection (Application) |
| 322 | 0x85, REPORT_ID_CONSUMER, // Report ID | 325 | 0x85, REPORT_ID_CONSUMER, // Report ID |
| 323 | 0x1A, 0x01, 0x00, // Usage Minimum (Consumer Control) | 326 | 0x19, 0x01, // Usage Minimum (Consumer Control) |
| 324 | 0x2A, 0x9C, 0x02, // Usage Maximum (AC Distribute Vertically) | 327 | 0x2A, 0xA0, 0x02, // Usage Maximum (AC Desktop Show All Applications) |
| 325 | 0x16, 0x01, 0x00, // Logical Minimum | 328 | 0x15, 0x01, // Logical Minimum |
| 326 | 0x26, 0x9C, 0x02, // Logical Maximum | 329 | 0x26, 0xA0, 0x02, // Logical Maximum |
| 327 | 0x95, 0x01, // Report Count (1) | 330 | 0x95, 0x01, // Report Count (1) |
| 328 | 0x75, 0x10, // Report Size (16) | 331 | 0x75, 0x10, // Report Size (16) |
| 329 | 0x81, 0x00, // Input (Data, Array, Absolute) | 332 | 0x81, 0x00, // Input (Data, Array, Absolute) |
| 330 | 0xC0 // End Collection | 333 | 0xC0 // End Collection |
| 331 | #endif | 334 | # endif |
| 332 | }; | 335 | }; |
| 336 | #endif | ||
| 333 | 337 | ||
| 334 | #ifndef USB_MAX_POWER_CONSUMPTION | 338 | #ifndef USB_MAX_POWER_CONSUMPTION |
| 335 | # define USB_MAX_POWER_CONSUMPTION 500 | 339 | # define USB_MAX_POWER_CONSUMPTION 500 |
| @@ -350,10 +354,19 @@ const PROGMEM char usbDescriptorConfiguration[] = { | |||
| 350 | /* USB configuration descriptor */ | 354 | /* USB configuration descriptor */ |
| 351 | 9, /* sizeof(usbDescriptorConfiguration): length of descriptor in bytes */ | 355 | 9, /* sizeof(usbDescriptorConfiguration): length of descriptor in bytes */ |
| 352 | USBDESCR_CONFIG, /* descriptor type */ | 356 | USBDESCR_CONFIG, /* descriptor type */ |
| 353 | 9 + (9 + 9 + 7) + (9 + 9 + 7), 0, | 357 | # if defined (MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE) |
| 358 | 59, // 9 + (9 + 9 + 7) + (9 + 9 + 7) | ||
| 359 | #else | ||
| 360 | 34, // 9 + (9 + 9 + 7) | ||
| 361 | # endif | ||
| 362 | 0, | ||
| 354 | // 18 + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT3 + 9, 0, | 363 | // 18 + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT3 + 9, 0, |
| 355 | /* total length of data returned (including inlined descriptors) */ | 364 | /* total length of data returned (including inlined descriptors) */ |
| 365 | # if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE) | ||
| 356 | 2, /* number of interfaces in this configuration */ | 366 | 2, /* number of interfaces in this configuration */ |
| 367 | # else | ||
| 368 | 1, | ||
| 369 | #endif | ||
| 357 | 1, /* index of this configuration */ | 370 | 1, /* index of this configuration */ |
| 358 | 0, /* configuration name string index */ | 371 | 0, /* configuration name string index */ |
| 359 | # if USB_CFG_IS_SELF_POWERED | 372 | # if USB_CFG_IS_SELF_POWERED |
| @@ -391,8 +404,9 @@ const PROGMEM char usbDescriptorConfiguration[] = { | |||
| 391 | USB_POLLING_INTERVAL_MS, /* in ms */ | 404 | USB_POLLING_INTERVAL_MS, /* in ms */ |
| 392 | # endif | 405 | # endif |
| 393 | 406 | ||
| 407 | # if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE) | ||
| 394 | /* | 408 | /* |
| 395 | * Mouse interface | 409 | * Mouse/extrakeys interface |
| 396 | */ | 410 | */ |
| 397 | /* Interface descriptor */ | 411 | /* Interface descriptor */ |
| 398 | 9, /* sizeof(usbDescrInterface): length of descriptor in bytes */ | 412 | 9, /* sizeof(usbDescrInterface): length of descriptor in bytes */ |
| @@ -411,8 +425,8 @@ const PROGMEM char usbDescriptorConfiguration[] = { | |||
| 411 | 0x00, /* target country code */ | 425 | 0x00, /* target country code */ |
| 412 | 0x01, /* number of HID Report (or other HID class) Descriptor infos to follow */ | 426 | 0x01, /* number of HID Report (or other HID class) Descriptor infos to follow */ |
| 413 | 0x22, /* descriptor type: report */ | 427 | 0x22, /* descriptor type: report */ |
| 414 | sizeof(mouse_hid_report), 0, /* total length of report descriptor */ | 428 | sizeof(mouse_extra_hid_report), 0, /* total length of report descriptor */ |
| 415 | # if USB_CFG_HAVE_INTRIN_ENDPOINT3 /* endpoint descriptor for endpoint 3 */ | 429 | # if USB_CFG_HAVE_INTRIN_ENDPOINT3 /* endpoint descriptor for endpoint 3 */ |
| 416 | /* Endpoint descriptor */ | 430 | /* Endpoint descriptor */ |
| 417 | 7, /* sizeof(usbDescrEndpoint) */ | 431 | 7, /* sizeof(usbDescrEndpoint) */ |
| 418 | USBDESCR_ENDPOINT, /* descriptor type = endpoint */ | 432 | USBDESCR_ENDPOINT, /* descriptor type = endpoint */ |
| @@ -420,6 +434,7 @@ const PROGMEM char usbDescriptorConfiguration[] = { | |||
| 420 | 0x03, /* attrib: Interrupt endpoint */ | 434 | 0x03, /* attrib: Interrupt endpoint */ |
| 421 | 8, 0, /* maximum packet size */ | 435 | 8, 0, /* maximum packet size */ |
| 422 | USB_POLLING_INTERVAL_MS, /* in ms */ | 436 | USB_POLLING_INTERVAL_MS, /* in ms */ |
| 437 | # endif | ||
| 423 | # endif | 438 | # endif |
| 424 | }; | 439 | }; |
| 425 | #endif | 440 | #endif |
| @@ -448,10 +463,12 @@ USB_PUBLIC usbMsgLen_t usbFunctionDescriptor(struct usbRequest *rq) { | |||
| 448 | usbMsgPtr = (unsigned char *)(usbDescriptorConfiguration + 9 + 9); | 463 | usbMsgPtr = (unsigned char *)(usbDescriptorConfiguration + 9 + 9); |
| 449 | len = 9; | 464 | len = 9; |
| 450 | break; | 465 | break; |
| 466 | #if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE) | ||
| 451 | case 1: | 467 | case 1: |
| 452 | usbMsgPtr = (unsigned char *)(usbDescriptorConfiguration + 9 + (9 + 9 + 7) + 9); | 468 | usbMsgPtr = (unsigned char *)(usbDescriptorConfiguration + 9 + (9 + 9 + 7) + 9); |
| 453 | len = 9; | 469 | len = 9; |
| 454 | break; | 470 | break; |
| 471 | #endif | ||
| 455 | } | 472 | } |
| 456 | break; | 473 | break; |
| 457 | case USBDESCR_HID_REPORT: | 474 | case USBDESCR_HID_REPORT: |
| @@ -461,10 +478,12 @@ USB_PUBLIC usbMsgLen_t usbFunctionDescriptor(struct usbRequest *rq) { | |||
| 461 | usbMsgPtr = (unsigned char *)keyboard_hid_report; | 478 | usbMsgPtr = (unsigned char *)keyboard_hid_report; |
| 462 | len = sizeof(keyboard_hid_report); | 479 | len = sizeof(keyboard_hid_report); |
| 463 | break; | 480 | break; |
| 481 | #if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE) | ||
| 464 | case 1: | 482 | case 1: |
| 465 | usbMsgPtr = (unsigned char *)mouse_hid_report; | 483 | usbMsgPtr = (unsigned char *)mouse_extra_hid_report; |
| 466 | len = sizeof(mouse_hid_report); | 484 | len = sizeof(mouse_extra_hid_report); |
| 467 | break; | 485 | break; |
| 486 | #endif | ||
| 468 | } | 487 | } |
| 469 | break; | 488 | break; |
| 470 | } | 489 | } |
