From 559da1f54966756dfadbc7af57b4ee6b3db69998 Mon Sep 17 00:00:00 2001 From: Danielo Rodriguez Date: Thu, 19 Mar 2020 17:53:42 +0100 Subject: [PATCH 1/2] feat: implement leader_no_timeout logic --- quantum/process_keycode/process_leader.c | 5 ++++- quantum/process_keycode/process_leader.h | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/quantum/process_keycode/process_leader.c b/quantum/process_keycode/process_leader.c index 58a615d85a59..0f0aa5eb11d2 100644 --- a/quantum/process_keycode/process_leader.c +++ b/quantum/process_keycode/process_leader.c @@ -49,7 +49,10 @@ bool process_leader(uint16_t keycode, keyrecord_t *record) { // Leader key set-up if (record->event.pressed) { if (leading) { - if (timer_elapsed(leader_time) < LEADER_TIMEOUT) { +# ifndef LEADER_NO_TIMEOUT + if (timer_elapsed(leader_time) < LEADER_TIMEOUT) +#endif // LEADER_NO_TIMEOUT + { # ifndef LEADER_KEY_STRICT_KEY_PROCESSING if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) { keycode = keycode & 0xFF; diff --git a/quantum/process_keycode/process_leader.h b/quantum/process_keycode/process_leader.h index e0edf57b3272..a3486c22f5ad 100644 --- a/quantum/process_keycode/process_leader.h +++ b/quantum/process_keycode/process_leader.h @@ -36,6 +36,11 @@ void qk_leader_start(void); extern uint16_t leader_time; \ extern uint16_t leader_sequence[5]; \ extern uint8_t leader_sequence_size -#define LEADER_DICTIONARY() if (leading && timer_elapsed(leader_time) > LEADER_TIMEOUT) + +#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 #endif From 6f1b86e4b50def106d3f22238fb92833b4777da8 Mon Sep 17 00:00:00 2001 From: Danielo Rodriguez Date: Sun, 1 Nov 2020 05:53:35 +0100 Subject: [PATCH 2/2] docs(leader_key): infinite leader timeout docs --- docs/feature_leader_key.md | 13 +++++++++++++ quantum/process_keycode/process_leader.c | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/docs/feature_leader_key.md b/docs/feature_leader_key.md index 1d3e2ef7f480..b4051adf85cd 100644 --- a/docs/feature_leader_key.md +++ b/docs/feature_leader_key.md @@ -72,6 +72,19 @@ SEQ_THREE_KEYS(KC_C, KC_C, KC_C) { } ``` +## Infinite Leader key timeout + +Sometimes your leader key is not on a comfortable places as the rest of keys on your sequence. Imagine that your leader key is one of your outer top right keys, you may need to reposition your hand just to reach your leader key. +This can make typing the entire sequence on time hard even if you are able to type most of the sequence fast. For example, if your sequence is `Leader + asd` typing `asd` fast is very easy once you have your hands in your home row. However starting the sequence in time after moving your hand out of the home row to reach the leader key and back is not. +To remove the stress this situation produces to your hands you can enable an infinite timeout just for the leader key. This mean that, after you hit the leader key you will have an infinite amount of time to start the rest of the sequence, allowing you to proper position your hands on the best position to type the rest of the sequence comfortably. +This infinite timeout only affects the leader key, so in our previous example of `Leader + asd` you will have an infinite amount of time between `Leader` and `a`, but once you start the sequence the timeout you have configured (global or per key) will work normally. +This way you can configure a very short `LEADER_TIMEOUT` but still have plenty of time to position your hands. + +In order to enable this, place this in your `config.h`: +```c +#define LEADER_NO_TIMEOUT +``` + ## Strict Key Processing By default, the Leader Key feature will filter the keycode out of [`Mod-Tap`](mod_tap.md) and [`Layer Tap`](feature_advanced_keycodes.md#switching-and-toggling-layers) functions when checking for the Leader sequences. That means if you're using `LT(3, KC_A)`, it will pick this up as `KC_A` for the sequence, rather than `LT(3, KC_A)`, giving a more expected behavior for newer users. diff --git a/quantum/process_keycode/process_leader.c b/quantum/process_keycode/process_leader.c index 0f0aa5eb11d2..cf63f2514137 100644 --- a/quantum/process_keycode/process_leader.c +++ b/quantum/process_keycode/process_leader.c @@ -49,9 +49,9 @@ 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 if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) {