1
0
Fork 0

Add support for key override introspection. (#24120)

This commit is contained in:
Nick Brassel 2024-07-16 09:22:17 +10:00 committed by GitHub
parent fef8e7195b
commit 8abaa3bc2d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 90 additions and 25 deletions

View file

@ -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) {