I’m attempting to port a macro to Kaleidoscope that enters a different set of enclosures depending on the modifier pressed. This is what I have:
#define K_LT LSHIFT(Key_Comma)
#define K_GT LSHIFT(Key_Period)
#define K_LParen LSHIFT(Key_9)
#define K_RParen LSHIFT(Key_0)
namespace kaleidoscope {
namespace plugin {
class ModBlocker : public Plugin {
public:
EventHandlerResult onAddToReport(Key key) {
if (active_ && key.isKeyboardModifier())
return EventHandlerResult::ABORT;
return EventHandlerResult::OK;
}
void enable() {
active_ = true;
}
void disable() {
active_ = false;
}
private:
bool active_{false};
};
}
}
kaleidoscope::plugin::ModBlocker ModBlocker;
const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) {
switch (macro_id) {
case MACRO_VERSION_INFO:
versionInfoMacro(event.state);
break;
case MACRO_BRACES:
if (keyToggledOn(event.state)) {
if (Kaleidoscope.hid().keyboard().wasModifierKeyActive(Key_LeftAlt)) {
Macros.tap(K_LParen);
Macros.tap(K_RParen);
}
else if (Kaleidoscope.hid().keyboard().wasModifierKeyActive(Key_LeftControl)) {
Macros.tap(K_LT);
Macros.tap(K_GT);
}
else {
// this handles shift too
Macros.tap(Key_LeftBracket);
Macros.tap(Key_RightBracket);
}
ModBlocker.enable();
Macros.tap(Key_LeftArrow);
ModBlocker.disable();
return MACRO_NONE;
}
break;
}
return MACRO_NONE;
}
The ModBlocker plugin is based on the ShiftBlocker example, but the enable does not work so the LeftArrow tap is getting mangled. Any suggestions?