From c6e976889fbbaa026b42c368bf5ebf4e00006262 Mon Sep 17 00:00:00 2001 From: Nulo Date: Tue, 22 Feb 2022 22:40:23 -0300 Subject: [PATCH] Deactivate one shot keys if already used in next keydown --- keyboards/atreus/keymaps/default/oneshot.c | 14 +++++++++++++- keyboards/atreus/keymaps/default/oneshot.h | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/keyboards/atreus/keymaps/default/oneshot.c b/keyboards/atreus/keymaps/default/oneshot.c index 33ec3895e2..071fa1faf0 100644 --- a/keyboards/atreus/keymaps/default/oneshot.c +++ b/keyboards/atreus/keymaps/default/oneshot.c @@ -37,6 +37,18 @@ void update_oneshot( *state = os_up_unqueued; unregister_code(mod); } + if (!is_oneshot_ignored_key(keycode)) { + switch (*state) { + case os_up_used: + unregister_code(mod); + break; + case os_up_queued: + *state = os_up_used; + break; + default: + break; + } + } } else { if (!is_oneshot_ignored_key(keycode)) { // On non-ignored keyup, consider the oneshot used. @@ -44,7 +56,7 @@ void update_oneshot( case os_down_unused: *state = os_down_used; break; - case os_up_queued: + case os_up_used: *state = os_up_unqueued; unregister_code(mod); break; diff --git a/keyboards/atreus/keymaps/default/oneshot.h b/keyboards/atreus/keymaps/default/oneshot.h index a6b8e17742..8a83addd9b 100644 --- a/keyboards/atreus/keymaps/default/oneshot.h +++ b/keyboards/atreus/keymaps/default/oneshot.h @@ -6,6 +6,7 @@ typedef enum { os_up_unqueued, os_up_queued, + os_up_used, os_down_unused, os_down_used, } oneshot_state;