OneShot: Repurpose the isLayerKey() macro to make some code read nicer

This is pretty much the same thing as keyboardio/Kaleidoscope-OneShot#23 by
@jamesnvc, except that it also changes the `isLayerKey()` macro, which was
otherwise unused.

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/441/head
Gergely Nagy 6 years ago
parent c8bead6d5c
commit cb83612195
No known key found for this signature in database
GPG Key ID: AC1E90BAC433F68F

@ -40,7 +40,7 @@ uint8_t OneShot::positions_[16];
#define isOneShotKey(key) (key.raw >= ranges::OS_FIRST && key.raw <= ranges::OS_LAST) #define isOneShotKey(key) (key.raw >= ranges::OS_FIRST && key.raw <= ranges::OS_LAST)
#define isModifier(key) (key.raw >= Key_LeftControl.raw && key.raw <= Key_RightGui.raw) #define isModifier(key) (key.raw >= Key_LeftControl.raw && key.raw <= Key_RightGui.raw)
#define isLayerKey(key) (key.flags == (KEY_FLAGS | SYNTHETIC | SWITCH_TO_KEYMAP) && key.keyCode >= LAYER_SHIFT_OFFSET && key.keyCode <= LAYER_SHIFT_OFFSET + 23) #define isLayerKey(key) (key.flags == (KEY_FLAGS | SYNTHETIC | SWITCH_TO_KEYMAP))
#define isOneShot(idx) (bitRead (state_.all, (idx))) #define isOneShot(idx) (bitRead (state_.all, (idx)))
#define setOneShot(idx) (bitWrite (state_.all, idx, 1)) #define setOneShot(idx) (bitWrite (state_.all, idx, 1))
@ -169,7 +169,7 @@ EventHandlerResult OneShot::onKeyswitchEvent(Key &mapped_key, byte row, byte col
if (keyIsPressed(keyState)) { if (keyIsPressed(keyState)) {
saveAsPrevious(mapped_key); saveAsPrevious(mapped_key);
if (!isModifier(mapped_key) && (mapped_key.flags != (KEY_FLAGS | SYNTHETIC | SWITCH_TO_KEYMAP))) { if (!isModifier(mapped_key) && !isLayerKey(mapped_key)) {
should_cancel_ = true; should_cancel_ = true;
} }
} }

Loading…
Cancel
Save