summaryrefslogtreecommitdiff
path: root/tmk_core/protocol/vusb/vusb.c
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/vusb/vusb.c
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/vusb/vusb.c')
-rw-r--r--tmk_core/protocol/vusb/vusb.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c
index e669384455..71263344fd 100644
--- a/tmk_core/protocol/vusb/vusb.c
+++ b/tmk_core/protocol/vusb/vusb.c
@@ -112,31 +112,25 @@ static void send_mouse(report_mouse_t *report) {
}
}
-typedef struct {
- uint8_t report_id;
- uint16_t usage;
-} __attribute__((packed)) report_extra_t;
-
-static void send_system(uint16_t data) {
+static void send_extra(uint8_t report_id, uint16_t data) {
+ static uint8_t last_id = 0;
static uint16_t last_data = 0;
- if (data == last_data) return;
+ if ((report_id == last_id) && (data == last_data)) return;
+ last_id = report_id;
last_data = data;
- report_extra_t report = {.report_id = REPORT_ID_SYSTEM, .usage = data};
+ report_extra_t report = {.report_id = report_id, .usage = data};
if (usbInterruptIsReady3()) {
usbSetInterrupt3((void *)&report, sizeof(report));
}
}
-static void send_consumer(uint16_t data) {
- static uint16_t last_data = 0;
- if (data == last_data) return;
- last_data = data;
+static void send_system(uint16_t data) {
+ send_extra(REPORT_ID_SYSTEM, data);
+}
- report_extra_t report = {.report_id = REPORT_ID_CONSUMER, .usage = data};
- if (usbInterruptIsReady3()) {
- usbSetInterrupt3((void *)&report, sizeof(report));
- }
+static void send_consumer(uint16_t data) {
+ send_extra(REPORT_ID_CONSUMER, data);
}
/*------------------------------------------------------------------*