From ef126a267efd52501e68edc01fd3a4935242180e Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Mon, 9 Nov 2020 10:30:55 -0600 Subject: [PATCH] Add Macros.isMacroKey() function This just isolates the test for a Macros plugin key to its own function. Signed-off-by: Michael Richters --- src/kaleidoscope/plugin/Macros.cpp | 8 +++++++- src/kaleidoscope/plugin/Macros.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/kaleidoscope/plugin/Macros.cpp b/src/kaleidoscope/plugin/Macros.cpp index 23ade38f..3b7c0a9f 100644 --- a/src/kaleidoscope/plugin/Macros.cpp +++ b/src/kaleidoscope/plugin/Macros.cpp @@ -243,8 +243,14 @@ const macro_t *Macros_::type(const char *string) { return MACRO_NONE; } +bool Macros_::isMacroKey(Key key) { + if (key.getFlags() == (SYNTHETIC | IS_MACRO)) + return true; + return false; +} + EventHandlerResult Macros_::onKeyswitchEvent(Key &mappedKey, KeyAddr key_addr, uint8_t keyState) { - if (mappedKey.getFlags() != (SYNTHETIC | IS_MACRO)) + if (! isMacroKey(mappedKey)) return EventHandlerResult::OK; addActiveMacroKey(mappedKey.getKeyCode(), key_addr.toInt(), keyState); diff --git a/src/kaleidoscope/plugin/Macros.h b/src/kaleidoscope/plugin/Macros.h index ca4aaf03..e0a3d0cf 100644 --- a/src/kaleidoscope/plugin/Macros.h +++ b/src/kaleidoscope/plugin/Macros.h @@ -80,6 +80,7 @@ class Macros_ : public kaleidoscope::Plugin { private: Key lookupAsciiCode(uint8_t ascii_code); + bool isMacroKey(Key key); }; }