|
|
@ -24,20 +24,22 @@
|
|
|
|
namespace kaleidoscope {
|
|
|
|
namespace kaleidoscope {
|
|
|
|
namespace plugin {
|
|
|
|
namespace plugin {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Key EscapeOneShot::cancel_oneshot_key_{Key_Escape};
|
|
|
|
|
|
|
|
|
|
|
|
EventHandlerResult EscapeOneShot::onKeyswitchEvent(
|
|
|
|
EventHandlerResult EscapeOneShot::onKeyswitchEvent(
|
|
|
|
Key &key, KeyAddr key_addr, uint8_t key_state) {
|
|
|
|
Key &key, KeyAddr key_addr, uint8_t key_state) {
|
|
|
|
// We only act on an escape key that has just been pressed, and not
|
|
|
|
// We only act on an escape key (or `cancel_oneshot_key_`, if that has been
|
|
|
|
// generated by some other plugin. Also, only if at least one
|
|
|
|
// set) that has just been pressed, and not generated by some other
|
|
|
|
// OneShot key is active and/or sticky. Last, only if there are no
|
|
|
|
// plugin. Also, only if at least one OneShot key is active and/or
|
|
|
|
// OneShot keys currently being held.
|
|
|
|
// sticky. Last, only if there are no OneShot keys currently being held.
|
|
|
|
if (key == Key_Escape &&
|
|
|
|
if (key == cancel_oneshot_key_ &&
|
|
|
|
keyToggledOn(key_state) &&
|
|
|
|
keyToggledOn(key_state) &&
|
|
|
|
!(key_state & INJECTED) &&
|
|
|
|
!(key_state & INJECTED) &&
|
|
|
|
::OneShot.isActive()) {
|
|
|
|
::OneShot.isActive()) {
|
|
|
|
// Cancel all OneShot keys
|
|
|
|
// Cancel all OneShot keys
|
|
|
|
::OneShot.cancel(true);
|
|
|
|
::OneShot.cancel(true);
|
|
|
|
// Change the escape key to a blank key, and signal that event processing is
|
|
|
|
// Change the cancellation key to a blank key, and signal that event
|
|
|
|
// complete.
|
|
|
|
// processing is complete.
|
|
|
|
key = Key_NoKey;
|
|
|
|
key = Key_NoKey;
|
|
|
|
return EventHandlerResult::EVENT_CONSUMED;
|
|
|
|
return EventHandlerResult::EVENT_CONSUMED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|