From 2fe4ef3aee1e43be98206f071713789c8e6a3866 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Fri, 4 Aug 2017 17:39:30 +0200 Subject: [PATCH] Held + normal key should prevent oneshot from firing When holding a one-shot key and tapping another that would cancel the one-shot effect, when we release the one-shot key within `hold_time_out`, do not start the oneshot effect. This is done by only clearing the `should_cancel_` flag in `loopHook` when cancellation did happen. If we clear anyway, then the flag set by the interrupting keypress will be lost by the time we release the one-shot key. Reported by @ToyKeeper, thanks a lot for the detailed explanation! Signed-off-by: Gergely Nagy --- src/Kaleidoscope/OneShot.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Kaleidoscope/OneShot.cpp b/src/Kaleidoscope/OneShot.cpp index e2a92c0d..2519b60f 100644 --- a/src/Kaleidoscope/OneShot.cpp +++ b/src/Kaleidoscope/OneShot.cpp @@ -170,19 +170,23 @@ void OneShot::loopHook(bool is_post_clear) { if (hasTimedOut()) cancel(); + bool is_cancelled = false; + for (uint8_t i = 0; i < 32; i++) { if (should_cancel_) { if (isSticky(i)) { if (should_cancel_stickies_) { + is_cancelled = true; clearSticky(i); } } else if (isOneShot(i) && !isPressed(i)) { + is_cancelled = true; cancelOneShot(i); } } } - if (should_cancel_) { + if (is_cancelled) { should_cancel_ = false; should_cancel_stickies_ = false; }