From 26ff408719fa37ee4e1bc57106ddb70461b6fe9f Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Mon, 17 Dec 2018 10:57:12 -0600 Subject: [PATCH] Update `live_composite_keymap_` with specified `mappedKey`, if any If `handleKeyswitchEvent()` is called with a `mappedKey` other than `Key_NoKey`, update `live_composite_keymap_` with the specified `mappedKey` instead of doing a keymap lookup on active layers. This allows a plugin to call `handleKeyswitchEvent()` and specify what the `Key` value should be, and not have to separately track what value to change it to every cycle. This is especially important when there's a layer change. In particular, this is the simplest way to allow Qukeys to use `ShiftToLayer()` keys that work properly. Fixes #501. Signed-off-by: Michael Richters --- src/kaleidoscope/key_events.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/kaleidoscope/key_events.cpp b/src/kaleidoscope/key_events.cpp index 72aba01a..f1c58159 100644 --- a/src/kaleidoscope/key_events.cpp +++ b/src/kaleidoscope/key_events.cpp @@ -81,8 +81,13 @@ 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)) - Layer.updateLiveCompositeKeymap(row, col); + if (keyToggledOn(keyState)) { + if (mappedKey.raw == Key_NoKey.raw) { + Layer.updateLiveCompositeKeymap(row, col); + } else { + Layer.updateLiveCompositeKeymap(row, col, mappedKey); + } + } /* If the key we are dealing with is masked, ignore it until it is released. * When releasing it, clear the mask, so future key events can be handled