summaryrefslogtreecommitdiff
path: root/tmk_core
diff options
context:
space:
mode:
authorJack Humbert <jack.humb@gmail.com>2022-12-08 12:08:36 -0500
committerGitHub <noreply@github.com>2022-12-09 04:08:36 +1100
commita23333eb586943c94dc9ab2d69cecc1c2ffc8e8e (patch)
treeaca445d5fb0570281ca9954fd327d512e63edede /tmk_core
parentdd93b17e963d4bf377407bc2a77790ab9ab996d5 (diff)
Return USB HID GET_REPORT requests (#14814)
Co-authored-by: Sergey Vlasov <sigprof@gmail.com> Co-authored-by: Nick Brassel <nick@tzarc.org>
Diffstat (limited to 'tmk_core')
-rw-r--r--tmk_core/protocol/chibios/usb_main.c55
1 files changed, 43 insertions, 12 deletions
diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c
index 5d36900bdd..3ffea0a712 100644
--- a/tmk_core/protocol/chibios/usb_main.c
+++ b/tmk_core/protocol/chibios/usb_main.c
@@ -76,12 +76,24 @@ static void keyboard_idle_timer_cb(void *arg);
#endif
report_keyboard_t keyboard_report_sent = {{0}};
-#ifdef MOUSE_ENABLE
-report_mouse_t mouse_report_blank = {0};
-#endif /* MOUSE_ENABLE */
+report_mouse_t mouse_report_sent = {0};
+
+union {
+ uint8_t report_id;
+ report_keyboard_t keyboard;
#ifdef EXTRAKEY_ENABLE
-uint8_t extra_report_blank[3] = {0};
-#endif /* EXTRAKEY_ENABLE */
+ report_extra_t extra;
+#endif
+#ifdef MOUSE_ENABLE
+ report_mouse_t mouse;
+#endif
+#ifdef DIGITIZER_ENABLE
+ report_digitizer_t digitizer;
+#endif
+#ifdef JOYSTICK_ENABLE
+ joystick_report_t joystick;
+#endif
+} universal_report_blank = {0};
/* ---------------------------------------------------------
* Descriptors and USB driver objects
@@ -114,7 +126,7 @@ static const USBDescriptor *usb_get_descriptor_cb(USBDriver *usbp, uint8_t dtype
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);
+ desc.ud_size = get_usb_descriptor(wValue, wIndex, wLength, (const void **const)&desc.ud_string);
if (desc.ud_string == NULL)
return NULL;
else
@@ -616,20 +628,38 @@ static bool usb_request_hook_cb(USBDriver *usbp) {
switch (usbp->setup[1]) { /* bRequest */
case HID_GET_REPORT:
switch (usbp->setup[4]) { /* LSB(wIndex) (check MSB==0?) */
+#ifndef KEYBOARD_SHARED_EP
case KEYBOARD_INTERFACE:
- usbSetupTransfer(usbp, (uint8_t *)&keyboard_report_sent, sizeof(keyboard_report_sent), NULL);
+ usbSetupTransfer(usbp, (uint8_t *)&keyboard_report_sent, KEYBOARD_REPORT_SIZE, NULL);
return TRUE;
break;
-
+#endif
#if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP)
case MOUSE_INTERFACE:
- usbSetupTransfer(usbp, (uint8_t *)&mouse_report_blank, sizeof(mouse_report_blank), NULL);
+ usbSetupTransfer(usbp, (uint8_t *)&mouse_report_sent, sizeof(mouse_report_sent), NULL);
return TRUE;
- break;
+ break;
#endif
-
+#ifdef SHARED_EP_ENABLE
+ case SHARED_INTERFACE:
+# ifdef KEYBOARD_SHARED_EP
+ if (usbp->setup[2] == REPORT_ID_KEYBOARD) {
+ usbSetupTransfer(usbp, (uint8_t *)&keyboard_report_sent, KEYBOARD_REPORT_SIZE, NULL);
+ return TRUE;
+ break;
+ }
+# endif
+# ifdef MOUSE_SHARED_EP
+ if (usbp->setup[2] == REPORT_ID_MOUSE) {
+ usbSetupTransfer(usbp, (uint8_t *)&mouse_report_sent, sizeof(mouse_report_sent), NULL);
+ return TRUE;
+ break;
+ }
+# endif
+#endif /* SHARED_EP_ENABLE */
default:
- usbSetupTransfer(usbp, NULL, 0, NULL);
+ universal_report_blank.report_id = usbp->setup[2];
+ usbSetupTransfer(usbp, (uint8_t *)&universal_report_blank, usbp->setup[6], NULL);
return TRUE;
break;
}
@@ -922,6 +952,7 @@ void send_mouse(report_mouse_t *report) {
}
}
usbStartTransmitI(&USB_DRIVER, MOUSE_IN_EPNUM, (uint8_t *)report, sizeof(report_mouse_t));
+ mouse_report_sent = *report;
osalSysUnlock();
}