isLayerKeyActive: Check for flag equality, not just two bits set

To find layer keys and layer keys only, we need to make sure that `key.flags`
has only these two bits set, and none of the others. Otherwise it may light up
keys as if they were layer keys, while they aren't, because they happen to have
`SYNTHETIC` and `SWITCH_TO_KEYMAP` set, `RESERVED` unset, but have other flags
that make the event handler loop treat them properly. Mouse keys are one such
thing.

Thanks to @ToyKeeper for reporting the issue!

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
pull/389/head
Gergely Nagy 7 years ago
parent f25480730e
commit 453e30038f

@ -51,8 +51,7 @@ bool ActiveModColorEffect::isLayerKeyActive(Key key) {
if (key.raw >= ranges::OSL_FIRST && key.raw <= ranges::OSL_LAST) {
layer = key.raw - ranges::OSL_FIRST;
} else if ((key.flags & (SYNTHETIC | SWITCH_TO_KEYMAP)) &&
!(key.flags & RESERVED)) {
} else if (key.flags == (SYNTHETIC | SWITCH_TO_KEYMAP)) {
layer = key.keyCode;
if (layer >= MOMENTARY_OFFSET)
layer -= MOMENTARY_OFFSET;

Loading…
Cancel
Save