summaryrefslogtreecommitdiffstats
path: root/quantum/process_keycode
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/process_keycode')
-rw-r--r--quantum/process_keycode/process_audio.c13
-rw-r--r--quantum/process_keycode/process_audio.h1
-rw-r--r--quantum/process_keycode/process_auto_shift.c36
-rw-r--r--quantum/process_keycode/process_clicky.c32
-rw-r--r--quantum/process_keycode/process_combo.c88
-rw-r--r--quantum/process_keycode/process_dynamic_macro.c18
-rw-r--r--quantum/process_keycode/process_grave_esc.c4
-rw-r--r--quantum/process_keycode/process_haptic.c3
-rw-r--r--quantum/process_keycode/process_joystick.c4
-rw-r--r--quantum/process_keycode/process_key_lock.c5
-rw-r--r--quantum/process_keycode/process_key_lock.h1
-rw-r--r--quantum/process_keycode/process_key_override.c24
-rw-r--r--quantum/process_keycode/process_leader.c4
-rw-r--r--quantum/process_keycode/process_magic.c12
-rw-r--r--quantum/process_keycode/process_midi.c26
-rw-r--r--quantum/process_keycode/process_midi.h4
-rw-r--r--quantum/process_keycode/process_music.c26
-rw-r--r--quantum/process_keycode/process_music.h8
-rw-r--r--quantum/process_keycode/process_printer.c12
-rw-r--r--quantum/process_keycode/process_printer.h2
-rw-r--r--quantum/process_keycode/process_printer_bb.c23
-rw-r--r--quantum/process_keycode/process_rgb.c6
-rw-r--r--quantum/process_keycode/process_steno.c24
-rw-r--r--quantum/process_keycode/process_tap_dance.c6
-rw-r--r--quantum/process_keycode/process_terminal.c34
-rw-r--r--quantum/process_keycode/process_ucis.c2
-rw-r--r--quantum/process_keycode/process_unicode_common.c24
-rw-r--r--quantum/process_keycode/process_unicode_common.h12
28 files changed, 308 insertions, 146 deletions
diff --git a/quantum/process_keycode/process_audio.c b/quantum/process_keycode/process_audio.c
index 3b5fa8490b..e7fe453308 100644
--- a/quantum/process_keycode/process_audio.c
+++ b/quantum/process_keycode/process_audio.c
@@ -50,10 +50,17 @@ bool process_audio(uint16_t keycode, keyrecord_t *record) {
return true;
}
-void process_audio_noteon(uint8_t note) { play_note(compute_freq_for_midi_note(note), 0xF); }
+void process_audio_noteon(uint8_t note) {
+ play_note(compute_freq_for_midi_note(note), 0xF);
+}
-void process_audio_noteoff(uint8_t note) { stop_note(compute_freq_for_midi_note(note)); }
+void process_audio_noteoff(uint8_t note) {
+ stop_note(compute_freq_for_midi_note(note));
+}
-void process_audio_all_notes_off(void) { stop_all_notes(); }
+void process_audio_all_notes_off(void) {
+ stop_all_notes();
+}
__attribute__((weak)) void audio_on_user() {}
+__attribute__((weak)) void audio_off_user() {}
diff --git a/quantum/process_keycode/process_audio.h b/quantum/process_keycode/process_audio.h
index d89a834ea8..42cfab4af2 100644
--- a/quantum/process_keycode/process_audio.h
+++ b/quantum/process_keycode/process_audio.h
@@ -8,3 +8,4 @@ void process_audio_noteoff(uint8_t note);
void process_audio_all_notes_off(void);
void audio_on_user(void);
+void audio_off_user(void);
diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c
index bbc6367ff1..2150edd7b2 100644
--- a/quantum/process_keycode/process_auto_shift.c
+++ b/quantum/process_keycode/process_auto_shift.c
@@ -62,7 +62,9 @@ static struct {
// clang-format on
/** \brief Called on physical press, returns whether key should be added to Auto Shift */
-__attribute__((weak)) bool get_custom_auto_shifted_key(uint16_t keycode, keyrecord_t *record) { return false; }
+__attribute__((weak)) bool get_custom_auto_shifted_key(uint16_t keycode, keyrecord_t *record) {
+ return false;
+}
/** \brief Called on physical press, returns whether is Auto Shift key */
__attribute__((weak)) bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *record) {
@@ -82,8 +84,12 @@ __attribute__((weak)) bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *r
}
/** \brief Called to check whether defines should apply if PER_KEY is set for it */
-__attribute__((weak)) bool get_auto_shift_repeat(uint16_t keycode, keyrecord_t *record) { return true; }
-__attribute__((weak)) bool get_auto_shift_no_auto_repeat(uint16_t keycode, keyrecord_t *record) { return true; }
+__attribute__((weak)) bool get_auto_shift_repeat(uint16_t keycode, keyrecord_t *record) {
+ return true;
+}
+__attribute__((weak)) bool get_auto_shift_no_auto_repeat(uint16_t keycode, keyrecord_t *record) {
+ return true;
+}
/** \brief Called when an Auto Shift key needs to be pressed */
__attribute__((weak)) void autoshift_press_user(uint16_t keycode, bool shifted, keyrecord_t *record) {
@@ -94,7 +100,9 @@ __attribute__((weak)) void autoshift_press_user(uint16_t keycode, bool shifted,
}
/** \brief Called when an Auto Shift key needs to be released */
-__attribute__((weak)) void autoshift_release_user(uint16_t keycode, bool shifted, keyrecord_t *record) { unregister_code16((IS_RETRO(keycode)) ? keycode & 0xFF : keycode); }
+__attribute__((weak)) void autoshift_release_user(uint16_t keycode, bool shifted, keyrecord_t *record) {
+ unregister_code16((IS_RETRO(keycode)) ? keycode & 0xFF : keycode);
+}
/** \brief Sets the shift state to use when keyrepeating, required by custom shifts */
void set_autoshift_shift_state(uint16_t keycode, bool shifted) {
@@ -311,7 +319,9 @@ void autoshift_toggle(void) {
autoshift_flush_shift();
}
-void autoshift_enable(void) { autoshift_flags.enabled = true; }
+void autoshift_enable(void) {
+ autoshift_flags.enabled = true;
+}
void autoshift_disable(void) {
autoshift_flags.enabled = false;
@@ -328,12 +338,20 @@ void autoshift_timer_report(void) {
}
# endif
-bool get_autoshift_state(void) { return autoshift_flags.enabled; }
+bool get_autoshift_state(void) {
+ return autoshift_flags.enabled;
+}
-uint16_t get_generic_autoshift_timeout() { return autoshift_timeout; }
-__attribute__((weak)) uint16_t get_autoshift_timeout(uint16_t keycode, keyrecord_t *record) { return autoshift_timeout; }
+uint16_t get_generic_autoshift_timeout() {
+ return autoshift_timeout;
+}
+__attribute__((weak)) uint16_t get_autoshift_timeout(uint16_t keycode, keyrecord_t *record) {
+ return autoshift_timeout;
+}
-void set_autoshift_timeout(uint16_t timeout) { autoshift_timeout = timeout; }
+void set_autoshift_timeout(uint16_t timeout) {
+ autoshift_timeout = timeout;
+}
bool process_auto_shift(uint16_t keycode, keyrecord_t *record) {
// Note that record->event.time isn't reliable, see:
diff --git a/quantum/process_keycode/process_clicky.c b/quantum/process_keycode/process_clicky.c
index 6ab382d4aa..9795734984 100644
--- a/quantum/process_keycode/process_clicky.c
+++ b/quantum/process_keycode/process_clicky.c
@@ -5,40 +5,40 @@
# ifndef AUDIO_CLICKY_DELAY_DURATION
# define AUDIO_CLICKY_DELAY_DURATION 1
-# endif // !AUDIO_CLICKY_DELAY_DURATION
+# endif // !AUDIO_CLICKY_DELAY_DURATION
# ifndef AUDIO_CLICKY_FREQ_DEFAULT
# define AUDIO_CLICKY_FREQ_DEFAULT 440.0f
-# endif // !AUDIO_CLICKY_FREQ_DEFAULT
+# endif // !AUDIO_CLICKY_FREQ_DEFAULT
# ifndef AUDIO_CLICKY_FREQ_MIN
# define AUDIO_CLICKY_FREQ_MIN 65.0f
-# endif // !AUDIO_CLICKY_FREQ_MIN
+# endif // !AUDIO_CLICKY_FREQ_MIN
# ifndef AUDIO_CLICKY_FREQ_MAX
# define AUDIO_CLICKY_FREQ_MAX 1500.0f
-# endif // !AUDIO_CLICKY_FREQ_MAX
+# endif // !AUDIO_CLICKY_FREQ_MAX
# ifndef AUDIO_CLICKY_FREQ_FACTOR
# define AUDIO_CLICKY_FREQ_FACTOR 1.18921f
-# endif // !AUDIO_CLICKY_FREQ_FACTOR
+# endif // !AUDIO_CLICKY_FREQ_FACTOR
# ifndef AUDIO_CLICKY_FREQ_RANDOMNESS
# define AUDIO_CLICKY_FREQ_RANDOMNESS 0.05f
-# endif // !AUDIO_CLICKY_FREQ_RANDOMNESS
+# endif // !AUDIO_CLICKY_FREQ_RANDOMNESS
float clicky_freq = AUDIO_CLICKY_FREQ_DEFAULT;
float clicky_rand = AUDIO_CLICKY_FREQ_RANDOMNESS;
// the first "note" is an intentional delay; the 2nd and 3rd notes are the "clicky"
-float clicky_song[][2] = {{AUDIO_CLICKY_FREQ_MIN, AUDIO_CLICKY_DELAY_DURATION}, {AUDIO_CLICKY_FREQ_DEFAULT, 3}, {AUDIO_CLICKY_FREQ_DEFAULT, 1}}; // 3 and 1 --> durations
+float clicky_song[][2] = {{AUDIO_CLICKY_FREQ_MIN, AUDIO_CLICKY_DELAY_DURATION}, {AUDIO_CLICKY_FREQ_DEFAULT, 3}, {AUDIO_CLICKY_FREQ_DEFAULT, 1}}; // 3 and 1 --> durations
extern audio_config_t audio_config;
# ifndef NO_MUSIC_MODE
extern bool music_activated;
extern bool midi_activated;
-# endif // !NO_MUSIC_MODE
+# endif // !NO_MUSIC_MODE
void clicky_play(void) {
# ifndef NO_MUSIC_MODE
if (music_activated || midi_activated || !audio_config.enable) return;
-# endif // !NO_MUSIC_MODE
+# endif // !NO_MUSIC_MODE
clicky_song[1][0] = 2.0f * clicky_freq * (1.0f + clicky_rand * (((float)rand()) / ((float)(RAND_MAX))));
clicky_song[2][0] = clicky_freq * (1.0f + clicky_rand * (((float)rand()) / ((float)(RAND_MAX))));
PLAY_SONG(clicky_song);
@@ -58,7 +58,9 @@ void clicky_freq_down(void) {
}
}
-void clicky_freq_reset(void) { clicky_freq = AUDIO_CLICKY_FREQ_DEFAULT; }
+void clicky_freq_reset(void) {
+ clicky_freq = AUDIO_CLICKY_FREQ_DEFAULT;
+}
void clicky_toggle(void) {
audio_config.clicky_enable ^= 1;
@@ -75,7 +77,9 @@ void clicky_off(void) {
eeconfig_update_audio(audio_config.raw);
}
-bool is_clicky_on(void) { return (audio_config.clicky_enable != 0); }
+bool is_clicky_on(void) {
+ return (audio_config.clicky_enable != 0);
+}
bool process_clicky(uint16_t keycode, keyrecord_t *record) {
if (keycode == CLICKY_TOGGLE && record->event.pressed) {
@@ -101,8 +105,8 @@ bool process_clicky(uint16_t keycode, keyrecord_t *record) {
}
if (audio_config.enable && audio_config.clicky_enable) {
- if (record->event.pressed) { // Leave this separate so it's easier to add upstroke sound
- if (keycode != AU_OFF && keycode != AU_TOG) { // DO NOT PLAY if audio will be disabled, and causes issuse on ARM
+ if (record->event.pressed) { // Leave this separate so it's easier to add upstroke sound
+ if (keycode != AU_OFF && keycode != AU_TOG) { // DO NOT PLAY if audio will be disabled, and causes issuse on ARM
clicky_play();
}
}
@@ -110,4 +114,4 @@ bool process_clicky(uint16_t keycode, keyrecord_t *record) {
return true;
}
-#endif // AUDIO_CLICKY
+#endif // AUDIO_CLICKY
diff --git a/quantum/process_keycode/process_combo.c b/quantum/process_keycode/process_combo.c
index a050161edf..efaf8fe0e9 100644
--- a/quantum/process_keycode/process_combo.c
+++ b/quantum/process_keycode/process_combo.c
@@ -17,6 +17,7 @@
#include "print.h"
#include "process_combo.h"
#include "action_tapping.h"
+#include "action.h"
#ifdef COMBO_COUNT
__attribute__((weak)) combo_t key_combos[COMBO_COUNT];
@@ -29,25 +30,45 @@ extern uint16_t COMBO_LEN;
__attribute__((weak)) void process_combo_event(uint16_t combo_index, bool pressed) {}
#ifdef COMBO_MUST_HOLD_PER_COMBO
-__attribute__((weak)) bool get_combo_must_hold(uint16_t index, combo_t *combo) { return false; }
+__attribute__((weak)) bool get_combo_must_hold(uint16_t index, combo_t *combo) {
+ return false;
+}
#endif
#ifdef COMBO_MUST_TAP_PER_COMBO
-__attribute__((weak)) bool get_combo_must_tap(uint16_t index, combo_t *combo) { return false; }
+__attribute__((weak)) bool get_combo_must_tap(uint16_t index, combo_t *combo) {
+ return false;
+}
#endif
#ifdef COMBO_TERM_PER_COMBO
-__attribute__((weak)) uint16_t get_combo_term(uint16_t index, combo_t *combo) { return COMBO_TERM; }
+__attribute__((weak)) uint16_t get_combo_term(uint16_t index, combo_t *combo) {
+ return COMBO_TERM;
+}
+#endif
+
+#ifdef COMBO_MUST_PRESS_IN_ORDER_PER_COMBO
+__attribute__((weak)) bool get_combo_must_press_in_order(uint16_t combo_index, combo_t *combo) {
+ return true;
+}
#endif
#ifdef COMBO_PROCESS_KEY_RELEASE
-__attribute__((weak)) bool process_combo_key_release(uint16_t combo_index, combo_t *combo, uint8_t key_index, uint16_t keycode) { return false; }
+__attribute__((weak)) bool process_combo_key_release(uint16_t combo_index, combo_t *combo, uint8_t key_index, uint16_t keycode) {
+ return false;
+}
+#endif
+
+#ifdef COMBO_SHOULD_TRIGGER
+__attribute__((weak)) bool combo_should_trigger(uint16_t combo_index, combo_t *combo, uint16_t keycode, keyrecord_t *record) {
+ return true;
+}
#endif
#ifndef COMBO_NO_TIMER
static uint16_t timer = 0;
#endif
-static bool b_combo_enable = true; // defaults to enabled
+static bool b_combo_enable = true; // defaults to enabled
static uint16_t longest_term = 0;
typedef struct {
@@ -185,6 +206,9 @@ void clear_combos(void) {
static inline void dump_key_buffer(void) {
/* First call start from 0 index; recursive calls need to start from i+1 index */
static uint8_t key_buffer_next = 0;
+#if TAP_CODE_DELAY > 0
+ bool delay_done = false;
+#endif
if (key_buffer_size == 0) {
return;
@@ -210,6 +234,15 @@ static inline void dump_key_buffer(void) {
#endif
}
record->event.time = 0;
+ clear_weak_mods();
+
+#if TAP_CODE_DELAY > 0
+ // only delay once and for a non-tapping key
+ if (!delay_done && !is_tap_record(record)) {
+ delay_done = true;
+ wait_ms(TAP_CODE_DELAY);
+ }
+#endif
}
key_buffer_next = key_buffer_size = 0;
@@ -350,6 +383,28 @@ combo_t *overlaps(combo_t *combo1, combo_t *combo2) {
return combo1;
}
+#if defined(COMBO_MUST_PRESS_IN_ORDER) || defined(COMBO_MUST_PRESS_IN_ORDER_PER_COMBO)
+static bool keys_pressed_in_order(uint16_t combo_index, combo_t *combo, uint16_t key_index, uint16_t keycode, keyrecord_t *record) {
+# ifdef COMBO_MUST_PRESS_IN_ORDER_PER_COMBO
+ if (!get_combo_must_press_in_order(combo_index, combo)) {
+ return true;
+ }
+# endif
+ if (
+ // The `state` bit for the key being pressed.
+ (1 << key_index) ==
+ // The *next* combo key's bit.
+ (COMBO_STATE(combo) + 1)
+ // E.g. two keys already pressed: `state == 11`.
+ // Next possible `state` is `111`.
+ // So the needed bit is `100` which we get with `11 + 1`.
+ ) {
+ return true;
+ }
+ return false;
+}
+#endif
+
static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *record, uint16_t combo_index) {
uint8_t key_count = 0;
uint16_t key_index = -1;
@@ -360,7 +415,14 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *
return false;
}
- bool key_is_part_of_combo = !COMBO_DISABLED(combo) && is_combo_enabled();
+ bool key_is_part_of_combo = (!COMBO_DISABLED(combo) && is_combo_enabled()
+#if defined(COMBO_MUST_PRESS_IN_ORDER) || defined(COMBO_MUST_PRESS_IN_ORDER_PER_COMBO)
+ && keys_pressed_in_order(combo_index, combo, key_index, keycode, record)
+#endif
+#ifdef COMBO_SHOULD_TRIGGER
+ && combo_should_trigger(combo_index, combo, keycode, record)
+#endif
+ );
if (record->event.pressed && key_is_part_of_combo) {
uint16_t time = _get_combo_term(combo_index, combo);
@@ -412,7 +474,7 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *
// get possible longer waiting time for tap-/hold-only combos.
longest_term = _get_wait_time(combo_index, combo);
}
- } // if timer elapsed end
+ } // if timer elapsed end
}
} else {
// chord releases
@@ -427,7 +489,7 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *
else if (get_combo_must_tap(combo_index, combo)) {
// immediately apply tap-only combo
apply_combo(combo_index, combo);
- apply_combos(); // also apply other prepared combos and dump key buffer
+ apply_combos(); // also apply other prepared combos and dump key buffer
# ifdef COMBO_PROCESS_KEY_RELEASE
if (process_combo_key_release(combo_index, combo, key_index, keycode)) {
release_combo(combo_index, combo);
@@ -509,7 +571,7 @@ bool process_combo(uint16_t keycode, keyrecord_t *record) {
key_buffer[key_buffer_size++] = (queued_record_t){
.record = *record,
.keycode = keycode,
- .combo_index = -1, // this will be set when applying combos
+ .combo_index = -1, // this will be set when applying combos
};
}
} else {
@@ -548,7 +610,9 @@ void combo_task(void) {
#endif
}
-void combo_enable(void) { b_combo_enable = true; }
+void combo_enable(void) {
+ b_combo_enable = true;
+}
void combo_disable(void) {
#ifndef COMBO_NO_TIMER
@@ -568,4 +632,6 @@ void combo_toggle(void) {
}
}
-bool is_combo_enabled(void) { return b_combo_enable; }
+bool is_combo_enabled(void) {
+ return b_combo_enable;
+}
diff --git a/quantum/process_keycode/process_dynamic_macro.c b/quantum/process_keycode/process_dynamic_macro.c
index 18c8d7ca2e..a1ada2d5a2 100644
--- a/quantum/process_keycode/process_dynamic_macro.c
+++ b/quantum/process_keycode/process_dynamic_macro.c
@@ -29,13 +29,21 @@ void dynamic_macro_led_blink(void) {
/* User hooks for Dynamic Macros */
-__attribute__((weak)) void dynamic_macro_record_start_user(void) { dynamic_macro_led_blink(); }
+__attribute__((weak)) void dynamic_macro_record_start_user(void) {
+ dynamic_macro_led_blink();
+}
-__attribute__((weak)) void dynamic_macro_play_user(int8_t direction) { dynamic_macro_led_blink(); }
+__attribute__((weak)) void dynamic_macro_play_user(int8_t direction) {
+ dynamic_macro_led_blink();
+}
-__attribute__((weak)) void dynamic_macro_record_key_user(int8_t direction, keyrecord_t *record) { dynamic_macro_led_blink(); }
+__attribute__((weak)) void dynamic_macro_record_key_user(int8_t direction, keyrecord_t *record) {
+ dynamic_macro_led_blink();
+}
-__attribute__((weak)) void dynamic_macro_record_end_user(int8_t direction) { dynamic_macro_led_blink(); }
+__attribute__((weak)) void dynamic_macro_record_end_user(int8_t direction) {
+ dynamic_macro_led_blink();
+}
/* Convenience macros used for retrieving the debug info. All of them
* need a `direction` variable accessible at the call site.
@@ -82,7 +90,7 @@ void dynamic_macro_play(keyrecord_t *macro_buffer, keyrecord_t *macro_end, int8_
clear_keyboard();
- layer_state = saved_layer_state;
+ layer_state_set(saved_layer_state);
dynamic_macro_play_user(direction);
}
diff --git a/quantum/process_keycode/process_grave_esc.c b/quantum/process_keycode/process_grave_esc.c
index 41c50f5cb8..ddf027391d 100644
--- a/quantum/process_keycode/process_grave_esc.c
+++ b/quantum/process_keycode/process_grave_esc.c
@@ -15,13 +15,13 @@
*/
#include "process_grave_esc.h"
-/* true if the last press of GRAVE_ESC was shifted (i.e. GUI or SHIFT were pressed), false otherwise.
+/* true if the last press of QK_GRAVE_ESCAPE was shifted (i.e. GUI or SHIFT were pressed), false otherwise.
* Used to ensure that the correct keycode is released if the key is released.
*/
static bool grave_esc_was_shifted = false;
bool process_grave_esc(uint16_t keycode, keyrecord_t *record) {
- if (keycode == GRAVE_ESC) {
+ if (keycode == QK_GRAVE_ESCAPE) {
const uint8_t mods = get_mods();
uint8_t shifted = mods & MOD_MASK_SG;
diff --git a/quantum/process_keycode/process_haptic.c b/quantum/process_keycode/process_haptic.c
index 85b2ffcddd..0f07f9ac75 100644
--- a/quantum/process_keycode/process_haptic.c
+++ b/quantum/process_keycode/process_haptic.c
@@ -35,9 +35,6 @@ __attribute__((weak)) bool get_haptic_enabled_key(uint16_t keycode, keyrecord_t
case QK_MOMENTARY ... QK_MOMENTARY_MAX:
case QK_LAYER_MOD ... QK_LAYER_MOD_MAX:
#endif
-#ifdef NO_HAPTIC_FN
- case KC_FN0 ... KC_FN31:
-#endif
#ifdef NO_HAPTIC_ALPHA
case KC_A ... KC_Z:
#endif
diff --git a/quantum/process_keycode/process_joystick.c b/quantum/process_keycode/process_joystick.c
index fa9c2c1dbc..2fb092c573 100644
--- a/quantum/process_keycode/process_joystick.c
+++ b/quantum/process_keycode/process_joystick.c
@@ -74,7 +74,9 @@ void restorePinState(pin_t pin, uint16_t restoreState) {
#endif
}
-__attribute__((weak)) bool process_joystick_analogread() { return process_joystick_analogread_quantum(); }
+__attribute__((weak)) bool process_joystick_analogread() {
+ return process_joystick_analogread_quantum();
+}
bool process_joystick_analogread_quantum() {
#if JOYSTICK_AXES_COUNT > 0
diff --git a/quantum/process_keycode/process_key_lock.c b/quantum/process_keycode/process_key_lock.c
index 4bd58f0c1e..941a2c5780 100644
--- a/quantum/process_keycode/process_key_lock.c
+++ b/quantum/process_keycode/process_key_lock.c
@@ -56,6 +56,11 @@ static inline uint16_t translate_keycode(uint16_t keycode) {
}
}
+void cancel_key_lock(void) {
+ watching = false;
+ UNSET_KEY_STATE(0x0);
+}
+
bool process_key_lock(uint16_t *keycode, keyrecord_t *record) {
// We start by categorizing the keypress event. In the event of a down
// event, there are several possibilities:
diff --git a/quantum/process_keycode/process_key_lock.h b/quantum/process_keycode/process_key_lock.h
index baa0b39077..5159b0ba02 100644
--- a/quantum/process_keycode/process_key_lock.h
+++ b/quantum/process_keycode/process_key_lock.h
@@ -18,4 +18,5 @@
#include "quantum.h"
+void cancel_key_lock(void);
bool process_key_lock(uint16_t *keycode, keyrecord_t *record);
diff --git a/quantum/process_keycode/process_key_override.c b/quantum/process_keycode/process_key_override.c
index 09b2725079..ad9683d106 100644
--- a/quantum/process_keycode/process_key_override.c
+++ b/quantum/process_keycode/process_key_override.c
@@ -106,7 +106,9 @@ void key_override_toggle(void) {
}
}
-bool key_override_is_enabled(void) { return enabled; }
+bool key_override_is_enabled(void) {
+ return enabled;
+}
// Returns whether the modifiers that are pressed are such that the override should activate
static bool key_override_matches_active_modifiers(const key_override_t *override, const uint8_t mods) {
@@ -150,7 +152,7 @@ static void schedule_deferred_register(const uint16_t keycode) {
} else {
// Wait a very short time when a modifier event triggers the override to avoid false activations when e.g. a modifier is pressed just before a key is released (with the intention of pairing the modifier with a different key), or a modifier is lifted shortly before the trigger key is lifted. Operating systems by default reject modifier-events that happen very close to a non-modifier event.
defer_reference_time = timer_read32();
- defer_delay = 50; // 50ms
+ defer_delay = 50; // 50ms
}
deferred_register = keycode;
}
@@ -174,8 +176,8 @@ const key_override_t *clear_active_override(const bool allow_reregister) {
const uint8_t mod_free_replacement = clear_mods_from(active_override->replacement);
- bool unregister_replacement = mod_free_replacement != KC_NO && // KC_NO is never registered
- mod_free_replacement < SAFE_RANGE; // Custom keycodes are never registered
+ bool unregister_replacement = mod_free_replacement != KC_NO && // KC_NO is never registered
+ mod_free_replacement < SAFE_RANGE; // Custom keycodes are never registered
// Try firing the custom handler
if (active_override->custom_action != NULL) {
@@ -195,11 +197,11 @@ const key_override_t *clear_active_override(const bool allow_reregister) {
const uint16_t trigger = active_override->trigger;
- const bool reregister_trigger = allow_reregister && // Check if allowed from caller
- (active_override->options & ko_option_no_reregister_trigger) == 0 && // Check if override allows
- active_override_trigger_is_down && // Check if trigger is even down
- trigger != KC_NO && // KC_NO is never registered
- trigger < SAFE_RANGE; // A custom keycode should not be registered
+ const bool reregister_trigger = allow_reregister && // Check if allowed from caller
+ (active_override->options & ko_option_no_reregister_trigger) == 0 && // Check if override allows
+ active_override_trigger_is_down && // Check if trigger is even down
+ trigger != KC_NO && // KC_NO is never registered
+ trigger < SAFE_RANGE; // A custom keycode should not be registered
// Optionally re-register the trigger if it is still down
if (reregister_trigger) {
@@ -336,8 +338,8 @@ static bool try_activating_override(const uint16_t keycode, const uint8_t layer,
const uint16_t mod_free_replacement = clear_mods_from(override->replacement);
- bool register_replacement = mod_free_replacement != KC_NO && // KC_NO is never registered
- mod_free_replacement < SAFE_RANGE; // Custom keycodes are never registered
+ bool register_replacement = mod_free_replacement != KC_NO && // KC_NO is never registered
+ mod_free_replacement < SAFE_RANGE; // Custom keycodes are never registered
// Try firing the custom handler
if (override->custom_action != NULL) {
diff --git a/quantum/process_keycode/process_leader.c b/quantum/process_keycode/process_leader.c
index cf63f25141..c2fd02e5c7 100644
--- a/quantum/process_keycode/process_leader.c
+++ b/quantum/process_keycode/process_leader.c
@@ -51,13 +51,13 @@ bool process_leader(uint16_t keycode, keyrecord_t *record) {
if (leading) {
# ifndef LEADER_NO_TIMEOUT
if (timer_elapsed(leader_time) < LEADER_TIMEOUT)
-# endif // LEADER_NO_TIMEOUT
+# endif // LEADER_NO_TIMEOUT
{
# ifndef LEADER_KEY_STRICT_KEY_PROCESSING
if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) {
keycode = keycode & 0xFF;
}
-# endif // LEADER_KEY_STRICT_KEY_PROCESSING
+# endif // LEADER_KEY_STRICT_KEY_PROCESSING
if (leader_sequence_size < (sizeof(leader_sequence) / sizeof(leader_sequence[0]))) {
leader_sequence[leader_sequence_size] = keycode;
leader_sequence_size++;
diff --git a/quantum/process_keycode/process_magic.c b/quantum/process_keycode/process_magic.c
index d5cff4f12a..10161adda3 100644
--- a/quantum/process_keycode/process_magic.c
+++ b/quantum/process_keycode/process_magic.c
@@ -44,6 +44,7 @@ bool process_magic(uint16_t keycode, keyrecord_t *record) {
case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_ALT_GUI:
case MAGIC_SWAP_LCTL_LGUI ... MAGIC_EE_HANDS_RIGHT:
case MAGIC_TOGGLE_GUI:
+ case MAGIC_TOGGLE_CONTROL_CAPSLOCK:
/* keymap config */
keymap_config.raw = eeconfig_read_keymap();
switch (keycode) {
@@ -75,7 +76,7 @@ bool process_magic(uint16_t keycode, keyrecord_t *record) {
keymap_config.swap_backslash_backspace = true;
break;
case MAGIC_HOST_NKRO:
- clear_keyboard(); // clear first buffer to prevent stuck keys
+ clear_keyboard(); // clear first buffer to prevent stuck keys
keymap_config.nkro = true;
break;
case MAGIC_SWAP_ALT_GUI:
@@ -118,7 +119,7 @@ bool process_magic(uint16_t keycode, keyrecord_t *record) {
keymap_config.swap_backslash_backspace = false;
break;
case MAGIC_UNHOST_NKRO:
- clear_keyboard(); // clear first buffer to prevent stuck keys
+ clear_keyboard(); // clear first buffer to prevent stuck keys
keymap_config.nkro = false;
break;
case MAGIC_UNSWAP_ALT_GUI:
@@ -156,7 +157,7 @@ bool process_magic(uint16_t keycode, keyrecord_t *record) {
#endif
break;
case MAGIC_TOGGLE_NKRO:
- clear_keyboard(); // clear first buffer to prevent stuck keys
+ clear_keyboard(); // clear first buffer to prevent stuck keys
keymap_config.nkro = !keymap_config.nkro;
break;
case MAGIC_EE_HANDS_LEFT:
@@ -168,10 +169,13 @@ bool process_magic(uint16_t keycode, keyrecord_t *record) {
case MAGIC_TOGGLE_GUI:
keymap_config.no_gui = !keymap_config.no_gui;
break;
+ case MAGIC_TOGGLE_CONTROL_CAPSLOCK:
+ keymap_config.swap_control_capslock = !keymap_config.swap_control_capslock;
+ break;
}
eeconfig_update_keymap(keymap_config.raw);
- clear_keyboard(); // clear to prevent stuck keys
+ clear_keyboard(); // clear to prevent stuck keys
return false;
}
diff --git a/quantum/process_keycode/process_midi.c b/quantum/process_keycode/process_midi.c
index 9632d2b757..c49c31a525 100644
--- a/quantum/process_keycode/process_midi.c
+++ b/quantum/process_keycode/process_midi.c
@@ -22,13 +22,19 @@
# ifdef MIDI_BASIC
-void process_midi_basic_noteon(uint8_t note) { midi_send_noteon(&midi_device, 0, note, 127); }
+void process_midi_basic_noteon(uint8_t note) {
+ midi_send_noteon(&midi_device, 0, note, 127);
+}
-void process_midi_basic_noteoff(uint8_t note) { midi_send_noteoff(&midi_device, 0, note, 0); }
+void process_midi_basic_noteoff(uint8_t note) {
+ midi_send_noteoff(&midi_device, 0, note, 0);
+}
-void process_m