summaryrefslogtreecommitdiffstats
path: root/tmk_core
diff options
context:
space:
mode:
authorRyan <fauxpark@gmail.com>2022-09-03 05:38:27 +1000
committerGitHub <noreply@github.com>2022-09-02 20:38:27 +0100
commit09d668eb0ed3ff6fa48ce1db98910b022bca2d90 (patch)
treeda13eca69e7e24e439c4bccdd1296fc4de212085 /tmk_core
parent0ceaaaae8e71f4713d232ac1b657906f4a45833f (diff)
Simplify extrakeys sending at the host driver level (#18230)
* Simplify extrakeys sending at the host driver level * There are two arguments here * Wrong syntax * Adjust keyboards which use a custom host driver
Diffstat (limited to 'tmk_core')
-rw-r--r--tmk_core/protocol/arm_atsam/main_arm_atsam.c17
-rw-r--r--tmk_core/protocol/chibios/chibios.c5
-rw-r--r--tmk_core/protocol/chibios/usb_main.c14
-rw-r--r--tmk_core/protocol/host.c4
-rw-r--r--tmk_core/protocol/host_driver.h5
-rw-r--r--tmk_core/protocol/lufa/lufa.c35
-rw-r--r--tmk_core/protocol/vusb/vusb.c17
7 files changed, 18 insertions, 79 deletions
diff --git a/tmk_core/protocol/arm_atsam/main_arm_atsam.c b/tmk_core/protocol/arm_atsam/main_arm_atsam.c
index 8ee9e042e7..a2f20db66e 100644
--- a/tmk_core/protocol/arm_atsam/main_arm_atsam.c
+++ b/tmk_core/protocol/arm_atsam/main_arm_atsam.c
@@ -37,14 +37,13 @@ void main_subtasks(void);
uint8_t keyboard_leds(void);
void send_keyboard(report_keyboard_t *report);
void send_mouse(report_mouse_t *report);
-void send_system(uint16_t data);
-void send_consumer(uint16_t data);
+void send_extra(uint8_t report_id, uint16_t data);
#ifdef DEFERRED_EXEC_ENABLE
void deferred_exec_task(void);
#endif // DEFERRED_EXEC_ENABLE
-host_driver_t arm_atsam_driver = {keyboard_leds, send_keyboard, send_mouse, send_system, send_consumer};
+host_driver_t arm_atsam_driver = {keyboard_leds, send_keyboard, send_mouse, send_extra};
uint8_t led_states;
@@ -132,18 +131,6 @@ void send_extra(uint8_t report_id, uint16_t data) {
}
#endif // EXTRAKEY_ENABLE
-void send_system(uint16_t data) {
-#ifdef EXTRAKEY_ENABLE
- send_extra(REPORT_ID_SYSTEM, data);
-#endif // EXTRAKEY_ENABLE
-}
-
-void send_consumer(uint16_t data) {
-#ifdef EXTRAKEY_ENABLE
- send_extra(REPORT_ID_CONSUMER, data);
-#endif // EXTRAKEY_ENABLE
-}
-
#ifdef CONSOLE_ENABLE
# define CONSOLE_PRINTBUF_SIZE 512
static char console_printbuf[CONSOLE_PRINTBUF_SIZE];
diff --git a/tmk_core/protocol/chibios/chibios.c b/tmk_core/protocol/chibios/chibios.c
index c9a480c325..024160a925 100644
--- a/tmk_core/protocol/chibios/chibios.c
+++ b/tmk_core/protocol/chibios/chibios.c
@@ -58,13 +58,12 @@
uint8_t keyboard_leds(void);
void send_keyboard(report_keyboard_t *report);
void send_mouse(report_mouse_t *report);
-void send_system(uint16_t data);
-void send_consumer(uint16_t data);
+void send_extra(uint8_t report_id, uint16_t data);
void send_programmable_button(uint32_t data);
void send_digitizer(report_digitizer_t *report);
/* host struct */
-host_driver_t chibios_driver = {keyboard_leds, send_keyboard, send_mouse, send_system, send_consumer, send_programmable_button};
+host_driver_t chibios_driver = {keyboard_leds, send_keyboard, send_mouse, send_extra, send_programmable_button};
#ifdef VIRTSER_ENABLE
void virtser_task(void);
diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c
index eb9ef82554..d218deb6f9 100644
--- a/tmk_core/protocol/chibios/usb_main.c
+++ b/tmk_core/protocol/chibios/usb_main.c
@@ -947,7 +947,7 @@ void shared_in_cb(USBDriver *usbp, usbep_t ep) {
*/
#ifdef EXTRAKEY_ENABLE
-static void send_extra(uint8_t report_id, uint16_t data) {
+void send_extra(uint8_t report_id, uint16_t data) {
osalSysLock();
if (usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) {
osalSysUnlock();
@@ -973,18 +973,6 @@ static void send_extra(uint8_t report_id, uint16_t data) {
}
#endif
-void send_system(uint16_t data) {
-#ifdef EXTRAKEY_ENABLE
- send_extra(REPORT_ID_SYSTEM, data);
-#endif
-}
-
-void send_consumer(uint16_t data) {
-#ifdef EXTRAKEY_ENABLE
- send_extra(REPORT_ID_CONSUMER, data);
-#endif
-}
-
void send_programmable_button(uint32_t data) {
#ifdef PROGRAMMABLE_BUTTON_ENABLE
osalSysLock();
diff --git a/tmk_core/protocol/host.c b/tmk_core/protocol/host.c
index 3d8604d541..2ebd176ea4 100644
--- a/tmk_core/protocol/host.c
+++ b/tmk_core/protocol/host.c
@@ -107,7 +107,7 @@ void host_system_send(uint16_t report) {
last_system_report = report;
if (!driver) return;
- (*driver->send_system)(report);
+ (*driver->send_extra)(REPORT_ID_SYSTEM, report);
}
void host_consumer_send(uint16_t report) {
@@ -115,7 +115,7 @@ void host_consumer_send(uint16_t report) {
last_consumer_report = report;
if (!driver) return;
- (*driver->send_consumer)(report);
+ (*driver->send_extra)(REPORT_ID_CONSUMER, report);
}
void host_digitizer_send(digitizer_t *digitizer) {
diff --git a/tmk_core/protocol/host_driver.h b/tmk_core/protocol/host_driver.h
index affd0dcb34..680d9727d3 100644
--- a/tmk_core/protocol/host_driver.h
+++ b/tmk_core/protocol/host_driver.h
@@ -27,9 +27,8 @@ typedef struct {
uint8_t (*keyboard_leds)(void);
void (*send_keyboard)(report_keyboard_t *);
void (*send_mouse)(report_mouse_t *);
- void (*send_system)(uint16_t);
- void (*send_consumer)(uint16_t);
+ void (*send_extra)(uint8_t, uint16_t);
void (*send_programmable_button)(uint32_t);
} host_driver_t;
-void send_digitizer(report_digitizer_t *report); \ No newline at end of file
+void send_digitizer(report_digitizer_t *report);
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c
index b4b03357a3..5c1a9b600e 100644
--- a/tmk_core/protocol/lufa/lufa.c
+++ b/tmk_core/protocol/lufa/lufa.c
@@ -101,10 +101,9 @@ static report_keyboard_t keyboard_report_sent;
static uint8_t keyboard_leds(void);
static void send_keyboard(report_keyboard_t *report);
static void send_mouse(report_mouse_t *report);
-static void send_system(uint16_t data);
-static void send_consumer(uint16_t data);
+static void send_extra(uint8_t report_id, uint16_t data);
static void send_programmable_button(uint32_t data);
-host_driver_t lufa_driver = {keyboard_leds, send_keyboard, send_mouse, send_system, send_consumer, send_programmable_button};
+host_driver_t lufa_driver = {keyboard_leds, send_keyboard, send_mouse, send_extra, send_programmable_button};
#ifdef VIRTSER_ENABLE
// clang-format off
@@ -748,30 +747,8 @@ static void send_report(void *report, size_t size) {
*/
#ifdef EXTRAKEY_ENABLE
static void send_extra(uint8_t report_id, uint16_t data) {
- static report_extra_t r;
- r = (report_extra_t){.report_id = report_id, .usage = data};
- send_report(&r, sizeof(r));
-}
-#endif
-
-/** \brief Send System
- *
- * FIXME: Needs doc
- */
-static void send_system(uint16_t data) {
-#ifdef EXTRAKEY_ENABLE
- send_extra(REPORT_ID_SYSTEM, data);
-#endif
-}
-
-/** \brief Send Consumer
- *
- * FIXME: Needs doc
- */
-static void send_consumer(uint16_t data) {
-#ifdef EXTRAKEY_ENABLE
# ifdef BLUETOOTH_ENABLE
- if (where_to_send() == OUTPUT_BLUETOOTH) {
+ if (report_id == REPORT_ID_CONSUMER && where_to_send() == OUTPUT_BLUETOOTH) {
# ifdef BLUETOOTH_BLUEFRUIT_LE
bluefruit_le_send_consumer_key(data);
# elif BLUETOOTH_RN42
@@ -781,9 +758,11 @@ static void send_consumer(uint16_t data) {
}
# endif
- send_extra(REPORT_ID_CONSUMER, data);
-#endif
+ static report_extra_t r;
+ r = (report_extra_t){.report_id = report_id, .usage = data};
+ send_report(&r, sizeof(r));
}
+#endif
static void send_programmable_button(uint32_t data) {
#ifdef PROGRAMMABLE_BUTTON_ENABLE
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c
index 65f5027574..ed90b1151a 100644
--- a/tmk_core/protocol/vusb/vusb.c
+++ b/tmk_core/protocol/vusb/vusb.c
@@ -224,11 +224,10 @@ void console_task(void) {
static uint8_t keyboard_leds(void);
static void send_keyboard(report_keyboard_t *report);
static void send_mouse(report_mouse_t *report);
-static void send_system(uint16_t data);
-static void send_consumer(uint16_t data);
+static void send_extra(uint8_t report_id, uint16_t data);
static void send_programmable_button(uint32_t data);
-static host_driver_t driver = {keyboard_leds, send_keyboard, send_mouse, send_system, send_consumer, send_programmable_button};
+static host_driver_t driver = {keyboard_leds, send_keyboard, send_mouse, send_extra, send_programmable_button};
host_driver_t *vusb_driver(void) {
return &driver;
@@ -285,18 +284,6 @@ static void send_extra(uint8_t report_id, uint16_t data) {
}
#endif
-static void send_system(uint16_t data) {
-#ifdef EXTRAKEY_ENABLE
- send_extra(REPORT_ID_SYSTEM, data);
-#endif
-}
-
-static void send_consumer(uint16_t data) {
-#ifdef EXTRAKEY_ENABLE
- send_extra(REPORT_ID_CONSUMER, data);
-#endif
-}
-
void send_digitizer(report_digitizer_t *report) {
#ifdef DIGITIZER_ENABLE
if (usbInterruptIsReadyShared()) {