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>
This commit is contained in:
parent
1b0854fdca
commit
95c24bbaf8
3 changed files with 51 additions and 2 deletions
|
@ -149,6 +149,8 @@ If you define these options you will enable the associated feature, which may in
|
||||||
* makes it possible to use a dual role key as modifier shortly after having been tapped
|
* makes it possible to use a dual role key as modifier shortly after having been tapped
|
||||||
* See [Hold after tap](feature_advanced_keycodes.md#tapping-force-hold)
|
* See [Hold after tap](feature_advanced_keycodes.md#tapping-force-hold)
|
||||||
* Breaks any Tap Toggle functionality (`TT` or the One Shot Tap Toggle)
|
* Breaks any Tap Toggle functionality (`TT` or the One Shot Tap Toggle)
|
||||||
|
* `#define TAPPING_FORCE_HOLD_PER_KEY`
|
||||||
|
* enables handling for per key `TAPPING_FORCE_HOLD` settings
|
||||||
* `#define LEADER_TIMEOUT 300`
|
* `#define LEADER_TIMEOUT 300`
|
||||||
* how long before the leader key times out
|
* how long before the leader key times out
|
||||||
* 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.
|
* 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.
|
||||||
|
|
|
@ -291,6 +291,25 @@ Normally, this would send `X` (`SHIFT`+`x`). With `Ignore Mod Tap Interrupt` ena
|
||||||
|
|
||||||
?> 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`.
|
?> 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`.
|
||||||
|
|
||||||
|
For more granular control of this feature, you can add the following to your `config.h`:
|
||||||
|
|
||||||
|
```c
|
||||||
|
#define IGNORE_MOD_TAP_INTERRUPT_PER_KEY
|
||||||
|
```
|
||||||
|
|
||||||
|
You can then add the following function to your keymap:
|
||||||
|
|
||||||
|
```c
|
||||||
|
bool get_ignore_mod_tap_interrupt(uint16_t keycode) {
|
||||||
|
switch (keycode) {
|
||||||
|
case SFT_T(KC_SPC):
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Tapping Force Hold
|
## Tapping Force Hold
|
||||||
|
|
||||||
To enable `tapping force hold`, add the following to your `config.h`:
|
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
|
||||||
|
|
||||||
!> `TAPPING_FORCE_HOLD` will break anything that uses tapping toggles (Such as the `TT` layer keycode, and the One Shot Tapping Toggle).
|
!> `TAPPING_FORCE_HOLD` will break anything that uses tapping toggles (Such as the `TT` layer keycode, and the One Shot Tapping Toggle).
|
||||||
|
|
||||||
|
For more granular control of this feature, you can add the following to your `config.h`:
|
||||||
|
|
||||||
|
```c
|
||||||
|
#define TAPPING_FORCE_HOLD_PER_KEY
|
||||||
|
```
|
||||||
|
|
||||||
|
You can then add the following function to your keymap:
|
||||||
|
|
||||||
|
```c
|
||||||
|
bool get_tapping_force_hold(uint16_t keycode, keyrecord_t *record) {
|
||||||
|
switch (keycode) {
|
||||||
|
case LT(1, KC_BSPC):
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Retro Tapping
|
## Retro Tapping
|
||||||
|
|
||||||
To enable `retro tapping`, add the following to your `config.h`:
|
To enable `retro tapping`, add the following to your `config.h`:
|
||||||
|
|
|
@ -27,6 +27,10 @@ __attribute__((weak)) uint16_t get_tapping_term(uint16_t keycode) { return TAPPI
|
||||||
# define WITHIN_TAPPING_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < TAPPING_TERM)
|
# define WITHIN_TAPPING_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < TAPPING_TERM)
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
# ifdef TAPPING_FORCE_HOLD_PER_KEY
|
||||||
|
__attribute__((weak)) bool get_tapping_force_hold(uint16_t keycode, keyrecord_t *record) { return false; }
|
||||||
|
# endif
|
||||||
|
|
||||||
static keyrecord_t tapping_key = {};
|
static keyrecord_t tapping_key = {};
|
||||||
static keyrecord_t waiting_buffer[WAITING_BUFFER_SIZE] = {};
|
static keyrecord_t waiting_buffer[WAITING_BUFFER_SIZE] = {};
|
||||||
static uint8_t waiting_buffer_head = 0;
|
static uint8_t waiting_buffer_head = 0;
|
||||||
|
@ -232,8 +236,13 @@ bool process_tapping(keyrecord_t *keyp) {
|
||||||
if (WITHIN_TAPPING_TERM(event)) {
|
if (WITHIN_TAPPING_TERM(event)) {
|
||||||
if (event.pressed) {
|
if (event.pressed) {
|
||||||
if (IS_TAPPING_KEY(event.key)) {
|
if (IS_TAPPING_KEY(event.key)) {
|
||||||
# ifndef TAPPING_FORCE_HOLD
|
//# ifndef TAPPING_FORCE_HOLD
|
||||||
if (!tapping_key.tap.interrupted && tapping_key.tap.count > 0) {
|
# if !defined(TAPPING_FORCE_HOLD) || defined(TAPPING_FORCE_HOLD_PER_KEY)
|
||||||
|
if (
|
||||||
|
# ifdef TAPPING_FORCE_HOLD_PER_KEY
|
||||||
|
!get_tapping_force_hold(get_event_keycode(tapping_key.event), keyp) &&
|
||||||
|
# endif
|
||||||
|
!tapping_key.tap.interrupted && tapping_key.tap.count > 0) {
|
||||||
// sequential tap.
|
// sequential tap.
|
||||||
keyp->tap = tapping_key.tap;
|
keyp->tap = tapping_key.tap;
|
||||||
if (keyp->tap.count < 15) keyp->tap.count += 1;
|
if (keyp->tap.count < 15) keyp->tap.count += 1;
|
||||||
|
|
Loading…
Reference in a new issue