summaryrefslogtreecommitdiffstats
path: root/keyboards/planck/keymaps
diff options
context:
space:
mode:
authorRyan <fauxpark@gmail.com>2023-02-13 03:19:02 +1100
committerGitHub <noreply@github.com>2023-02-13 03:19:02 +1100
commitbbf7a20b33de2d203518687cb5cd1aa85005ea27 (patch)
treeee1a5c412a02021d085c81a26321c3424eca7022 /keyboards/planck/keymaps
parentd10350cd2ceb2b9d80522cdec3ea908118f7fd35 (diff)
Refactor Leader key feature (#19632)
Co-authored-by: Drashna Jaelre <drashna@live.com>
Diffstat (limited to 'keyboards/planck/keymaps')
-rw-r--r--keyboards/planck/keymaps/copface/keymap.c78
-rw-r--r--keyboards/planck/keymaps/experimental/keymap.c61
-rw-r--r--keyboards/planck/keymaps/jdelkins/keymap.c120
-rw-r--r--keyboards/planck/keymaps/jweickm/keymap.c21
-rw-r--r--keyboards/planck/keymaps/rootiest/keymap.c154
-rw-r--r--keyboards/planck/keymaps/yhaliaw/keymap.c44
6 files changed, 220 insertions, 258 deletions
diff --git a/keyboards/planck/keymaps/copface/keymap.c b/keyboards/planck/keymaps/copface/keymap.c
index 8435ef405d..376ceeb288 100644
--- a/keyboards/planck/keymaps/copface/keymap.c
+++ b/keyboards/planck/keymaps/copface/keymap.c
@@ -157,47 +157,41 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
return true;
}
-LEADER_EXTERNS();
-void matrix_scan_user(void) {
- LEADER_DICTIONARY() {
- leading = false;
- leader_end();
-
- // Screenshot
- SEQ_ONE_KEY(KC_S) {
- tap_code16(G(C(S(KC_4))));
- }
- // Record Screen
- SEQ_TWO_KEYS(KC_S, KC_S) {
- tap_code16(S(G(KC_5)));
- }
- // 1Pass browser
- SEQ_ONE_KEY(KC_A) {
- tap_code16(G(A(KC_BSLS)));
- }
- // 1Pass mini
- SEQ_TWO_KEYS(KC_A, KC_A) {
- tap_code16(G(KC_BSLS));
- }
- // Comment out
- SEQ_ONE_KEY(KC_F) {
- tap_code16(G(KC_SLSH));
- }
- // Spotlight
- SEQ_ONE_KEY(KC_SPC) {
- tap_code16(G(KC_SPC));
- }
- // Auto format
- SEQ_ONE_KEY(KC_ENT) {
- tap_code16(S(G(A(KC_F))));
- }
- // Focus file tree
- SEQ_ONE_KEY(KC_TAB) {
- tap_code16(G(KC_1));
- }
- // Caps-lock
- SEQ_TWO_KEYS(KC_TAB, KC_TAB) {
- tap_code16(KC_CAPS);
- }
+void leader_end_user(void) {
+ // Screenshot
+ if (leader_sequence_one_key(KC_S)) {
+ tap_code16(G(C(S(KC_4))));
+ }
+ // Record Screen
+ if (leader_sequence_two_keys(KC_S, KC_S)) {
+ tap_code16(S(G(KC_5)));
+ }
+ // 1Pass browser
+ if (leader_sequence_one_key(KC_A)) {
+ tap_code16(G(A(KC_BSLS)));
+ }
+ // 1Pass mini
+ if (leader_sequence_two_keys(KC_A, KC_A)) {
+ tap_code16(G(KC_BSLS));
+ }
+ // Comment out
+ if (leader_sequence_one_key(KC_F)) {
+ tap_code16(G(KC_SLSH));
+ }
+ // Spotlight
+ if (leader_sequence_one_key(KC_SPC)) {
+ tap_code16(G(KC_SPC));
+ }
+ // Auto format
+ if (leader_sequence_one_key(KC_ENT)) {
+ tap_code16(S(G(A(KC_F))));
+ }
+ // Focus file tree
+ if (leader_sequence_one_key(KC_TAB)) {
+ tap_code16(G(KC_1));
+ }
+ // Caps-lock
+ if (leader_sequence_two_keys(KC_TAB, KC_TAB)) {
+ tap_code16(KC_CAPS);
}
}
diff --git a/keyboards/planck/keymaps/experimental/keymap.c b/keyboards/planck/keymaps/experimental/keymap.c
index e0ade650fe..d5c7425439 100644
--- a/keyboards/planck/keymaps/experimental/keymap.c
+++ b/keyboards/planck/keymaps/experimental/keymap.c
@@ -372,39 +372,32 @@ void music_scale_user(void)
#endif
-LEADER_EXTERNS();
-
-void matrix_scan_user(void) {
- LEADER_DICTIONARY() {
- leading = false;
- leader_end();
-
- SEQ_ONE_KEY (KC_R) {
- tap_random_base64();
- tap_random_base64();
- tap_random_base64();
- tap_random_base64();
- tap_random_base64();
- tap_random_base64();
- tap_random_base64();
- tap_random_base64();
- tap_random_base64();
- }
- SEQ_ONE_KEY (KC_V) {
- SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
- }
- SEQ_ONE_KEY(KC_F) {
- SEND_STRING("if yes\n\tpeanut butter\nelse\n\trice snacks");
- }
- SEQ_TWO_KEYS(KC_A, KC_S) {
- register_code(KC_H);
- unregister_code(KC_H);
- }
- SEQ_THREE_KEYS(KC_A, KC_S, KC_D) {
- register_code(KC_LGUI);
- register_code(KC_S);
- unregister_code(KC_S);
- unregister_code(KC_LGUI);
- }
+void leader_end_user(void) {
+ if (leader_sequence_one_key(KC_R)) {
+ tap_random_base64();
+ tap_random_base64();
+ tap_random_base64();
+ tap_random_base64();
+ tap_random_base64();
+ tap_random_base64();
+ tap_random_base64();
+ tap_random_base64();
+ tap_random_base64();
+ }
+ if (leader_sequence_one_key(KC_V)) {
+ SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
+ }
+ if (leader_sequence_one_key(KC_F)) {
+ SEND_STRING("if yes\n\tpeanut butter\nelse\n\trice snacks");
+ }
+ if (leader_sequence_two_keys(KC_A, KC_S)) {
+ register_code(KC_H);
+ unregister_code(KC_H);
+ }
+ if (leader_sequence_three_keys(KC_A, KC_S, KC_D)) {
+ register_code(KC_LGUI);
+ register_code(KC_S);
+ unregister_code(KC_S);
+ unregister_code(KC_LGUI);
}
}
diff --git a/keyboards/planck/keymaps/jdelkins/keymap.c b/keyboards/planck/keymaps/jdelkins/keymap.c
index 9d306abc78..ecb49da406 100644
--- a/keyboards/planck/keymaps/jdelkins/keymap.c
+++ b/keyboards/planck/keymaps/jdelkins/keymap.c
@@ -408,7 +408,64 @@ void keyboard_post_init_keymap(void) {
bspc_timer = 0;
}
-LEADER_EXTERNS();
+void leader_end_user(void) {
+ if (leader_sequence_one_key(KC_K)) {
+ layer_invert(_KP);
+ }
+ if (leader_sequence_one_key(KC_G)) {
+ layer_invert(_GAME);
+ }
+ if (leader_sequence_one_key(KC_KP_5)) {
+ layer_invert(_KP);
+ }
+ if (leader_sequence_one_key(KC_5)) {
+ layer_invert(_KP);
+ }
+ if (leader_sequence_two_keys(KC_SCLN, KC_1)) {
+ send_secret_string(0);
+ }
+ if (leader_sequence_two_keys(KC_SCLN, KC_2)) {
+ send_secret_string(1);
+ }
+ if (leader_sequence_two_keys(KC_SCLN, KC_3)) {
+ send_secret_string(2);
+ }
+ if (leader_sequence_two_keys(KC_SCLN, KC_4)) {
+ send_secret_string(3);
+ }
+ if (leader_sequence_two_keys(KC_SCLN, KC_5)) {
+ send_secret_string(4);
+ }
+ if (leader_sequence_two_keys(KC_SCLN, KC_6)) {
+ send_secret_string(5);
+ }
+ if (leader_sequence_two_keys(KC_SCLN, KC_M)) {
+ send_secret_string(0);
+ }
+ if (leader_sequence_two_keys(KC_SCLN, KC_COMM)) {
+ send_secret_string(1);
+ }
+ if (leader_sequence_two_keys(KC_SCLN, KC_DOT)) {
+ send_secret_string(2);
+ }
+ if (leader_sequence_two_keys(KC_SCLN, KC_J)) {
+ send_secret_string(3);
+ }
+ if (leader_sequence_two_keys(KC_SCLN, KC_K)) {
+ send_secret_string(4);
+ }
+ if (leader_sequence_two_keys(KC_SCLN, KC_L)) {
+ send_secret_string(5);
+ }
+ if (leader_sequence_one_key(KC_C)) {
+ tap_code16(C(KC_C));
+ }
+ // neovim: terminal escape
+ if (leader_sequence_one_key(KC_QUOT)) {
+ tap_code16(C(KC_BSLS));
+ tap_code16(C(KC_N));
+ }
+}
void matrix_scan_keymap(void) {
#ifdef AUDIO_ENABLE
@@ -436,67 +493,6 @@ void matrix_scan_keymap(void) {
bspc_timer = 0;
register_code(KC_BSPC);
}
- LEADER_DICTIONARY() {
- leading = false;
- leader_end();
-
- SEQ_ONE_KEY(KC_K) {
- layer_invert(_KP);
- }
- SEQ_ONE_KEY(KC_G) {
- layer_invert(_GAME);
- }
- SEQ_ONE_KEY(KC_KP_5) {
- layer_invert(_KP);
- }
- SEQ_ONE_KEY(KC_5) {
- layer_invert(_KP);
- }
- SEQ_TWO_KEYS(KC_SCLN, KC_1) {
- send_secret_string(0);
- }
- SEQ_TWO_KEYS(KC_SCLN, KC_2) {
- send_secret_string(1);
- }
- SEQ_TWO_KEYS(KC_SCLN, KC_3) {
- send_secret_string(2);
- }
- SEQ_TWO_KEYS(KC_SCLN, KC_4) {
- send_secret_string(3);
- }
- SEQ_TWO_KEYS(KC_SCLN, KC_5) {
- send_secret_string(4);
- }
- SEQ_TWO_KEYS(KC_SCLN, KC_6) {
- send_secret_string(5);
- }
- SEQ_TWO_KEYS(KC_SCLN, KC_M) {
- send_secret_string(0);
- }
- SEQ_TWO_KEYS(KC_SCLN, KC_COMM) {
- send_secret_string(1);
- }
- SEQ_TWO_KEYS(KC_SCLN, KC_DOT) {
- send_secret_string(2);
- }
- SEQ_TWO_KEYS(KC_SCLN, KC_J) {
- send_secret_string(3);
- }
- SEQ_TWO_KEYS(KC_SCLN, KC_K) {
- send_secret_string(4);
- }
- SEQ_TWO_KEYS(KC_SCLN, KC_L) {
- send_secret_string(5);
- }
- SEQ_ONE_KEY(KC_C) {
- tap_code16(C(KC_C));
- }
- // neovim: terminal escape
- SEQ_ONE_KEY(KC_QUOT) {
- tap_code16(C(KC_BSLS));
- tap_code16(C(KC_N));
- }
- }
}
bool music_mask_user(uint16_t keycode) {
diff --git a/keyboards/planck/keymaps/jweickm/keymap.c b/keyboards/planck/keymaps/jweickm/keymap.c
index eb3391c171..b206b8511e 100644
--- a/keyboards/planck/keymaps/jweickm/keymap.c
+++ b/keyboards/planck/keymaps/jweickm/keymap.c
@@ -984,31 +984,26 @@ bool dip_switch_update_user(uint8_t index, bool active) {
return true;
}
-
-LEADER_EXTERNS();
-
-void matrix_scan_user(void) {
- LEADER_DICTIONARY() {
- leading = false;
- leader_end();
-
- SEQ_ONE_KEY(KC_F) {
+void leader_end_user(void) {
+ if (leader_sequence_one_key(KC_F)) {
// Anything you can do in a macro.
SEND_STRING("QMK is awesome.");
}
- SEQ_TWO_KEYS(KC_D, KC_D) {
+ if (leader_sequence_two_keys(KC_D, KC_D)) {
SEND_STRING(SS_LCTL("a") SS_LCTL("c"));
}
- SEQ_THREE_KEYS(KC_D, KC_D, KC_S) {
+ if (leader_sequence_three_keys(KC_D, KC_D, KC_S)) {
SEND_STRING("https://start.duckduckgo.com\n");
}
- SEQ_TWO_KEYS(KC_A, KC_S) {
+ if (leader_sequence_two_keys(KC_A, KC_S)) {
register_code(KC_LGUI);
register_code(KC_S);
unregister_code(KC_S);
unregister_code(KC_LGUI);
}
- }
+}
+
+void matrix_scan_user(void) {
#ifdef AUDIO_ENABLE
if (muse_mode) {
if (muse_counter == 0) {
diff --git a/keyboards/planck/keymaps/rootiest/keymap.c b/keyboards/planck/keymaps/rootiest/keymap.c
index 5aec280af3..ce3b69ed1f 100644
--- a/keyboards/planck/keymaps/rootiest/keymap.c
+++ b/keyboards/planck/keymaps/rootiest/keymap.c
@@ -240,7 +240,6 @@ uint16_t muse_tempo = 50;
// Used by Leader key chords
bool did_leader_succeed;
-LEADER_EXTERNS();
// Tap-Dance stuffs, initializing functions that are coded further below
td_state_t cur_dance(tap_dance_state_t* state);
@@ -1404,6 +1403,81 @@ void leader_start_user(void) {
}
// Called when either the leader sequence is completed, or the leader timeout is hit
void leader_end_user(void) {
+ did_leader_succeed = false;
+
+ if (leader_sequence_one_key(KC_E)) {
+ SEND_STRING(SS_LCTL(SS_LSFT("t")));
+ did_leader_succeed = true;
+ }
+ if (leader_sequence_one_key(KC_C)) {
+ SEND_STRING(SS_LGUI("r") SS_DELAY(250) "calc\n");
+ did_leader_succeed = true;
+ }
+ else if (leader_sequence_one_key(KC_V)) {
+ SEND_STRING(SS_LCTL("v"));
+ did_leader_succeed = true;
+ }
+ else if (leader_sequence_two_keys(KC_E, KC_D)) {
+ SEND_STRING(SS_LGUI("r") "cmd\n" SS_LCTL("c"));
+ did_leader_succeed = true;
+ }
+ else if (leader_sequence_two_keys(KC_A, KC_C)) {
+ SEND_STRING(SS_LCTL("a") SS_LCTL("c"));
+ did_leader_succeed = true;
+ }
+ else if (leader_sequence_three_keys(KC_C, KC_A, KC_T)) {
+ send_unicode_string("😸");
+ did_leader_succeed = true;
+ }
+ else if (leader_sequence_three_keys(KC_B, KC_A, KC_T)) {
+ send_unicode_string("🦇");
+ did_leader_succeed = true;
+ }
+ else if (leader_sequence_three_keys(KC_D, KC_O, KC_G)) {
+ send_unicode_string("🐶");
+ did_leader_succeed = true;
+ }
+ else if (leader_sequence_five_keys(KC_S, KC_M, KC_I, KC_L, KC_E)) {
+ send_unicode_string("🙂");
+ did_leader_succeed = true;
+ }
+ else if (leader_sequence_four_keys(KC_H, KC_A, KC_P, KC_Y)) {
+ send_unicode_string("🙂");
+ did_leader_succeed = true;
+ }
+ else if (leader_sequence_five_keys(KC_H, KC_A, KC_P, KC_P, KC_Y)) {
+ send_unicode_string("🙂");
+ did_leader_succeed = true;
+ }
+ else if (leader_sequence_three_keys(KC_S, KC_A, KC_D)) {
+ send_unicode_string("🙁");
+ did_leader_succeed = true;
+ }
+ else if (leader_sequence_three_keys(KC_Y, KC_E, KC_S)) {
+ send_unicode_string("👍");
+ did_leader_succeed = true;
+ }
+ else if (leader_sequence_two_keys(KC_N, KC_O)) {
+ send_unicode_string("👎");
+ did_leader_succeed = true;
+ }
+ else if (leader_sequence_three_keys(KC_W, KC_O, KC_W)) {
+ send_unicode_string("🤯");
+ did_leader_succeed = true;
+ }
+ else if (leader_sequence_three_keys(KC_P, KC_O, KC_O)) {
+ send_unicode_string("💩");
+ did_leader_succeed = true;
+ }
+ else if (leader_sequence_four_keys(KC_P, KC_O, KC_O, KC_P)) {
+ send_unicode_string("💩");
+ did_leader_succeed = true;
+ }
+ else if (leader_sequence_four_keys(KC_B, KC_O, KC_A, KC_T)) {
+ send_unicode_string("⛵");
+ did_leader_succeed = true;
+ }
+
if (did_leader_succeed) {
#ifdef AUDIO_ENABLE
PLAY_SONG(leader_succeed);
@@ -1758,84 +1832,6 @@ void matrix_scan_user(void) {
is_alt_tab_active = false;
}
}
- // Monitor and perform leader-key chords
- LEADER_DICTIONARY() {
- did_leader_succeed = leading = false;
-
- SEQ_ONE_KEY(KC_E) {
- SEND_STRING(SS_LCTL(SS_LSFT("t")));
- did_leader_succeed = true;
- }
- SEQ_ONE_KEY(KC_C) {
- SEND_STRING(SS_LGUI("r") SS_DELAY(250) "calc\n");
- did_leader_succeed = true;
- }
- else SEQ_ONE_KEY(KC_V) {
- SEND_STRING(SS_LCTL("v"));
- did_leader_succeed = true;
- }
- else SEQ_TWO_KEYS(KC_E, KC_D) {
- SEND_STRING(SS_LGUI("r") "cmd\n" SS_LCTL("c"));
- did_leader_succeed = true;
- }
- else SEQ_TWO_KEYS(KC_A, KC_C) {
- SEND_STRING(SS_LCTL("a") SS_LCTL("c"));
- did_leader_succeed = true;
- }
- else SEQ_THREE_KEYS(KC_C, KC_A, KC_T) {
- send_unicode_string("😸");
- did_leader_succeed = true;
- }
- else SEQ_THREE_KEYS(KC_B, KC_A, KC_T) {
- send_unicode_string("🦇");
- did_leader_succeed = true;
- }
- else SEQ_THREE_KEYS(KC_D, KC_O, KC_G) {
- send_unicode_string("🐶");
- did_leader_succeed = true;
- }
- else SEQ_FIVE_KEYS(KC_S, KC_M, KC_I, KC_L, KC_E) {
- send_unicode_string("🙂");
- did_leader_succeed = true;
- }
- else SEQ_FOUR_KEYS(KC_H, KC_A, KC_P, KC_Y) {
- send_unicode_string("🙂");
- did_leader_succeed = true;
- }
- else SEQ_FIVE_KEYS(KC_H, KC_A, KC_P, KC_P, KC_Y) {
- send_unicode_string("🙂");
- did_leader_succeed = true;
- }
- else SEQ_THREE_KEYS(KC_S, KC_A, KC_D) {
- send_unicode_string("🙁");
- did_leader_succeed = true;
- }
- else SEQ_THREE_KEYS(KC_Y, KC_E, KC_S) {
- send_unicode_string("👍");
- did_leader_succeed = true;
- }
- else SEQ_TWO_KEYS(KC_N, KC_O) {
- send_unicode_string("👎");
- did_leader_succeed = true;
- }
- else SEQ_THREE_KEYS(KC_W, KC_O, KC_W) {
- send_unicode_string("🤯");
- did_leader_succeed = true;
- }
- else SEQ_THREE_KEYS(KC_P, KC_O, KC_O) {
- send_unicode_string("💩");
- did_leader_succeed = true;
- }
- else SEQ_FOUR_KEYS(KC_P, KC_O, KC_O, KC_P) {
- send_unicode_string("💩");
- did_leader_succeed = true;
- }
- else SEQ_FOUR_KEYS(KC_B, KC_O, KC_A, KC_T) {
- send_unicode_string("⛵");
- did_leader_succeed = true;
- }
- leader_end();
- }
// Run the wake-up RGB animation if performing wake-up
if (do_wake_animation) {
rgb_wakeup_sequence();
diff --git a/keyboards/planck/keymaps/yhaliaw/keymap.c b/keyboards/planck/keymaps/yhaliaw/keymap.c
index 62d856e9f2..8931101fef 100644
--- a/keyboards/planck/keymaps/yhaliaw/keymap.c
+++ b/keyboards/planck/keymaps/yhaliaw/keymap.c
@@ -158,36 +158,24 @@ void keyboard_post_init_user(void) {
}
bool leader_found;
-LEADER_EXTERNS();
-
-void matrix_scan_user(void) {
- LEADER_DICTIONARY() {
- leading = false;
- leader_found = false;
- SEQ_ONE_KEY(L_RESET) {
- leader_found = true;
- reset_keyboard();
- }
- else
- SEQ_ONE_KEY(KC_DEL) {
- leader_found = true;
- layer_clear();
- }
- else
- SEQ_ONE_KEY(LOWER) {
- leader_found = true;
- layer_on(_LOWER);
- }
- else
- SEQ_ONE_KEY(RAISE) {
- leader_found = true;
- layer_on(_RAISE);
- }
- leader_end();
- }
-}
void leader_end_user(void) {
+ leader_found = false;
+
+ if (leader_sequence_one_key(L_RESET)) {
+ leader_found = true;
+ reset_keyboard();
+ } else if (leader_sequence_one_key(KC_DEL)) {
+ leader_found = true;
+ layer_clear();
+ } else if (leader_sequence_one_key(LOWER)) {
+ leader_found = true;
+ layer_on(_LOWER);
+ } else if (leader_sequence_one_key(RAISE)) {
+ leader_found = true;
+ layer_on(_RAISE);
+ }
+
// Plays sound on if leader sequence found.
if (leader_found) {
#ifdef AUDIO_ENABLE