From 66f79c7cbdf4e8e943fe53a5295c5644b3f48e83 Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Wed, 13 Feb 2019 13:24:03 -0600 Subject: [PATCH] Added EPHEMERAL keyswitch state flag An `EPHEMERAL` keyswitch event is one that gets ignored by updates to `live_composite_keymap_[]`, and thus doesn't change the keymap at all. This is useful for a plugin that needs to retain its own key type in the keymap in order to do something particular when it toggles off, but needs to inject an event with a different `Key` value, with real key coordinates. Signed-off-by: Michael Richters --- src/kaleidoscope/key_events.cpp | 2 +- src/kaleidoscope/keyswitch_state.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/kaleidoscope/key_events.cpp b/src/kaleidoscope/key_events.cpp index f1c58159..dd02be13 100644 --- a/src/kaleidoscope/key_events.cpp +++ b/src/kaleidoscope/key_events.cpp @@ -82,7 +82,7 @@ void handleKeyswitchEvent(Key mappedKey, byte row, byte col, uint8_t keyState) { /* If a key had an on event, we update the live composite keymap. See * layers.h for an explanation about the different caches we have. */ if (keyToggledOn(keyState)) { - if (mappedKey.raw == Key_NoKey.raw) { + if (mappedKey.raw == Key_NoKey.raw || keyState & EPHEMERAL) { Layer.updateLiveCompositeKeymap(row, col); } else { Layer.updateLiveCompositeKeymap(row, col, mappedKey); diff --git a/src/kaleidoscope/keyswitch_state.h b/src/kaleidoscope/keyswitch_state.h index 1c87b026..dd3a24f2 100644 --- a/src/kaleidoscope/keyswitch_state.h +++ b/src/kaleidoscope/keyswitch_state.h @@ -20,6 +20,7 @@ #include #define INJECTED B10000000 +#define EPHEMERAL B01000000 #define IS_PRESSED B00000010 #define WAS_PRESSED B00000001