Macro or shortcut or ...?

Hi there,

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 :slight_smile:

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));

To reiterate: I got it working if I add D(D) to the end of the macro.



Neat, I didn’t know that! I’ve fixed it now with LSHIFT(LGUI(Key_LeftAlt)) is anyone will find this thread!

1 Like

I wanted to edit my post and deleted it by mistake, but you got it correcly.

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:

if (keyIsPressed(keyState)) {
  return MACRO(D(LeftShift), D(LeftGui), D(LeftAlt));
} else {
  return MACRO_NONE;
1 Like

Bookmarking this. I understood more or less why it didn’t work, but how to fix it (i.e. keyIsPressed) went beyond me.

Thanks for the help!

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).

I hope that helps, and wasn’t too redundant.

1 Like