summaryrefslogtreecommitdiff
path: root/quantum/process_keycode
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/process_keycode')
-rw-r--r--quantum/process_keycode/process_audio.c4
-rw-r--r--quantum/process_keycode/process_auto_shift.c45
-rw-r--r--quantum/process_keycode/process_auto_shift.h5
-rw-r--r--quantum/process_keycode/process_autocorrect.c2
-rw-r--r--quantum/process_keycode/process_caps_word.c2
-rw-r--r--quantum/process_keycode/process_combo.c14
-rw-r--r--quantum/process_keycode/process_combo.h2
-rw-r--r--quantum/process_keycode/process_key_override.c8
-rw-r--r--quantum/process_keycode/process_leader.c83
-rw-r--r--quantum/process_keycode/process_leader.h22
-rw-r--r--quantum/process_keycode/process_music.c6
-rw-r--r--quantum/process_keycode/process_sequencer.c24
-rw-r--r--quantum/process_keycode/process_space_cadet.c10
-rw-r--r--quantum/process_keycode/process_steno.c2
-rw-r--r--quantum/process_keycode/process_tap_dance.c46
-rw-r--r--quantum/process_keycode/process_tap_dance.h42
-rw-r--r--quantum/process_keycode/process_tri_layer.c30
-rw-r--r--quantum/process_keycode/process_tri_layer.h16
-rw-r--r--quantum/process_keycode/process_ucis.c52
-rw-r--r--quantum/process_keycode/process_ucis.h16
-rw-r--r--quantum/process_keycode/process_unicodemap.h2
21 files changed, 210 insertions, 223 deletions
diff --git a/quantum/process_keycode/process_audio.c b/quantum/process_keycode/process_audio.c
index 03b0af9277..c189dd02b7 100644
--- a/quantum/process_keycode/process_audio.c
+++ b/quantum/process_keycode/process_audio.c
@@ -62,5 +62,5 @@ void process_audio_all_notes_off(void) {
stop_all_notes();
}
-__attribute__((weak)) void audio_on_user() {}
-__attribute__((weak)) void audio_off_user() {}
+__attribute__((weak)) void audio_on_user(void) {}
+__attribute__((weak)) void audio_off_user(void) {}
diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c
index 35d4851ee5..aad1a164ae 100644
--- a/quantum/process_keycode/process_auto_shift.c
+++ b/quantum/process_keycode/process_auto_shift.c
@@ -344,7 +344,7 @@ bool get_autoshift_state(void) {
return autoshift_flags.enabled;
}
-uint16_t get_generic_autoshift_timeout() {
+uint16_t get_generic_autoshift_timeout(void) {
return autoshift_timeout;
}
__attribute__((weak)) uint16_t get_autoshift_timeout(uint16_t keycode, keyrecord_t *record) {
@@ -397,8 +397,17 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) {
break;
# endif
}
- // If Retro Shift is disabled, possible custom actions shouldn't happen.
- // clang-format off
+ // If Retro Shift is disabled, possible custom actions shouldn't happen.
+ // clang-format off
+# if defined(RETRO_SHIFT) && !defined(NO_ACTION_TAPPING)
+# if defined(HOLD_ON_OTHER_KEY_PRESS_PER_KEY)
+ const bool is_hold_on_interrupt = get_hold_on_other_key_press(keycode, record);
+# elif defined(IGNORE_MOD_TAP_INTERRUPT)
+ const bool is_hold_on_interrupt = false;
+# else
+ const bool is_hold_on_interrupt = IS_QK_MOD_TAP(keycode);
+# endif
+# endif
if (IS_RETRO(keycode)
# if defined(RETRO_SHIFT) && !defined(NO_ACTION_TAPPING)
// Not tapped or #defines mean that rolls should use hold action.
@@ -407,27 +416,7 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) {
# ifdef RETRO_TAPPING_PER_KEY
|| !get_retro_tapping(keycode, record)
# endif
- || (record->tap.interrupted && (IS_LT(keycode)
-# if defined(HOLD_ON_OTHER_KEY_PRESS) || defined(HOLD_ON_OTHER_KEY_PRESS_PER_KEY)
-# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY
- ? get_hold_on_other_key_press(keycode, record)
-# else
- ? true
-# endif
-# else
- ? false
-# endif
-# if defined(IGNORE_MOD_TAP_INTERRUPT) || defined(IGNORE_MOD_TAP_INTERRUPT_PER_KEY)
-# ifdef IGNORE_MOD_TAP_INTERRUPT_PER_KEY
- : !get_ignore_mod_tap_interrupt(keycode, record)
-# else
- : false
-# endif
-# else
- : true
-# endif
- ))
- )
+ || (record->tap.interrupted && is_hold_on_interrupt))
# endif
) {
// clang-format on
@@ -454,10 +443,10 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) {
# endif
) {
// Fixes modifiers not being applied to rolls with AUTO_SHIFT_MODIFIERS set.
-# if !defined(IGNORE_MOD_TAP_INTERRUPT) || defined(IGNORE_MOD_TAP_INTERRUPT_PER_KEY)
+# if !defined(IGNORE_MOD_TAP_INTERRUPT) || defined(HOLD_ON_OTHER_KEY_PRESS_PER_KEY)
if (autoshift_flags.in_progress
-# ifdef IGNORE_MOD_TAP_INTERRUPT_PER_KEY
- && !get_ignore_mod_tap_interrupt(keycode, record)
+# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY
+ && get_hold_on_other_key_press(keycode, record)
# endif
) {
autoshift_end(KC_NO, now, false, &autoshift_lastrecord);
@@ -495,7 +484,7 @@ void retroshift_poll_time(keyevent_t *event) {
retroshift_time = timer_read();
}
// Used to swap the times of Retro Shifted key and Auto Shift key that interrupted it.
-void retroshift_swap_times() {
+void retroshift_swap_times(void) {
if (last_retroshift_time != 0 && autoshift_flags.in_progress) {
uint16_t temp = retroshift_time;
retroshift_time = last_retroshift_time;
diff --git a/quantum/process_keycode/process_auto_shift.h b/quantum/process_keycode/process_auto_shift.h
index 86adb04985..66a4b3138a 100644
--- a/quantum/process_keycode/process_auto_shift.h
+++ b/quantum/process_keycode/process_auto_shift.h
@@ -22,9 +22,8 @@
# define AUTO_SHIFT_TIMEOUT 175
#endif
-#define IS_LT(kc) ((kc) >= QK_LAYER_TAP && (kc) <= QK_LAYER_TAP_MAX)
-#define IS_MT(kc) ((kc) >= QK_MOD_TAP && (kc) <= QK_MOD_TAP_MAX)
-#define IS_RETRO(kc) (IS_MT(kc) || IS_LT(kc))
+#define IS_RETRO(kc) (IS_QK_MOD_TAP(kc) || IS_QK_LAYER_TAP(kc))
+
#define DO_GET_AUTOSHIFT_TIMEOUT(keycode, record, ...) record
// clang-format off
#define AUTO_SHIFT_ALPHA KC_A ... KC_Z
diff --git a/quantum/process_keycode/process_autocorrect.c b/quantum/process_keycode/process_autocorrect.c
index 8aeebf0e06..c89dffeaad 100644
--- a/quantum/process_keycode/process_autocorrect.c
+++ b/quantum/process_keycode/process_autocorrect.c
@@ -126,7 +126,7 @@ __attribute__((weak)) bool process_autocorrect_user(uint16_t *keycode, keyrecord
// and mask for base keycode when they are tapped.
case QK_SWAP_HANDS ... QK_SWAP_HANDS_MAX:
#ifdef SWAP_HANDS_ENABLE
- // Note: IS_SWAP_HANDS_KEYCODE() actually tests for the special action keycodes like SH_TG, SH_TT, ...,
+ // Note: IS_SWAP_HANDS_KEYCODE() actually tests for the special action keycodes like SH_TOGG, SH_TT, ...,
// which currently overlap the SH_T(kc) range.
if (IS_SWAP_HANDS_KEYCODE(*keycode) || !record->tap.count) {
return false;
diff --git a/quantum/process_keycode/process_caps_word.c b/quantum/process_keycode/process_caps_word.c
index 4c0217eba7..933abe629e 100644
--- a/quantum/process_keycode/process_caps_word.c
+++ b/quantum/process_keycode/process_caps_word.c
@@ -143,7 +143,7 @@ bool process_caps_word(uint16_t keycode, keyrecord_t* record) {
#ifdef SWAP_HANDS_ENABLE
case QK_SWAP_HANDS ... QK_SWAP_HANDS_MAX:
- // Note: IS_SWAP_HANDS_KEYCODE() actually tests for the special action keycodes like SH_TG, SH_TT, ...,
+ // Note: IS_SWAP_HANDS_KEYCODE() actually tests for the special action keycodes like SH_TOGG, SH_TT, ...,
// which currently overlap the SH_T(kc) range.
if (IS_SWAP_HANDS_KEYCODE(keycode) || record->tap.count == 0) {
return true;
diff --git a/quantum/process_keycode/process_combo.c b/quantum/process_keycode/process_combo.c
index d8b089db16..8597649c92 100644
--- a/quantum/process_keycode/process_combo.c
+++ b/quantum/process_keycode/process_combo.c
@@ -29,6 +29,12 @@ extern uint16_t COMBO_LEN;
__attribute__((weak)) void process_combo_event(uint16_t combo_index, bool pressed) {}
+#ifndef COMBO_ONLY_FROM_LAYER
+__attribute__((weak)) uint8_t combo_ref_from_layer(uint8_t layer) {
+ return layer;
+}
+#endif
+
#ifdef COMBO_MUST_HOLD_PER_COMBO
__attribute__((weak)) bool get_combo_must_hold(uint16_t index, combo_t *combo) {
return false;
@@ -304,7 +310,7 @@ void apply_combo(uint16_t combo_index, combo_t *combo) {
#if defined(EXTRA_EXTRA_LONG_COMBOS)
uint32_t state = 0;
#elif defined(EXTRA_LONG_COMBOS)
- uint16_t state = 0;
+ uint16_t state = 0;
#else
uint8_t state = 0;
#endif
@@ -549,6 +555,12 @@ bool process_combo(uint16_t keycode, keyrecord_t *record) {
#ifdef COMBO_ONLY_FROM_LAYER
/* Only check keycodes from one layer. */
keycode = keymap_key_to_keycode(COMBO_ONLY_FROM_LAYER, record->event.key);
+#else
+ uint8_t highest_layer = get_highest_layer(layer_state);
+ uint8_t ref_layer = combo_ref_from_layer(highest_layer);
+ if (ref_layer != highest_layer) {
+ keycode = keymap_key_to_keycode(ref_layer, record->event.key);
+ }
#endif
for (uint16_t idx = 0; idx < COMBO_LEN; ++idx) {
diff --git a/quantum/process_keycode/process_combo.h b/quantum/process_keycode/process_combo.h
index 4c4e574e34..e430c4a5f7 100644
--- a/quantum/process_keycode/process_combo.h
+++ b/quantum/process_keycode/process_combo.h
@@ -69,7 +69,7 @@ typedef struct {
#endif
/* check if keycode is only modifiers */
-#define KEYCODE_IS_MOD(code) (IS_MOD(code) || (code >= QK_MODS && code <= QK_MODS_MAX && !(code & QK_BASIC_MAX)))
+#define KEYCODE_IS_MOD(code) (IS_MODIFIER_KEYCODE(code) || (IS_QK_MODS(code) && !QK_MODS_GET_BASIC_KEYCODE(code)))
bool process_combo(uint16_t keycode, keyrecord_t *record);
void combo_task(void);
diff --git a/quantum/process_keycode/process_key_override.c b/quantum/process_keycode/process_key_override.c
index 9c5abccd4f..17e490e67a 100644
--- a/quantum/process_keycode/process_key_override.c
+++ b/quantum/process_keycode/process_key_override.c
@@ -186,7 +186,7 @@ const key_override_t *clear_active_override(const bool allow_reregister) {
// Then unregister the mod-free replacement key if desired
if (unregister_replacement) {
- if (IS_KEY(mod_free_replacement)) {
+ if (IS_BASIC_KEYCODE(mod_free_replacement)) {
del_key(mod_free_replacement);
} else {
key_override_printf("NOT KEY 1\n");
@@ -329,7 +329,7 @@ static bool try_activating_override(const uint16_t keycode, const uint8_t layer,
if (!trigger_down && !no_trigger) {
// When activating a key override the trigger is is always unregistered. In the case where the key that newly pressed is not the trigger key, we have to explicitly remove the trigger key from the keyboard report. If the trigger was just pressed down we simply suppress the event which also has the effect of the trigger key not being registered in the keyboard report.
- if (IS_KEY(override->trigger)) {
+ if (IS_BASIC_KEYCODE(override->trigger)) {
del_key(override->trigger);
} else {
unregister_code(override->trigger);
@@ -356,7 +356,7 @@ static bool try_activating_override(const uint16_t keycode, const uint8_t layer,
schedule_deferred_register(mod_free_replacement);
send_keyboard_report();
} else {
- if (IS_KEY(mod_free_replacement)) {
+ if (IS_BASIC_KEYCODE(mod_free_replacement)) {
add_key(mod_free_replacement);
} else {
key_override_printf("NOT KEY 2\n");
@@ -402,7 +402,7 @@ bool process_key_override(const uint16_t keycode, const keyrecord_t *const recor
#endif
const bool key_down = record->event.pressed;
- const bool is_mod = IS_MOD(keycode);
+ const bool is_mod = IS_MODIFIER_KEYCODE(keycode);
if (key_down) {
switch (keycode) {
diff --git a/quantum/process_keycode/process_leader.c b/quantum/process_keycode/process_leader.c
index b74b4927a8..a9823b6285 100644
--- a/quantum/process_keycode/process_leader.c
+++ b/quantum/process_keycode/process_leader.c
@@ -14,72 +14,35 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifdef LEADER_ENABLE
-
-# include "process_leader.h"
-# include <string.h>
-
-# ifndef LEADER_TIMEOUT
-# define LEADER_TIMEOUT 300
-# endif
-
-__attribute__((weak)) void leader_start(void) {}
-
-__attribute__((weak)) void leader_end(void) {}
-
-// Leader key stuff
-bool leading = false;
-uint16_t leader_time = 0;
-
-uint16_t leader_sequence[5] = {0, 0, 0, 0, 0};
-uint8_t leader_sequence_size = 0;
-
-void qk_leader_start(void) {
- if (leading) {
- return;
- }
- leader_start();
- leading = true;
- leader_time = timer_read();
- leader_sequence_size = 0;
- memset(leader_sequence, 0, sizeof(leader_sequence));
-}
+#include "process_leader.h"
+#include "leader.h"
bool process_leader(uint16_t keycode, keyrecord_t *record) {
- // Leader key set-up
if (record->event.pressed) {
- if (leading) {
-# ifndef LEADER_NO_TIMEOUT
- if (timer_elapsed(leader_time) < LEADER_TIMEOUT)
-# endif // LEADER_NO_TIMEOUT
- {
-# ifndef LEADER_KEY_STRICT_KEY_PROCESSING
- if (IS_QK_MOD_TAP(keycode)) {
- keycode = QK_MOD_TAP_GET_TAP_KEYCODE(keycode);
- } else if (IS_QK_LAYER_TAP(keycode)) {
- keycode = QK_LAYER_TAP_GET_TAP_KEYCODE(keycode);
- }
-# endif // LEADER_KEY_STRICT_KEY_PROCESSING
- if (leader_sequence_size < ARRAY_SIZE(leader_sequence)) {
- leader_sequence[leader_sequence_size] = keycode;
- leader_sequence_size++;
- } else {
- leading = false;
- leader_end();
- return true;
- }
-# ifdef LEADER_PER_KEY_TIMING
- leader_time = timer_read();
-# endif
- return false;
+ if (leader_sequence_active() && !leader_sequence_timed_out()) {
+#ifndef LEADER_KEY_STRICT_KEY_PROCESSING
+ if (IS_QK_MOD_TAP(keycode)) {
+ keycode = QK_MOD_TAP_GET_TAP_KEYCODE(keycode);
+ } else if (IS_QK_LAYER_TAP(keycode)) {
+ keycode = QK_LAYER_TAP_GET_TAP_KEYCODE(keycode);
}
- } else {
- if (keycode == QK_LEADER) {
- qk_leader_start();
+#endif
+
+ if (!leader_sequence_add(keycode)) {
+ leader_end();
+
+ return true;
}
+
+#ifdef LEADER_PER_KEY_TIMING
+ leader_reset_timer();
+#endif
+
+ return false;
+ } else if (keycode == QK_LEADER) {
+ leader_start();
}
}
+
return true;
}
-
-#endif
diff --git a/quantum/process_keycode/process_leader.h b/quantum/process_keycode/process_leader.h
index f3fe14a432..eb0f721f60 100644
--- a/quantum/process_keycode/process_leader.h
+++ b/quantum/process_keycode/process_leader.h
@@ -19,25 +19,3 @@
#include "quantum.h"
bool process_leader(uint16_t keycode, keyrecord_t *record);
-
-void leader_start(void);
-void leader_end(void);
-void qk_leader_start(void);
-
-#define SEQ_ONE_KEY(key) if (leader_sequence[0] == (key) && leader_sequence[1] == 0 && leader_sequence[2] == 0 && leader_sequence[3] == 0 && leader_sequence[4] == 0)
-#define SEQ_TWO_KEYS(key1, key2) if (leader_sequence[0] == (key1) && leader_sequence[1] == (key2) && leader_sequence[2] == 0 && leader_sequence[3] == 0 && leader_sequence[4] == 0)
-#define SEQ_THREE_KEYS(key1, key2, key3) if (leader_sequence[0] == (key1) && leader_sequence[1] == (key2) && leader_sequence[2] == (key3) && leader_sequence[3] == 0 && leader_sequence[4] == 0)
-#define SEQ_FOUR_KEYS(key1, key2, key3, key4) if (leader_sequence[0] == (key1) && leader_sequence[1] == (key2) && leader_sequence[2] == (key3) && leader_sequence[3] == (key4) && leader_sequence[4] == 0)
-#define SEQ_FIVE_KEYS(key1, key2, key3, key4, key5) if (leader_sequence[0] == (key1) && leader_sequence[1] == (key2) && leader_sequence[2] == (key3) && leader_sequence[3] == (key4) && leader_sequence[4] == (key5))
-
-#define LEADER_EXTERNS() \
- extern bool leading; \
- extern uint16_t leader_time; \
- extern uint16_t leader_sequence[5]; \
- extern uint8_t leader_sequence_size
-
-#ifdef LEADER_NO_TIMEOUT
-# define LEADER_DICTIONARY() if (leading && leader_sequence_size > 0 && timer_elapsed(leader_time) > LEADER_TIMEOUT)
-#else
-# define LEADER_DICTIONARY() if (leading && timer_elapsed(leader_time) > LEADER_TIMEOUT)
-#endif
diff --git a/quantum/process_keycode/process_music.c b/quantum/process_keycode/process_music.c
index ee697a0cc6..7c572079a7 100644
--- a/quantum/process_keycode/process_music.c
+++ b/quantum/process_keycode/process_music.c
@@ -317,10 +317,10 @@ void music_task(void) {
}
}
-__attribute__((weak)) void music_on_user() {}
+__attribute__((weak)) void music_on_user(void) {}
-__attribute__((weak)) void midi_on_user() {}
+__attribute__((weak)) void midi_on_user(void) {}
-__attribute__((weak)) void music_scale_user() {}
+__attribute__((weak)) void music_scale_user(void) {}
#endif // defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))
diff --git a/quantum/process_keycode/process_sequencer.c b/quantum/process_keycode/process_sequencer.c
index 334b4c0092..6391d1ba9d 100644
--- a/quantum/process_keycode/process_sequencer.c
+++ b/quantum/process_keycode/process_sequencer.c
@@ -19,39 +19,39 @@
bool process_sequencer(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
switch (keycode) {
- case SQ_ON:
+ case QK_SEQUENCER_ON:
sequencer_on();
return false;
- case SQ_OFF:
+ case QK_SEQUENCER_OFF:
sequencer_off();
return false;
- case SQ_TOG:
+ case QK_SEQUENCER_TOGGLE:
sequencer_toggle();
return false;
- case SQ_TMPD:
+ case QK_SEQUENCER_TEMPO_DOWN:
sequencer_decrease_tempo();
return false;
- case SQ_TMPU:
+ case QK_SEQUENCER_TEMPO_UP:
sequencer_increase_tempo();
return false;
- case SEQUENCER_RESOLUTION_MIN ... SEQUENCER_RESOLUTION_MAX:
- sequencer_set_resolution(keycode - SEQUENCER_RESOLUTION_MIN);
- return false;
- case SQ_RESD:
+ case QK_SEQUENCER_RESOLUTION_DOWN:
sequencer_decrease_resolution();
return false;
- case SQ_RESU:
+ case QK_SEQUENCER_RESOLUTION_UP:
sequencer_increase_resolution();
return false;
- case SQ_SALL:
+ case QK_SEQUENCER_STEPS_ALL:
sequencer_set_all_steps_on();
return false;
- case SQ_SCLR:
+ case QK_SEQUENCER_STEPS_CLEAR:
sequencer_set_all_steps_off();
return false;
case SEQUENCER_STEP_MIN ... SEQUENCER_STEP_MAX:
sequencer_toggle_step(keycode - SEQUENCER_STEP_MIN);
return false;
+ case SEQUENCER_RESOLUTION_MIN ... SEQUENCER_RESOLUTION_MAX:
+ sequencer_set_resolution(keycode - SEQUENCER_RESOLUTION_MIN);
+ return false;
case SEQUENCER_TRACK_MIN ... SEQUENCER_TRACK_MAX:
sequencer_toggle_single_active_track(keycode - SEQUENCER_TRACK_MIN);
return false;
diff --git a/quantum/process_keycode/process_space_cadet.c b/quantum/process_keycode/process_space_cadet.c
index a62cd60a70..3109ea1711 100644
--- a/quantum/process_keycode/process_space_cadet.c
+++ b/quantum/process_keycode/process_space_cadet.c
@@ -89,16 +89,16 @@ void perform_space_cadet(keyrecord_t *record, uint16_t sc_keycode, uint8_t holdM
#ifdef SPACE_CADET_MODIFIER_CARRYOVER
sc_mods = get_mods();
#endif
- if (IS_MOD(holdMod)) {
+ if (IS_MODIFIER_KEYCODE(holdMod)) {
register_mods(MOD_BIT(holdMod));
}
} else {
if (sc_last == holdMod && timer_elapsed(sc_timer) < GET_TAPPING_TERM(sc_keycode, record)) {
if (holdMod != tapMod) {
- if (IS_MOD(holdMod)) {
+ if (IS_MODIFIER_KEYCODE(holdMod)) {
unregister_mods(MOD_BIT(holdMod));
}
- if (IS_MOD(tapMod)) {
+ if (IS_MODIFIER_KEYCODE(tapMod)) {
register_mods(MOD_BIT(tapMod));
}
}
@@ -109,11 +109,11 @@ void perform_space_cadet(keyrecord_t *record, uint16_t sc_keycode, uint8_t holdM
#ifdef SPACE_CADET_MODIFIER_CARRYOVER
clear_weak_mods();
#endif
- if (IS_MOD(tapMod)) {
+ if (IS_MODIFIER_KEYCODE(tapMod)) {
unregister_mods(MOD_BIT(tapMod));
}
} else {
- if (IS_MOD(holdMod)) {
+ if (IS_MODIFIER_KEYCODE(holdMod)) {
unregister_mods(MOD_BIT(holdMod));
}
}
diff --git a/quantum/process_keycode/process_steno.c b/quantum/process_keycode/process_steno.c
index 30a0d4056f..8ba98bd4bb 100644
--- a/quantum/process_keycode/process_steno.c
+++ b/quantum/process_keycode/process_steno.c
@@ -127,7 +127,7 @@ static const uint16_t combinedmap_second[] PROGMEM = {STN_S2, STN_KL, STN_WL, ST
#endif
#ifdef STENO_ENABLE_ALL
-void steno_init() {
+void steno_init(void) {
if (!eeconfig_is_enabled()) {
eeconfig_init();
}
diff --git a/quantum/process_keycode/process_tap_dance.c b/quantum/process_keycode/process_tap_dance.c
index 6e8e596673..706f5cddbb 100644
--- a/quantum/process_keycode/process_tap_dance.c
+++ b/quantum/process_keycode/process_tap_dance.c
@@ -18,8 +18,8 @@
static uint16_t active_td;
static uint16_t last_tap_time;
-void qk_tap_dance_pair_on_each_tap(qk_tap_dance_state_t *state, void *user_data) {
- qk_tap_dance_pair_t *pair = (qk_tap_dance_pair_t *)user_data;
+void tap_dance_pair_on_each_tap(tap_dance_state_t *state, void *user_data) {
+ tap_dance_pair_t *pair = (tap_dance_pair_t *)user_data;
if (state->count == 2) {
register_code16(pair->kc2);
@@ -27,14 +27,14 @@ void qk_tap_dance_pair_on_each_tap(qk_tap_dance_state_t *state, void *user_data)
}
}
-void qk_tap_dance_pair_finished(qk_tap_dance_state_t *state, void *user_data) {
- qk_tap_dance_pair_t *pair = (qk_tap_dance_pair_t *)user_data;
+void tap_dance_pair_finished(tap_dance_state_t *state, void *user_data) {
+ tap_dance_pair_t *pair = (tap_dance_pair_t *)user_data;
register_code16(pair->kc1);
}
-void qk_tap_dance_pair_reset(qk_tap_dance_state_t *state, void *user_data) {
- qk_tap_dance_pair_t *pair = (qk_tap_dance_pair_t *)user_data;
+void tap_dance_pair_reset(tap_dance_state_t *state, void *user_data) {
+ tap_dance_pair_t *pair = (tap_dance_pair_t *)user_data;
if (state->count == 1) {
wait_ms(TAP_CODE_DELAY);
@@ -44,8 +44,8 @@ void qk_tap_dance_pair_reset(qk_tap_dance_state_t *state, void *user_data) {
}
}
-void qk_tap_dance_dual_role_on_each_tap(qk_tap_dance_state_t *state, void *user_data) {
- qk_tap_dance_dual_role_t *pair = (qk_tap_dance_dual_role_t *)user_data;
+void tap_dance_dual_role_on_each_tap(tap_dance_state_t *state, void *user_data) {
+ tap_dance_dual_role_t *pair = (tap_dance_dual_role_t *)user_data;
if (state->count == 2) {
layer_move(pair->layer);
@@ -53,8 +53,8 @@ void qk_tap_dance_dual_role_on_each_tap(qk_tap_dance_state_t *state, void *user_
}
}
-void qk_tap_dance_dual_role_finished(qk_tap_dance_state_t *state, void *user_data) {
- qk_tap_dance_dual_role_t *pair = (qk_tap_dance_dual_role_t *)user_data;
+void tap_dance_dual_role_finished(tap_dance_state_t *state, void *user_data) {
+ tap_dance_dual_role_t *pair = (tap_dance_dual_role_t *)user_data;
if (state->count == 1) {
register_code16(pair->kc);
@@ -63,8 +63,8 @@ void qk_tap_dance_dual_role_finished(qk_tap_dance_state_t *state, void *user_dat
}
}
-void qk_tap_dance_dual_role_reset(qk_tap_dance_state_t *state, void *user_data) {
- qk_tap_dance_dual_role_t *pair = (qk_tap_dance_dual_role_t *)user_data;
+void tap_dance_dual_role_reset(tap_dance_state_t *state, void *user_data) {
+ tap_dance_dual_role_t *pair = (tap_dance_dual_role_t *)user_data;
if (state->count == 1) {
wait_ms(TAP_CODE_DELAY);
@@ -72,13 +72,13 @@ void qk_tap_dance_dual_role_reset(qk_tap_dance_state_t *state, void *user_data)
}
}
-static inline void _process_tap_dance_action_fn(qk_tap_dance_state_t *state, void *user_data, qk_tap_dance_user_fn_t fn) {
+static inline void _process_tap_dance_action_fn(tap_dance_state_t *state, void *user_data, tap_dance_user_fn_t fn) {
if (fn) {
fn(state, user_data);
}
}
-static inline void process_tap_dance_action_on_each_tap(qk_tap_dance_action_t *action) {
+static inline void process_tap_dance_action_on_each_tap(tap_dance_action_t *action) {
action->state.count++;
action->state.weak_mods = get_mods();
action->state.weak_mods |= get_weak_mods();
@@ -88,17 +88,17 @@ static inline void process_tap_dance_action_on_each_tap(qk_tap_dance_action_t *a
_process_tap_dance_action_fn(&action->state, action->user_data, action->fn.on_each_tap);
}
-static inline void process_tap_dance_action_on_reset(qk_tap_dance_action_t *action) {
+static inline void process_tap_dance_action_on_reset(tap_dance_action_t *action) {
_process_tap_dance_action_fn(&action->state, action->user_data, action->fn.on_reset);
del_weak_mods(action->state.weak_mods);
#ifndef NO_ACTION_ONESHOT
del_mods(action->state.oneshot_mods);
#endif
send_keyboard_report();
- action->state = (const qk_tap_dance_state_t){0};
+ action->state = (const tap_dance_state_t){0};
}
-static inline void process_tap_dance_action_on_dance_finished(qk_tap_dance_action_t *action) {
+static inline void process_tap_dance_action_on_dance_finished(tap_dance_action_t *action) {
if (!action->state.finished) {
action->state.finished = true;
add_weak_mods(action->state.weak_mods);
@@ -116,7 +116,7 @@ static inline void process_tap_dance_action_on_dance_finished(qk_tap_dance_actio
}
bool preprocess_tap_dance(uint16_t keycode, keyrecord_t *record) {
- qk_tap_dance_action_t *action;
+ tap_dance_action_t *action;
if (!record->event.pressed) return false;
@@ -139,7 +139,7 @@ bool preprocess_tap_dance(uint16_t keycode, keyrecord_t *record) {
}
bool process_tap_dance(uint16_t keycode, keyrecord_t *record) {
- qk_tap_dance_action_t *action;
+ tap_dance_action_t *action;
switch (keycode) {
case QK_TAP_DANCE ... QK_TAP_DANCE_MAX:
@@ -162,8 +162,8 @@ bool process_tap_dance(uint16_t keycode, keyrecord_t *record) {
return true;
}
-void tap_dance_task() {
- qk_tap_dance_action_t *action;
+void tap_dance_task(void) {
+ tap_dance_action_t *action;
if (!active_td || timer_elapsed(last_tap_time) <= GET_TAPPING_TERM(active_td, &(keyrecord_t){})) return;
@@ -173,7 +173,7 @@ void tap_dance_task() {
}
}
-void reset_tap_dance(qk_tap_dance_state_t *state) {
+void reset_tap_dance(tap_dance_state_t *state) {
active_td = 0;
- process_tap_dance_action_on_reset((qk_tap_dance_action_t *)state);
+ process_tap_dance_action_on_reset((tap_dance_action_t *)state);
}
diff --git a/quantum/process_keycode/process_tap_dance.h b/quantum/process_keycode/process_tap_dance.h
index d6d6c136dc..5cb6d9202c 100644
--- a/quantum/process_keycode/process_tap_dance.h
+++ b/quantum/process_keycode/process_tap_dance.h
@@ -31,39 +31,39 @@ typedef struct {
bool pressed : 1;
bool finished : 1;
bool interrupted : 1;
-} qk_tap_dance_state_t;
+} tap_dance_state_t;
-typedef void (*qk_tap_dance_user_fn_t)(qk_tap_dance_state_t *state, void *user_data);
+typedef void (*tap_dance_user_fn_t)(tap_dance_state_t *state, void *user_data);
typedef struct {
- qk_tap_dance_state_t state;
+ tap_dance_state_t state;
struct {
- qk_tap_dance_user_fn_t on_each_tap;
- qk_tap_dance_user_fn_t on_dance_finished;
- qk_tap_dance_user_fn_t on_reset;
+ tap_dance_user_fn_t on_each_tap;
+ tap_dance_user_fn_t on_dance_finished;
+ tap_dance_user_fn_t on_reset;
} fn;
void *user_data;
-} qk_tap_dance_action_t;
+} tap_dance_action_t;
typedef struct {
uint16_t kc1;
uint16_t kc2;
-} qk_tap_dance_pair_t;
+} tap_dance_pair_t;
typedef struct {
uint16_t kc;
uint8_t layer;
void (*layer_function)(uint8_t);
-} qk_tap_dance_dual_role_t;
+} tap_dance_dual_role_t;
# define ACTION_TAP_DANCE_DOUBLE(kc1, kc2) \
- { .fn = {qk_tap_dance_pair_on_each_tap, qk_tap_dance_pair_finished, qk_tap_dance_pair_reset}, .user_data = (void *)&((qk_tap_dance_pair_t){kc1, kc2}), }
+ { .fn = {tap_dance_pair_on_each_tap, tap_dance_pair_finished, tap_dance_pair_reset}, .user_data = (void *)&((tap_dance_pair_t){kc1, kc2}), }
# define ACTION_TAP_DANCE_LAYER_MOVE(kc, layer) \
- { .fn = {qk_tap_dance_dual_role_on_each_tap, qk_tap_dance_dual_role_finished, qk_tap_dance_dual_role_reset}, .user_data = (void *)&((qk_tap_dance_dual_role_t){kc, layer, layer_move}), }
+ { .fn = {tap_dance_dual_role_on_each_tap, tap_dance_dual_role_finished, tap_dance_dual_role_reset}, .user_data = (void *)&((tap_dance_dual_role_t){kc, layer, layer_move}), }
# define ACTION_TAP_DANCE_LAYER_TOGGLE(kc, layer) \
- { .fn = {NULL, qk_tap_dance_dual_role_finished, qk_tap_dance_dual_role_reset}, .user_data = (void *)&((qk_tap_dance_dual_role_t){kc, layer, layer_invert}), }
+ { .fn = {NULL, tap_dance_dual_role_finished, tap_dance_dual_role_reset}, .user_data = (void *)&((tap_dance_dual_role_t){kc, layer, layer_invert}), }
# define ACTION_TAP_DANCE_FN(user_fn) \
{ .fn = {NULL, user_fn, NULL}, .user_data = NULL, }
@@ -73,11 +73,11 @@ typedef struct {
# define TD(n) (QK_TAP_DANCE | TD_INDEX(n))
# define TD_INDEX(code) ((code)&0xFF)
-# define TAP_DANCE_KEYCODE(state) TD(((qk_tap_dance_action_t *)state) - tap_dance_actions)
+# define TAP_DANCE_KEYCODE(state) TD(((tap_dance_action_t *)state) - tap_dance_actions)
-extern qk_tap_dance_action_t tap_dance_actions[];
+extern tap_dance_action_t tap_dance_actions[];
-void reset_tap_dance(qk_tap_dance_state_t *state);
+void reset_tap_dance(tap_dance_state_t *state);
/* To be used internally */
@@ -85,13 +85,13 @@ bool preprocess_tap_dance(uint16_t keycode, keyrecord_t *record);
bool process_tap_dance(uint16_t keycode, keyrecord_t *record);
void tap_dance_task(void);
-void qk_tap_dance_pair_on_each_tap(qk_tap_dance_state_t *state, void *user_data);
-void qk_tap_dance_pair_finished(qk_tap_dance_state_t *state, void *user_data);
-void qk_tap_dance_pair_reset(qk_tap_dance_state_t *state, void *user_data);
+void tap_dance_pair_on_each_tap(tap_dance_state_t *state, void *user_data);
+void tap_dance_pair_finished(tap_dance_state_t *state, void *user_data);
+void tap_dance_pair_reset(tap_dance_state_t *state, void *user_data);
-void qk_tap_dance_dual_role_on_each_tap(qk_tap_dance_state_t *state, void *user_data);
-void qk_tap_dance_dual_role_finished(qk_tap_dance_state_t *state, void *user_data);
-void qk_tap_dance_dual_role_reset(qk_tap_dance_state_t *state, void *user_data);
+void tap_dance_dual_role_on_each_tap(tap_dance_state_t *state, void *user_data);
+void tap_dance_dual_role_finished(tap_dance_state_t *state, void *user_data);
+void tap_dance_dual_role_reset(tap_dance_state_t *state, void *user_data);
#else
diff --git a/quantum/process_keycode/process_tri_layer.c b/quantum/process_keycode/process_tri_layer.c
new file mode 100644
index 0000000000..1e681b9a1c
--- /dev/null
+++ b/quantum/process_keycode/process_tri_layer.c
@@ -0,0 +1,30 @@
+// Copyright 2023 QMK
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "process_tri_layer.h"
+#include "tri_layer.h"
+#include "action_layer.h"
+
+bool process_tri_layer(uint16_t keycode, keyrecord_t *record) {
+ switch (keycode) {
+ case QK_TRI_LAYER_LOWER:
+ if (record->event.pressed) {
+ layer_on(get_tri_layer_lower_layer());
+ update_tri_layer(get_tri_layer_lower_layer(), get_tri_layer_upper_layer(), get_tri_layer_adjust_layer());
+ } else {
+ layer_off(get_tri_layer_lower_layer());
+ update_tri_layer(get_tri_layer_lower_layer(), get_tri_layer_upper_layer(), get_tri_layer_adjust_layer());
+ }
+ return false;
+ case QK_TRI_LAYER_UPPER:
+ if (record->event.pressed) {
+ layer_on(get_tri_layer_upper_layer());
+ update_tri_layer(get_tri_layer_lower_layer(), get_tri_layer_upper_layer(), get_tri_layer_adjust_layer());
+ } else {
+ layer_off(get_tri_layer_upper_layer());
+ update_tri_layer(get_tri_layer_lower_layer(), get_tri_layer_upper_layer(), get_tri_layer_adjust_layer());
+ }
+ return false;
+ }
+ return true;
+}
diff --git a/quantum/process_keycode/process_tri_layer.h b/quantum/process_keycode/process_tri_layer.h
new file mode 100644
index 0000000000..9c4e3df1c2
--- /dev/null
+++ b/quantum/process_keycode/process_tri_layer.h
@@ -0,0 +1,16 @@
+// Copyright 2023 QMK
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include "action.h"
+
+/**
+ * @brief Handles tri layer behavior
+ *
+ * @param keycode the keycode
+ * @param record the key record structure
+ * @return true continue handling keycodes
+ * @return false stop handling keycodes
+ */
+bool process_tri_layer(uint16_t keycode, keyrecord_t *record);
diff --git a/quantum/process_keycode/process_ucis.c b/quantum/process_keycode/process_ucis.c
index 646471bc4d..3aa09d5948 100644
--- a/quantum/process_keycode/process_ucis.c
+++ b/quantum/process_keycode/process_ucis.c
@@ -19,20 +19,20 @@
#include "keycode.h"
#include "wait.h"
-qk_ucis_state_t qk_ucis_state;
+ucis_state_t ucis_state;
-void qk_ucis_start(void) {
- qk_ucis_state.count = 0;
- qk_ucis_state.in_progress = true;
+void ucis_start(void) {
+ ucis_state.count = 0;
+ ucis_state.in_progress = true;
- qk_ucis_start_user();
+ ucis_start_user();
}
-__attribute__((weak)) void qk_ucis_start_user(void) {
+__attribute__((weak)) void ucis_start_user(void) {
register_unicode(0x2328); // ⌨
}
-__attribute__((weak)) void qk_ucis_success(uint8_t symbol_index) {}
+__attribute__((weak)) void ucis_success(uint8_t symbol_index) {}
static bool is_uni_seq(char *seq) {
uint8_t i;
@@ -43,20 +43,20 @@ static bool is_uni_seq(char *seq) {
} else {
keycode = seq[i] - 'a' + KC_A;
}
- if (i > qk_ucis_state.count || qk_ucis_state.codes[i] != keycode) {
+ if (i > ucis_state.count || ucis_state.codes[i] != keycode) {
return false;
}
}
- return qk_ucis_state.codes[i] == KC_ENTER || qk_ucis_state.codes[i] == KC_SPACE;
+ return ucis_state.codes[i] == KC_ENTER || ucis_state.codes[i] == KC_SPACE;
}
-__attribute__((weak)) void qk_ucis_symbol_fallback(void) {
- for (uint8_t i = 0; i < qk_ucis_state.count - 1; i++) {
- tap_code(qk_ucis_state.codes[i]);
+__attribute__((weak)) void ucis_symbol_fallback(void) {
+ for (uint8_t i = 0; i < ucis_state.count - 1; i++) {
+ tap_code(ucis_state.codes[i]);
}
}
-__attribute__((weak)) void qk_ucis_cancel(void) {}
+__attribute__((weak)) void ucis_cancel(void) {}
void register_ucis(const uint32_t *code_points) {
for (int i = 0; i < UCIS_MAX_CODE_POINTS && code_points[i]; i++) {
@@ -65,38 +65,38 @@ void register_ucis(const uint32_t *code_points) {
}
bool process_ucis(uint16_t keycode, keyrecord_t *record) {
- if (!qk_ucis_state.in_progress || !record->event.pressed) {
+ if (!ucis_state.in_progress || !record->event.pressed) {
return true;
}
bool special = keycode == KC_SPACE || keycode == KC_ENTER || keycode == KC_ESCAPE || keycode == KC_BACKSPACE;
- if (qk_ucis_state.count >= UCIS_MAX_SYMBOL_LENGTH && !special) {
+ if (ucis_state.count >= UCIS_MAX_SYMBOL_LENGTH && !special) {
return false;
}
- qk_ucis_state.codes[qk_ucis_state.count] = keycode;
- qk_ucis_state.count++;
+ ucis_state.codes[ucis_state.count] = keycode;
+ ucis_state.count++;
switch (keycode) {
case KC_BACKSPACE:
- if (qk_ucis_state.count >= 2) {
- qk_ucis_state.count -= 2;
+ if (ucis_state.count >= 2) {
+ ucis_state.count -= 2;
return true;
} else {
- qk_ucis_state.count--;
+ ucis_state.count--;
return false;
}
case KC_SPACE:
case KC_ENTER:
case KC_ESCAPE:
- for (uint8_t i = 0; i < qk_ucis_state.count; i++) {
+ for (uint8_t i = 0; i < ucis_state.count; i++) {
tap_code(KC_BACKSPACE);
}
if (keycode == KC_ESCAPE) {
- qk_ucis_state.in_progress = false;
- qk_ucis_cancel();
+ ucis_state.in_progress = false;
+ ucis_cancel();
return false;
}
@@ -110,12 +110,12 @@ bool process_ucis(uint16_t keycode, keyrecord_t *record) {
}
}
if (symbol_found) {
- qk_ucis_success(i);
+ ucis_success(i);
} else {
- qk_ucis_symbol_fallback();
+ ucis_symbol_fallback();
}
- qk_ucis_state.in_progress = false;
+ ucis_state.in_progress = false;
return false;
default:
diff --git a/quantum/process_keycode/process_ucis.h b/quantum/process_keycode/process_ucis.h
index 3de0707762..54eb9413d4 100644
--- a/quantum/process_keycode/process_ucis.h
+++ b/quantum/process_keycode/process_ucis.h
@@ -31,15 +31,15 @@
typedef struct {
char * symbol;
uint32_t code_points[UCIS_MAX_CODE_POINTS];
-} qk_ucis_symbol_t;
+} ucis_symbol_t;
typedef struct {
uint8_t count;
uint16_t codes[UCIS_MAX_SYMBOL_LENGTH];
bool in_progress : 1;
-} qk_ucis_state_t;
+} ucis_state_t;
-extern qk_ucis_state_t qk_ucis_state;
+extern ucis_state_t ucis_state;
// clang-format off
@@ -53,12 +53,12 @@ extern qk_ucis_state_t qk_ucis_state;
// clang-format on
-extern const qk_ucis_symbol_t ucis_symbol_table[];
+extern const ucis_symbol_t ucis_symbol_table[];
-void qk_ucis_start(void);
-void qk_ucis_start_user(void);
-void qk_ucis_symbol_fallback(void);
-void qk_ucis_success(uint8_t symbol_index);
+void ucis_start(void);
+void ucis_start_user(void);
+void ucis_symbol_fallback(void);
+void ucis_success(uint8_t symbol_index);
void register_ucis(const uint32_t *code_points);
diff --git a/quantum/process_keycode/process_unicodemap.h b/quantum/process_keycode/process_unicodemap.h
index 73f5449864..5a3aeb0000 100644
--- a/quantum/process_keycode/process_unicodemap.h
+++ b/quantum/process_keycode/process_unicodemap.h
@@ -22,7 +22,7 @@
#include "action.h"
#include "progmem.h"
-extern const uint32_t PROGMEM unicode_map[];
+extern const uint32_t unicode_map[] PROGMEM;
uint16_t unicodemap_index(uint16_t keycode);
bool process_unicodemap(uint16_t keycode, keyrecord_t *record);