Simplify extrakeys sending at the host driver level (#18230)
* Simplify extrakeys sending at the host driver level * There are two arguments here * Wrong syntax * Adjust keyboards which use a custom host driver
This commit is contained in:
@ -37,14 +37,13 @@ void main_subtasks(void);
|
||||
uint8_t keyboard_leds(void);
|
||||
void send_keyboard(report_keyboard_t *report);
|
||||
void send_mouse(report_mouse_t *report);
|
||||
void send_system(uint16_t data);
|
||||
void send_consumer(uint16_t data);
|
||||
void send_extra(uint8_t report_id, uint16_t data);
|
||||
|
||||
#ifdef DEFERRED_EXEC_ENABLE
|
||||
void deferred_exec_task(void);
|
||||
#endif // DEFERRED_EXEC_ENABLE
|
||||
|
||||
host_driver_t arm_atsam_driver = {keyboard_leds, send_keyboard, send_mouse, send_system, send_consumer};
|
||||
host_driver_t arm_atsam_driver = {keyboard_leds, send_keyboard, send_mouse, send_extra};
|
||||
|
||||
uint8_t led_states;
|
||||
|
||||
@ -132,18 +131,6 @@ void send_extra(uint8_t report_id, uint16_t data) {
|
||||
}
|
||||
#endif // EXTRAKEY_ENABLE
|
||||
|
||||
void send_system(uint16_t data) {
|
||||
#ifdef EXTRAKEY_ENABLE
|
||||
send_extra(REPORT_ID_SYSTEM, data);
|
||||
#endif // EXTRAKEY_ENABLE
|
||||
}
|
||||
|
||||
void send_consumer(uint16_t data) {
|
||||
#ifdef EXTRAKEY_ENABLE
|
||||
send_extra(REPORT_ID_CONSUMER, data);
|
||||
#endif // EXTRAKEY_ENABLE
|
||||
}
|
||||
|
||||
#ifdef CONSOLE_ENABLE
|
||||
# define CONSOLE_PRINTBUF_SIZE 512
|
||||
static char console_printbuf[CONSOLE_PRINTBUF_SIZE];
|
||||
|
@ -58,13 +58,12 @@
|
||||
uint8_t keyboard_leds(void);
|
||||
void send_keyboard(report_keyboard_t *report);
|
||||
void send_mouse(report_mouse_t *report);
|
||||
void send_system(uint16_t data);
|
||||
void send_consumer(uint16_t data);
|
||||
void send_extra(uint8_t report_id, uint16_t data);
|
||||
void send_programmable_button(uint32_t data);
|
||||
void send_digitizer(report_digitizer_t *report);
|
||||
|
||||
/* host struct */
|
||||
host_driver_t chibios_driver = {keyboard_leds, send_keyboard, send_mouse, send_system, send_consumer, send_programmable_button};
|
||||
host_driver_t chibios_driver = {keyboard_leds, send_keyboard, send_mouse, send_extra, send_programmable_button};
|
||||
|
||||
#ifdef VIRTSER_ENABLE
|
||||
void virtser_task(void);
|
||||
|
@ -947,7 +947,7 @@ void shared_in_cb(USBDriver *usbp, usbep_t ep) {
|
||||
*/
|
||||
|
||||
#ifdef EXTRAKEY_ENABLE
|
||||
static void send_extra(uint8_t report_id, uint16_t data) {
|
||||
void send_extra(uint8_t report_id, uint16_t data) {
|
||||
osalSysLock();
|
||||
if (usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) {
|
||||
osalSysUnlock();
|
||||
@ -973,18 +973,6 @@ static void send_extra(uint8_t report_id, uint16_t data) {
|
||||
}
|
||||
#endif
|
||||
|
||||
void send_system(uint16_t data) {
|
||||
#ifdef EXTRAKEY_ENABLE
|
||||
send_extra(REPORT_ID_SYSTEM, data);
|
||||
#endif
|
||||
}
|
||||
|
||||
void send_consumer(uint16_t data) {
|
||||
#ifdef EXTRAKEY_ENABLE
|
||||
send_extra(REPORT_ID_CONSUMER, data);
|
||||
#endif
|
||||
}
|
||||
|
||||
void send_programmable_button(uint32_t data) {
|
||||
#ifdef PROGRAMMABLE_BUTTON_ENABLE
|
||||
osalSysLock();
|
||||
|
@ -107,7 +107,7 @@ void host_system_send(uint16_t report) {
|
||||
last_system_report = report;
|
||||
|
||||
if (!driver) return;
|
||||
(*driver->send_system)(report);
|
||||
(*driver->send_extra)(REPORT_ID_SYSTEM, report);
|
||||
}
|
||||
|
||||
void host_consumer_send(uint16_t report) {
|
||||
@ -115,7 +115,7 @@ void host_consumer_send(uint16_t report) {
|
||||
last_consumer_report = report;
|
||||
|
||||
if (!driver) return;
|
||||
(*driver->send_consumer)(report);
|
||||
(*driver->send_extra)(REPORT_ID_CONSUMER, report);
|
||||
}
|
||||
|
||||
void host_digitizer_send(digitizer_t *digitizer) {
|
||||
|
@ -27,9 +27,8 @@ typedef struct {
|
||||
uint8_t (*keyboard_leds)(void);
|
||||
void (*send_keyboard)(report_keyboard_t *);
|
||||
void (*send_mouse)(report_mouse_t *);
|
||||
void (*send_system)(uint16_t);
|
||||
void (*send_consumer)(uint16_t);
|
||||
void (*send_extra)(uint8_t, uint16_t);
|
||||
void (*send_programmable_button)(uint32_t);
|
||||
} host_driver_t;
|
||||
|
||||
void send_digitizer(report_digitizer_t *report);
|
||||
void send_digitizer(report_digitizer_t *report);
|
||||
|
@ -101,10 +101,9 @@ static report_keyboard_t keyboard_report_sent;
|
||||
static uint8_t keyboard_leds(void);
|
||||
static void send_keyboard(report_keyboard_t *report);
|
||||
static void send_mouse(report_mouse_t *report);
|
||||
static void send_system(uint16_t data);
|
||||
static void send_consumer(uint16_t data);
|
||||
static void send_extra(uint8_t report_id, uint16_t data);
|
||||
static void send_programmable_button(uint32_t data);
|
||||
host_driver_t lufa_driver = {keyboard_leds, send_keyboard, send_mouse, send_system, send_consumer, send_programmable_button};
|
||||
host_driver_t lufa_driver = {keyboard_leds, send_keyboard, send_mouse, send_extra, send_programmable_button};
|
||||
|
||||
#ifdef VIRTSER_ENABLE
|
||||
// clang-format off
|
||||
@ -748,30 +747,8 @@ static void send_report(void *report, size_t size) {
|
||||
*/
|
||||
#ifdef EXTRAKEY_ENABLE
|
||||
static void send_extra(uint8_t report_id, uint16_t data) {
|
||||
static report_extra_t r;
|
||||
r = (report_extra_t){.report_id = report_id, .usage = data};
|
||||
send_report(&r, sizeof(r));
|
||||
}
|
||||
#endif
|
||||
|
||||
/** \brief Send System
|
||||
*
|
||||
* FIXME: Needs doc
|
||||
*/
|
||||
static void send_system(uint16_t data) {
|
||||
#ifdef EXTRAKEY_ENABLE
|
||||
send_extra(REPORT_ID_SYSTEM, data);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** \brief Send Consumer
|
||||
*
|
||||
* FIXME: Needs doc
|
||||
*/
|
||||
static void send_consumer(uint16_t data) {
|
||||
#ifdef EXTRAKEY_ENABLE
|
||||
# ifdef BLUETOOTH_ENABLE
|
||||
if (where_to_send() == OUTPUT_BLUETOOTH) {
|
||||
if (report_id == REPORT_ID_CONSUMER && where_to_send() == OUTPUT_BLUETOOTH) {
|
||||
# ifdef BLUETOOTH_BLUEFRUIT_LE
|
||||
bluefruit_le_send_consumer_key(data);
|
||||
# elif BLUETOOTH_RN42
|
||||
@ -781,9 +758,11 @@ static void send_consumer(uint16_t data) {
|
||||
}
|
||||
# endif
|
||||
|
||||
send_extra(REPORT_ID_CONSUMER, data);
|
||||
#endif
|
||||
static report_extra_t r;
|
||||
r = (report_extra_t){.report_id = report_id, .usage = data};
|
||||
send_report(&r, sizeof(r));
|
||||
}
|
||||
#endif
|
||||
|
||||
static void send_programmable_button(uint32_t data) {
|
||||
#ifdef PROGRAMMABLE_BUTTON_ENABLE
|
||||
|
@ -224,11 +224,10 @@ void console_task(void) {
|
||||
static uint8_t keyboard_leds(void);
|
||||
static void send_keyboard(report_keyboard_t *report);
|
||||
static void send_mouse(report_mouse_t *report);
|
||||
static void send_system(uint16_t data);
|
||||
static void send_consumer(uint16_t data);
|
||||
static void send_extra(uint8_t report_id, uint16_t data);
|
||||
static void send_programmable_button(uint32_t data);
|
||||
|
||||
static host_driver_t driver = {keyboard_leds, send_keyboard, send_mouse, send_system, send_consumer, send_programmable_button};
|
||||
static host_driver_t driver = {keyboard_leds, send_keyboard, send_mouse, send_extra, send_programmable_button};
|
||||
|
||||
host_driver_t *vusb_driver(void) {
|
||||
return &driver;
|
||||
@ -285,18 +284,6 @@ static void send_extra(uint8_t report_id, uint16_t data) {
|
||||
}
|
||||
#endif
|
||||
|
||||
static void send_system(uint16_t data) {
|
||||
#ifdef EXTRAKEY_ENABLE
|
||||
send_extra(REPORT_ID_SYSTEM, data);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void send_consumer(uint16_t data) {
|
||||
#ifdef EXTRAKEY_ENABLE
|
||||
send_extra(REPORT_ID_CONSUMER, data);
|
||||
#endif
|
||||
}
|
||||
|
||||
void send_digitizer(report_digitizer_t *report) {
|
||||
#ifdef DIGITIZER_ENABLE
|
||||
if (usbInterruptIsReadyShared()) {
|
||||
|
Reference in New Issue
Block a user