diff options
author | Nick Brassel <[email protected]> | 2024-07-16 09:22:17 +1000 |
---|---|---|
committer | GitHub <[email protected]> | 2024-07-16 09:22:17 +1000 |
commit | 8abaa3bc2df4fda13a96d0c5c4ce74b70c974fb7 (patch) | |
tree | 3075091c9032beb60388dee536ecf0452f79035c /quantum/process_keycode | |
parent | fef8e7195b09158a9b43ffd05df60128f3cd3ac3 (diff) | |
download | qmk_firmware-8abaa3bc2df4fda13a96d0c5c4ce74b70c974fb7.tar.gz qmk_firmware-8abaa3bc2df4fda13a96d0c5c4ce74b70c974fb7.zip |
Add support for key override introspection. (#24120)
Diffstat (limited to 'quantum/process_keycode')
-rw-r--r-- | quantum/process_keycode/process_key_override.c | 10 | ||||
-rw-r--r-- | quantum/process_keycode/process_key_override.h | 5 |
2 files changed, 5 insertions, 10 deletions
diff --git a/quantum/process_keycode/process_key_override.c b/quantum/process_keycode/process_key_override.c index 264e2562b8..ce30477ee8 100644 --- a/quantum/process_keycode/process_key_override.c +++ b/quantum/process_keycode/process_key_override.c @@ -23,6 +23,7 @@ #include "action_util.h" #include "quantum.h" #include "quantum_keycodes.h" +#include "keymap_introspection.h" #ifndef KEY_OVERRIDE_REPEAT_DELAY # define KEY_OVERRIDE_REPEAT_DELAY 500 @@ -83,9 +84,6 @@ static uint16_t deferred_register = 0; // TODO: in future maybe save in EEPROM? static bool enabled = true; -// Public variables -__attribute__((weak)) const key_override_t **key_overrides = NULL; - // Forward decls static const key_override_t *clear_active_override(const bool allow_reregister); @@ -247,12 +245,12 @@ static bool check_activation_event(const key_override_t *override, const bool ke /** Iterates through the list of key overrides and tries activating each, until it finds one that activates or reaches the end of overrides. Returns true if the key action for `keycode` should be sent */ static bool try_activating_override(const uint16_t keycode, const uint8_t layer, const bool key_down, const bool is_mod, const uint8_t active_mods, bool *activated) { - if (key_overrides == NULL) { + if (key_override_count() == 0) { return true; } - for (uint8_t i = 0;; i++) { - const key_override_t *const override = key_overrides[i]; + for (uint8_t i = 0; i < key_override_count(); i++) { + const key_override_t *const override = key_override_get(i); // End of array if (override == NULL) { diff --git a/quantum/process_keycode/process_key_override.h b/quantum/process_keycode/process_key_override.h index 3e37c7e63a..9ec84dbe6e 100644 --- a/quantum/process_keycode/process_key_override.h +++ b/quantum/process_keycode/process_key_override.h @@ -55,7 +55,7 @@ typedef enum { } ko_option_t; /** Defines a single key override */ -typedef struct { +typedef struct key_override_t { // The non-modifier keycode that triggers the override. This keycode, and the necessary modifiers (trigger_mods) must be pressed to activate this override. Set this to the keycode of the key that should activate the override. Set to KC_NO to require only the necessary modifiers to be pressed and no non-modifier. uint16_t trigger; @@ -87,9 +87,6 @@ typedef struct { bool *enabled; } key_override_t; -/** Define this as a null-terminated array of pointers to key overrides. These key overrides will be used by qmk. */ -extern const key_override_t **key_overrides; - /** Turns key overrides on */ void key_override_on(void); |