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) --- keyboards/annepro2/annepro2_ble.c | 8 ++++---- keyboards/bioi/ble.c | 13 ++++--------- keyboards/hhkb/rn42/rn42.c | 12 ++++++------ 3 files changed, 14 insertions(+), 19 deletions(-) (limited to 'keyboards') diff --git a/keyboards/annepro2/annepro2_ble.c b/keyboards/annepro2/annepro2_ble.c index c75de6720c..64364a6c8e 100644 --- a/keyboards/annepro2/annepro2_ble.c +++ b/keyboards/annepro2/annepro2_ble.c @@ -24,7 +24,7 @@ /* -------------------- Static Function Prototypes -------------------------- */ static uint8_t ap2_ble_leds(void); static void ap2_ble_mouse(report_mouse_t *report); -static void ap2_ble_extra(uint8_t report_id, uint16_t data); +static void ap2_ble_extra(report_extra_t *report); static void ap2_ble_keyboard(report_keyboard_t *report); static void ap2_ble_swtich_ble_driver(void); @@ -149,11 +149,11 @@ static inline uint16_t CONSUMER2AP2(uint16_t usage) { } } -static void ap2_ble_extra(uint8_t report_id, uint16_t data) { - if (report_id == REPORT_ID_CONSUMER) { +static void ap2_ble_extra(report_extra_t *report) { + if (report->report_id == REPORT_ID_CONSUMER) { sdPut(&SD1, 0x0); sdWrite(&SD1, ble_mcu_send_consumer_report, sizeof(ble_mcu_send_consumer_report)); - sdPut(&SD1, CONSUMER2AP2(data)); + sdPut(&SD1, CONSUMER2AP2(report->usage)); static const uint8_t dummy[3] = {0}; sdWrite(&SD1, dummy, sizeof(dummy)); } diff --git a/keyboards/bioi/ble.c b/keyboards/bioi/ble.c index b050b2f6cb..7118cef8c6 100644 --- a/keyboards/bioi/ble.c +++ b/keyboards/bioi/ble.c @@ -96,7 +96,7 @@ static void bluefruit_serial_send(uint8_t data) 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_extra(uint8_t report_id, uint16_t data); +static void send_extra(report_extra_t *report); host_driver_t bluefruit_driver = { keyboard_leds, @@ -177,15 +177,10 @@ static void send_mouse(report_mouse_t *report) #define CONSUMER2BLUEFRUIT(usage) \ (usage == AUDIO_MUTE ? 0x00e2 : (usage == AUDIO_VOL_UP ? 0x00e9 : (usage == AUDIO_VOL_DOWN ? 0x00ea : (usage == TRANSPORT_NEXT_TRACK ? 0x00b5 : (usage == TRANSPORT_PREV_TRACK ? 0x00b6 : (usage == TRANSPORT_STOP ? 0x00b7 : (usage == TRANSPORT_STOP_EJECT ? 0x00b8 : (usage == TRANSPORT_PLAY_PAUSE ? 0x00b1 : (usage == AL_CC_CONFIG ? 0x0183 : (usage == AL_EMAIL ? 0x018c : (usage == AL_CALCULATOR ? 0x0192 : (usage == AL_LOCAL_BROWSER ? 0x0196 : (usage == AC_SEARCH ? 0x021f : (usage == AC_HOME ? 0x0223 : (usage == AC_BACK ? 0x0224 : (usage == AC_FORWARD ? 0x0225 : (usage == AC_STOP ? 0x0226 : (usage == AC_REFRESH ? 0x0227 : (usage == AC_BOOKMARKS ? 0x022a : 0))))))))))))))))))) -static void send_extra(uint8_t report_id, uint16_t data) +static void send_extra(report_extra_t *report) { - if (report_id == REPORT_ID_CONSUMER) { - static uint16_t last_data = 0; - if (data == last_data) - return; - last_data = data; - - uint16_t bitmap = CONSUMER2BLUEFRUIT(data); + if (report->report_id == REPORT_ID_CONSUMER) { + uint16_t bitmap = CONSUMER2BLUEFRUIT(report->usage); #ifdef BLUEFRUIT_TRACE_SERIAL dprintf("\nData: "); diff --git a/keyboards/hhkb/rn42/rn42.c b/keyboards/hhkb/rn42/rn42.c index b35b319352..1cd24af5e9 100644 --- a/keyboards/hhkb/rn42/rn42.c +++ b/keyboards/hhkb/rn42/rn42.c @@ -12,7 +12,7 @@ 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_extra(uint8_t report_id, uint16_t data); +static void send_extra(report_extra_t *report); host_driver_t rn42_driver = { keyboard_leds, @@ -221,10 +221,10 @@ static uint16_t usage2bits(uint16_t usage) } -static void send_extra(uint8_t report_id, uint16_t data) +static void send_extra(report_extra_t *report) { - if (report_id == REPORT_ID_CONSUMER) { - uint16_t bits = usage2bits(data); + if (report->report_id == REPORT_ID_CONSUMER) { + uint16_t bits = usage2bits(report->usage); serial_send(0xFD); // Raw report mode serial_send(3); // length serial_send(3); // descriptor type @@ -238,7 +238,7 @@ static void send_extra(uint8_t report_id, uint16_t data) static uint8_t config_keyboard_leds(void); static void config_send_keyboard(report_keyboard_t *report); static void config_send_mouse(report_mouse_t *report); -static void config_send_extra(uint8_t report_id, uint16_t data); +static void config_send_extra(report_extra_t *report); host_driver_t rn42_config_driver = { config_keyboard_leds, @@ -250,4 +250,4 @@ host_driver_t rn42_config_driver = { static uint8_t config_keyboard_leds(void) { return leds; } static void config_send_keyboard(report_keyboard_t *report) {} static void config_send_mouse(report_mouse_t *report) {} -static void config_send_extra(uint8_t report_id, uint16_t data) {} +static void config_send_extra(report_extra_t *report) {} -- cgit v1.2.3