From 6dbbeea46a0ac7527235982cb6406802df846805 Mon Sep 17 00:00:00 2001 From: Ryan Date: Fri, 7 Oct 2022 13:35:01 +1100 Subject: Refactor `send_extra` (#18615) --- tmk_core/protocol/host.c | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) (limited to 'tmk_core/protocol/host.c') diff --git a/tmk_core/protocol/host.c b/tmk_core/protocol/host.c index e6c12d8a36..b441d2d5d9 100644 --- a/tmk_core/protocol/host.c +++ b/tmk_core/protocol/host.c @@ -41,8 +41,8 @@ extern keymap_config_t keymap_config; #endif static host_driver_t *driver; -static uint16_t last_system_report = 0; -static uint16_t last_consumer_report = 0; +static uint16_t last_system_usage = 0; +static uint16_t last_consumer_usage = 0; void host_set_driver(host_driver_t *d) { driver = d; @@ -126,27 +126,37 @@ void host_mouse_send(report_mouse_t *report) { (*driver->send_mouse)(report); } -void host_system_send(uint16_t report) { - if (report == last_system_report) return; - last_system_report = report; +void host_system_send(uint16_t usage) { + if (usage == last_system_usage) return; + last_system_usage = usage; if (!driver) return; - (*driver->send_extra)(REPORT_ID_SYSTEM, report); + + report_extra_t report = { + .report_id = REPORT_ID_SYSTEM, + .usage = usage, + }; + (*driver->send_extra)(&report); } -void host_consumer_send(uint16_t report) { - if (report == last_consumer_report) return; - last_consumer_report = report; +void host_consumer_send(uint16_t usage) { + if (usage == last_consumer_usage) return; + last_consumer_usage = usage; #ifdef BLUETOOTH_ENABLE if (where_to_send() == OUTPUT_BLUETOOTH) { - bluetooth_send_consumer(report); + bluetooth_send_consumer(usage); return; } #endif if (!driver) return; - (*driver->send_extra)(REPORT_ID_CONSUMER, report); + + report_extra_t report = { + .report_id = REPORT_ID_CONSUMER, + .usage = usage, + }; + (*driver->send_extra)(&report); } #ifdef JOYSTICK_ENABLE @@ -232,10 +242,10 @@ void host_programmable_button_send(uint32_t data) { __attribute__((weak)) void send_programmable_button(report_programmable_button_t *report) {} -uint16_t host_last_system_report(void) { - return last_system_report; +uint16_t host_last_system_usage(void) { + return last_system_usage; } -uint16_t host_last_consumer_report(void) { - return last_consumer_report; +uint16_t host_last_consumer_usage(void) { + return last_consumer_usage; } -- cgit v1.2.3