I want a macro that when I hit the keys, it does ctrl-b and then the key pressed. I can hard-code each macro, but I was hoping for a simpler solution. I tried to use T(Macros.col)
to tap the number, but I get an error. I tried to search the forums, but I couldn’t find anything. Does anyone know how I could dynamically do this?
I think you want the PrefixLayers plugin:
Though, that might not be updated for the v2 plugin API yet… I guess I’ll have to submit a PR to move it forward. The plugin does precisely what you wish to do
Ah yes, I was meaning to update this for the v2 API…I’ll have a look at that later today.
I don’t want a whole layer prefixed. I just want the num keys prefixed. I want it to be the default for the numbers because I actually use a layer with hometown for normal numbers.
Amos King
Binary Noggin
Ah, I see. Well, in any case my plugin is updated to the version 2 API; I think it would be fairly straightforward to modify the code to the keys to trigger the prefix configurable & use that instead of the layer; basically, if you make the keys of the dict my plugin uses be key codes instead of layers, then instead of the check for Layer.isOn
in the key handler, you can check if the pressed key equals the key in question.
Looks like I will have to do some reading of the code. Thanks for the pointer!
Hmm… Another option: since macros have an index, you can use that to figure out which one’s pressed.
Something like this:
void CtrlBNumber(uint8_t macroIndex, uint8_t keyState) {
uint8_t number = macroIndex - M_ONE;
if (!keyToggledOn(keyState))
return;
handleKeyswitchEvent(LCTRL(Key_B), UNKNOWN_KEYSWITCH_LOCATION, IS_PRESSED);
kaleidoscope::hid::sendKeyboardReport();
handleKeyswitchEvent(LCTRL(Key_B), UNKNOWN_KEYSWITCH_LOCATION, WAS_PRESSED);
kaleidoscope::hid::sendKeyboardReport();
handleKeyswitchEvent((Key){.keyCode = Key_1.keyCode + number},
Macros.row, Macros.col, keyState);
}
Just make sure your macros are in the proper order (with 0
being the last number), and this should work. It’s completely untested however.
Thanks, that might work. I might make a prefix plug-in that add a prefix to a key that is pushed without a layer being required. Or I might just use that macro hack but it feels dirty.
Amos King
Binary Noggin
The plugin would need to do something very similar too. The advantage of the plugin would be that it is easier to share, and a tiny bit more efficient. But under the hood, it would be doing the same.
It may feel dirty, but rest assured it isn’t dirtier than any other trick we make the keyboard do.