Merge pull request #441 from keyboardio/oneshot/isLayerKey

OneShot: Repurpose the isLayerKey() macro to make some code read nicer
pull/442/head
Jesse Vincent 6 years ago committed by GitHub
commit 11087e8a43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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