From f39cb776a3e49c6fef5f37ebed55e9720ebb54c4 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Wed, 16 Aug 2017 09:47:55 +0200 Subject: [PATCH] Lift out the `isOS` macro into `OneShot.isOneShotKey`. Signed-off-by: Gergely Nagy --- src/Kaleidoscope/OneShot.cpp | 6 +++--- src/Kaleidoscope/OneShot.h | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Kaleidoscope/OneShot.cpp b/src/Kaleidoscope/OneShot.cpp index bb1bf4ee..11a19069 100644 --- a/src/Kaleidoscope/OneShot.cpp +++ b/src/Kaleidoscope/OneShot.cpp @@ -36,7 +36,7 @@ bool OneShot::should_mask_on_interrupt_ = false; // --- helper macros ------ -#define isOS(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 isLayerKey(key) (key.flags == (KEY_FLAGS | SYNTHETIC | SWITCH_TO_KEYMAP) && key.keyCode >= MOMENTARY_OFFSET && key.keyCode <= MOMENTARY_OFFSET + 23) @@ -88,7 +88,7 @@ Key OneShot::eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_st return mapped_key; if (!state_.all) { - if (!isOS(mapped_key)) { + if (!isOneShotKey(mapped_key)) { return mapped_key; } @@ -113,7 +113,7 @@ Key OneShot::eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_st if (!keyIsPressed(key_state) && !keyWasPressed(key_state)) return mapped_key; - if (isOS(mapped_key)) { + if (isOneShotKey(mapped_key)) { if (isSticky(idx)) { if (keyToggledOn(key_state)) { // maybe on _off instead? saveAsPrevious(mapped_key); diff --git a/src/Kaleidoscope/OneShot.h b/src/Kaleidoscope/OneShot.h index 93564860..35ed6862 100644 --- a/src/Kaleidoscope/OneShot.h +++ b/src/Kaleidoscope/OneShot.h @@ -32,6 +32,9 @@ class OneShot : public KaleidoscopePlugin { void begin(void) final; + static bool isOneShotKey(Key key) { + return (key.raw >= kaleidoscope::ranges::OS_FIRST && key.raw <= kaleidoscope::ranges::OS_LAST); + } static bool isActive(void); static void cancel(bool with_stickies); static void cancel(void) {