diff options
author | ridingqwerty <george.g.koenig@gmail.com> | 2020-01-17 15:49:23 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-17 15:49:23 -0500 |
commit | 95c24bbaf8ed2b3c9ee79226dea782dc84764c56 (patch) | |
tree | b261a23add06ad615e4503cf423bf788b1b050ba | |
parent | 1b0854fdca06d24324eecbb565702bbd337ef339 (diff) | |
download | qmk_firmware-95c24bbaf8ed2b3c9ee79226dea782dc84764c56.tar.gz qmk_firmware-95c24bbaf8ed2b3c9ee79226dea782dc84764c56.zip |
Implement and document TAPPING_FORCE_HOLD_PER_KEY (#7859)
* Implement and document TAPPING_FORCE_HOLD_PER_KEY
* Added "record" parameter to "get_tapping_force_hold"
* Correct typo -- remove 'IGNORE_' from 'IGNORE_TAPPING_FORCE_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 | 38 | ||||
-rw-r--r-- | tmk_core/common/action_tapping.c | 13 |
3 files changed, 51 insertions, 2 deletions
diff --git a/docs/config_options.md b/docs/config_options.md index 0b83ed9e4..6df082335 100644 --- a/docs/config_options.md +++ b/docs/config_options.md | |||
@@ -149,6 +149,8 @@ If you define these options you will enable the associated feature, which may in | |||
149 | * makes it possible to use a dual role key as modifier shortly after having been tapped | 149 | * makes it possible to use a dual role key as modifier shortly after having been tapped |
150 | * See [Hold after tap](feature_advanced_keycodes.md#tapping-force-hold) | 150 | * See [Hold after tap](feature_advanced_keycodes.md#tapping-force-hold) |
151 | * Breaks any Tap Toggle functionality (`TT` or the One Shot Tap Toggle) | 151 | * Breaks any Tap Toggle functionality (`TT` or the One Shot Tap Toggle) |
152 | * `#define TAPPING_FORCE_HOLD_PER_KEY` | ||
153 | * enables handling for per key `TAPPING_FORCE_HOLD` settings | ||
152 | * `#define LEADER_TIMEOUT 300` | 154 | * `#define LEADER_TIMEOUT 300` |
153 | * how long before the leader key times out | 155 | * how long before the leader key times out |
154 | * If you're having issues finishing the sequence before it times out, you may need to increase the timeout setting. Or you may want to enable the `LEADER_PER_KEY_TIMING` option, which resets the timeout after each key is tapped. | 156 | * If you're having issues finishing the sequence before it times out, you may need to increase the timeout setting. Or you may want to enable the `LEADER_PER_KEY_TIMING` option, which resets the timeout after each key is tapped. |
diff --git a/docs/feature_advanced_keycodes.md b/docs/feature_advanced_keycodes.md index ec3807f40..ebb24dc99 100644 --- a/docs/feature_advanced_keycodes.md +++ b/docs/feature_advanced_keycodes.md | |||
@@ -291,6 +291,25 @@ Normally, this would send `X` (`SHIFT`+`x`). With `Ignore Mod Tap Interrupt` ena | |||
291 | 291 | ||
292 | ?> If you have `Permissive Hold` 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`. | 292 | ?> If you have `Permissive Hold` 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`. |
293 | 293 | ||
294 | For more granular control of this feature, you can add the following to your `config.h`: | ||
295 | |||
296 | ```c | ||
297 | #define IGNORE_MOD_TAP_INTERRUPT_PER_KEY | ||
298 | ``` | ||
299 | |||
300 | You can then add the following function to your keymap: | ||
301 | |||
302 | ```c | ||
303 | bool get_ignore_mod_tap_interrupt(uint16_t keycode) { | ||
304 | switch (keycode) { | ||
305 | case SFT_T(KC_SPC): | ||
306 | return true; | ||
307 | default: | ||
308 | return false; | ||
309 | } | ||
310 | } | ||
311 | ``` | ||
312 | |||
294 | ## Tapping Force Hold | 313 | ## Tapping Force Hold |
295 | 314 | ||
296 | To enable `tapping force hold`, add the following to your `config.h`: | 315 | To enable `tapping force hold`, add the following to your `config.h`: |
@@ -315,6 +334,25 @@ With `TAPPING_FORCE_HOLD`, the second press will be interpreted as a Shift, allo | |||
315 | 334 | ||
316 | !> `TAPPING_FORCE_HOLD` will break anything that uses tapping toggles (Such as the `TT` layer keycode, and the One Shot Tapping Toggle). | 335 | !> `TAPPING_FORCE_HOLD` will break anything that uses tapping toggles (Such as the `TT` layer keycode, and the One Shot Tapping Toggle). |
317 | 336 | ||
337 | For more granular control of this feature, you can add the following to your `config.h`: | ||
338 | |||
339 | ```c | ||
340 | #define TAPPING_FORCE_HOLD_PER_KEY | ||
341 | ``` | ||
342 | |||
343 | You can then add the following function to your keymap: | ||
344 | |||
345 | ```c | ||
346 | bool get_tapping_force_hold(uint16_t keycode, keyrecord_t *record) { | ||
347 | switch (keycode) { | ||
348 | case LT(1, KC_BSPC): | ||
349 | return true; | ||
350 | default: | ||
351 | return false; | ||
352 | } | ||
353 | } | ||
354 | ``` | ||
355 | |||
318 | ## Retro Tapping | 356 | ## Retro Tapping |
319 | 357 | ||
320 | To enable `retro tapping`, add the following to your `config.h`: | 358 | To enable `retro tapping`, add the following to your `config.h`: |
diff --git a/tmk_core/common/action_tapping.c b/tmk_core/common/action_tapping.c index 8531dff36..c0f1f694b 100644 --- a/tmk_core/common/action_tapping.c +++ b/tmk_core/common/action_tapping.c | |||
@@ -27,6 +27,10 @@ __attribute__((weak)) uint16_t get_tapping_term(uint16_t keycode) { return TAPPI | |||
27 | # define WITHIN_TAPPING_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < TAPPING_TERM) | 27 | # define WITHIN_TAPPING_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < TAPPING_TERM) |
28 | # endif | 28 | # endif |
29 | 29 | ||
30 | # ifdef TAPPING_FORCE_HOLD_PER_KEY | ||
31 | __attribute__((weak)) bool get_tapping_force_hold(uint16_t keycode, keyrecord_t *record) { return false; } | ||
32 | # endif | ||
33 | |||
30 | static keyrecord_t tapping_key = {}; | 34 | static keyrecord_t tapping_key = {}; |
31 | static keyrecord_t waiting_buffer[WAITING_BUFFER_SIZE] = {}; | 35 | static keyrecord_t waiting_buffer[WAITING_BUFFER_SIZE] = {}; |
32 | static uint8_t waiting_buffer_head = 0; | 36 | static uint8_t waiting_buffer_head = 0; |
@@ -232,8 +236,13 @@ bool process_tapping(keyrecord_t *keyp) { | |||
232 | if (WITHIN_TAPPING_TERM(event)) { | 236 | if (WITHIN_TAPPING_TERM(event)) { |
233 | if (event.pressed) { | 237 | if (event.pressed) { |
234 | if (IS_TAPPING_KEY(event.key)) { | 238 | if (IS_TAPPING_KEY(event.key)) { |
235 | # ifndef TAPPING_FORCE_HOLD | 239 | //# ifndef TAPPING_FORCE_HOLD |
236 | if (!tapping_key.tap.interrupted && tapping_key.tap.count > 0) { | 240 | # if !defined(TAPPING_FORCE_HOLD) || defined(TAPPING_FORCE_HOLD_PER_KEY) |
241 | if ( | ||
242 | # ifdef TAPPING_FORCE_HOLD_PER_KEY | ||
243 | !get_tapping_force_hold(get_event_keycode(tapping_key.event), keyp) && | ||
244 | # endif | ||
245 | !tapping_key.tap.interrupted && tapping_key.tap.count > 0) { | ||
237 | // sequential tap. | 246 | // sequential tap. |
238 | keyp->tap = tapping_key.tap; | 247 | keyp->tap = tapping_key.tap; |
239 | if (keyp->tap.count < 15) keyp->tap.count += 1; | 248 | if (keyp->tap.count < 15) keyp->tap.count += 1; |