forked from mirrors/qmk_userspace
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
This commit is contained in:
parent
5b91c3e0a0
commit
b2ce2f8a34
6 changed files with 39 additions and 65 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue