summaryrefslogtreecommitdiffstats
path: root/tmk_core/protocol/lufa
diff options
context:
space:
mode:
authorfauxpark <fauxpark@gmail.com>2020-02-03 07:17:05 +1100
committerGitHub <noreply@github.com>2020-02-02 12:17:05 -0800
commitb2ce2f8a34fba72e4b4ac2fba0ec11431b0acb0c (patch)
tree58494d6dd519ac3b87b431188bd9b0e1b14befae /tmk_core/protocol/lufa
parent5b91c3e0a0dc8152f69130cf047f3df0d0f94421 (diff)
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
Diffstat (limited to 'tmk_core/protocol/lufa')
-rw-r--r--tmk_core/protocol/lufa/lufa.c27
-rw-r--r--tmk_core/protocol/lufa/lufa.h6
2 files changed, 14 insertions, 19 deletions
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c
index db66a07222..792db43402 100644
--- a/tmk_core/protocol/lufa/lufa.c
+++ b/tmk_core/protocol/lufa/lufa.c
@@ -662,17 +662,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 */
@@ -681,6 +681,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
}
@@ -690,7 +700,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
@@ -729,15 +738,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
}
diff --git a/tmk_core/protocol/lufa/lufa.h b/tmk_core/protocol/lufa/lufa.h
index 652e4e79b7..1b88060f14 100644
--- a/tmk_core/protocol/lufa/lufa.h
+++ b/tmk_core/protocol/lufa/lufa.h
@@ -58,12 +58,6 @@ extern host_driver_t lufa_driver;
}
#endif
-/* extra report structure */
-typedef struct {
- uint8_t report_id;
- uint16_t usage;
-} __attribute__((packed)) report_extra_t;
-
#ifdef API_ENABLE
# include "api.h"
#endif