summaryrefslogtreecommitdiff
path: root/tmk_core/protocol
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/protocol')
-rw-r--r--tmk_core/protocol/chibios/usb_main.c64
-rw-r--r--tmk_core/protocol/lufa/lufa.c2
-rw-r--r--tmk_core/protocol/usb_descriptor.c10
-rw-r--r--tmk_core/protocol/usb_descriptor.h2
-rw-r--r--tmk_core/protocol/vusb/vusb.c7
5 files changed, 64 insertions, 21 deletions
diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c
index 62a11faff7..47edd7cb8c 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
@@ -111,9 +123,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 +598,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)) {
@@ -614,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;
#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;
}
@@ -665,8 +697,7 @@ static bool usb_request_hook_cb(USBDriver *usbp) {
if ((usbp->setup[4] == KEYBOARD_INTERFACE) && (usbp->setup[5] == 0)) { /* wIndex */
keyboard_protocol = ((usbp->setup[2]) != 0x00); /* LSB(wValue) */
#ifdef NKRO_ENABLE
- keymap_config.nkro = !!keyboard_protocol;
- if (!keymap_config.nkro && keyboard_idle) {
+ if (!keyboard_protocol && keyboard_idle) {
#else /* NKRO_ENABLE */
if (keyboard_idle) {
#endif /* NKRO_ENABLE */
@@ -921,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();
}
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c
index 8f36e02b9a..99f7d31287 100644
--- a/tmk_core/protocol/lufa/lufa.c
+++ b/tmk_core/protocol/lufa/lufa.c
@@ -901,5 +901,5 @@ void protocol_post_task(void) {
}
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint16_t wIndex, const void **const DescriptorAddress) {
- return get_usb_descriptor(wValue, wIndex, DescriptorAddress);
+ return get_usb_descriptor(wValue, wIndex, USB_ControlRequest.wLength, DescriptorAddress);
}
diff --git a/tmk_core/protocol/usb_descriptor.c b/tmk_core/protocol/usb_descriptor.c
index 99c52952a0..5ab9e3ff4f 100644
--- a/tmk_core/protocol/usb_descriptor.c
+++ b/tmk_core/protocol/usb_descriptor.c
@@ -45,8 +45,9 @@
# include "joystick.h"
#endif
-// TODO: wb32 support defines ISO macro which breaks PRODUCT stringification
-#undef ISO
+#ifdef OS_DETECTION_ENABLE
+# include "os_detection.h"
+#endif
// clang-format off
@@ -1095,7 +1096,7 @@ const USB_Descriptor_String_t PROGMEM SerialNumberString = {
* is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the
* USB host.
*/
-uint16_t get_usb_descriptor(const uint16_t wValue, const uint16_t wIndex, const void** const DescriptorAddress) {
+uint16_t get_usb_descriptor(const uint16_t wValue, const uint16_t wIndex, const uint16_t wLength, const void** const DescriptorAddress) {
const uint8_t DescriptorType = (wValue >> 8);
const uint8_t DescriptorIndex = (wValue & 0xFF);
const void* Address = NULL;
@@ -1137,6 +1138,9 @@ uint16_t get_usb_descriptor(const uint16_t wValue, const uint16_t wIndex, const
break;
#endif
}
+#ifdef OS_DETECTION_ENABLE
+ process_wlength(wLength);
+#endif
break;
case HID_DTYPE_HID:
diff --git a/tmk_core/protocol/usb_descriptor.h b/tmk_core/protocol/usb_descriptor.h
index bc5e84e586..ed84f4c9ab 100644
--- a/tmk_core/protocol/usb_descriptor.h
+++ b/tmk_core/protocol/usb_descriptor.h
@@ -308,4 +308,4 @@ enum usb_endpoints {
#define JOYSTICK_EPSIZE 8
#define DIGITIZER_EPSIZE 8
-uint16_t get_usb_descriptor(const uint16_t wValue, const uint16_t wIndex, const void** const DescriptorAddress);
+uint16_t get_usb_descriptor(const uint16_t wValue, const uint16_t wIndex, const uint16_t wLength, const void** const DescriptorAddress);
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c
index 2d17761978..b3eeff9e01 100644
--- a/tmk_core/protocol/vusb/vusb.c
+++ b/tmk_core/protocol/vusb/vusb.c
@@ -44,6 +44,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# include "ring_buffer.h"
#endif
+#ifdef OS_DETECTION_ENABLE
+# include "os_detection.h"
+#endif
+
#define NEXT_INTERFACE __COUNTER__
/*
@@ -1013,6 +1017,9 @@ USB_PUBLIC usbMsgLen_t usbFunctionDescriptor(struct usbRequest *rq) {
break;
#endif
}
+#ifdef OS_DETECTION_ENABLE
+ process_wlength(rq->wLength.word);
+#endif
break;
case USBDESCR_HID:
switch (rq->wValue.bytes[0]) {