From b218143faf5975b5e5b061a3172575338cf75c36 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Sun, 13 Aug 2017 11:15:16 +0200 Subject: [PATCH] When a momentary layer is held, reactivate the layer if it turns off If we have two keys on our keymap that momentarily go to the same layer (which is the case for the factory firmware), we hold both, and release one, we want the layer to remain active still. To this effect, in `handleKeymapKeyswitchEvent` we will handle the case when a momentary layer key is pressed, but not toggled on (that is, it is held): if it is not a next/previous switch, we re-activate the layer if it wasn't on. This fixes #154, thanks to @ToyKeeper for the report. Signed-off-by: Gergely Nagy --- src/layers.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/layers.cpp b/src/layers.cpp index 765615e1..0e046eab 100644 --- a/src/layers.cpp +++ b/src/layers.cpp @@ -20,6 +20,11 @@ static void handleKeymapKeyswitchEvent(Key keymapEntry, uint8_t keyState) { } else { Layer.on(target); } + } else if (keyIsPressed(keyState) && + target != KEYMAP_NEXT && + target != KEYMAP_PREVIOUS) { + if (!Layer.isOn(target)) + Layer.on(target); } if (keyToggledOff(keyState)) { if (target == KEYMAP_NEXT) {