diff options
| author | Ryan <fauxpark@gmail.com> | 2022-10-07 13:35:01 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-06 19:35:01 -0700 |
| commit | 6dbbeea46a0ac7527235982cb6406802df846805 (patch) | |
| tree | 55b2a71430ad3726ab098a53b581a69efdd1602d | |
| parent | cbe1c22d468d64d7a3274061ce9c2073ecb208a4 (diff) | |
Refactor `send_extra` (#18615)
| -rw-r--r-- | keyboards/annepro2/annepro2_ble.c | 8 | ||||
| -rw-r--r-- | keyboards/bioi/ble.c | 13 | ||||
| -rw-r--r-- | keyboards/hhkb/rn42/rn42.c | 12 | ||||
| -rw-r--r-- | tests/test_common/test_driver.cpp | 4 | ||||
| -rw-r--r-- | tests/test_common/test_driver.hpp | 4 | ||||
| -rw-r--r-- | tmk_core/protocol/arm_atsam/main_arm_atsam.c | 9 | ||||
| -rw-r--r-- | tmk_core/protocol/arm_atsam/usb/udi_device_conf.h | 14 | ||||
| -rw-r--r-- | tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c | 29 | ||||
| -rw-r--r-- | tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.h | 1 | ||||
| -rw-r--r-- | tmk_core/protocol/chibios/chibios.c | 2 | ||||
| -rw-r--r-- | tmk_core/protocol/chibios/usb_main.c | 7 | ||||
| -rw-r--r-- | tmk_core/protocol/host.c | 40 | ||||
| -rw-r--r-- | tmk_core/protocol/host.h | 8 | ||||
| -rw-r--r-- | tmk_core/protocol/host_driver.h | 2 | ||||
| -rw-r--r-- | tmk_core/protocol/lufa/lufa.c | 8 | ||||
| -rw-r--r-- | tmk_core/protocol/vusb/vusb.c | 14 |
16 files changed, 68 insertions, 107 deletions
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 @@ | |||
| 24 | /* -------------------- Static Function Prototypes -------------------------- */ | 24 | /* -------------------- Static Function Prototypes -------------------------- */ |
| 25 | static uint8_t ap2_ble_leds(void); | 25 | static uint8_t ap2_ble_leds(void); |
| 26 | static void ap2_ble_mouse(report_mouse_t *report); | 26 | static void ap2_ble_mouse(report_mouse_t *report); |
| 27 | static void ap2_ble_extra(uint8_t report_id, uint16_t data); | 27 | static void ap2_ble_extra(report_extra_t *report); |
| 28 | static void ap2_ble_keyboard(report_keyboard_t *report); | 28 | static void ap2_ble_keyboard(report_keyboard_t *report); |
| 29 | 29 | ||
| 30 | static void ap2_ble_swtich_ble_driver(void); | 30 | static void ap2_ble_swtich_ble_driver(void); |
| @@ -149,11 +149,11 @@ static inline uint16_t CONSUMER2AP2(uint16_t usage) { | |||
| 149 | } | 149 | } |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | static void ap2_ble_extra(uint8_t report_id, uint16_t data) { | 152 | static void ap2_ble_extra(report_extra_t *report) { |
| 153 | if (report_id == REPORT_ID_CONSUMER) { | 153 | if (report->report_id == REPORT_ID_CONSUMER) { |
| 154 | sdPut(&SD1, 0x0); | 154 | sdPut(&SD1, 0x0); |
| 155 | sdWrite(&SD1, ble_mcu_send_consumer_report, sizeof(ble_mcu_send_consumer_report)); | 155 | sdWrite(&SD1, ble_mcu_send_consumer_report, sizeof(ble_mcu_send_consumer_report)); |
| 156 | sdPut(&SD1, CONSUMER2AP2(data)); | 156 | sdPut(&SD1, CONSUMER2AP2(report->usage)); |
| 157 | static const uint8_t dummy[3] = {0}; | 157 | static const uint8_t dummy[3] = {0}; |
| 158 | sdWrite(&SD1, dummy, sizeof(dummy)); | 158 | sdWrite(&SD1, dummy, sizeof(dummy)); |
| 159 | } | 159 | } |
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) | |||
| 96 | static uint8_t keyboard_leds(void); | 96 | static uint8_t keyboard_leds(void); |
| 97 | static void send_keyboard(report_keyboard_t *report); | 97 | static void send_keyboard(report_keyboard_t *report); |
| 98 | static void send_mouse(report_mouse_t *report); | 98 | static void send_mouse(report_mouse_t *report); |
| 99 | static void send_extra(uint8_t report_id, uint16_t data); | 99 | static void send_extra(report_extra_t *report); |
| 100 | 100 | ||
| 101 | host_driver_t bluefruit_driver = { | 101 | host_driver_t bluefruit_driver = { |
| 102 | keyboard_leds, | 102 | keyboard_leds, |
| @@ -177,15 +177,10 @@ static void send_mouse(report_mouse_t *report) | |||
| 177 | #define CONSUMER2BLUEFRUIT(usage) \ | 177 | #define CONSUMER2BLUEFRUIT(usage) \ |
| 178 | (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))))))))))))))))))) | 178 | (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))))))))))))))))))) |
| 179 | 179 | ||
| 180 | static void send_extra(uint8_t report_id, uint16_t data) | 180 | static void send_extra(report_extra_t *report) |
| 181 | { | 181 | { |
| 182 | if (report_id == REPORT_ID_CONSUMER) { | 182 | if (report->report_id == REPORT_ID_CONSUMER) { |
| 183 | static uint16_t last_data = 0; | 183 | uint16_t bitmap = CONSUMER2BLUEFRUIT(report->usage); |
| 184 | if (data == last_data) | ||
| 185 | return; | ||
| 186 | last_data = data; | ||
| 187 | |||
| 188 | uint16_t bitmap = CONSUMER2BLUEFRUIT(data); | ||
| 189 | 184 | ||
| 190 | #ifdef BLUEFRUIT_TRACE_SERIAL | 185 | #ifdef BLUEFRUIT_TRACE_SERIAL |
| 191 | dprintf("\nData: "); | 186 | 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 @@ | |||
| 12 | static uint8_t keyboard_leds(void); | 12 | static uint8_t keyboard_leds(void); |
| 13 | static void send_keyboard(report_keyboard_t *report); | 13 | static void send_keyboard(report_keyboard_t *report); |
| 14 | static void send_mouse(report_mouse_t *report); | 14 | static void send_mouse(report_mouse_t *report); |
| 15 | static void send_extra(uint8_t report_id, uint16_t data); | 15 | static void send_extra(report_extra_t *report); |
| 16 | 16 | ||
| 17 | host_driver_t rn42_driver = { | 17 | host_driver_t rn42_driver = { |
| 18 | keyboard_leds, | 18 | keyboard_leds, |
| @@ -221,10 +221,10 @@ static uint16_t usage2bits(uint16_t usage) | |||
| 221 | } | 221 | } |
| 222 | 222 | ||
| 223 | 223 | ||
| 224 | static void send_extra(uint8_t report_id, uint16_t data) | 224 | static void send_extra(report_extra_t *report) |
| 225 | { | 225 | { |
| 226 | if (report_id == REPORT_ID_CONSUMER) { | 226 | if (report->report_id == REPORT_ID_CONSUMER) { |
| 227 | uint16_t bits = usage2bits(data); | 227 | uint16_t bits = usage2bits(report->usage); |
| 228 | serial_send(0xFD); // Raw report mode | 228 | serial_send(0xFD); // Raw report mode |
| 229 | serial_send(3); // length | 229 | serial_send(3); // length |
| 230 | serial_send(3); // descriptor type | 230 | serial_send(3); // descriptor type |
| @@ -238,7 +238,7 @@ static void send_extra(uint8_t report_id, uint16_t data) | |||
| 238 | static uint8_t config_keyboard_leds(void); | 238 | static uint8_t config_keyboard_leds(void); |
| 239 | static void config_send_keyboard(report_keyboard_t *report); | 239 | static void config_send_keyboard(report_keyboard_t *report); |
| 240 | static void config_send_mouse(report_mouse_t *report); | 240 | static void config_send_mouse(report_mouse_t *report); |
| 241 | static void config_send_extra(uint8_t report_id, uint16_t data); | 241 | static void config_send_extra(report_extra_t *report); |
| 242 | 242 | ||
| 243 | host_driver_t rn42_config_driver = { | 243 | host_driver_t rn42_config_driver = { |
| 244 | config_keyboard_leds, | 244 | config_keyboard_leds, |
| @@ -250,4 +250,4 @@ host_driver_t rn42_config_driver = { | |||
| 250 | static uint8_t config_keyboard_leds(void) { return leds; } | 250 | static uint8_t config_keyboard_leds(void) { return leds; } |
| 251 | static void config_send_keyboard(report_keyboard_t *report) {} | 251 | static void config_send_keyboard(report_keyboard_t *report) {} |
| 252 | static void config_send_mouse(report_mouse_t *report) {} | 252 | static void config_send_mouse(report_mouse_t *report) {} |
| 253 | static void config_send_extra(uint8_t report_id, uint16_t data) {} | 253 | static void config_send_extra(report_extra_t *report) {} |
diff --git a/tests/test_common/test_driver.cpp b/tests/test_common/test_driver.cpp index 7ecd4931ed..f1c52cb7b6 100644 --- a/tests/test_common/test_driver.cpp +++ b/tests/test_common/test_driver.cpp | |||
| @@ -53,8 +53,8 @@ void TestDriver::send_mouse(report_mouse_t* report) { | |||
| 53 | m_this->send_mouse_mock(*report); | 53 | m_this->send_mouse_mock(*report); |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | void TestDriver::send_extra(uint8_t report_id, uint16_t data) { | 56 | void TestDriver::send_extra(report_extra_t* report) { |
| 57 | m_this->send_extra_mock(report_id, data); | 57 | m_this->send_extra_mock(*report); |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | namespace internal { | 60 | namespace internal { |
diff --git a/tests/test_common/test_driver.hpp b/tests/test_common/test_driver.hpp index 666bfb1fba..c97bda8bc5 100644 --- a/tests/test_common/test_driver.hpp +++ b/tests/test_common/test_driver.hpp | |||
| @@ -32,13 +32,13 @@ class TestDriver { | |||
| 32 | 32 | ||
| 33 | MOCK_METHOD1(send_keyboard_mock, void(report_keyboard_t&)); | 33 | MOCK_METHOD1(send_keyboard_mock, void(report_keyboard_t&)); |
| 34 | MOCK_METHOD1(send_mouse_mock, void(report_mouse_t&)); | 34 | MOCK_METHOD1(send_mouse_mock, void(report_mouse_t&)); |
| 35 | MOCK_METHOD2(send_extra_mock, void(uint8_t, uint16_t)); | 35 | MOCK_METHOD1(send_extra_mock, void(report_extra_t&)); |
| 36 | 36 | ||
| 37 | private: | 37 | private: |
| 38 | static uint8_t keyboard_leds(void); | 38 | static uint8_t keyboard_leds(void); |
| 39 | static void send_keyboard(report_keyboard_t* report); | 39 | static void send_keyboard(report_keyboard_t* report); |
| 40 | static void send_mouse(report_mouse_t* report); | 40 | static void send_mouse(report_mouse_t* report); |
| 41 | static void send_extra(uint8_t report_id, uint16_t data); | 41 | static void send_extra(report_extra_t* report); |
| 42 | host_driver_t m_driver; | 42 | host_driver_t m_driver; |
| 43 | uint8_t m_leds = 0; | 43 | uint8_t m_leds = 0; |
| 44 | static TestDriver* m_this; | 44 | static TestDriver* m_this; |
diff --git a/tmk_core/protocol/arm_atsam/main_arm_atsam.c b/tmk_core/protocol/arm_atsam/main_arm_atsam.c index 0537e3937d..1ccfbfb54a 100644 --- a/tmk_core/protocol/arm_atsam/main_arm_atsam.c +++ b/tmk_core/protocol/arm_atsam/main_arm_atsam.c | |||
| @@ -37,7 +37,7 @@ void main_subtasks(void); | |||
| 37 | uint8_t keyboard_leds(void); | 37 | uint8_t keyboard_leds(void); |
| 38 | void send_keyboard(report_keyboard_t *report); | 38 | void send_keyboard(report_keyboard_t *report); |
| 39 | void send_mouse(report_mouse_t *report); | 39 | void send_mouse(report_mouse_t *report); |
| 40 | void send_extra(uint8_t report_id, uint16_t data); | 40 | void send_extra(report_extra_t *report); |
| 41 | 41 | ||
| 42 | #ifdef DEFERRED_EXEC_ENABLE | 42 | #ifdef DEFERRED_EXEC_ENABLE |
| 43 | void deferred_exec_task(void); | 43 | void deferred_exec_task(void); |
| @@ -113,7 +113,7 @@ void send_mouse(report_mouse_t *report) { | |||
| 113 | #endif // MOUSEKEY_ENABLE | 113 | #endif // MOUSEKEY_ENABLE |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | void send_extra(uint8_t report_id, uint16_t data) { | 116 | void send_extra(report_extra_t *report) { |
| 117 | #ifdef EXTRAKEY_ENABLE | 117 | #ifdef EXTRAKEY_ENABLE |
| 118 | uint32_t irqflags; | 118 | uint32_t irqflags; |
| 119 | 119 | ||
| @@ -121,9 +121,8 @@ void send_extra(uint8_t report_id, uint16_t data) { | |||
| 121 | __disable_irq(); | 121 | __disable_irq(); |
| 122 | __DMB(); | 122 | __DMB(); |
| 123 | 123 | ||
| 124 | udi_hid_exk_report.desc.report_id = report_id; | 124 | memcpy(udi_hid_exk_report, report, UDI_HID_EXK_REPORT_SIZE); |
| 125 | udi_hid_exk_report.desc.report_data = data; | 125 | udi_hid_exk_b_report_valid = 1; |
| 126 | udi_hid_exk_b_report_valid = 1; | ||
| 127 | udi_hid_exk_send_report(); | 126 | udi_hid_exk_send_report(); |
| 128 | 127 | ||
| 129 | __DMB(); | 128 | __DMB(); |
diff --git a/tmk_core/protocol/arm_atsam/usb/udi_device_conf.h b/tmk_core/protocol/arm_atsam/usb/udi_device_conf.h index eeed196275..a3c6f1c397 100644 --- a/tmk_core/protocol/arm_atsam/usb/udi_device_conf.h +++ b/tmk_core/protocol/arm_atsam/usb/udi_device_conf.h | |||
| @@ -352,21 +352,9 @@ typedef struct { | |||
| 352 | 352 | ||
| 353 | // clang-format on | 353 | // clang-format on |
| 354 | 354 | ||
| 355 | // set report buffer (from host) | ||
| 356 | extern uint8_t udi_hid_exk_report_set; | ||
| 357 | |||
| 358 | // report buffer | 355 | // report buffer |
| 359 | # define UDI_HID_EXK_REPORT_SIZE 3 | 356 | # define UDI_HID_EXK_REPORT_SIZE 3 |
| 360 | 357 | extern uint8_t udi_hid_exk_report[UDI_HID_EXK_REPORT_SIZE]; | |
| 361 | typedef union { | ||
| 362 | struct { | ||
| 363 | uint8_t report_id; | ||
| 364 | uint16_t report_data; | ||
| 365 | } desc; | ||
| 366 | uint8_t raw[UDI_HID_EXK_REPORT_SIZE]; | ||
| 367 | } udi_hid_exk_report_t; | ||
| 368 | |||
| 369 | extern udi_hid_exk_report_t udi_hid_exk_report; | ||
| 370 | 358 | ||
| 371 | COMPILER_PACK_RESET() | 359 | COMPILER_PACK_RESET() |
| 372 | 360 | ||
diff --git a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c index be4f2bb0c9..5d681a8b71 100644 --- a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c +++ b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c | |||
| @@ -371,13 +371,13 @@ static uint8_t udi_hid_exk_rate; | |||
| 371 | COMPILER_WORD_ALIGNED | 371 | COMPILER_WORD_ALIGNED |
| 372 | static uint8_t udi_hid_exk_protocol; | 372 | static uint8_t udi_hid_exk_protocol; |
| 373 | 373 | ||
| 374 | COMPILER_WORD_ALIGNED | 374 | // COMPILER_WORD_ALIGNED |
| 375 | uint8_t udi_hid_exk_report_set; | 375 | // uint8_t udi_hid_exk_report_set; |
| 376 | 376 | ||
| 377 | bool udi_hid_exk_b_report_valid; | 377 | bool udi_hid_exk_b_report_valid; |
| 378 | 378 | ||
| 379 | COMPILER_WORD_ALIGNED | 379 | COMPILER_WORD_ALIGNED |
| 380 | udi_hid_exk_report_t udi_hid_exk_report; | 380 | uint8_t udi_hid_exk_report[UDI_HID_EXK_REPORT_SIZE]; |
| 381 | 381 | ||
| 382 | static bool udi_hid_exk_b_report_trans_ongoing; | 382 | static bool udi_hid_exk_b_report_trans_ongoing; |
| 383 | 383 | ||
| @@ -415,39 +415,24 @@ UDC_DESC_STORAGE udi_hid_exk_report_desc_t udi_hid_exk_report_desc = {{ | |||
| 415 | //clang-format on | 415 | //clang-format on |
| 416 | }}; | 416 | }}; |
| 417 | 417 | ||
| 418 | static bool udi_hid_exk_setreport(void); | ||
| 419 | |||
| 420 | static void udi_hid_exk_report_sent(udd_ep_status_t status, iram_size_t nb_sent, udd_ep_id_t ep); | 418 | static void udi_hid_exk_report_sent(udd_ep_status_t status, iram_size_t nb_sent, udd_ep_id_t ep); |
| 421 | 419 | ||
| 422 | static void udi_hid_exk_setreport_valid(void); | ||
| 423 | |||
| 424 | bool udi_hid_exk_enable(void) { | 420 | bool udi_hid_exk_enable(void) { |
| 425 | // Initialize internal values | 421 | // Initialize internal values |
| 426 | udi_hid_exk_rate = 0; | 422 | udi_hid_exk_rate = 0; |
| 427 | udi_hid_exk_protocol = 0; | 423 | udi_hid_exk_protocol = 0; |
| 428 | udi_hid_exk_b_report_trans_ongoing = false; | 424 | udi_hid_exk_b_report_trans_ongoing = false; |
| 429 | memset(udi_hid_exk_report.raw, 0, UDI_HID_EXK_REPORT_SIZE); | 425 | memset(udi_hid_exk_report, 0, UDI_HID_EXK_REPORT_SIZE); |
| 430 | udi_hid_exk_b_report_valid = false; | 426 | udi_hid_exk_b_report_valid = false; |
| 431 | return UDI_HID_EXK_ENABLE_EXT(); | 427 | return UDI_HID_EXK_ENABLE_EXT(); |
| 432 | } | 428 | } |
| 433 | 429 | ||
| 434 | void udi_hid_exk_disable(void) { UDI_HID_EXK_DISABLE_EXT(); } | 430 | void udi_hid_exk_disable(void) { UDI_HID_EXK_DISABLE_EXT(); } |
| 435 | 431 | ||
| 436 | bool udi_hid_exk_setup(void) { return udi_hid_setup(&udi_hid_exk_rate, &udi_hid_exk_protocol, (uint8_t *)&udi_hid_exk_report_desc, udi_hid_exk_setreport); } | 432 | bool udi_hid_exk_setup(void) { return udi_hid_setup(&udi_hid_exk_rate, &udi_hid_exk_protocol, (uint8_t *)&udi_hid_exk_report_desc, NULL); } |
| 437 | 433 | ||
| 438 | uint8_t udi_hid_exk_getsetting(void) { return 0; } | 434 | uint8_t udi_hid_exk_getsetting(void) { return 0; } |
| 439 | 435 | ||
| 440 | static bool udi_hid_exk_setreport(void) { | ||
| 441 | if ((USB_HID_REPORT_TYPE_OUTPUT == (udd_g_ctrlreq.req.wValue >> 8)) && (0 == (0xFF & udd_g_ctrlreq.req.wValue)) && (1 == udd_g_ctrlreq.req.wLength)) { | ||
| 442 | // Report OUT type on report ID 0 from USB Host | ||
| 443 | udd_g_ctrlreq.payload = &udi_hid_exk_report_set; | ||
| 444 | udd_g_ctrlreq.callback = udi_hid_exk_setreport_valid; | ||
| 445 | udd_g_ctrlreq.payload_size = 1; | ||
| 446 | return true; | ||
| 447 | } | ||
| 448 | return false; | ||
| 449 | } | ||
| 450 | |||
| 451 | bool udi_hid_exk_send_report(void) { | 436 | bool udi_hid_exk_send_report(void) { |
| 452 | if (!main_b_exk_enable) { | 437 | if (!main_b_exk_enable) { |
| 453 | return false; | 438 | return false; |
| @@ -457,7 +442,7 @@ bool udi_hid_exk_send_report(void) { | |||
| 457 | return false; | 442 | return false; |
| 458 | } | 443 | } |
| 459 | 444 | ||
| 460 | memcpy(udi_hid_exk_report_trans, udi_hid_exk_report.raw, UDI_HID_EXK_REPORT_SIZE); | 445 | memcpy(udi_hid_exk_report_trans, udi_hid_exk_report, UDI_HID_EXK_REPORT_SIZE); |
| 461 | udi_hid_exk_b_report_valid = false; | 446 | udi_hid_exk_b_report_valid = false; |
| 462 | udi_hid_exk_b_report_trans_ongoing = udd_ep_run(UDI_HID_EXK_EP_IN | USB_EP_DIR_IN, false, udi_hid_exk_report_trans, UDI_HID_EXK_REPORT_SIZE, udi_hid_exk_report_sent); | 447 | udi_hid_exk_b_report_trans_ongoing = udd_ep_run(UDI_HID_EXK_EP_IN | USB_EP_DIR_IN, false, udi_hid_exk_report_trans, UDI_HID_EXK_REPORT_SIZE, udi_hid_exk_report_sent); |
| 463 | 448 | ||
| @@ -474,8 +459,6 @@ static void udi_hid_exk_report_sent(udd_ep_status_t status, iram_size_t nb_sent, | |||
| 474 | } | 459 | } |
| 475 | } | 460 | } |
| 476 | 461 | ||
| 477 | static void udi_hid_exk_setreport_valid(void) {} | ||
| 478 | |||
| 479 | #endif // EXTRAKEY_ENABLE | 462 | #endif // EXTRAKEY_ENABLE |
| 480 | 463 | ||
| 481 | //******************************************************************************************** | 464 | //******************************************************************************************** |
diff --git a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.h b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.h index a330014498..e17538fa70 100644 --- a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.h +++ b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.h | |||
| @@ -79,7 +79,6 @@ bool udi_hid_nkro_send_report(void); | |||
| 79 | #ifdef EXTRAKEY_ENABLE | 79 | #ifdef EXTRAKEY_ENABLE |
| 80 | extern UDC_DESC_STORAGE udi_api_t udi_api_hid_exk; | 80 | extern UDC_DESC_STORAGE udi_api_t udi_api_hid_exk; |
| 81 | extern bool udi_hid_exk_b_report_valid; | 81 | extern bool udi_hid_exk_b_report_valid; |
| 82 | extern uint8_t udi_hid_exk_report_set; | ||
| 83 | bool udi_hid_exk_send_report(void); | 82 | bool udi_hid_exk_send_report(void); |
| 84 | #endif // EXTRAKEY_ENABLE | 83 | #endif // EXTRAKEY_ENABLE |
| 85 | 84 | ||
diff --git a/tmk_core/protocol/chibios/chibios.c b/tmk_core/protocol/chibios/chibios.c index 82ade4259b..10a976608a 100644 --- a/tmk_core/protocol/chibios/chibios.c +++ b/tmk_core/protocol/chibios/chibios.c | |||
| @@ -58,7 +58,7 @@ | |||
| 58 | uint8_t keyboard_leds(void); | 58 | uint8_t keyboard_leds(void); |
| 59 | void send_keyboard(report_keyboard_t *report); | 59 | void send_keyboard(report_keyboard_t *report); |
| 60 | void send_mouse(report_mouse_t *report); | 60 | void send_mouse(report_mouse_t *report); |
| 61 | void send_extra(uint8_t report_id, uint16_t data); | 61 | void send_extra(report_extra_t *report); |
| 62 | 62 | ||
| 63 | /* host struct */ | 63 | /* host struct */ |
| 64 | host_driver_t chibios_driver = {keyboard_leds, send_keyboard, send_mouse, send_extra}; | 64 | host_driver_t chibios_driver = {keyboard_leds, send_keyboard, send_mouse, send_extra}; |
diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index 3fd34a604e..5eda5dd09f 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c | |||
| @@ -943,7 +943,7 @@ void shared_in_cb(USBDriver *usbp, usbep_t ep) { | |||
| 943 | * --------------------------------------------------------- | 943 | * --------------------------------------------------------- |
| 944 | */ | 944 | */ |
| 945 | 945 | ||
| 946 | void send_extra(uint8_t report_id, uint16_t data) { | 946 | void send_extra(report_extra_t *report) { |
| 947 | #ifdef EXTRAKEY_ENABLE | 947 | #ifdef EXTRAKEY_ENABLE |
| 948 | osalSysLock(); | 948 | osalSysLock(); |
| 949 | if (usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) { | 949 | if (usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) { |
| @@ -962,10 +962,7 @@ void send_extra(uint8_t report_id, uint16_t data) { | |||
| 962 | } | 962 | } |
| 963 | } | 963 | } |
| 964 | 964 | ||
| 965 | static report_extra_t report; | 965 | usbStartTransmitI(&USB_DRIVER, SHARED_IN_EPNUM, (uint8_t *)report, sizeof(report_extra_t)); |
| 966 | report = (report_extra_t){.report_id = report_id, .usage = data}; | ||
| 967 | |||
| 968 | usbStartTransmitI(&USB_DRIVER, SHARED_IN_EPNUM, (uint8_t *)&report, sizeof(report_extra_t)); | ||
| 969 | osalSysUnlock(); | 966 | osalSysUnlock(); |
| 970 | #endif | 967 | #endif |
| 971 | } | 968 | } |
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; | |||
| 41 | #endif | 41 | #endif |
| 42 | 42 | ||
| 43 | static host_driver_t *driver; | 43 | static host_driver_t *driver; |
| 44 | static uint16_t last_system_report = 0; | 44 | static uint16_t last_system_usage = 0; |
| 45 | static uint16_t last_consumer_report = 0; | 45 | static uint16_t last_consumer_usage = 0; |
| 46 | 46 | ||
| 47 | void host_set_driver(host_driver_t *d) { | 47 | void host_set_driver(host_driver_t *d) { |
| 48 | driver = d; | 48 | driver = d; |
| @@ -126,27 +126,37 @@ void host_mouse_send(report_mouse_t *report) { | |||
| 126 | (*driver->send_mouse)(report); | 126 | (*driver->send_mouse)(report); |
| 127 | } | 127 | } |
| 128 | 128 | ||
| 129 | void host_system_send(uint16_t report) { | 129 | void host_system_send(uint16_t usage) { |
| 130 | if (report == last_system_report) return; | 130 | if (usage == last_system_usage) return; |
| 131 | last_system_report = report; | 131 | last_system_usage = usage; |
| 132 | 132 | ||
| 133 | if (!driver) return; | 133 | if (!driver) return; |
| 134 | (*driver->send_extra)(REPORT_ID_SYSTEM, report); | 134 | |
| 135 | report_extra_t report = { | ||
| 136 | .report_id = REPORT_ID_SYSTEM, | ||
| 137 | .usage = usage, | ||
| 138 | }; | ||
| 139 | (*driver->send_extra)(&report); | ||
| 135 | } | 140 | } |
| 136 | 141 | ||
| 137 | void host_consumer_send(uint16_t report) { | 142 | void host_consumer_send(uint16_t usage) { |
| 138 | if (report == last_consumer_report) return; | 143 | if (usage == last_consumer_usage) return; |
| 139 | last_consumer_report = report; | 144 | last_consumer_usage = usage; |
| 140 | 145 | ||
| 141 | #ifdef BLUETOOTH_ENABLE | 146 | #ifdef BLUETOOTH_ENABLE |
| 142 | if (where_to_send() == OUTPUT_BLUETOOTH) { | 147 | if (where_to_send() == OUTPUT_BLUETOOTH) { |
| 143 | bluetooth_send_consumer(report); | 148 | bluetooth_send_consumer(usage); |
| 144 | return; | 149 | return; |
| 145 | } | 150 | } |
| 146 | #endif | 151 | #endif |
| 147 | 152 | ||
| 148 | if (!driver) return; | 153 | if (!driver) return; |
| 149 | (*driver->send_extra)(REPORT_ID_CONSUMER, report); | 154 | |
| 155 | report_extra_t report = { | ||
| 156 | .report_id = REPORT_ID_CONSUMER, | ||
| 157 | .usage = usage, | ||
| 158 | }; | ||
| 159 | (*driver->send_extra)(&report); | ||
| 150 | } | 160 | } |
| 151 | 161 | ||
| 152 | #ifdef JOYSTICK_ENABLE | 162 | #ifdef JOYSTICK_ENABLE |
| @@ -232,10 +242,10 @@ void host_programmable_button_send(uint32_t data) { | |||
| 232 | 242 | ||
| 233 | __attribute__((weak)) void send_programmable_button(report_programmable_button_t *report) {} | 243 | __attribute__((weak)) void send_programmable_button(report_programmable_button_t *report) {} |
| 234 | 244 | ||
| 235 | uint16_t host_last_system_report(void) { | 245 | uint16_t host_last_system_usage(void) { |
| 236 | return last_system_report; | 246 | return last_system_usage; |
| 237 | } | 247 | } |
| 238 | 248 | ||
| 239 | uint16_t host_last_consumer_report(void) { | 249 | uint16_t host_last_consumer_usage(void) { |
| 240 | return last_consumer_report; | 250 | return last_consumer_usage; |
| 241 | } | 251 | } |
diff --git a/tmk_core/protocol/host.h b/tmk_core/protocol/host.h index 08bd498d38..dfa86cd7b5 100644 --- a/tmk_core/protocol/host.h +++ b/tmk_core/protocol/host.h | |||
| @@ -45,12 +45,12 @@ uint8_t host_keyboard_leds(void); | |||
| 45 | led_t host_keyboard_led_state(void); | 45 | led_t host_keyboard_led_state(void); |
| 46 | void host_keyboard_send(report_keyboard_t *report); | 46 | void host_keyboard_send(report_keyboard_t *report); |
| 47 | void host_mouse_send(report_mouse_t *report); | 47 | void host_mouse_send(report_mouse_t *report); |
| 48 | void host_system_send(uint16_t data); | 48 | void host_system_send(uint16_t usage); |
| 49 | void host_consumer_send(uint16_t data); | 49 | void host_consumer_send(uint16_t usage); |
| 50 | void host_programmable_button_send(uint32_t data); | 50 | void host_programmable_button_send(uint32_t data); |
| 51 | 51 | ||
| 52 | uint16_t host_last_system_report(void); | 52 | uint16_t host_last_system_usage(void); |
| 53 | uint16_t host_last_consumer_report(void); | 53 | uint16_t host_last_consumer_usage(void); |
| 54 | 54 | ||
| 55 | #ifdef __cplusplus | 55 | #ifdef __cplusplus |
| 56 | } | 56 | } |
diff --git a/tmk_core/protocol/host_driver.h b/tmk_core/protocol/host_driver.h index bb4dcdd877..7dc6c3d810 100644 --- a/tmk_core/protocol/host_driver.h +++ b/tmk_core/protocol/host_driver.h | |||
| @@ -27,7 +27,7 @@ typedef struct { | |||
| 27 | uint8_t (*keyboard_leds)(void); | 27 | uint8_t (*keyboard_leds)(void); |
| 28 | void (*send_keyboard)(report_keyboard_t *); | 28 | void (*send_keyboard)(report_keyboard_t *); |
| 29 | void (*send_mouse)(report_mouse_t *); | 29 | void (*send_mouse)(report_mouse_t *); |
| 30 | void (*send_extra)(uint8_t, uint16_t); | 30 | void (*send_extra)(report_extra_t *); |
| 31 | } host_driver_t; | 31 | } host_driver_t; |
| 32 | 32 | ||
| 33 | void send_joystick(report_joystick_t *report); | 33 | void send_joystick(report_joystick_t *report); |
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 869ed71d76..fa3ced8fd6 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c | |||
| @@ -84,7 +84,7 @@ static report_keyboard_t keyboard_report_sent; | |||
| 84 | static uint8_t keyboard_leds(void); | 84 | static uint8_t keyboard_leds(void); |
| 85 | static void send_keyboard(report_keyboard_t *report); | 85 | static void send_keyboard(report_keyboard_t *report); |
| 86 | static void send_mouse(report_mouse_t *report); | 86 | static void send_mouse(report_mouse_t *report); |
| 87 | static void send_extra(uint8_t report_id, uint16_t data); | 87 | static void send_extra(report_extra_t *report); |
| 88 | host_driver_t lufa_driver = {keyboard_leds, send_keyboard, send_mouse, send_extra}; | 88 | host_driver_t lufa_driver = {keyboard_leds, send_keyboard, send_mouse, send_extra}; |
| 89 | 89 | ||
| 90 | #ifdef VIRTSER_ENABLE | 90 | #ifdef VIRTSER_ENABLE |
| @@ -663,11 +663,9 @@ static void send_report(void *report, size_t size) { | |||
| 663 | * | 663 | * |
| 664 | * FIXME: Needs doc | 664 | * FIXME: Needs doc |
| 665 | */ | 665 | */ |
| 666 | static void send_extra(uint8_t report_id, uint16_t data) { | 666 | static void send_extra(report_extra_t *report) { |
| 667 | #ifdef EXTRAKEY_ENABLE | 667 | #ifdef EXTRAKEY_ENABLE |
| 668 | static report_extra_t r; | 668 | send_report(report, sizeof(report_extra_t)); |
| 669 | r = (report_extra_t){.report_id = report_id, .usage = data}; | ||
| 670 | send_report(&r, sizeof(r)); | ||
| 671 | #endif | 669 | #endif |
| 672 | } | 670 | } |
| 673 | 671 | ||
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c index 8456d2c5ab..84b01b203e 100644 --- a/tmk_core/protocol/vusb/vusb.c +++ b/tmk_core/protocol/vusb/vusb.c | |||
| @@ -224,7 +224,7 @@ void console_task(void) { | |||
| 224 | static uint8_t keyboard_leds(void); | 224 | static uint8_t keyboard_leds(void); |
| 225 | static void send_keyboard(report_keyboard_t *report); | 225 | static void send_keyboard(report_keyboard_t *report); |
| 226 | static void send_mouse(report_mouse_t *report); | 226 | static void send_mouse(report_mouse_t *report); |
| 227 | static void send_extra(uint8_t report_id, uint16_t data); | 227 | static void send_extra(report_extra_t *report); |
| 228 | 228 | ||
| 229 | static host_driver_t driver = {keyboard_leds, send_keyboard, send_mouse, send_extra}; | 229 | static host_driver_t driver = {keyboard_leds, send_keyboard, send_mouse, send_extra}; |
| 230 | 230 | ||
| @@ -267,18 +267,10 @@ static void send_mouse(report_mouse_t *report) { | |||
| 267 | #endif | 267 | #endif |
| 268 | } | 268 | } |
| 269 | 269 | ||
| 270 | static void send_extra(uint8_t report_id, uint16_t data) { | 270 | static void send_extra(report_extra_t *report) { |
| 271 | #ifdef EXTRAKEY_ENABLE | 271 | #ifdef EXTRAKEY_ENABLE |
| 272 | static uint8_t last_id = 0; | ||
| 273 | static uint16_t last_data = 0; | ||
| 274 | if ((report_id == last_id) && (data == last_data)) return; | ||
| 275 | last_id = report_id; | ||
| 276 | last_data = data; | ||
| 277 | |||
| 278 | static report_extra_t report; | ||
| 279 | report = (report_extra_t){.report_id = report_id, .usage = data}; | ||
| 280 | if (usbInterruptIsReadyShared()) { | 272 | if (usbInterruptIsReadyShared()) { |
| 281 | usbSetInterruptShared((void *)&report, sizeof(report_extra_t)); | 273 | usbSetInterruptShared((void *)report, sizeof(report_extra_t)); |
| 282 | } | 274 | } |
| 283 | #endif | 275 | #endif |
| 284 | } | 276 | } |
