diff options
| author | fauxpark <fauxpark@gmail.com> | 2020-02-03 07:17:05 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-02 12:17:05 -0800 |
| commit | b2ce2f8a34fba72e4b4ac2fba0ec11431b0acb0c (patch) | |
| tree | 58494d6dd519ac3b87b431188bd9b0e1b14befae /tmk_core/protocol/vusb/vusb.c | |
| parent | 5b91c3e0a0dc8152f69130cf047f3df0d0f94421 (diff) | |
| download | qmk_firmware-b2ce2f8a34fba72e4b4ac2fba0ec11431b0acb0c.tar.gz qmk_firmware-b2ce2f8a34fba72e4b4ac2fba0ec11431b0acb0c.zip | |
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.c | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c index e66938445..71263344f 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) { | |||
| 112 | } | 112 | } |
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | typedef struct { | 115 | static void send_extra(uint8_t report_id, uint16_t data) { |
| 116 | uint8_t report_id; | 116 | static uint8_t last_id = 0; |
| 117 | uint16_t usage; | ||
| 118 | } __attribute__((packed)) report_extra_t; | ||
| 119 | |||
| 120 | static void send_system(uint16_t data) { | ||
| 121 | static uint16_t last_data = 0; | 117 | static uint16_t last_data = 0; |
| 122 | if (data == last_data) return; | 118 | if ((report_id == last_id) && (data == last_data)) return; |
| 119 | last_id = report_id; | ||
| 123 | last_data = data; | 120 | last_data = data; |
| 124 | 121 | ||
| 125 | report_extra_t report = {.report_id = REPORT_ID_SYSTEM, .usage = data}; | 122 | report_extra_t report = {.report_id = report_id, .usage = data}; |
| 126 | if (usbInterruptIsReady3()) { | 123 | if (usbInterruptIsReady3()) { |
| 127 | usbSetInterrupt3((void *)&report, sizeof(report)); | 124 | usbSetInterrupt3((void *)&report, sizeof(report)); |
| 128 | } | 125 | } |
| 129 | } | 126 | } |
| 130 | 127 | ||
| 131 | static void send_consumer(uint16_t data) { | 128 | static void send_system(uint16_t data) { |
| 132 | static uint16_t last_data = 0; | 129 | send_extra(REPORT_ID_SYSTEM, data); |
| 133 | if (data == last_data) return; | 130 | } |
| 134 | last_data = data; | ||
| 135 | 131 | ||
| 136 | report_extra_t report = {.report_id = REPORT_ID_CONSUMER, .usage = data}; | 132 | static void send_consumer(uint16_t data) { |
| 137 | if (usbInterruptIsReady3()) { | 133 | send_extra(REPORT_ID_CONSUMER, data); |
| 138 | usbSetInterrupt3((void *)&report, sizeof(report)); | ||
| 139 | } | ||
| 140 | } | 134 | } |
| 141 | 135 | ||
| 142 | /*------------------------------------------------------------------* | 136 | /*------------------------------------------------------------------* |
