Standardize Macros to use Kaleidoscope-Ranges

Macros was still using its own bit in the `Key.flags_` byte to define Macros
keys, unlike all the other plugins that define their own special `Key`
values. This standardizes Macros to make it more like other plugins.

Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>
pull/966/head
Michael Richters 4 years ago
parent ef126a267e
commit ec7cdbcecb
No known key found for this signature in database
GPG Key ID: 1288FD13E4EEF0C0

@ -49,6 +49,8 @@ enum : uint16_t {
SC_LAST, SC_LAST,
REDIAL, REDIAL,
TURBO, TURBO,
MACRO_FIRST,
MACRO_LAST = MACRO_FIRST + 255,
DYNAMIC_MACRO_FIRST, DYNAMIC_MACRO_FIRST,
DYNAMIC_MACRO_LAST = DYNAMIC_MACRO_FIRST + 31, DYNAMIC_MACRO_LAST = DYNAMIC_MACRO_FIRST + 31,

@ -244,7 +244,7 @@ const macro_t *Macros_::type(const char *string) {
} }
bool Macros_::isMacroKey(Key key) { bool Macros_::isMacroKey(Key key) {
if (key.getFlags() == (SYNTHETIC | IS_MACRO)) if (key >= ranges::MACRO_FIRST && key <= ranges::MACRO_LAST)
return true; return true;
return false; return false;
} }
@ -253,7 +253,8 @@ EventHandlerResult Macros_::onKeyswitchEvent(Key &mappedKey, KeyAddr key_addr, u
if (! isMacroKey(mappedKey)) if (! isMacroKey(mappedKey))
return EventHandlerResult::OK; return EventHandlerResult::OK;
addActiveMacroKey(mappedKey.getKeyCode(), key_addr.toInt(), keyState); uint8_t macro_index = mappedKey.getRaw() - ranges::MACRO_FIRST;
addActiveMacroKey(macro_index, key_addr.toInt(), keyState);
return EventHandlerResult::EVENT_CONSUMED; return EventHandlerResult::EVENT_CONSUMED;
} }

@ -16,9 +16,12 @@
#pragma once #pragma once
#define IS_MACRO B00100000 #include "Kaleidoscope-Ranges.h"
constexpr Key M(uint8_t n) {
return Key(kaleidoscope::ranges::MACRO_FIRST + n);
}
#define M(n) Key(n, KEY_FLAGS | SYNTHETIC | IS_MACRO)
#define Key_macroKey1 M(1) #define Key_macroKey1 M(1)
#define Key_macroKey2 M(2) #define Key_macroKey2 M(2)
#define Key_macroKey3 M(3) #define Key_macroKey3 M(3)

Loading…
Cancel
Save