From 3627db25413f5e40ef7525bed20e21eb9c8f8eeb Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Sun, 21 Oct 2018 10:07:39 +0200 Subject: [PATCH] Redial: Improved the way it remembers keys Instead of remembering a key whenever a new one toggles on, remember only when Redial itself is not held. We keep track of the last pressed key while Redial is held, though, so we can update the key to redial when we're released ourselves. This should fix #396. Signed-off-by: Gergely Nagy --- src/kaleidoscope/plugin/Redial.cpp | 11 ++++++++++- src/kaleidoscope/plugin/Redial.h | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/kaleidoscope/plugin/Redial.cpp b/src/kaleidoscope/plugin/Redial.cpp index 6bfaa538..bc399da3 100644 --- a/src/kaleidoscope/plugin/Redial.cpp +++ b/src/kaleidoscope/plugin/Redial.cpp @@ -23,18 +23,27 @@ namespace plugin { Key Redial::key; Key Redial::key_to_redial_; +Key Redial::last_key_; +bool Redial::redial_held_ = false; EventHandlerResult Redial::onKeyswitchEvent(Key &mapped_key, byte row, byte col, uint8_t key_state) { if (key == Key_NoKey) return EventHandlerResult::OK; if (mapped_key == key) { + if (keyToggledOff(key_state)) + key_to_redial_ = last_key_; + mapped_key = key_to_redial_; + redial_held_ = keyIsPressed(key_state); + return EventHandlerResult::OK; } if (keyToggledOn(key_state) && shouldRemember(mapped_key)) { - key_to_redial_ = mapped_key; + last_key_ = mapped_key; + if (!redial_held_) + key_to_redial_ = mapped_key; } return EventHandlerResult::OK; diff --git a/src/kaleidoscope/plugin/Redial.h b/src/kaleidoscope/plugin/Redial.h index 72519672..29119eb6 100644 --- a/src/kaleidoscope/plugin/Redial.h +++ b/src/kaleidoscope/plugin/Redial.h @@ -35,6 +35,8 @@ class Redial : public kaleidoscope::Plugin { private: static Key key_to_redial_; + static Key last_key_; + static bool redial_held_; }; }