diff options
author | Thomas Weißschuh <thomas@t-8ch.de> | 2021-09-15 17:40:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-15 08:40:22 -0700 |
commit | 83988597f4d916a37b2b0987f393ceaa007532eb (patch) | |
tree | ba5d07ccf743cb27bee77b4d6cd2128035ce365e /tmk_core/common | |
parent | 1a68feb842ebcc6a7d1aef7cd7f83865cc18fab1 (diff) | |
download | qmk_firmware-83988597f4d916a37b2b0987f393ceaa007532eb.tar.gz qmk_firmware-83988597f4d916a37b2b0987f393ceaa007532eb.zip |
Add Support for USB programmable buttons (#12950)
Diffstat (limited to 'tmk_core/common')
-rw-r--r-- | tmk_core/common/chibios/suspend.c | 4 | ||||
-rw-r--r-- | tmk_core/common/host.c | 15 | ||||
-rw-r--r-- | tmk_core/common/host.h | 2 | ||||
-rw-r--r-- | tmk_core/common/host_driver.h | 1 | ||||
-rw-r--r-- | tmk_core/common/report.h | 6 |
5 files changed, 26 insertions, 2 deletions
diff --git a/tmk_core/common/chibios/suspend.c b/tmk_core/common/chibios/suspend.c index 991fe6e08b..9310a99920 100644 --- a/tmk_core/common/chibios/suspend.c +++ b/tmk_core/common/chibios/suspend.c @@ -7,6 +7,7 @@ #include "action.h" #include "action_util.h" #include "mousekey.h" +#include "programmable_button.h" #include "host.h" #include "suspend.h" #include "led.h" @@ -79,6 +80,9 @@ void suspend_wakeup_init(void) { #ifdef MOUSEKEY_ENABLE mousekey_clear(); #endif /* MOUSEKEY_ENABLE */ +#ifdef PROGRAMMABLE_BUTTON_ENABLE + programmable_button_clear(); +#endif /* PROGRAMMABLE_BUTTON_ENABLE */ #ifdef EXTRAKEY_ENABLE host_system_send(0); host_consumer_send(0); diff --git a/tmk_core/common/host.c b/tmk_core/common/host.c index f0c396b189..56d4bb0847 100644 --- a/tmk_core/common/host.c +++ b/tmk_core/common/host.c @@ -30,8 +30,9 @@ extern keymap_config_t keymap_config; #endif static host_driver_t *driver; -static uint16_t last_system_report = 0; -static uint16_t last_consumer_report = 0; +static uint16_t last_system_report = 0; +static uint16_t last_consumer_report = 0; +static uint32_t last_programmable_button_report = 0; void host_set_driver(host_driver_t *d) { driver = d; } @@ -122,6 +123,16 @@ void host_digitizer_send(digitizer_t *digitizer) { __attribute__((weak)) void send_digitizer(report_digitizer_t *report) {} +void host_programmable_button_send(uint32_t report) { + if (report == last_programmable_button_report) return; + last_programmable_button_report = report; + + if (!driver) return; + (*driver->send_programmable_button)(report); +} + uint16_t host_last_system_report(void) { return last_system_report; } uint16_t host_last_consumer_report(void) { return last_consumer_report; } + +uint32_t host_last_programmable_button_report(void) { return last_programmable_button_report; } diff --git a/tmk_core/common/host.h b/tmk_core/common/host.h index 2cffef6e15..6b15f0d0c1 100644 --- a/tmk_core/common/host.h +++ b/tmk_core/common/host.h @@ -47,9 +47,11 @@ void host_keyboard_send(report_keyboard_t *report); void host_mouse_send(report_mouse_t *report); void host_system_send(uint16_t data); void host_consumer_send(uint16_t data); +void host_programmable_button_send(uint32_t data); uint16_t host_last_system_report(void); uint16_t host_last_consumer_report(void); +uint32_t host_last_programmable_button_report(void); #ifdef __cplusplus } diff --git a/tmk_core/common/host_driver.h b/tmk_core/common/host_driver.h index 2aebca043d..affd0dcb34 100644 --- a/tmk_core/common/host_driver.h +++ b/tmk_core/common/host_driver.h @@ -29,6 +29,7 @@ typedef struct { void (*send_mouse)(report_mouse_t *); void (*send_system)(uint16_t); void (*send_consumer)(uint16_t); + void (*send_programmable_button)(uint32_t); } host_driver_t; void send_digitizer(report_digitizer_t *report);
\ No newline at end of file diff --git a/tmk_core/common/report.h b/tmk_core/common/report.h index f2223e8063..1adc892f3b 100644 --- a/tmk_core/common/report.h +++ b/tmk_core/common/report.h @@ -29,6 +29,7 @@ enum hid_report_ids { REPORT_ID_MOUSE, REPORT_ID_SYSTEM, REPORT_ID_CONSUMER, + REPORT_ID_PROGRAMMABLE_BUTTON, REPORT_ID_NKRO, REPORT_ID_JOYSTICK, REPORT_ID_DIGITIZER @@ -196,6 +197,11 @@ typedef struct { } __attribute__((packed)) report_extra_t; typedef struct { + uint8_t report_id; + uint32_t usage; +} __attribute__((packed)) report_programmable_button_t; + +typedef struct { #ifdef MOUSE_SHARED_EP uint8_t report_id; #endif |