Adapt Escape-OneShot to active keys cache

Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>
f/keymap-cache-redesign
Michael Richters 4 years ago committed by Jesse Vincent
parent 23d8c6577e
commit e5ba44a6da
No known key found for this signature in database
GPG Key ID: 122F5DF7108E4046

@ -23,21 +23,19 @@
namespace kaleidoscope {
namespace plugin {
bool EscapeOneShot::did_escape_;
EventHandlerResult EscapeOneShot::onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t keyState) {
if (mapped_key != Key_Escape || (keyState & INJECTED))
return EventHandlerResult::OK;
if (did_escape_)
mapped_key = Key_NoKey;
did_escape_ = !keyToggledOff(keyState);
if (!keyToggledOn(keyState))
return EventHandlerResult::OK;
if ((!::OneShot.isActive() || ::OneShot.isPressed()) && !::OneShot.isSticky()) {
return EventHandlerResult::OK;
}
::OneShot.cancel(true);
mapped_key = Key_NoKey;
return EventHandlerResult::EVENT_CONSUMED;
}

@ -27,8 +27,6 @@ class EscapeOneShot : public kaleidoscope::Plugin {
EventHandlerResult onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t keyState);
private:
static bool did_escape_;
};
}
}

Loading…
Cancel
Save