From ab0c06ebfe41a6ed87da6ef8261e966fbee6c4a4 Mon Sep 17 00:00:00 2001 From: zvecr Date: Tue, 27 Jul 2021 23:53:39 +0100 Subject: [PATCH 1/3] Minor tidy up of key overrides --- common_features.mk | 10 ++++---- .../process_keycode/process_key_override.c | 2 +- .../process_keycode/process_key_override.h | 14 +++++++---- .../process_key_override_private.h | 24 ------------------- quantum/quantum.c | 10 +------- 5 files changed, 17 insertions(+), 43 deletions(-) delete mode 100644 quantum/process_keycode/process_key_override_private.h diff --git a/common_features.mk b/common_features.mk index a4991b05b020..99020830e883 100644 --- a/common_features.mk +++ b/common_features.mk @@ -334,11 +334,6 @@ ifeq ($(strip $(PRINTING_ENABLE)), yes) SRC += $(TMK_DIR)/protocol/serial_uart.c endif -ifeq ($(strip $(KEY_OVERRIDE_ENABLE)), yes) - OPT_DEFS += -DKEY_OVERRIDE_ENABLE - SRC += $(QUANTUM_DIR)/process_keycode/process_key_override.c -endif - ifeq ($(strip $(SERIAL_LINK_ENABLE)), yes) SERIAL_SRC := $(wildcard $(SERIAL_PATH)/protocol/*.c) SERIAL_SRC += $(wildcard $(SERIAL_PATH)/system/*.c) @@ -668,6 +663,11 @@ ifeq ($(strip $(COMBO_ENABLE)), yes) OPT_DEFS += -DCOMBO_ENABLE endif +ifeq ($(strip $(KEY_OVERRIDE_ENABLE)), yes) + SRC += $(QUANTUM_DIR)/process_keycode/process_key_override.c + OPT_DEFS += -DKEY_OVERRIDE_ENABLE +endif + ifeq ($(strip $(TAP_DANCE_ENABLE)), yes) SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c OPT_DEFS += -DTAP_DANCE_ENABLE diff --git a/quantum/process_keycode/process_key_override.c b/quantum/process_keycode/process_key_override.c index fe43eacc40f4..8b45a94043f2 100644 --- a/quantum/process_keycode/process_key_override.c +++ b/quantum/process_keycode/process_key_override.c @@ -380,7 +380,7 @@ static bool try_activating_override(const uint16_t keycode, const uint8_t layer, return true; } -void matrix_scan_key_override(void) { +void key_override_task(void) { if (deferred_register == 0) { return; } diff --git a/quantum/process_keycode/process_key_override.h b/quantum/process_keycode/process_key_override.h index 9ba59e4e9ba6..fd76f297a807 100644 --- a/quantum/process_keycode/process_key_override.h +++ b/quantum/process_keycode/process_key_override.h @@ -92,16 +92,22 @@ typedef struct { extern const key_override_t **key_overrides; /** Turns key overrides on */ -extern void key_override_on(void); +void key_override_on(void); /** Turns key overrides off */ -extern void key_override_off(void); +void key_override_off(void); /** Toggles key overrides on */ -extern void key_override_toggle(void); +void key_override_toggle(void); /** Returns whether key overrides are enabled */ -extern bool key_override_is_enabled(void); +bool key_override_is_enabled(void); + +/** Handling of key overrides and its implemented keycodes */ +bool process_key_override(const uint16_t keycode, const keyrecord_t *const record); + +/** Perform any deferred keys */ +void key_override_task(void); /** * Preferrably use these macros to create key overrides. They fix many of the options to a standard setting that should satisfy most basic use-cases. Only directly create a key_override_t struct when you really need to. diff --git a/quantum/process_keycode/process_key_override_private.h b/quantum/process_keycode/process_key_override_private.h deleted file mode 100644 index 1d0e134a19c0..000000000000 --- a/quantum/process_keycode/process_key_override_private.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2021 Jonas Gessner - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include -#include "action.h" - -bool process_key_override(const uint16_t keycode, const keyrecord_t *const record); -void matrix_scan_key_override(void); diff --git a/quantum/quantum.c b/quantum/quantum.c index f430a521b301..b1378c622ba0 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -51,14 +51,6 @@ float default_layer_songs[][16][2] = DEFAULT_LAYER_SONGS; # endif #endif -#ifdef AUTO_SHIFT_ENABLE -# include "process_auto_shift.h" -#endif - -#ifdef KEY_OVERRIDE_ENABLE -# include "process_key_override_private.h" -#endif - uint8_t extract_mod_bits(uint16_t code) { switch (code) { case QK_MODS ... QK_MODS_MAX: @@ -415,7 +407,7 @@ void matrix_scan_quantum() { #endif #ifdef KEY_OVERRIDE_ENABLE - matrix_scan_key_override(); + key_override_task(); #endif #ifdef SEQUENCER_ENABLE From 342591fe660d738c41b5a15bc6461bc66ff23e33 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Wed, 28 Jul 2021 01:57:48 +0100 Subject: [PATCH 2/3] Update quantum/quantum.c --- quantum/quantum.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/quantum/quantum.c b/quantum/quantum.c index b1378c622ba0..4707f3feafdb 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -51,6 +51,9 @@ float default_layer_songs[][16][2] = DEFAULT_LAYER_SONGS; # endif #endif +#ifdef AUTO_SHIFT_ENABLE +# include "process_auto_shift.h" +#endif uint8_t extract_mod_bits(uint16_t code) { switch (code) { case QK_MODS ... QK_MODS_MAX: From e5ffa6501b0208dcfbad3a775200d80d15b07c6e Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Wed, 28 Jul 2021 01:58:36 +0100 Subject: [PATCH 3/3] Update quantum/quantum.c --- quantum/quantum.c | 1 + 1 file changed, 1 insertion(+) diff --git a/quantum/quantum.c b/quantum/quantum.c index 4707f3feafdb..939192b12cff 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -54,6 +54,7 @@ float default_layer_songs[][16][2] = DEFAULT_LAYER_SONGS; #ifdef AUTO_SHIFT_ENABLE # include "process_auto_shift.h" #endif + uint8_t extract_mod_bits(uint16_t code) { switch (code) { case QK_MODS ... QK_MODS_MAX: