bugfix: sticky keys held for longer than release-after-ms
get stuck
Sticky keys work to modify the next keypress, but also have utility in being held to achieve certain behaviours such as making multiple selections with a mouse. The current implementation of sticky keys does not account for the case where a sticky key is held longer than `release-after-ms`. In this case, the sticky key gets stuck. This PR proposes releasing the sticky key 1ms after the key is released if `release-after-ms` has lapsed during the hold, so that the sticky key behaves like a momentary key for long holds. I have tested this for the past few days and have found it fixes my use cases.
This commit is contained in:
parent
2a5e914a77
commit
72a1520a84
1 changed files with 2 additions and 3 deletions
|
@ -167,9 +167,8 @@ static int on_sticky_key_binding_released(struct zmk_behavior_binding *binding,
|
||||||
sticky_key->release_at = event.timestamp + sticky_key->config->release_after_ms;
|
sticky_key->release_at = event.timestamp + sticky_key->config->release_after_ms;
|
||||||
// adjust timer in case this behavior was queued by a hold-tap
|
// adjust timer in case this behavior was queued by a hold-tap
|
||||||
int32_t ms_left = sticky_key->release_at - k_uptime_get();
|
int32_t ms_left = sticky_key->release_at - k_uptime_get();
|
||||||
if (ms_left > 0) {
|
ms_left = ms_left > 0 ? ms_left : 1;
|
||||||
k_work_schedule(&sticky_key->release_timer, K_MSEC(ms_left));
|
k_work_schedule(&sticky_key->release_timer, K_MSEC(ms_left));
|
||||||
}
|
|
||||||
return ZMK_BEHAVIOR_OPAQUE;
|
return ZMK_BEHAVIOR_OPAQUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue