diff options
-rw-r--r-- | docs/feature_leader_key.md | 12 | ||||
-rw-r--r-- | keyboards/dz60/keymaps/jdelkins/keymap.c | 2 | ||||
-rw-r--r-- | keyboards/dztech/dz65rgb/keymaps/drootz/keymap.c | 4 | ||||
-rw-r--r-- | keyboards/ergodox_ez/keymaps/hacker_dvorak/tap_dance/mod_tap_layer_dances/none_lead.c | 2 | ||||
-rw-r--r-- | keyboards/massdrop/alt/keymaps/jdelkins/keymap.c | 2 | ||||
-rw-r--r-- | keyboards/planck/keymaps/jdelkins/keymap.c | 2 | ||||
-rw-r--r-- | keyboards/planck/keymaps/rootiest/keymap.c | 4 | ||||
-rw-r--r-- | keyboards/planck/keymaps/yhaliaw/keymap.c | 2 | ||||
-rw-r--r-- | keyboards/preonic/keymaps/pcurt854/keymap.c | 4 | ||||
-rw-r--r-- | keyboards/preonic/keymaps/yhaliaw/keymap.c | 2 | ||||
-rw-r--r-- | quantum/process_keycode/process_leader.c | 42 | ||||
-rw-r--r-- | quantum/process_keycode/process_leader.h | 4 | ||||
-rw-r--r-- | users/danielo515/danielo515.c | 4 | ||||
-rw-r--r-- | users/kuchosauronad0/leader.c | 4 |
14 files changed, 46 insertions, 44 deletions
diff --git a/docs/feature_leader_key.md b/docs/feature_leader_key.md index e285d10597..4e7a487be7 100644 --- a/docs/feature_leader_key.md +++ b/docs/feature_leader_key.md @@ -93,18 +93,18 @@ While, this may be fine for most, if you want to specify the whole keycode (eg, ## Customization -The Leader Key feature has some additional customization to how the Leader Key feature works. It has two functions that can be called at certain parts of the process. Namely `leader_start()` and `leader_end()`. +The Leader Key feature has some additional customization to how the Leader Key feature works. It has two functions that can be called at certain parts of the process. Namely `leader_start_user()` and `leader_end_user()`. -The `leader_start()` function is called when you tap the `QK_LEAD` key, and the `leader_end()` function is called when either the leader sequence is completed, or the leader timeout is hit. +The `leader_start_user()` function is called when you tap the `QK_LEAD` key, and the `leader_end_user()` function is called when either the leader sequence is completed, or the leader timeout is hit. You can add these functions to your code (`keymap.c` usually) to add feedback to the Leader sequences (such as beeping or playing music). ```c -void leader_start(void) { +void leader_start_user(void) { // sequence started } -void leader_end(void) { +void leader_end_user(void) { // sequence ended (no success/failure detection) } ``` @@ -139,13 +139,13 @@ void matrix_scan_user(void) { } } -void leader_start(void) { +void leader_start_user(void) { #ifdef AUDIO_ENABLE PLAY_SONG(leader_start); #endif } -void leader_end(void) { +void leader_end_user(void) { if (did_leader_succeed) { #ifdef AUDIO_ENABLE PLAY_SONG(leader_succeed); diff --git a/keyboards/dz60/keymaps/jdelkins/keymap.c b/keyboards/dz60/keymaps/jdelkins/keymap.c index 4e80724159..786d3afa3e 100644 --- a/keyboards/dz60/keymaps/jdelkins/keymap.c +++ b/keyboards/dz60/keymaps/jdelkins/keymap.c @@ -38,7 +38,7 @@ int ctl_state = 0; void ctl_finished(qk_tap_dance_state_t *state, void *user_data) { ctl_state = cur_dance(state); switch (ctl_state) { - case SINGLE_TAP: qk_leader_start(); break; + case SINGLE_TAP: leader_start(); break; case SINGLE_HOLD: register_code(KC_LCTL); break; case DOUBLE_TAP: tap_code(KC_RCTL); break; case DOUBLE_HOLD: register_code(KC_RCTL); break; diff --git a/keyboards/dztech/dz65rgb/keymaps/drootz/keymap.c b/keyboards/dztech/dz65rgb/keymaps/drootz/keymap.c index d0d22f28b4..123cf71853 100644 --- a/keyboards/dztech/dz65rgb/keymaps/drootz/keymap.c +++ b/keyboards/dztech/dz65rgb/keymaps/drootz/keymap.c @@ -708,11 +708,11 @@ void matrix_scan_user(void) } } -void leader_start(void) { +void leader_start_user(void) { isLeader = true; } -void leader_end(void) { +void leader_end_user(void) { isLeader = false; } diff --git a/keyboards/ergodox_ez/keymaps/hacker_dvorak/tap_dance/mod_tap_layer_dances/none_lead.c b/keyboards/ergodox_ez/keymaps/hacker_dvorak/tap_dance/mod_tap_layer_dances/none_lead.c index 0ba31cec81..3550067993 100644 --- a/keyboards/ergodox_ez/keymaps/hacker_dvorak/tap_dance/mod_tap_layer_dances/none_lead.c +++ b/keyboards/ergodox_ez/keymaps/hacker_dvorak/tap_dance/mod_tap_layer_dances/none_lead.c @@ -17,7 +17,7 @@ void none_lead_finished(qk_tap_dance_state_t *state, void *user_data) { break; case DOUBLE_TAP: - qk_leader_start(); + leader_start(); break; } } diff --git a/keyboards/massdrop/alt/keymaps/jdelkins/keymap.c b/keyboards/massdrop/alt/keymaps/jdelkins/keymap.c index 1adfcb7d71..d953b4fcfe 100644 --- a/keyboards/massdrop/alt/keymaps/jdelkins/keymap.c +++ b/keyboards/massdrop/alt/keymaps/jdelkins/keymap.c @@ -45,7 +45,7 @@ int ctl_state = 0; void ctl_finished(qk_tap_dance_state_t *state, void *user_data) { ctl_state = cur_dance(state); switch(ctl_state) { - case SINGLE_TAP: qk_leader_start(); break; + case SINGLE_TAP: leader_start(); break; case SINGLE_HOLD: register_code(KC_LCTL); break; case DOUBLE_TAP: tap_code(KC_RCTL); break; case DOUBLE_HOLD: register_code(KC_RCTL); break; diff --git a/keyboards/planck/keymaps/jdelkins/keymap.c b/keyboards/planck/keymaps/jdelkins/keymap.c index 521ade05b9..fc6d01e176 100644 --- a/keyboards/planck/keymaps/jdelkins/keymap.c +++ b/keyboards/planck/keymaps/jdelkins/keymap.c @@ -43,7 +43,7 @@ int ctl_state = 0; void ctl_finished(qk_tap_dance_state_t *state, void *user_data) { ctl_state = cur_dance(state); switch (ctl_state) { - case SINGLE_TAP: qk_leader_start(); break; + case SINGLE_TAP: leader_start(); break; case SINGLE_HOLD: register_code(KC_LCTL); break; case DOUBLE_TAP: tap_code(KC_RCTL); break; case DOUBLE_HOLD: register_code(KC_RCTL); break; diff --git a/keyboards/planck/keymaps/rootiest/keymap.c b/keyboards/planck/keymaps/rootiest/keymap.c index 9b6bc9cc18..6ffcd5a0b4 100644 --- a/keyboards/planck/keymaps/rootiest/keymap.c +++ b/keyboards/planck/keymaps/rootiest/keymap.c @@ -1397,13 +1397,13 @@ bool get_permissive_hold(uint16_t keycode, keyrecord_t* record) { * by playing sound at different stages of the leader chord */ // Called when you tap the Leader key -void leader_start(void) { +void leader_start_user(void) { #ifdef AUDIO_ENABLE PLAY_SONG(leader_started); #endif } // Called when either the leader sequence is completed, or the leader timeout is hit -void leader_end(void) { +void leader_end_user(void) { if (did_leader_succeed) { #ifdef AUDIO_ENABLE PLAY_SONG(leader_succeed); diff --git a/keyboards/planck/keymaps/yhaliaw/keymap.c b/keyboards/planck/keymaps/yhaliaw/keymap.c index 54bf431f22..62d856e9f2 100644 --- a/keyboards/planck/keymaps/yhaliaw/keymap.c +++ b/keyboards/planck/keymaps/yhaliaw/keymap.c @@ -187,7 +187,7 @@ void matrix_scan_user(void) { } } -void leader_end(void) { +void leader_end_user(void) { // Plays sound on if leader sequence found. if (leader_found) { #ifdef AUDIO_ENABLE diff --git a/keyboards/preonic/keymaps/pcurt854/keymap.c b/keyboards/preonic/keymaps/pcurt854/keymap.c index c039320b34..15e31df0a6 100644 --- a/keyboards/preonic/keymaps/pcurt854/keymap.c +++ b/keyboards/preonic/keymaps/pcurt854/keymap.c @@ -469,13 +469,13 @@ void matrix_scan_user(void) { } } -void leader_start(void) { +void leader_start_user(void) { #ifdef AUDIO_ENABLE PLAY_SONG(leader_start_song); #endif } -void leader_end(void) { +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 139bd16a29..b64aa7d745 100644 --- a/keyboards/preonic/keymaps/yhaliaw/keymap.c +++ b/keyboards/preonic/keymaps/yhaliaw/keymap.c @@ -197,7 +197,7 @@ void matrix_scan_user(void) { } } -void leader_end(void) { +void leader_end_user(void) { // Plays sound on if leader sequence found. if (leader_found) { #ifdef AUDIO_ENABLE diff --git a/quantum/process_keycode/process_leader.c b/quantum/process_keycode/process_leader.c index b74b4927a8..80bc96e65f 100644 --- a/quantum/process_keycode/process_leader.c +++ b/quantum/process_keycode/process_leader.c @@ -14,18 +14,16 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifdef LEADER_ENABLE +#include "process_leader.h" +#include <string.h> -# include "process_leader.h" -# include <string.h> - -# ifndef LEADER_TIMEOUT -# define LEADER_TIMEOUT 300 -# endif +#ifndef LEADER_TIMEOUT +# define LEADER_TIMEOUT 300 +#endif -__attribute__((weak)) void leader_start(void) {} +__attribute__((weak)) void leader_start_user(void) {} -__attribute__((weak)) void leader_end(void) {} +__attribute__((weak)) void leader_end_user(void) {} // Leader key stuff bool leading = false; @@ -34,52 +32,54 @@ 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) { +void leader_start(void) { if (leading) { return; } - leader_start(); + leader_start_user(); leading = true; leader_time = timer_read(); leader_sequence_size = 0; memset(leader_sequence, 0, sizeof(leader_sequence)); } +void leader_end(void) { + leader_end_user(); +} + bool process_leader(uint16_t keycode, keyrecord_t *record) { // Leader key set-up if (record->event.pressed) { if (leading) { -# ifndef LEADER_NO_TIMEOUT +#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 +#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 +#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(); + leader_end_user(); return true; } -# ifdef LEADER_PER_KEY_TIMING +#ifdef LEADER_PER_KEY_TIMING leader_time = timer_read(); -# endif +#endif return false; } } else { if (keycode == QK_LEADER) { - qk_leader_start(); + leader_start(); } } } return true; } - -#endif diff --git a/quantum/process_keycode/process_leader.h b/quantum/process_keycode/process_leader.h index f3fe14a432..82b4a3ed7b 100644 --- a/quantum/process_keycode/process_leader.h +++ b/quantum/process_keycode/process_leader.h @@ -20,9 +20,11 @@ bool process_leader(uint16_t keycode, keyrecord_t *record); +void leader_start_user(void); +void leader_end_user(void); + 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) diff --git a/users/danielo515/danielo515.c b/users/danielo515/danielo515.c index 9b09aed9d7..ea91ec55bf 100644 --- a/users/danielo515/danielo515.c +++ b/users/danielo515/danielo515.c @@ -7,9 +7,9 @@ bool onMac = true; LEADER_EXTERNS(); # ifdef RGBLIGHT_ENABLE -void leader_start() { rgblight_setrgb_range(5, 100, 199, 10, 15); }; +void leader_start_user() { rgblight_setrgb_range(5, 100, 199, 10, 15); }; -void leader_end() { rgblight_setrgb_range(200, 200, 255, 10, 15); }; +void leader_end_user() { rgblight_setrgb_range(200, 200, 255, 10, 15); }; # endif void matrix_scan_user(void) { diff --git a/users/kuchosauronad0/leader.c b/users/kuchosauronad0/leader.c index ac2a6599a1..e8935ec401 100644 --- a/users/kuchosauronad0/leader.c +++ b/users/kuchosauronad0/leader.c @@ -93,7 +93,7 @@ void matrix_scan_user(void) { // matrix_scan_keymap(); } -void leader_start(void) { +void leader_start_user(void) { #ifdef RGBLIGHT_ENABLE rgblight_savebase(); rgblight_mode_noeeprom(1); @@ -101,7 +101,7 @@ void leader_start(void) { #endif } -void leader_end(void) { +void leader_end_user(void) { // pick color depending of success /fail // fade leader_start from 100 to 0 // fade new color from 0 to 100 to 0 |