From 94736aaffb267f9e3e3327b352611da662cf57ec Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Sat, 20 Oct 2018 13:48:12 +0200 Subject: [PATCH] OneShot: Fix EscapeOneShot so that it cancels stickies too EscapeOneShot needs to stop bailing out early when a oneshot is pressed (sticky appears pressed), and continue with its process if there's a sticky oneshot. This makes stickies cancelable via the EscapeOneShot plugin. For this to work, OneShot needed an `.isSticky()` method, much like `.isActive()` and `.isPressed()`. Fixes #413 and likely addresses part of #408 too. Signed-off-by: Gergely Nagy --- src/kaleidoscope/plugin/Escape-OneShot.cpp | 3 ++- src/kaleidoscope/plugin/OneShot.h | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/kaleidoscope/plugin/Escape-OneShot.cpp b/src/kaleidoscope/plugin/Escape-OneShot.cpp index 965d3f7c..3beb5adc 100644 --- a/src/kaleidoscope/plugin/Escape-OneShot.cpp +++ b/src/kaleidoscope/plugin/Escape-OneShot.cpp @@ -28,8 +28,9 @@ EventHandlerResult EscapeOneShot::onKeyswitchEvent(Key &mapped_key, byte row, by !keyToggledOn(keyState)) return EventHandlerResult::OK; - if (!::OneShot.isActive() || ::OneShot.isPressed()) + if ((!::OneShot.isActive() || ::OneShot.isPressed()) && !::OneShot.isSticky()) { return EventHandlerResult::OK; + } KeyboardHardware.maskKey(row, col); diff --git a/src/kaleidoscope/plugin/OneShot.h b/src/kaleidoscope/plugin/OneShot.h index b78d3106..10b15e12 100644 --- a/src/kaleidoscope/plugin/OneShot.h +++ b/src/kaleidoscope/plugin/OneShot.h @@ -37,6 +37,9 @@ class OneShot : public kaleidoscope::Plugin { static bool isPressed() { return !!pressed_state_.all; } + static bool isSticky() { + return !!sticky_state_.all; + } static bool isActive(Key key); static bool isSticky(Key key); static void cancel(bool with_stickies);