From df6e5f16b6c334f464ac444f6c0e350daf7ec873 Mon Sep 17 00:00:00 2001 From: fauxpark Date: Mon, 3 Feb 2020 07:17:05 +1100 Subject: Dedupe extrakey report struct, and send functions in V-USB & LUFA (#7993) * Dedupe extrakey report struct, and send functions in V-USB & LUFA * Doc comment for consistency * Wrap it in ifdef to prevent unused function error * Do the same for ATSAM --- tmk_core/protocol/lufa/lufa.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'tmk_core/protocol/lufa/lufa.c') diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 4f9ab4f62c..c632b35c6e 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -774,17 +774,17 @@ static void send_mouse(report_mouse_t *report) { #endif } -/** \brief Send System +/** \brief Send Extra * * FIXME: Needs doc */ -static void send_system(uint16_t data) { #ifdef EXTRAKEY_ENABLE +static void send_extra(uint8_t report_id, uint16_t data) { uint8_t timeout = 255; if (USB_DeviceState != DEVICE_STATE_Configured) return; - report_extra_t r = {.report_id = REPORT_ID_SYSTEM, .usage = data - SYSTEM_POWER_DOWN + 1}; + report_extra_t r = {.report_id = report_id, .usage = data}; Endpoint_SelectEndpoint(SHARED_IN_EPNUM); /* Check if write ready for a polling interval around 10ms */ @@ -793,6 +793,16 @@ static void send_system(uint16_t data) { Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL); Endpoint_ClearIN(); +} +#endif + +/** \brief Send System + * + * FIXME: Needs doc + */ +static void send_system(uint16_t data) { +#ifdef EXTRAKEY_ENABLE + send_extra(REPORT_ID_SYSTEM, data - SYSTEM_POWER_DOWN + 1); #endif } @@ -802,7 +812,6 @@ static void send_system(uint16_t data) { */ static void send_consumer(uint16_t data) { #ifdef EXTRAKEY_ENABLE - uint8_t timeout = 255; uint8_t where = where_to_send(); # ifdef BLUETOOTH_ENABLE @@ -841,15 +850,7 @@ static void send_consumer(uint16_t data) { return; } - report_extra_t r = {.report_id = REPORT_ID_CONSUMER, .usage = data}; - Endpoint_SelectEndpoint(SHARED_IN_EPNUM); - - /* Check if write ready for a polling interval around 10ms */ - while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40); - if (!Endpoint_IsReadWriteAllowed()) return; - - Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL); - Endpoint_ClearIN(); + send_extra(REPORT_ID_CONSUMER, data); #endif } -- cgit v1.2.3