diff options
author | Ryan <fauxpark@gmail.com> | 2023-02-13 03:19:02 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-13 03:19:02 +1100 |
commit | bbf7a20b33de2d203518687cb5cd1aa85005ea27 (patch) | |
tree | ee1a5c412a02021d085c81a26321c3424eca7022 /keyboards/dztech | |
parent | d10350cd2ceb2b9d80522cdec3ea908118f7fd35 (diff) |
Refactor Leader key feature (#19632)
Co-authored-by: Drashna Jaelre <drashna@live.com>
Diffstat (limited to 'keyboards/dztech')
-rw-r--r-- | keyboards/dztech/dz65rgb/keymaps/drootz/keymap.c | 159 |
1 files changed, 74 insertions, 85 deletions
diff --git a/keyboards/dztech/dz65rgb/keymaps/drootz/keymap.c b/keyboards/dztech/dz65rgb/keymaps/drootz/keymap.c index f98873f3df..3870c6aae3 100644 --- a/keyboards/dztech/dz65rgb/keymaps/drootz/keymap.c +++ b/keyboards/dztech/dz65rgb/keymaps/drootz/keymap.c @@ -418,54 +418,52 @@ void ldrkey_send_curlybrace_wrap_selection(void) { onMac ? SEND_STRING(SS_LGUI(SS_TAP(X_X)) "{}" SS_TAP(X_LEFT) SS_LGUI(SS_TAP(X_V)) SS_TAP(X_RIGHT)) : SEND_STRING(SS_LCTL(SS_TAP(X_X)) "{}" SS_TAP(X_LEFT) SS_LCTL(SS_TAP(X_V)) SS_TAP(X_RIGHT)); } -LEADER_EXTERNS(); +void leader_start_user(void) { + isLeader = true; +} -void matrix_scan_user(void) -{ - LEADER_DICTIONARY() - { - leading = false; - leader_end(); +void leader_end_user(void) { + isLeader = false; - /* Sequences on layer _MAIN & _MAC */ + /* Sequences on layer _MAIN & _MAC */ /* éÉ => LdrKey > / */ - SEQ_ONE_KEY(KC_SLSH) { + if (leader_sequence_one_key(KC_SLSH)) { send_french_accent(_E, _ACUTE); } /* àÀ => LdrKey > A */ - SEQ_ONE_KEY(KC_A) { + if (leader_sequence_one_key(KC_A)) { send_french_accent(_A, _GRAVE); } /* èÈ => LdrKey > E */ - SEQ_ONE_KEY(KC_E) { + if (leader_sequence_one_key(KC_E)) { send_french_accent(_E, _GRAVE); } /* ùÙ => LdrKey > U */ - SEQ_ONE_KEY(KC_U) { + if (leader_sequence_one_key(KC_U)) { send_french_accent(_U, _GRAVE); } /* â => LdrKey > A > A */ - SEQ_TWO_KEYS(KC_A, KC_A) { + if (leader_sequence_two_keys(KC_A, KC_A)) { send_french_accent(_A, _CIRCUMFLEX); } /* êÊ => LdrKey > E > E */ - SEQ_TWO_KEYS(KC_E, KC_E) { + if (leader_sequence_two_keys(KC_E, KC_E)) { send_french_accent(_E, _CIRCUMFLEX); } /* îÎ => LdrKey > I > I */ - SEQ_TWO_KEYS(KC_I, KC_I) { + if (leader_sequence_two_keys(KC_I, KC_I)) { send_french_accent(_I, _CIRCUMFLEX); } /* ôÔ => LdrKey > O > O */ - SEQ_TWO_KEYS(KC_O, KC_O) { + if (leader_sequence_two_keys(KC_O, KC_O)) { send_french_accent(_O, _CIRCUMFLEX); } /* ûÛ => LdrKey > U > U */ - SEQ_TWO_KEYS(KC_U, KC_U) { + if (leader_sequence_two_keys(KC_U, KC_U)) { send_french_accent(_U, _CIRCUMFLEX); } /* çÇ => LdrKey > C */ - SEQ_ONE_KEY(KC_C) { + if (leader_sequence_one_key(KC_C)) { if (onMac) { SEND_STRING(SS_LALT("c")); } else { @@ -473,247 +471,238 @@ void matrix_scan_user(void) } } /* CapsLock */ - SEQ_ONE_KEY(QK_LEAD) { + if (leader_sequence_one_key(QK_LEAD)) { tap_code(KC_CAPS); } /* ± => LdrKey > = > - */ - SEQ_TWO_KEYS(KC_EQL, KC_MINS) { + if (leader_sequence_two_keys(KC_EQL, KC_MINS)) { onMac ? SEND_STRING(SS_LALT(SS_LSFT(SS_TAP(X_EQL)))) : SEND_STRING(SS_DOWN(X_LALT) SS_TAP(X_P2) SS_TAP(X_P4) SS_TAP(X_P1) SS_UP(X_LALT)); } /* ≤ => LdrKey > - > = */ - SEQ_TWO_KEYS(KC_MINS, KC_EQL) { + if (leader_sequence_two_keys(KC_MINS, KC_EQL)) { onMac ? SEND_STRING(SS_LALT(SS_TAP(X_COMM))) : SEND_STRING(SS_DOWN(X_LALT) SS_TAP(X_P2) SS_TAP(X_P4) SS_TAP(X_P3) SS_UP(X_LALT)); } /* ≥ => LdrKey > = > = */ - SEQ_TWO_KEYS(KC_EQL, KC_EQL) { + if (leader_sequence_two_keys(KC_EQL, KC_EQL)) { onMac ? SEND_STRING(SS_LALT(SS_TAP(X_DOT))) : SEND_STRING(SS_DOWN(X_LALT) SS_TAP(X_P2) SS_TAP(X_P4) SS_TAP(X_P2) SS_UP(X_LALT)); } /* <= => LdrKey > , > , */ - SEQ_TWO_KEYS(KC_COMM, KC_COMM) { + if (leader_sequence_two_keys(KC_COMM, KC_COMM)) { SEND_STRING(SS_LSFT(SS_TAP(X_COMM)) SS_TAP(X_SPC) SS_TAP(X_EQL) SS_TAP(X_LEFT) SS_TAP(X_BSPC) SS_TAP(X_RIGHT)); } /* => => LdrKey > . > . */ - SEQ_TWO_KEYS(KC_DOT, KC_DOT) { + if (leader_sequence_two_keys(KC_DOT, KC_DOT)) { SEND_STRING("=>"); } /* ", " => LdrKey > " " */ - SEQ_ONE_KEY(KC_SPC) { + if (leader_sequence_one_key(KC_SPC)) { SEND_STRING(", "); } /* ". " => LdrKey > " " > " " */ - SEQ_TWO_KEYS(KC_SPC, KC_SPC) { + if (leader_sequence_two_keys(KC_SPC, KC_SPC)) { SEND_STRING(". "); } /* Backward delete current word (on cursor) */ - SEQ_TWO_KEYS(KC_BSPC, KC_BSPC) { + if (leader_sequence_two_keys(KC_BSPC, KC_BSPC)) { onMac ? SEND_STRING(SS_LALT(SS_TAP(X_RIGHT)) SS_LALT(SS_LSFT(SS_TAP(X_LEFT))) SS_TAP(X_BSPC)) : SEND_STRING(SS_LCTL(SS_TAP(X_RIGHT)) SS_LCTL(SS_LSFT(SS_TAP(X_LEFT))) SS_TAP(X_BSPC)); } /* Previous word delete */ - SEQ_ONE_KEY(KC_BSPC) { + if (leader_sequence_one_key(KC_BSPC)) { onMac ? SEND_STRING(SS_LALT(SS_LSFT(SS_TAP(X_LEFT))) SS_TAP(X_BSPC)) : SEND_STRING(SS_LCTL(SS_LSFT(SS_TAP(X_LEFT))) SS_TAP(X_BSPC)); } /* Forward delete current word (on cursor) */ - SEQ_TWO_KEYS(KC_DEL, KC_DEL) { + if (leader_sequence_two_keys(KC_DEL, KC_DEL)) { onMac ? SEND_STRING(SS_LALT(SS_TAP(X_LEFT)) SS_LALT(SS_LSFT(SS_TAP(X_RIGHT))) SS_TAP(X_DEL)) : SEND_STRING(SS_LCTL(SS_TAP(X_LEFT)) SS_LCTL(SS_LSFT(SS_TAP(X_RIGHT))) SS_TAP(X_DEL)); } /* Next word delete */ - SEQ_ONE_KEY(KC_DEL) { + if (leader_sequence_one_key(KC_DEL)) { onMac ? SEND_STRING(SS_LALT(SS_LSFT(SS_TAP(X_RIGHT))) SS_TAP(X_DEL)): SEND_STRING(SS_LCTL(SS_LSFT(SS_TAP(X_RIGHT))) SS_TAP(X_DEL)); } /* ` => LdrKey > Escape */ - SEQ_ONE_KEY(QK_GESC) { + if (leader_sequence_one_key(QK_GESC)) { SEND_STRING("`"); } /* ``` => LdrKey > Escape > Escape > Escape */ - SEQ_THREE_KEYS(QK_GESC, QK_GESC, QK_GESC) { + if (leader_sequence_three_keys(QK_GESC, QK_GESC, QK_GESC)) { SEND_STRING("```"); } /* Printscreen => LdrKey > Insert */ - SEQ_ONE_KEY(KC_INS) { + if (leader_sequence_one_key(KC_INS)) { onMac ? SEND_STRING(SS_LGUI(SS_LSFT(SS_TAP(X_4)))) : SEND_STRING(SS_TAP(X_PSCR)); } /* Home => LdrKey > Page Up */ - SEQ_ONE_KEY(KC_PGUP) { + if (leader_sequence_one_key(KC_PGUP)) { onMac ? SEND_STRING(SS_TAP(X_HOME)) : SEND_STRING(SS_LCTL(SS_TAP(X_HOME))); } /* End => LdrKey > Page Down */ - SEQ_ONE_KEY(KC_PGDN) { + if (leader_sequence_one_key(KC_PGDN)) { onMac ? SEND_STRING(SS_TAP(X_END)) : SEND_STRING(SS_LCTL(SS_TAP(X_END))); } /* Close Curernt File/Tab => LdrKey > W */ - SEQ_ONE_KEY(KC_W) { + if (leader_sequence_one_key(KC_W)) { onMac ? SEND_STRING(SS_LGUI(SS_TAP(X_W))) : SEND_STRING(SS_LCTL(SS_TAP(X_W))); } /* Close Current App => LdrKey > Q */ - SEQ_ONE_KEY(KC_Q) { + if (leader_sequence_one_key(KC_Q)) { onMac ? SEND_STRING(SS_LGUI(SS_TAP(X_Q))) : SEND_STRING(SS_LALT(SS_TAP(X_F4))); } /* " => LdrKey > ' */ - SEQ_ONE_KEY(KC_QUOT) { + if (leader_sequence_one_key(KC_QUOT)) { SEND_STRING("\""); } /* "|" => LdrKey > ' > ' */ - SEQ_TWO_KEYS(KC_QUOT, KC_QUOT) { + if (leader_sequence_two_keys(KC_QUOT, KC_QUOT)) { SEND_STRING("\"\"" SS_TAP(X_LEFT)); } /* "X" wrap => LdrKey > ' > ' > ' */ - SEQ_THREE_KEYS(KC_QUOT, KC_QUOT, KC_QUOT) { + if (leader_sequence_three_keys(KC_QUOT, KC_QUOT, KC_QUOT)) { onMac ? SEND_STRING(SS_LALT(SS_TAP(X_LEFT)) "\"" SS_LALT(SS_TAP(X_RIGHT)) "\"") : SEND_STRING(SS_LCTL(SS_TAP(X_LEFT)) "\"" SS_LCTL(SS_TAP(X_RIGHT)) "\""); } /* ( => LdrKey > Left Shift */ - SEQ_ONE_KEY(KC_LSFT) { + if (leader_sequence_one_key(KC_LSFT)) { SEND_STRING("("); } /* ) => LdrKey > Right Shift */ - SEQ_ONE_KEY(KC_RSFT) { + if (leader_sequence_one_key(KC_RSFT)) { SEND_STRING(")"); } /* (|) => LdrKey > Left Shift > Left Shift */ - SEQ_TWO_KEYS(KC_LSFT, KC_LSFT) { + if (leader_sequence_two_keys(KC_LSFT, KC_LSFT)) { ldrkey_send_paranthesis_wrap_ini(); } /* (|) => LdrKey > Right Shift > Right Shift */ - SEQ_TWO_KEYS(KC_RSFT, KC_RSFT) { + if (leader_sequence_two_keys(KC_RSFT, KC_RSFT)) { ldrkey_send_paranthesis_wrap_ini(); } /* (X) wrap => LdrKey > Left Shift > W */ - SEQ_TWO_KEYS(KC_LSFT, KC_W) { + if (leader_sequence_two_keys(KC_LSFT, KC_W)) { ldrkey_send_paranthesis_wrap_word(); } /* (X) wrap => LdrKey > Right Shift > W */ - SEQ_TWO_KEYS(KC_RSFT, KC_W) { + if (leader_sequence_two_keys(KC_RSFT, KC_W)) { ldrkey_send_paranthesis_wrap_word(); } /* (X) wrap selection => LdrKey > Left Shift > W > W */ - SEQ_THREE_KEYS(KC_LSFT, KC_W, KC_W) { + if (leader_sequence_three_keys(KC_LSFT, KC_W, KC_W)) { ldrkey_send_paranthesis_wrap_selection(); } /* (X) wrap selection => LdrKey > Right Shift > W > W */ - SEQ_THREE_KEYS(KC_RSFT, KC_W, KC_W) { + if (leader_sequence_three_keys(KC_RSFT, KC_W, KC_W)) { ldrkey_send_paranthesis_wrap_selection(); } /* [ => LdrKey > Left CTL */ - SEQ_ONE_KEY(KC_LCTL) { + if (leader_sequence_one_key(KC_LCTL)) { SEND_STRING("["); } /* ] => LdrKey > Right CTL */ - SEQ_ONE_KEY(KC_RCTL) { + if (leader_sequence_one_key(KC_RCTL)) { SEND_STRING("]"); } /* [|] => LdrKey > Left CTL > Left CTL */ - SEQ_TWO_KEYS(KC_LCTL, KC_LCTL) { + if (leader_sequence_two_keys(KC_LCTL, KC_LCTL)) { ldrkey_send_bracket_wrap_ini(); } /* [|] => LdrKey > Right CTL > Right CTL */ - SEQ_TWO_KEYS(KC_RCTL, KC_RCTL) { + if (leader_sequence_two_keys(KC_RCTL, KC_RCTL)) { ldrkey_send_bracket_wrap_ini(); } /* [X] wrap => LdrKey > Left CTL > W */ - SEQ_TWO_KEYS(KC_LCTL, KC_W) { + if (leader_sequence_two_keys(KC_LCTL, KC_W)) { ldrkey_send_bracket_wrap_word(); } /* [X] wrap => LdrKey > Right CTL > W */ - SEQ_TWO_KEYS(KC_RCTL, KC_W) { + if (leader_sequence_two_keys(KC_RCTL, KC_W)) { ldrkey_send_bracket_wrap_word(); } /* [X] wrap selection => LdrKey > Left CTL > W > W */ - SEQ_THREE_KEYS(KC_LCTL, KC_W, KC_W) { + if (leader_sequence_three_keys(KC_LCTL, KC_W, KC_W)) { ldrkey_send_bracket_wrap_selection(); } /* [X] wrap selection => LdrKey > Right CTL > W > W */ - SEQ_THREE_KEYS(KC_RCTL, KC_W, KC_W) { + if (leader_sequence_three_keys(KC_RCTL, KC_W, KC_W)) { ldrkey_send_bracket_wrap_selection(); } /* { => LdrKey > Left ALT */ - SEQ_ONE_KEY(KC_LALT) { + if (leader_sequence_one_key(KC_LALT)) { SEND_STRING("{"); } /* } => LdrKey > Right ALT */ - SEQ_ONE_KEY(KC_RALT) { + if (leader_sequence_one_key(KC_RALT)) { SEND_STRING("}"); } /* {|} => LdrKey > Left ALT > Left ALT */ - SEQ_TWO_KEYS(KC_LALT, KC_LALT) { + if (leader_sequence_two_keys(KC_LALT, KC_LALT)) { ldrkey_send_curlybrace_wrap_ini(); } /* {|} => LdrKey > Right ALT > Right ALT */ - SEQ_TWO_KEYS(KC_RALT, KC_RALT) { + if (leader_sequence_two_keys(KC_RALT, KC_RALT)) { ldrkey_send_curlybrace_wrap_ini(); } /* {X} wrap => LdrKey > Left ALT > W */ - SEQ_TWO_KEYS(KC_LALT, KC_W) { + if (leader_sequence_two_keys(KC_LALT, KC_W)) { ldrkey_send_curlybrace_wrap_word(); } /* {X} wrap => LdrKey > Right ALT > W */ - SEQ_TWO_KEYS(KC_RALT, KC_W) { + if (leader_sequence_two_keys(KC_RALT, KC_W)) { ldrkey_send_curlybrace_wrap_word(); } /* {X} wrap selection => LdrKey > Left ALT > W > W */ - SEQ_THREE_KEYS(KC_LALT, KC_W, KC_W) { + if (leader_sequence_three_keys(KC_LALT, KC_W, KC_W)) { ldrkey_send_curlybrace_wrap_selection(); } /* {X} wrap selection => LdrKey > Right ALT > W > W */ - SEQ_THREE_KEYS(KC_RALT, KC_W, KC_W) { + if (leader_sequence_three_keys(KC_RALT, KC_W, KC_W)) { ldrkey_send_curlybrace_wrap_selection(); } /* Select everything on this line before cursor => LdrKey > Left */ - SEQ_ONE_KEY(KC_LEFT) { + if (leader_sequence_one_key(KC_LEFT)) { onMac ? SEND_STRING(SS_LSFT(SS_LGUI(SS_TAP(X_LEFT)))) : SEND_STRING(SS_LSFT(SS_TAP(X_HOME))); } /* Select everything on this line after cursor => LdrKey > Right */ - SEQ_ONE_KEY(KC_RIGHT) { + if (leader_sequence_one_key(KC_RIGHT)) { onMac ? SEND_STRING(SS_LSFT(SS_LGUI(SS_TAP(X_RIGHT)))) : SEND_STRING(SS_LSFT(SS_TAP(X_END))); } /* Select everything on this line before cursor and bring on previous line => LdrKey > Left > Left */ - SEQ_TWO_KEYS(KC_LEFT, KC_LEFT) { + if (leader_sequence_two_keys(KC_LEFT, KC_LEFT)) { onMac ? SEND_STRING(SS_LSFT(SS_TAP(X_UP) SS_LGUI(SS_TAP(X_RIGHT)))) : SEND_STRING(SS_LSFT(SS_TAP(X_UP) SS_TAP(X_END))); } /* Select everything on this line => LdrKey > Right > Left */ - SEQ_TWO_KEYS(KC_RIGHT, KC_LEFT) { + if (leader_sequence_two_keys(KC_RIGHT, KC_LEFT)) { onMac ? SEND_STRING(SS_LGUI(SS_TAP(X_RIGHT) SS_LSFT(SS_LGUI(SS_TAP(X_LEFT))))) : SEND_STRING(SS_TAP(X_END) SS_LSFT(SS_TAP(X_HOME))); } /* Select 1x Page Up on the page before the cursor => LdrKey > Up */ - SEQ_ONE_KEY(KC_UP) { + if (leader_sequence_one_key(KC_UP)) { SEND_STRING(SS_LSFT(SS_TAP(X_PGUP))); } /* Select 1x Page Down on the page after the cursor => LdrKey > Down */ - SEQ_ONE_KEY(KC_DOWN) { + if (leader_sequence_one_key(KC_DOWN)) { SEND_STRING(SS_LSFT(SS_TAP(X_PGDN))); } /* Select everything on the page before the cursor => LdrKey > Up > Up */ - SEQ_TWO_KEYS(KC_UP, KC_UP) { + if (leader_sequence_two_keys(KC_UP, KC_UP)) { onMac ? SEND_STRING(SS_LSFT(SS_LGUI(SS_TAP(X_UP)))) : SEND_STRING(SS_LSFT(SS_LCTL(SS_TAP(X_HOME)))); } /* Select everything on the page after the cursor => LdrKey > Down > Down */ - SEQ_TWO_KEYS(KC_DOWN, KC_DOWN) { + if (leader_sequence_two_keys(KC_DOWN, KC_DOWN)) { onMac ? SEND_STRING(SS_LSFT(SS_LGUI(SS_TAP(X_DOWN)))) : SEND_STRING(SS_LSFT(SS_LCTL(SS_TAP(X_END)))); } /* HELPER => spit out the url of the layout description page on github */ - SEQ_FIVE_KEYS(QK_GESC, QK_GESC, QK_GESC, QK_GESC, QK_GESC) { + if (leader_sequence_five_keys(QK_GESC, QK_GESC, QK_GESC, QK_GESC, QK_GESC)) { SEND_STRING("https://github.com/qmk/qmk_firmware/tree/master/keyboards/dztech/dz65rgb/keymaps/drootz"); } /* google.ca => LdrKey > G > G */ - SEQ_TWO_KEYS(KC_G, KC_G) { + if (leader_sequence_two_keys(KC_G, KC_G)) { SEND_STRING("https://google.ca" SS_TAP(X_ENT)); } /* @gmail => LdrKey > M > L > T */ - SEQ_THREE_KEYS(KC_M, KC_L, KC_T) { + if (leader_sequence_three_keys(KC_M, KC_L, KC_T)) { SEND_STRING("mailto." SS_TAP(X_D) SS_TAP(X_A) SS_TAP(X_N) SS_TAP(X_I) SS_TAP(X_E) SS_TAP(X_L) SS_TAP(X_R) SS_TAP(X_A) SS_TAP(X_C) SS_TAP(X_I) SS_TAP(X_N) SS_TAP(X_E) "@gmail.com"); } /* Show Desktop => LdrKey > D */ - SEQ_ONE_KEY(KC_D) { + if (leader_sequence_one_key(KC_D)) { onMac ? SEND_STRING(SS_LGUI(SS_TAP(X_SPC)) "Mission" SS_TAP(X_ENT)) : SEND_STRING(SS_LGUI(SS_TAP(X_D))); } - } -} - -void leader_start_user(void) { - isLeader = true; -} - -void leader_end_user(void) { - isLeader = false; } #endif /* LEADER */ |