diff options
| -rw-r--r-- | builddefs/common_features.mk | 5 | ||||
| -rw-r--r-- | drivers/bluetooth/bluetooth.c | 2 | ||||
| -rw-r--r-- | drivers/bluetooth/bluetooth.h | 8 | ||||
| -rw-r--r-- | quantum/raw_hid.c | 15 | ||||
| -rw-r--r-- | tmk_core/protocol.mk | 4 | ||||
| -rw-r--r-- | tmk_core/protocol/chibios/chibios.c | 12 | ||||
| -rw-r--r-- | tmk_core/protocol/chibios/usb_main.c | 12 | ||||
| -rw-r--r-- | tmk_core/protocol/host.c | 12 | ||||
| -rw-r--r-- | tmk_core/protocol/host.h | 1 | ||||
| -rw-r--r-- | tmk_core/protocol/host_driver.h | 3 | ||||
| -rw-r--r-- | tmk_core/protocol/lufa/lufa.c | 35 | ||||
| -rw-r--r-- | tmk_core/protocol/vusb/vusb.c | 22 |
12 files changed, 95 insertions, 36 deletions
diff --git a/builddefs/common_features.mk b/builddefs/common_features.mk index f62b925817..3d01be8205 100644 --- a/builddefs/common_features.mk +++ b/builddefs/common_features.mk | |||
| @@ -643,6 +643,11 @@ ifeq ($(strip $(VIA_ENABLE)), yes) | |||
| 643 | TRI_LAYER_ENABLE := yes | 643 | TRI_LAYER_ENABLE := yes |
| 644 | endif | 644 | endif |
| 645 | 645 | ||
| 646 | ifeq ($(strip $(RAW_ENABLE)), yes) | ||
| 647 | OPT_DEFS += -DRAW_ENABLE | ||
| 648 | SRC += raw_hid.c | ||
| 649 | endif | ||
| 650 | |||
| 646 | ifeq ($(strip $(DYNAMIC_KEYMAP_ENABLE)), yes) | 651 | ifeq ($(strip $(DYNAMIC_KEYMAP_ENABLE)), yes) |
| 647 | SEND_STRING_ENABLE := yes | 652 | SEND_STRING_ENABLE := yes |
| 648 | endif | 653 | endif |
diff --git a/drivers/bluetooth/bluetooth.c b/drivers/bluetooth/bluetooth.c index 61a3f0f32a..e61e24e1f2 100644 --- a/drivers/bluetooth/bluetooth.c +++ b/drivers/bluetooth/bluetooth.c | |||
| @@ -28,3 +28,5 @@ __attribute__((weak)) void bluetooth_send_mouse(report_mouse_t *report) {} | |||
| 28 | __attribute__((weak)) void bluetooth_send_consumer(uint16_t usage) {} | 28 | __attribute__((weak)) void bluetooth_send_consumer(uint16_t usage) {} |
| 29 | 29 | ||
| 30 | __attribute__((weak)) void bluetooth_send_system(uint16_t usage) {} | 30 | __attribute__((weak)) void bluetooth_send_system(uint16_t usage) {} |
| 31 | |||
| 32 | __attribute__((weak)) void bluetooth_send_raw_hid(uint8_t *data, uint8_t length) {} | ||
diff --git a/drivers/bluetooth/bluetooth.h b/drivers/bluetooth/bluetooth.h index e50b588db2..bbd41a9194 100644 --- a/drivers/bluetooth/bluetooth.h +++ b/drivers/bluetooth/bluetooth.h | |||
| @@ -81,3 +81,11 @@ void bluetooth_send_consumer(uint16_t usage); | |||
| 81 | * \param usage The system usage to send. | 81 | * \param usage The system usage to send. |
| 82 | */ | 82 | */ |
| 83 | void bluetooth_send_system(uint16_t usage); | 83 | void bluetooth_send_system(uint16_t usage); |
| 84 | |||
| 85 | /** | ||
| 86 | * \brief Send a raw_hid packet. | ||
| 87 | * | ||
| 88 | * \param data A pointer to the buffer to be sent. Always 32 bytes in length. | ||
| 89 | * \param length The length of the buffer. Always 32. | ||
| 90 | */ | ||
| 91 | void bluetooth_send_raw_hid(uint8_t *data, uint8_t length); | ||
diff --git a/quantum/raw_hid.c b/quantum/raw_hid.c new file mode 100644 index 0000000000..2c7a75f325 --- /dev/null +++ b/quantum/raw_hid.c | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | // Copyright 2025 QMK | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include "raw_hid.h" | ||
| 5 | #include "host.h" | ||
| 6 | |||
| 7 | void raw_hid_send(uint8_t *data, uint8_t length) { | ||
| 8 | host_raw_hid_send(data, length); | ||
| 9 | } | ||
| 10 | |||
| 11 | __attribute__((weak)) void raw_hid_receive(uint8_t *data, uint8_t length) { | ||
| 12 | // Users should #include "raw_hid.h" in their own code | ||
| 13 | // and implement this function there. Leave this as weak linkage | ||
| 14 | // so users can opt to not handle data coming in. | ||
| 15 | } | ||
diff --git a/tmk_core/protocol.mk b/tmk_core/protocol.mk index 2930efc283..81520c1bc8 100644 --- a/tmk_core/protocol.mk +++ b/tmk_core/protocol.mk | |||
| @@ -33,10 +33,6 @@ ifeq ($(strip $(PROGRAMMABLE_BUTTON_ENABLE)), yes) | |||
| 33 | SHARED_EP_ENABLE = yes | 33 | SHARED_EP_ENABLE = yes |
| 34 | endif | 34 | endif |
| 35 | 35 | ||
| 36 | ifeq ($(strip $(RAW_ENABLE)), yes) | ||
| 37 | OPT_DEFS += -DRAW_ENABLE | ||
| 38 | endif | ||
| 39 | |||
| 40 | ifeq ($(strip $(CONSOLE_ENABLE)), yes) | 36 | ifeq ($(strip $(CONSOLE_ENABLE)), yes) |
| 41 | OPT_DEFS += -DCONSOLE_ENABLE | 37 | OPT_DEFS += -DCONSOLE_ENABLE |
| 42 | else | 38 | else |
diff --git a/tmk_core/protocol/chibios/chibios.c b/tmk_core/protocol/chibios/chibios.c index d752f3746b..19d8121e34 100644 --- a/tmk_core/protocol/chibios/chibios.c +++ b/tmk_core/protocol/chibios/chibios.c | |||
| @@ -66,9 +66,19 @@ void send_keyboard(report_keyboard_t *report); | |||
| 66 | void send_nkro(report_nkro_t *report); | 66 | void send_nkro(report_nkro_t *report); |
| 67 | void send_mouse(report_mouse_t *report); | 67 | void send_mouse(report_mouse_t *report); |
| 68 | void send_extra(report_extra_t *report); | 68 | void send_extra(report_extra_t *report); |
| 69 | void send_raw_hid(uint8_t *data, uint8_t length); | ||
| 69 | 70 | ||
| 70 | /* host struct */ | 71 | /* host struct */ |
| 71 | host_driver_t chibios_driver = {.keyboard_leds = usb_device_state_get_leds, .send_keyboard = send_keyboard, .send_nkro = send_nkro, .send_mouse = send_mouse, .send_extra = send_extra}; | 72 | host_driver_t chibios_driver = { |
| 73 | .keyboard_leds = usb_device_state_get_leds, | ||
| 74 | .send_keyboard = send_keyboard, | ||
| 75 | .send_nkro = send_nkro, | ||
| 76 | .send_mouse = send_mouse, | ||
| 77 | .send_extra = send_extra, | ||
| 78 | #ifdef RAW_ENABLE | ||
| 79 | .send_raw_hid = send_raw_hid, | ||
| 80 | #endif | ||
| 81 | }; | ||
| 72 | 82 | ||
| 73 | #ifdef VIRTSER_ENABLE | 83 | #ifdef VIRTSER_ENABLE |
| 74 | void virtser_task(void); | 84 | void virtser_task(void); |
diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index 5a5354416f..f9d7f5c4d6 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c | |||
| @@ -32,6 +32,10 @@ | |||
| 32 | #include "usb_driver.h" | 32 | #include "usb_driver.h" |
| 33 | #include "usb_types.h" | 33 | #include "usb_types.h" |
| 34 | 34 | ||
| 35 | #ifdef RAW_ENABLE | ||
| 36 | # include "raw_hid.h" | ||
| 37 | #endif | ||
| 38 | |||
| 35 | #ifdef NKRO_ENABLE | 39 | #ifdef NKRO_ENABLE |
| 36 | # include "keycode_config.h" | 40 | # include "keycode_config.h" |
| 37 | 41 | ||
| @@ -515,19 +519,13 @@ void console_task(void) { | |||
| 515 | #endif /* CONSOLE_ENABLE */ | 519 | #endif /* CONSOLE_ENABLE */ |
| 516 | 520 | ||
| 517 | #ifdef RAW_ENABLE | 521 | #ifdef RAW_ENABLE |
| 518 | void raw_hid_send(uint8_t *data, uint8_t length) { | 522 | void send_raw_hid(uint8_t *data, uint8_t length) { |
| 519 | if (length != RAW_EPSIZE) { | 523 | if (length != RAW_EPSIZE) { |
| 520 | return; | 524 | return; |
| 521 | } | 525 | } |
| 522 | send_report(USB_ENDPOINT_IN_RAW, data, length); | 526 | send_report(USB_ENDPOINT_IN_RAW, data, length); |
| 523 | } | 527 | } |
| 524 | 528 | ||
| 525 | __attribute__((weak)) void raw_hid_receive(uint8_t *data, uint8_t length) { | ||
| 526 | // Users should #include "raw_hid.h" in their own code | ||
| 527 | // and implement this function there. Leave this as weak linkage | ||
| 528 | // so users can opt to not handle data coming in. | ||
| 529 | } | ||
| 530 | |||
| 531 | void raw_hid_task(void) { | 529 | void raw_hid_task(void) { |
| 532 | uint8_t buffer[RAW_EPSIZE]; | 530 | uint8_t buffer[RAW_EPSIZE]; |
| 533 | while (receive_report(USB_ENDPOINT_OUT_RAW, buffer, sizeof(buffer))) { | 531 | while (receive_report(USB_ENDPOINT_OUT_RAW, buffer, sizeof(buffer))) { |
diff --git a/tmk_core/protocol/host.c b/tmk_core/protocol/host.c index e785cb24cc..4874d7c1d3 100644 --- a/tmk_core/protocol/host.c +++ b/tmk_core/protocol/host.c | |||
| @@ -55,6 +55,9 @@ host_driver_t bt_driver = { | |||
| 55 | .send_nkro = bluetooth_send_nkro, | 55 | .send_nkro = bluetooth_send_nkro, |
| 56 | .send_mouse = bluetooth_send_mouse, | 56 | .send_mouse = bluetooth_send_mouse, |
| 57 | .send_extra = bluetooth_send_extra, | 57 | .send_extra = bluetooth_send_extra, |
| 58 | # ifdef RAW_ENABLE | ||
| 59 | .send_raw_hid = bluetooth_send_raw_hid, | ||
| 60 | # endif | ||
| 58 | }; | 61 | }; |
| 59 | #endif | 62 | #endif |
| 60 | 63 | ||
| @@ -299,6 +302,15 @@ void host_programmable_button_send(uint32_t data) { | |||
| 299 | 302 | ||
| 300 | __attribute__((weak)) void send_programmable_button(report_programmable_button_t *report) {} | 303 | __attribute__((weak)) void send_programmable_button(report_programmable_button_t *report) {} |
| 301 | 304 | ||
| 305 | #ifdef RAW_ENABLE | ||
| 306 | void host_raw_hid_send(uint8_t *data, uint8_t length) { | ||
| 307 | host_driver_t *driver = host_get_active_driver(); | ||
| 308 | if (!driver || !driver->send_raw_hid) return; | ||
| 309 | |||
| 310 | (*driver->send_raw_hid)(data, length); | ||
| 311 | } | ||
| 312 | #endif | ||
| 313 | |||
| 302 | uint16_t host_last_system_usage(void) { | 314 | uint16_t host_last_system_usage(void) { |
| 303 | return last_system_usage; | 315 | return last_system_usage; |
| 304 | } | 316 | } |
diff --git a/tmk_core/protocol/host.h b/tmk_core/protocol/host.h index 8e8a18e2ed..a0b1e73dcc 100644 --- a/tmk_core/protocol/host.h +++ b/tmk_core/protocol/host.h | |||
| @@ -41,6 +41,7 @@ void host_mouse_send(report_mouse_t *report); | |||
| 41 | void host_system_send(uint16_t usage); | 41 | void host_system_send(uint16_t usage); |
| 42 | void host_consumer_send(uint16_t usage); | 42 | void host_consumer_send(uint16_t usage); |
| 43 | void host_programmable_button_send(uint32_t data); | 43 | void host_programmable_button_send(uint32_t data); |
| 44 | void host_raw_hid_send(uint8_t *data, uint8_t length); | ||
| 44 | 45 | ||
| 45 | uint16_t host_last_system_usage(void); | 46 | uint16_t host_last_system_usage(void); |
| 46 | uint16_t host_last_consumer_usage(void); | 47 | uint16_t host_last_consumer_usage(void); |
diff --git a/tmk_core/protocol/host_driver.h b/tmk_core/protocol/host_driver.h index 8aa38b6dee..c2835aaa99 100644 --- a/tmk_core/protocol/host_driver.h +++ b/tmk_core/protocol/host_driver.h | |||
| @@ -29,6 +29,9 @@ typedef struct { | |||
| 29 | void (*send_nkro)(report_nkro_t *); | 29 | void (*send_nkro)(report_nkro_t *); |
| 30 | void (*send_mouse)(report_mouse_t *); | 30 | void (*send_mouse)(report_mouse_t *); |
| 31 | void (*send_extra)(report_extra_t *); | 31 | void (*send_extra)(report_extra_t *); |
| 32 | #ifdef RAW_ENABLE | ||
| 33 | void (*send_raw_hid)(uint8_t *, uint8_t); | ||
| 34 | #endif | ||
| 32 | } host_driver_t; | 35 | } host_driver_t; |
| 33 | 36 | ||
| 34 | void send_joystick(report_joystick_t *report); | 37 | void send_joystick(report_joystick_t *report); |
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 81da035f0c..d59468133c 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c | |||
| @@ -75,11 +75,24 @@ | |||
| 75 | static report_keyboard_t keyboard_report_sent; | 75 | static report_keyboard_t keyboard_report_sent; |
| 76 | 76 | ||
| 77 | /* Host driver */ | 77 | /* Host driver */ |
| 78 | static void send_keyboard(report_keyboard_t *report); | 78 | static void send_keyboard(report_keyboard_t *report); |
| 79 | static void send_nkro(report_nkro_t *report); | 79 | static void send_nkro(report_nkro_t *report); |
| 80 | static void send_mouse(report_mouse_t *report); | 80 | static void send_mouse(report_mouse_t *report); |
| 81 | static void send_extra(report_extra_t *report); | 81 | static void send_extra(report_extra_t *report); |
| 82 | host_driver_t lufa_driver = {.keyboard_leds = usb_device_state_get_leds, .send_keyboard = send_keyboard, .send_nkro = send_nkro, .send_mouse = send_mouse, .send_extra = send_extra}; | 82 | #ifdef RAW_ENABLE |
| 83 | static void send_raw_hid(uint8_t *data, uint8_t length); | ||
| 84 | #endif | ||
| 85 | |||
| 86 | host_driver_t lufa_driver = { | ||
| 87 | .keyboard_leds = usb_device_state_get_leds, | ||
| 88 | .send_keyboard = send_keyboard, | ||
| 89 | .send_nkro = send_nkro, | ||
| 90 | .send_mouse = send_mouse, | ||
| 91 | .send_extra = send_extra, | ||
| 92 | #ifdef RAW_ENABLE | ||
| 93 | .send_raw_hid = send_raw_hid, | ||
| 94 | #endif | ||
| 95 | }; | ||
| 83 | 96 | ||
| 84 | void send_report(uint8_t endpoint, void *report, size_t size) { | 97 | void send_report(uint8_t endpoint, void *report, size_t size) { |
| 85 | uint8_t timeout = 255; | 98 | uint8_t timeout = 255; |
| @@ -131,21 +144,11 @@ USB_ClassInfo_CDC_Device_t cdc_device = { | |||
| 131 | * | 144 | * |
| 132 | * FIXME: Needs doc | 145 | * FIXME: Needs doc |
| 133 | */ | 146 | */ |
| 134 | void raw_hid_send(uint8_t *data, uint8_t length) { | 147 | static void send_raw_hid(uint8_t *data, uint8_t length) { |
| 135 | if (length != RAW_EPSIZE) return; | 148 | if (length != RAW_EPSIZE) return; |
| 136 | send_report(RAW_IN_EPNUM, data, RAW_EPSIZE); | 149 | send_report(RAW_IN_EPNUM, data, RAW_EPSIZE); |
| 137 | } | 150 | } |
| 138 | 151 | ||
| 139 | /** \brief Raw HID Receive | ||
| 140 | * | ||
| 141 | * FIXME: Needs doc | ||
| 142 | */ | ||
| 143 | __attribute__((weak)) void raw_hid_receive(uint8_t *data, uint8_t length) { | ||
| 144 | // Users should #include "raw_hid.h" in their own code | ||
| 145 | // and implement this function there. Leave this as weak linkage | ||
| 146 | // so users can opt to not handle data coming in. | ||
| 147 | } | ||
| 148 | |||
| 149 | /** \brief Raw HID Task | 152 | /** \brief Raw HID Task |
| 150 | * | 153 | * |
| 151 | * FIXME: Needs doc | 154 | * FIXME: Needs doc |
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c index 56cf82e5a6..43cce6eb2f 100644 --- a/tmk_core/protocol/vusb/vusb.c +++ b/tmk_core/protocol/vusb/vusb.c | |||
| @@ -144,7 +144,7 @@ static void send_report(uint8_t endpoint, void *report, size_t size) { | |||
| 144 | static uint8_t raw_output_buffer[RAW_BUFFER_SIZE]; | 144 | static uint8_t raw_output_buffer[RAW_BUFFER_SIZE]; |
| 145 | static uint8_t raw_output_received_bytes = 0; | 145 | static uint8_t raw_output_received_bytes = 0; |
| 146 | 146 | ||
| 147 | void raw_hid_send(uint8_t *data, uint8_t length) { | 147 | static void send_raw_hid(uint8_t *data, uint8_t length) { |
| 148 | if (length != RAW_BUFFER_SIZE) { | 148 | if (length != RAW_BUFFER_SIZE) { |
| 149 | return; | 149 | return; |
| 150 | } | 150 | } |
| @@ -152,12 +152,6 @@ void raw_hid_send(uint8_t *data, uint8_t length) { | |||
| 152 | send_report(4, data, 32); | 152 | send_report(4, data, 32); |
| 153 | } | 153 | } |
| 154 | 154 | ||
| 155 | __attribute__((weak)) void raw_hid_receive(uint8_t *data, uint8_t length) { | ||
| 156 | // Users should #include "raw_hid.h" in their own code | ||
| 157 | // and implement this function there. Leave this as weak linkage | ||
| 158 | // so users can opt to not handle data coming in. | ||
| 159 | } | ||
| 160 | |||
| 161 | void raw_hid_task(void) { | 155 | void raw_hid_task(void) { |
| 162 | usbPoll(); | 156 | usbPoll(); |
| 163 | 157 | ||
| @@ -213,8 +207,20 @@ static void send_keyboard(report_keyboard_t *report); | |||
| 213 | static void send_nkro(report_nkro_t *report); | 207 | static void send_nkro(report_nkro_t *report); |
| 214 | static void send_mouse(report_mouse_t *report); | 208 | static void send_mouse(report_mouse_t *report); |
| 215 | static void send_extra(report_extra_t *report); | 209 | static void send_extra(report_extra_t *report); |
| 210 | #ifdef RAW_ENABLE | ||
| 211 | static void send_raw_hid(uint8_t *data, uint8_t length); | ||
| 212 | #endif | ||
| 216 | 213 | ||
| 217 | static host_driver_t driver = {.keyboard_leds = usb_device_state_get_leds, .send_keyboard = send_keyboard, .send_nkro = send_nkro, .send_mouse = send_mouse, .send_extra = send_extra}; | 214 | static host_driver_t driver = { |
| 215 | .keyboard_leds = usb_device_state_get_leds, | ||
| 216 | .send_keyboard = send_keyboard, | ||
| 217 | .send_nkro = send_nkro, | ||
| 218 | .send_mouse = send_mouse, | ||
| 219 | .send_extra = send_extra, | ||
| 220 | #ifdef RAW_ENABLE | ||
| 221 | .send_raw_hid = send_raw_hid, | ||
| 222 | #endif | ||
| 223 | }; | ||
| 218 | 224 | ||
| 219 | host_driver_t *vusb_driver(void) { | 225 | host_driver_t *vusb_driver(void) { |
| 220 | return &driver; | 226 | return &driver; |
