I was trying to setup a macro (remapped to the Butterfly key) so that it simulates option, shift, command. I want to use it such that when I hold down butterfly and D (for example), the keyboard simulates shift option command D
Right now I got it working if I hard code the D in the macro, but that’s not ideal, as I’d love to use it with more than just D
The code to create the macro is (there is also MACRO_SOC in the enum and in the layout there’s M(MACRO_SOC)):
case MACRO_SOC:
return MACRODOWN(D(LeftShift), D(LeftGui), D(LeftAlt));
break;
To reiterate: I got it working if I add D(D) to the end of the macro.
While a solution has been found, I’d like to explain why the macro did not work. It didn’t work because of MACRODOWN, which only fires when a key toggles on. When you continue holding, it doesn’t do anything. This is important to keep in mind, because we clear the report every cycle, so any key that isn’t re-registered, will not be in the report.
To do this with a macro, you’d do something like this:
keyState is a bitfield that has bits for the current and previous state of the keyswitch that’s being processed. keyIsPressed() is a function that checks the current state of that switch, and returns true if the key is currently down (and false otherwise).
MACRODOWN() is a preprocessor macro that uses keyToggledOn(keyState) instead of keyIsPressed(keyState), and that function only returns true if the current state of the switch is on (pressed) and the previous state was off (not pressed). So MACRODOWN() only has an effect at the moment a key is pressed, not continuously while the key is held (though it could possibly produce OneShot presses, which would have a more lasting effect).