summaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorOkke Formsma <okke@formsma.nl>2020-11-30 22:02:57 +0100
committerPete Johanson <peter@peterjohanson.com>2020-12-06 00:33:20 -0500
commite00eceb5089d50fce2e298628c5bcf6c3b0596cd (patch)
treed4c1f5d9ab2639d66f22199f848ae6de6915e09a /app/src
parentf86e0fff14c4c6419a1388f963c5535a4f9c201a (diff)
fix(sticky keys): fix tapping-sticky-keys bug.
Sticky keys should be cleared when they were tapped in rapid succession before the timer runs out.
Diffstat (limited to 'app/src')
-rw-r--r--app/src/behaviors/behavior_sticky_key.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/app/src/behaviors/behavior_sticky_key.c b/app/src/behaviors/behavior_sticky_key.c
index 7a7f136..3ea5868 100644
--- a/app/src/behaviors/behavior_sticky_key.c
+++ b/app/src/behaviors/behavior_sticky_key.c
@@ -127,9 +127,13 @@ static int on_sticky_key_binding_pressed(struct zmk_behavior_binding *binding,
struct zmk_behavior_binding_event event) {
struct device *dev = device_get_binding(binding->behavior_dev);
const struct behavior_sticky_key_config *cfg = dev->config_info;
-
- struct active_sticky_key *sticky_key =
- store_sticky_key(event.position, binding->param1, binding->param2, cfg);
+ struct active_sticky_key *sticky_key;
+ sticky_key = find_sticky_key(event.position);
+ if (sticky_key != NULL) {
+ stop_timer(sticky_key);
+ release_sticky_key_behavior(sticky_key, event.timestamp);
+ }
+ sticky_key = store_sticky_key(event.position, binding->param1, binding->param2, cfg);
if (sticky_key == NULL) {
LOG_ERR("unable to store sticky key, did you press more than %d sticky_key?",
ZMK_BHV_STICKY_KEY_MAX_HELD);