summaryrefslogtreecommitdiff
path: root/keyboards/preonic
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/preonic
parentd10350cd2ceb2b9d80522cdec3ea908118f7fd35 (diff)
Refactor Leader key feature (#19632)
Co-authored-by: Drashna Jaelre <drashna@live.com>
Diffstat (limited to 'keyboards/preonic')
-rw-r--r--keyboards/preonic/keymaps/brauner/keymap.c43
-rw-r--r--keyboards/preonic/keymaps/pcurt854/keymap.c193
-rw-r--r--keyboards/preonic/keymaps/yhaliaw/keymap.c44
3 files changed, 126 insertions, 154 deletions
diff --git a/keyboards/preonic/keymaps/brauner/keymap.c b/keyboards/preonic/keymaps/brauner/keymap.c
index 123a4fc215..fa1c7611cf 100644
--- a/keyboards/preonic/keymaps/brauner/keymap.c
+++ b/keyboards/preonic/keymaps/brauner/keymap.c
@@ -363,44 +363,35 @@ bool dip_switch_update_user(uint8_t index, bool active) {
return true;
}
-LEADER_EXTERNS();
-
static inline void register_ctrl_sequence(uint16_t keycode) {
tap_code16(RCTL(keycode));
}
-static inline void leader_bindings(void) {
- LEADER_DICTIONARY() {
- leading = false;
- leader_end();
-
- SEQ_THREE_KEYS(KC_A, KC_C, KC_K) {
- SEND_STRING("Acked-by: Christian Brauner <brauner@kernel.org>");
- }
+void leader_end_user(void) {
+ if (leader_sequence_three_keys(KC_A, KC_C, KC_K)) {
+ SEND_STRING("Acked-by: Christian Brauner <brauner@kernel.org>");
+ }
- SEQ_THREE_KEYS(KC_R, KC_V, KC_B) {
- SEND_STRING("Reviewed-by: Christian Brauner <brauner@kernel.org>");
- }
+ if (leader_sequence_three_keys(KC_R, KC_V, KC_B)) {
+ SEND_STRING("Reviewed-by: Christian Brauner <brauner@kernel.org>");
+ }
- SEQ_THREE_KEYS(KC_S, KC_O, KC_B) {
- SEND_STRING("Signed-off-by: Christian Brauner <brauner@kernel.org>");
- }
+ if (leader_sequence_three_keys(KC_S, KC_O, KC_B)) {
+ SEND_STRING("Signed-off-by: Christian Brauner <brauner@kernel.org>");
+ }
- /* Support vim-style copy. */
- SEQ_ONE_KEY(KC_Y) {
- tap_code16(C(S(KC_C)));
- }
+ /* Support vim-style copy. */
+ if (leader_sequence_one_key(KC_Y)) {
+ tap_code16(C(S(KC_C)));
+ }
- /* Support vim-style paste. */
- SEQ_ONE_KEY(KC_P) {
- tap_code16(C(S(KC_V)));
- }
+ /* Support vim-style paste. */
+ if (leader_sequence_one_key(KC_P)) {
+ tap_code16(C(S(KC_V)));
}
}
void matrix_scan_user(void) {
- leader_bindings();
-
#ifdef AUDIO_ENABLE
if (muse_mode) {
if (muse_counter == 0) {
diff --git a/keyboards/preonic/keymaps/pcurt854/keymap.c b/keyboards/preonic/keymaps/pcurt854/keymap.c
index 15e31df0a6..af88b10f3b 100644
--- a/keyboards/preonic/keymaps/pcurt854/keymap.c
+++ b/keyboards/preonic/keymaps/pcurt854/keymap.c
@@ -362,120 +362,113 @@ float leader_succeed_song[][2] = SONG(STARTUP_SOUND);
//float leader_fail_song[][2] = SONG(GOODBYE_SOUND);
float leader_fail_song[][2] = SONG(NO_SOUND);
#endif
-LEADER_EXTERNS();
-void matrix_scan_user(void) {
- LEADER_DICTIONARY() {
- did_leader_succeed = leading = false;
-
- // tap dance
- // sort by first key
+void leader_start_user(void) {
+#ifdef AUDIO_ENABLE
+ PLAY_SONG(leader_start_song);
+#endif
+}
- SEQ_ONE_KEY(KC_C) {
- SEND_STRING(SS_TAP(X_CAPS));
- did_leader_succeed = true;
- }
+void leader_end_user(void) {
+ did_leader_succeed = false;
- SEQ_ONE_KEY(KC_BSPC) {
- SEND_STRING(SS_TAP(X_DEL));
- did_leader_succeed = true;
- }
+ // tap dance
+ // sort by first key
- SEQ_ONE_KEY(KC_D) {
- SEND_STRING("{}"SS_TAP(X_LEFT));
- did_leader_succeed = true;
- }
- SEQ_TWO_KEYS(KC_D, KC_B) {
- SEND_STRING("Dear Brother");
- did_leader_succeed = true;
- }
- SEQ_THREE_KEYS(KC_D, KC_B, KC_S) {
- SEND_STRING("Dear Brothers and Sister");
- did_leader_succeed = true;
- }
- SEQ_TWO_KEYS(KC_D, KC_D) {
- SEND_STRING("{");
- did_leader_succeed = true;
- }
- SEQ_THREE_KEYS(KC_D, KC_D, KC_D) {
- SEND_STRING("}");
- did_leader_succeed = true;
- }
- SEQ_TWO_KEYS(KC_D, KC_S) {
- SEND_STRING("Dear Sister");
- did_leader_succeed = true;
- }
+ if (leader_sequence_one_key(KC_C)) {
+ SEND_STRING(SS_TAP(X_CAPS));
+ did_leader_succeed = true;
+ }
- // Html Tags
- SEQ_TWO_KEYS(KC_H, KC_T) {
- SEND_STRING("<></>"SS_TAP(X_LEFT));
- did_leader_succeed = true;
- }
+ if (leader_sequence_one_key(KC_BSPC)) {
+ SEND_STRING(SS_TAP(X_DEL));
+ did_leader_succeed = true;
+ }
- SEQ_TWO_KEYS(KC_I, KC_C) {
- SEND_STRING("In Christ,");
- did_leader_succeed = true;
- }
+ if (leader_sequence_one_key(KC_D)) {
+ SEND_STRING("{}"SS_TAP(X_LEFT));
+ did_leader_succeed = true;
+ }
+ if (leader_sequence_two_keys(KC_D, KC_B)) {
+ SEND_STRING("Dear Brother");
+ did_leader_succeed = true;
+ }
+ if (leader_sequence_three_keys(KC_D, KC_B, KC_S)) {
+ SEND_STRING("Dear Brothers and Sister");
+ did_leader_succeed = true;
+ }
+ if (leader_sequence_two_keys(KC_D, KC_D)) {
+ SEND_STRING("{");
+ did_leader_succeed = true;
+ }
+ if (leader_sequence_three_keys(KC_D, KC_D, KC_D)) {
+ SEND_STRING("}");
+ did_leader_succeed = true;
+ }
+ if (leader_sequence_two_keys(KC_D, KC_S)) {
+ SEND_STRING("Dear Sister");
+ did_leader_succeed = true;
+ }
- SEQ_ONE_KEY(KC_J) {
- SEND_STRING("<>"SS_TAP(X_LEFT));
- did_leader_succeed = true;
- }
- SEQ_TWO_KEYS(KC_J, KC_J) {
- SEND_STRING("<");
- did_leader_succeed = true;
- }
- SEQ_THREE_KEYS(KC_J, KC_J, KC_J) {
- SEND_STRING(">");
- did_leader_succeed = true;
- }
+ // Html Tags
+ if (leader_sequence_two_keys(KC_H, KC_T)) {
+ SEND_STRING("<></>"SS_TAP(X_LEFT));
+ did_leader_succeed = true;
+ }
- SEQ_TWO_KEYS(KC_T, KC_S) {
- SEND_STRING("Thanks!");
- did_leader_succeed = true;
- }
- SEQ_TWO_KEYS(KC_T, KC_Y) {
- SEND_STRING("Thank you!");
- did_leader_succeed = true;
- }
+ if (leader_sequence_two_keys(KC_I, KC_C)) {
+ SEND_STRING("In Christ,");
+ did_leader_succeed = true;
+ }
- SEQ_ONE_KEY(KC_X) {
- SEND_STRING("()"SS_TAP(X_LEFT));
- did_leader_succeed = true;
- }
- SEQ_TWO_KEYS(KC_X, KC_X) {
- SEND_STRING("(");
- did_leader_succeed = true;
- }
- SEQ_THREE_KEYS(KC_X, KC_X, KC_X) {
- SEND_STRING(")");
- did_leader_succeed = true;
- }
+ if (leader_sequence_one_key(KC_J)) {
+ SEND_STRING("<>"SS_TAP(X_LEFT));
+ did_leader_succeed = true;
+ }
+ if (leader_sequence_two_keys(KC_J, KC_J)) {
+ SEND_STRING("<");
+ did_leader_succeed = true;
+ }
+ if (leader_sequence_three_keys(KC_J, KC_J, KC_J)) {
+ SEND_STRING(">");
+ did_leader_succeed = true;
+ }
- SEQ_ONE_KEY(KC_Z) {
- SEND_STRING("[]"SS_TAP(X_LEFT));
- did_leader_succeed = true;
- }
- SEQ_TWO_KEYS(KC_Z, KC_Z) {
- SEND_STRING("[");
- did_leader_succeed = true;
- }
- SEQ_THREE_KEYS(KC_Z, KC_Z, KC_Z) {
- SEND_STRING("]");
- did_leader_succeed = true;
- }
+ if (leader_sequence_two_keys(KC_T, KC_S)) {
+ SEND_STRING("Thanks!");
+ did_leader_succeed = true;
+ }
+ if (leader_sequence_two_keys(KC_T, KC_Y)) {
+ SEND_STRING("Thank you!");
+ did_leader_succeed = true;
+ }
- leader_end();
+ if (leader_sequence_one_key(KC_X)) {
+ SEND_STRING("()"SS_TAP(X_LEFT));
+ did_leader_succeed = true;
+ }
+ if (leader_sequence_two_keys(KC_X, KC_X)) {
+ SEND_STRING("(");
+ did_leader_succeed = true;
+ }
+ if (leader_sequence_three_keys(KC_X, KC_X, KC_X)) {
+ SEND_STRING(")");
+ did_leader_succeed = true;
}
-}
-void leader_start_user(void) {
-#ifdef AUDIO_ENABLE
- PLAY_SONG(leader_start_song);
-#endif
-}
+ if (leader_sequence_one_key(KC_Z)) {
+ SEND_STRING("[]"SS_TAP(X_LEFT));
+ did_leader_succeed = true;
+ }
+ if (leader_sequence_two_keys(KC_Z, KC_Z)) {
+ SEND_STRING("[");
+ did_leader_succeed = true;
+ }
+ if (leader_sequence_three_keys(KC_Z, KC_Z, KC_Z)) {
+ SEND_STRING("]");
+ did_leader_succeed = true;
+ }
-void leader_end_user(void) {
if (did_leader_succeed) {
#ifdef AUDIO_ENABLE
PLAY_SONG(leader_succeed_song);
diff --git a/keyboards/preonic/keymaps/yhaliaw/keymap.c b/keyboards/preonic/keymaps/yhaliaw/keymap.c
index b64aa7d745..7771199e9c 100644
--- a/keyboards/preonic/keymaps/yhaliaw/keymap.c
+++ b/keyboards/preonic/keymaps/yhaliaw/keymap.c
@@ -168,36 +168,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