urob / zmk-helpers

Convenience macros simplifying ZMK's keymap configuration
MIT License
235 stars 79 forks source link

Parameterized macros support #20

Closed JeffDess closed 1 year ago

JeffDess commented 1 year ago

Hi! ZMK recently added two new behaviors for macros, both allowing to pass parameters from the keymap.

I've simply added the macro-one-param and macro-two-param definitions into the helper and it seems to work fine when configuring bindings according to documentation.

Example:

/* Calling this macro in keybindings with "MAC K" where K is a keypress parameter */
ZMK_BEHAVIOR(MAC, macro_one_param, bindings =
    <&macro_param_1to1>,
    <&kp MACRO_PLACEHOLDER>;)

Also added those two to the readme, in the allowed behavior types. Hope this helps!

urob commented 1 year ago

Great, thanks!

smallstepman commented 10 months ago

I'm trying to use it but can't figure out how - can you help?

#define TMUX_PREFIX LC(B)
ZMK_BEHAVIOR(tmux, macro_one_param, bindings = <&macro_param_1to2>, <&kp TMUX_PREFIX &kp MACRO_PLACEHOLDER>;)
// ...
// and then in layer
// ...
&tmux B
JeffDess commented 10 months ago

@smallstepman I would try :

ZMK_BEHAVIOR(tmux, macro_one_param, bindings = 
    <&kp TMUX_PREFIX>,
    <&macro_param_1to1>,
    <&kp MACRO_PLACEHOLDER>;
)