I found a solution, but I am not sure if this is optimal.
I created a new layer that has only one key that is not transparent, and that is the key that I am using to trigger the macro, but on this new layer, it has a different macro, eg:
[PRIMARY] = KEYMAP_STACKED
(
...
M(MACRO_SWITCH_SPACE_CADET)
...
),
[SECONDARY] = KEYMAP_STACKED
(
...
M(MACRO_SWITCH_SPACE_CADET2)
...
),
Both macros trigger the same function:
const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) {
switch (macro_id) {
...
case MACRO_SWITCH_SPACE_CADET:
case MACRO_SWITCH_SPACE_CADET2:
toggleSpaceCadet(event.state);
break;
...
}
}
The function toggles the layer together with the status of SpaceCadet and OneShot:
static void toggleSpaceCadet(uint8_t key_state) {
if (keyToggledOn(key_state)) {
OneShot.toggleAutoOneShot();
if (SpaceCadet.active()) {
SpaceCadet.disable();
Layer.move(PRIMARY);
}
else {
SpaceCadet.enable();
Layer.move(SECONDARY);
}
}
}
Since I use custom colors in FunctionalColor for some keys, I just defined the macros to have different colors:
FC_START_COLOR_LIST(customColors)
//// // Set the color of keys with brightness macros
//// // Use any number of FCGROUPKEYs above a FC_KEYCOLOR to set several keys to the same color
FC_KEYCOLOR(M(MACRO_SWITCH_SPACE_CADET), dim(greenyellow, 255))
FC_KEYCOLOR(M(MACRO_SWITCH_SPACE_CADET2), dim(skyblue, 255))
FC_KEYCOLOR(Key_CapsLock, dim(purple,128 ))
FC_END_COLOR_LIST_DEFAULT(dim(forestgreen, 255));
FunctionalColor funColorCustom(FC_COLOR_LIST(customColors));
Let me know if you know of a better solution, as this seems to use quite a bit of extra memory.