[Feature] Key Overrides (#11422)

This commit is contained in:
Jonas Gessner 2021-07-13 19:13:51 +02:00 committed by GitHub
parent 1ae4d52013
commit 52cfc9259b
Failed to generate hash of commit
14 changed files with 984 additions and 3 deletions

View file

@ -27,6 +27,10 @@ extern keymap_config_t keymap_config;
static uint8_t real_mods = 0;
static uint8_t weak_mods = 0;
static uint8_t macro_mods = 0;
#ifdef KEY_OVERRIDE_ENABLE
static uint8_t weak_override_mods = 0;
static uint8_t suppressed_mods = 0;
#endif
#ifdef USB_6KRO_ENABLE
# define RO_ADD(a, b) ((a + b) % KEYBOARD_REPORT_KEYS)
@ -229,6 +233,7 @@ void send_keyboard_report(void) {
keyboard_report->mods = real_mods;
keyboard_report->mods |= weak_mods;
keyboard_report->mods |= macro_mods;
#ifndef NO_ACTION_ONESHOT
if (oneshot_mods) {
# if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
@ -244,6 +249,13 @@ void send_keyboard_report(void) {
}
#endif
#ifdef KEY_OVERRIDE_ENABLE
// These need to be last to be able to properly control key overrides
keyboard_report->mods &= ~suppressed_mods;
keyboard_report->mods |= weak_override_mods;
#endif
host_keyboard_send(keyboard_report);
}
@ -299,6 +311,22 @@ void set_weak_mods(uint8_t mods) { weak_mods = mods; }
*/
void clear_weak_mods(void) { weak_mods = 0; }
#ifdef KEY_OVERRIDE_ENABLE
/** \brief set weak mods used by key overrides. DO not call this manually
*/
void set_weak_override_mods(uint8_t mods) { weak_override_mods = mods; }
/** \brief clear weak mods used by key overrides. DO not call this manually
*/
void clear_weak_override_mods(void) { weak_override_mods = 0; }
/** \brief set suppressed mods used by key overrides. DO not call this manually
*/
void set_suppressed_override_mods(uint8_t mods) { suppressed_mods = mods; }
/** \brief clear suppressed mods used by key overrides. DO not call this manually
*/
void clear_suppressed_override_mods(void) { suppressed_mods = 0; }
#endif
/* macro modifier */
/** \brief get macro mods
*