Implement key masking for momentary layer keys

The goal is to ignore key events from still-held keys in a situation where we
just turned a layer off. Thus, if one holds a momentary layer key, then presses
and holds another key, releases the layer key, we want to ignore the other held
keys until they are released.

This is accomplished by masking all held keys when a momentary layer has been
turned off, and ignoring all masked key events in `handleKeyswitchEvent` until
they are released, when we unmask them.

This should address #150, but requires
keyboardio/Kaleidoscope-Hardware-Model01#9.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
pull/152/head
Gergely Nagy 7 years ago
parent e9c532509f
commit f0b3ad2b14

@ -47,6 +47,14 @@ void handleKeyswitchEvent(Key mappedKey, byte row, byte col, uint8_t keyState) {
if (!(keyState & INJECTED)) { if (!(keyState & INJECTED)) {
mappedKey = Layer.lookup(row, col); mappedKey = Layer.lookup(row, col);
} }
if (KeyboardHardware.isKeyMasked(row, col)) {
if (keyToggledOff(keyState)) {
KeyboardHardware.unMaskKey(row, col);
}
return;
}
for (byte i = 0; Kaleidoscope.eventHandlers[i] != NULL && i < HOOK_MAX; i++) { for (byte i = 0; Kaleidoscope.eventHandlers[i] != NULL && i < HOOK_MAX; i++) {
Kaleidoscope_::eventHandlerHook handler = Kaleidoscope.eventHandlers[i]; Kaleidoscope_::eventHandlerHook handler = Kaleidoscope.eventHandlers[i];
mappedKey = (*handler)(mappedKey, row, col, keyState); mappedKey = (*handler)(mappedKey, row, col, keyState);

@ -28,6 +28,8 @@ static void handleKeymapKeyswitchEvent(Key keymapEntry, uint8_t keyState) {
} else { } else {
Layer.off(target); Layer.off(target);
} }
KeyboardHardware.maskHeldKeys();
} }
// switch keymap and stay there // switch keymap and stay there

Loading…
Cancel
Save