|
|
@ -183,21 +183,23 @@ const macro_t *Macros_::type(const char *string) {
|
|
|
|
return MACRO_NONE;
|
|
|
|
return MACRO_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Key Macros_::handleMacroEvent(Key mappedKey, byte row, byte col, uint8_t keyState) {
|
|
|
|
kaleidoscope::EventHandlerResult Macros_::onKeyswitchEvent(Key &mappedKey, byte row, byte col, uint8_t keyState) {
|
|
|
|
if (mappedKey.flags != (SYNTHETIC | IS_MACRO))
|
|
|
|
if (mappedKey.flags != (SYNTHETIC | IS_MACRO))
|
|
|
|
return mappedKey;
|
|
|
|
return kaleidoscope::EventHandlerResult::OK;
|
|
|
|
|
|
|
|
|
|
|
|
byte key_id = (row * COLS) + col;
|
|
|
|
byte key_id = (row * COLS) + col;
|
|
|
|
addActiveMacroKey(mappedKey.keyCode, key_id, keyState);
|
|
|
|
addActiveMacroKey(mappedKey.keyCode, key_id, keyState);
|
|
|
|
return Key_NoKey;
|
|
|
|
|
|
|
|
|
|
|
|
return kaleidoscope::EventHandlerResult::EVENT_CONSUMED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Macros_::loopHook(bool post_clear) {
|
|
|
|
kaleidoscope::EventHandlerResult Macros_::afterEachCycle() {
|
|
|
|
if (post_clear) {
|
|
|
|
|
|
|
|
active_macro_count = 0;
|
|
|
|
active_macro_count = 0;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
return kaleidoscope::EventHandlerResult::OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
kaleidoscope::EventHandlerResult Macros_::beforeReportingState() {
|
|
|
|
for (byte i = 0; i < active_macro_count; ++i) {
|
|
|
|
for (byte i = 0; i < active_macro_count; ++i) {
|
|
|
|
if (active_macros[i].key_id == 0xFF) {
|
|
|
|
if (active_macros[i].key_id == 0xFF) {
|
|
|
|
// i.e. UNKNOWN_KEYSWITCH_LOCATION
|
|
|
|
// i.e. UNKNOWN_KEYSWITCH_LOCATION
|
|
|
@ -211,16 +213,30 @@ void Macros_::loopHook(bool post_clear) {
|
|
|
|
active_macros[i].key_state);
|
|
|
|
active_macros[i].key_state);
|
|
|
|
Macros.play(m);
|
|
|
|
Macros.play(m);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return kaleidoscope::EventHandlerResult::OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Macros_::Macros_(void) {
|
|
|
|
// Legacy V1 API
|
|
|
|
|
|
|
|
#if KALEIDOSCOPE_ENABLE_V1_PLUGIN_API
|
|
|
|
|
|
|
|
void Macros_::begin() {
|
|
|
|
|
|
|
|
Kaleidoscope.useEventHandlerHook(legacyEventHandler);
|
|
|
|
|
|
|
|
Kaleidoscope.useLoopHook(legacyLoopHook);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
Key Macros_::legacyEventHandler(Key mapped_key, byte row, byte col, uint8_t key_state) {
|
|
|
|
Macros_::begin(void) {
|
|
|
|
kaleidoscope::EventHandlerResult r = Macros.onKeyswitchEvent(mapped_key, row, col, key_state);
|
|
|
|
active_macro_count = 0;
|
|
|
|
if (r == kaleidoscope::EventHandlerResult::OK)
|
|
|
|
Kaleidoscope.useEventHandlerHook(handleMacroEvent);
|
|
|
|
return mapped_key;
|
|
|
|
Kaleidoscope.useLoopHook(loopHook);
|
|
|
|
return Key_NoKey;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Macros_::legacyLoopHook(bool is_post_clear) {
|
|
|
|
|
|
|
|
if (is_post_clear) {
|
|
|
|
|
|
|
|
Macros.afterEachCycle();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Macros.beforeReportingState();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
Macros_ Macros;
|
|
|
|
Macros_ Macros;
|
|
|
|