diff options
author | Ruslan Sayfutdinov <ruslan@sayfutdinov.com> | 2022-12-08 16:45:30 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-09 03:45:30 +1100 |
commit | 85ee55ff3becd29e1590376c3462c6a99c976fa0 (patch) | |
tree | 36ab093ee44919070ac260f8aaf2770871d14910 /tmk_core/protocol/chibios | |
parent | e06f50c489e02068465dfb3e5b3c7473006e6273 (diff) |
Detect host OS based on USB fingerprint (#18463)
Co-authored-by: Drashna Jaelre <drashna@live.com>
Co-authored-by: Nick Brassel <nick@tzarc.org>
Diffstat (limited to 'tmk_core/protocol/chibios')
-rw-r--r-- | tmk_core/protocol/chibios/usb_main.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index 094c14d1b3..5d36900bdd 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c @@ -111,9 +111,10 @@ uint8_t extra_report_blank[3] = {0}; static const USBDescriptor *usb_get_descriptor_cb(USBDriver *usbp, uint8_t dtype, uint8_t dindex, uint16_t wIndex) { (void)usbp; static USBDescriptor desc; - uint16_t wValue = ((uint16_t)dtype << 8) | dindex; - desc.ud_string = NULL; - desc.ud_size = get_usb_descriptor(wValue, wIndex, (const void **const) & desc.ud_string); + uint16_t wValue = ((uint16_t)dtype << 8) | dindex; + uint16_t wLength = ((uint16_t)usbp->setup[7] << 8) | usbp->setup[6]; + desc.ud_string = NULL; + desc.ud_size = get_usb_descriptor(wValue, wIndex, wLength, (const void **const) & desc.ud_string); if (desc.ud_string == NULL) return NULL; else @@ -585,7 +586,8 @@ static uint16_t get_hword(uint8_t *p) { */ static uint8_t set_report_buf[2] __attribute__((aligned(4))); -static void set_led_transfer_cb(USBDriver *usbp) { + +static void set_led_transfer_cb(USBDriver *usbp) { if (usbp->setup[6] == 2) { /* LSB(wLength) */ uint8_t report_id = set_report_buf[0]; if ((report_id == REPORT_ID_KEYBOARD) || (report_id == REPORT_ID_NKRO)) { |