Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore layer tap interrupts #10409

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/config_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ If you define these options you will enable the associated feature, which may in
* See [Ignore Mod Tap Interrupt](tap_hold.md#ignore-mod-tap-interrupt) for details
* `#define IGNORE_MOD_TAP_INTERRUPT_PER_KEY`
* enables handling for per key `IGNORE_MOD_TAP_INTERRUPT` settings
* `#define IGNORE_LAYER_TAP_INTERRUPT`
* Like `IGNORE_MOD_TAP_INTERRUPT`, but for layer tapping.
* See [Ignore Layer Tap Interrupt](tap_hold.md#ignore-mod-tap-interrupt) for details
* `#define TAPPING_FORCE_HOLD`
* makes it possible to use a dual role key as modifier shortly after having been tapped
* See [Tapping Force Hold](tap_hold.md#tapping-force-hold)
Expand Down
26 changes: 26 additions & 0 deletions docs/tap_hold.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,32 @@ bool get_ignore_mod_tap_interrupt(uint16_t keycode, keyrecord_t *record) {
}
```

The described functionality only works for mod taps. To get the same results for layer taps, add this to your `config.h`:

```c
#define IGNORE_LAYER_TAP_INTERRUPT
```

In case you also enabled `IGNORE_MOD_TAP_INTERRUPT_PER_KEY`, you can reuse this function to control layer taps:

```c
bool get_ignore_mod_tap_interrupt(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case SFT_T(KC_SPC):
return true;
case LT(_FN, KC_F):
// interrupt causes 'f'
return true;
case LT(_RAISE, KC_BSPC):
// interrupt causes layer switch
return false;
default:
return false;
}
}
```


## Tapping Force Hold

To enable `tapping force hold`, add the following to your `config.h`:
Expand Down
18 changes: 16 additions & 2 deletions tmk_core/common/action.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,8 +562,22 @@ void process_action(keyrecord_t *record, action_t action) {
/* tap key */
if (event.pressed) {
if (tap_count > 0) {
dprint("KEYMAP_TAP_KEY: Tap: register_code\n");
register_code(action.layer_tap.code);
# ifdef IGNORE_LAYER_TAP_INTERRUPT
if (
# ifdef IGNORE_MOD_TAP_INTERRUPT_PER_KEY
!get_ignore_mod_tap_interrupt(get_event_keycode(record->event, false), record) &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a fan of this using the same function here. Would prefer a different function or a generic name for both.

# endif
record->tap.interrupted) {
dprint("layer_tap: tap: cancel: layer_on\n");
// ad hoc: set 0 to cancel tap
record->tap.count = 0;
layer_on(action.layer_tap.val);
} else
# endif
{
dprint("KEYMAP_TAP_KEY: Tap: register_code\n");
register_code(action.layer_tap.code);
}
} else {
dprint("KEYMAP_TAP_KEY: No tap: On on press\n");
layer_on(action.layer_tap.val);
Expand Down