diff options
author | ridingqwerty <george.g.koenig@gmail.com> | 2020-02-25 13:25:52 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-25 13:25:52 -0500 |
commit | b949343b783da729b1dfebd38507cc56a8cd12e3 (patch) | |
tree | 6f35b98c798d071c5ce6603f62d5088da760b5d0 | |
parent | f6111d49bbfeb90fdb86c4595ba339590b364da7 (diff) | |
download | qmk_firmware-b949343b783da729b1dfebd38507cc56a8cd12e3.tar.gz qmk_firmware-b949343b783da729b1dfebd38507cc56a8cd12e3.zip |
New feature: PERMISSIVE_HOLD_PER_KEY (#7994)
* Implement 'PERMISSIVE_HOLD_PER_KEY'
* Document 'PERMISSIVE_HOLD_PER_KEY'
Co-authored-by: GeorgeKoenig <35542036+GeorgeKoenig@users.noreply.github.com>
-rw-r--r-- | docs/config_options.md | 2 | ||||
-rw-r--r-- | docs/feature_advanced_keycodes.md | 19 | ||||
-rw-r--r-- | tmk_core/common/action_tapping.c | 15 |
3 files changed, 32 insertions, 4 deletions
diff --git a/docs/config_options.md b/docs/config_options.md index d048d1767..df4b67dc1 100644 --- a/docs/config_options.md +++ b/docs/config_options.md | |||
@@ -142,6 +142,8 @@ If you define these options you will enable the associated feature, which may in | |||
142 | * `#define PERMISSIVE_HOLD` | 142 | * `#define PERMISSIVE_HOLD` |
143 | * makes tap and hold keys trigger the hold if another key is pressed before releasing, even if it hasn't hit the `TAPPING_TERM` | 143 | * makes tap and hold keys trigger the hold if another key is pressed before releasing, even if it hasn't hit the `TAPPING_TERM` |
144 | * See [Permissive Hold](feature_advanced_keycodes.md#permissive-hold) for details | 144 | * See [Permissive Hold](feature_advanced_keycodes.md#permissive-hold) for details |
145 | * `#define PERMISSIVE_HOLD_PER_KEY` | ||
146 | * enabled handling for per key `PERMISSIVE_HOLD` settings | ||
145 | * `#define IGNORE_MOD_TAP_INTERRUPT` | 147 | * `#define IGNORE_MOD_TAP_INTERRUPT` |
146 | * makes it possible to do rolling combos (zx) with keys that convert to other keys on hold, by enforcing the `TAPPING_TERM` for both keys. | 148 | * makes it possible to do rolling combos (zx) with keys that convert to other keys on hold, by enforcing the `TAPPING_TERM` for both keys. |
147 | * See [Mod tap interrupt](feature_advanced_keycodes.md#ignore-mod-tap-interrupt) for details | 149 | * See [Mod tap interrupt](feature_advanced_keycodes.md#ignore-mod-tap-interrupt) for details |
diff --git a/docs/feature_advanced_keycodes.md b/docs/feature_advanced_keycodes.md index ebb24dc99..8c3449460 100644 --- a/docs/feature_advanced_keycodes.md +++ b/docs/feature_advanced_keycodes.md | |||
@@ -265,6 +265,25 @@ Normally, if you do all this within the `TAPPING_TERM` (default: 200ms) this wil | |||
265 | 265 | ||
266 | ?> If you have `Ignore Mod Tap Interrupt` enabled, as well, this will modify how both work. The regular key has the modifier added if the first key is released first or if both keys are held longer than the `TAPPING_TERM`. | 266 | ?> If you have `Ignore Mod Tap Interrupt` enabled, as well, this will modify how both work. The regular key has the modifier added if the first key is released first or if both keys are held longer than the `TAPPING_TERM`. |
267 | 267 | ||
268 | For more granular control of this feature, you can add the following to your `config.h`: | ||
269 | |||
270 | ```c | ||
271 | #define PERMISSIVE_HOLD_PER_KEY | ||
272 | ``` | ||
273 | |||
274 | You can then add the following function to your keymap: | ||
275 | |||
276 | ```c | ||
277 | bool get_permissive_hold(uint16_t keycode, keyrecord_t *record) { | ||
278 | switch (keycode) { | ||
279 | case SFT_T(KC_A): | ||
280 | return true; | ||
281 | default: | ||
282 | return false; | ||
283 | } | ||
284 | } | ||
285 | ``` | ||
286 | |||
268 | ## Ignore Mod Tap Interrupt | 287 | ## Ignore Mod Tap Interrupt |
269 | 288 | ||
270 | To enable this setting, add this to your `config.h`: | 289 | To enable this setting, add this to your `config.h`: |
diff --git a/tmk_core/common/action_tapping.c b/tmk_core/common/action_tapping.c index c0f1f694b..65ef0a185 100644 --- a/tmk_core/common/action_tapping.c +++ b/tmk_core/common/action_tapping.c | |||
@@ -31,6 +31,10 @@ __attribute__((weak)) uint16_t get_tapping_term(uint16_t keycode) { return TAPPI | |||
31 | __attribute__((weak)) bool get_tapping_force_hold(uint16_t keycode, keyrecord_t *record) { return false; } | 31 | __attribute__((weak)) bool get_tapping_force_hold(uint16_t keycode, keyrecord_t *record) { return false; } |
32 | # endif | 32 | # endif |
33 | 33 | ||
34 | # ifdef PERMISSIVE_HOLD_PER_KEY | ||
35 | __attribute__((weak)) bool get_permissive_hold(uint16_t keycode, keyrecord_t *record) { return false; } | ||
36 | # endif | ||
37 | |||
34 | static keyrecord_t tapping_key = {}; | 38 | static keyrecord_t tapping_key = {}; |
35 | static keyrecord_t waiting_buffer[WAITING_BUFFER_SIZE] = {}; | 39 | static keyrecord_t waiting_buffer[WAITING_BUFFER_SIZE] = {}; |
36 | static uint8_t waiting_buffer_head = 0; | 40 | static uint8_t waiting_buffer_head = 0; |
@@ -115,12 +119,15 @@ bool process_tapping(keyrecord_t *keyp) { | |||
115 | * This can register the key before settlement of tapping, | 119 | * This can register the key before settlement of tapping, |
116 | * useful for long TAPPING_TERM but may prevent fast typing. | 120 | * useful for long TAPPING_TERM but may prevent fast typing. |
117 | */ | 121 | */ |
118 | # if defined(TAPPING_TERM_PER_KEY) || (TAPPING_TERM >= 500) || defined(PERMISSIVE_HOLD) | 122 | # if defined(TAPPING_TERM_PER_KEY) || (TAPPING_TERM >= 500) || defined(PERMISSIVE_HOLD) || defined(PERMISSIVE_HOLD_PER_KEY) |
123 | else if ( | ||
119 | # ifdef TAPPING_TERM_PER_KEY | 124 | # ifdef TAPPING_TERM_PER_KEY |
120 | else if ((get_tapping_term(get_event_keycode(tapping_key.event)) >= 500) && IS_RELEASED(event) && waiting_buffer_typed(event)) | 125 | (get_tapping_term(get_event_keycode(tapping_key.event)) >= 500) && |
121 | # else | 126 | # endif |
122 | else if (IS_RELEASED(event) && waiting_buffer_typed(event)) | 127 | # ifdef PERMISSIVE_HOLD_PER_KEY |
128 | !get_permissive_hold(get_event_keycode(tapping_key.event), keyp) && | ||
123 | # endif | 129 | # endif |
130 | IS_RELEASED(event) && waiting_buffer_typed(event)) | ||
124 | { | 131 | { |
125 | debug("Tapping: End. No tap. Interfered by typing key\n"); | 132 | debug("Tapping: End. No tap. Interfered by typing key\n"); |
126 | process_record(&tapping_key); | 133 | process_record(&tapping_key); |