diff options
| author | Ryan <fauxpark@gmail.com> | 2023-10-25 09:54:43 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-25 00:54:43 +0100 |
| commit | b7e62af755da6d35a1d44855b16651d9eed6f525 (patch) | |
| tree | 9c544c6603f9065298b8d4a97cc505d2c8f7b984 /tmk_core | |
| parent | 7e0147f8e6cebbf88a6f25c448cbd0246d3ab260 (diff) | |
V-USB: Implement `GET_PROTOCOL` and `SET_PROTOCOL` handling (#22324)
Diffstat (limited to 'tmk_core')
| -rw-r--r-- | tmk_core/protocol/vusb/vusb.c | 62 |
1 files changed, 38 insertions, 24 deletions
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c index d2c7749937..d7d2227687 100644 --- a/tmk_core/protocol/vusb/vusb.c +++ b/tmk_core/protocol/vusb/vusb.c | |||
| @@ -325,30 +325,44 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) { | |||
| 325 | usbRequest_t *rq = (void *)data; | 325 | usbRequest_t *rq = (void *)data; |
| 326 | 326 | ||
| 327 | if ((rq->bmRequestType & USBRQ_TYPE_MASK) == USBRQ_TYPE_CLASS) { /* class request type */ | 327 | if ((rq->bmRequestType & USBRQ_TYPE_MASK) == USBRQ_TYPE_CLASS) { /* class request type */ |
| 328 | if (rq->bRequest == USBRQ_HID_GET_REPORT) { | 328 | switch (rq->bRequest) { |
| 329 | dprint("GET_REPORT:"); | 329 | case USBRQ_HID_GET_REPORT: |
| 330 | if (rq->wIndex.word == KEYBOARD_INTERFACE) { | 330 | dprint("GET_REPORT:"); |
| 331 | usbMsgPtr = (usbMsgPtr_t)&keyboard_report_sent; | 331 | if (rq->wIndex.word == KEYBOARD_INTERFACE) { |
| 332 | return sizeof(keyboard_report_sent); | 332 | usbMsgPtr = (usbMsgPtr_t)&keyboard_report_sent; |
| 333 | } | 333 | return sizeof(keyboard_report_sent); |
| 334 | } else if (rq->bRequest == USBRQ_HID_GET_IDLE) { | 334 | } |
| 335 | dprint("GET_IDLE:"); | 335 | break; |
| 336 | usbMsgPtr = (usbMsgPtr_t)&vusb_idle_rate; | 336 | case USBRQ_HID_GET_IDLE: |
| 337 | return 1; | 337 | dprint("GET_IDLE:"); |
| 338 | } else if (rq->bRequest == USBRQ_HID_SET_IDLE) { | 338 | usbMsgPtr = (usbMsgPtr_t)&vusb_idle_rate; |
| 339 | vusb_idle_rate = rq->wValue.bytes[1]; | 339 | return 1; |
| 340 | dprintf("SET_IDLE: %02X", vusb_idle_rate); | 340 | case USBRQ_HID_GET_PROTOCOL: |
| 341 | } else if (rq->bRequest == USBRQ_HID_SET_REPORT) { | 341 | dprint("GET_PROTOCOL:"); |
| 342 | dprint("SET_REPORT:"); | 342 | usbMsgPtr = (usbMsgPtr_t)&keyboard_protocol; |
| 343 | // Report Type: 0x02(Out)/ReportID: 0x00(none) && Interface: 0(keyboard) | 343 | return 1; |
| 344 | if (rq->wValue.word == 0x0200 && rq->wIndex.word == KEYBOARD_INTERFACE) { | 344 | case USBRQ_HID_SET_REPORT: |
| 345 | dprint("SET_LED:"); | 345 | dprint("SET_REPORT:"); |
| 346 | last_req.kind = SET_LED; | 346 | // Report Type: 0x02(Out)/ReportID: 0x00(none) && Interface: 0(keyboard) |
| 347 | last_req.len = rq->wLength.word; | 347 | if (rq->wValue.word == 0x0200 && rq->wIndex.word == KEYBOARD_INTERFACE) { |
| 348 | } | 348 | dprint("SET_LED:"); |
| 349 | return USB_NO_MSG; // to get data in usbFunctionWrite | 349 | last_req.kind = SET_LED; |
| 350 | } else { | 350 | last_req.len = rq->wLength.word; |
| 351 | dprint("UNKNOWN:"); | 351 | } |
| 352 | return USB_NO_MSG; // to get data in usbFunctionWrite | ||
| 353 | case USBRQ_HID_SET_IDLE: | ||
| 354 | vusb_idle_rate = rq->wValue.bytes[1]; | ||
| 355 | dprintf("SET_IDLE: %02X", vusb_idle_rate); | ||
| 356 | break; | ||
| 357 | case USBRQ_HID_SET_PROTOCOL: | ||
| 358 | if (rq->wIndex.word == KEYBOARD_INTERFACE) { | ||
| 359 | keyboard_protocol = rq->wValue.word & 0xFF; | ||
| 360 | dprintf("SET_PROTOCOL: %02X", keyboard_protocol); | ||
| 361 | } | ||
| 362 | break; | ||
| 363 | default: | ||
| 364 | dprint("UNKNOWN:"); | ||
| 365 | break; | ||
| 352 | } | 366 | } |
| 353 | } else { | 367 | } else { |
| 354 | dprint("VENDOR:"); | 368 | dprint("VENDOR:"); |
