Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fails when using &macro_press, &macro_wait_for_release, and &macro_release in macros.dtsi #11

Closed
ringil-forge opened this issue Sep 18, 2022 · 5 comments

Comments

@ringil-forge
Copy link

When adding a macro that uses syntax from the ZMK Macro Documentation, the build fails with the errors:

adv360_left.dts.pre.tmp:784.42-793.3: ERROR (phandle_references): /behaviors/macro_vscode_format: Reference to non-existent node or label "macro_press"

adv360_left.dts.pre.tmp:784.42-793.3: ERROR (phandle_references): /behaviors/macro_vscode_format: Reference to non-existent node or label "macro_pause_for_release"

adv360_left.dts.pre.tmp:784.42-793.3: ERROR (phandle_references): /behaviors/macro_vscode_format: Reference to non-existent node or label "macro_release"

I added a macro following the documentation creating a macro w/ &macro_press like in the below example pulled from the docs:

bindings
    = <&macro_press &kp LSHFT>
    , <&macro_tap &kp Z &kp M &kp K>
    , <&macro_release &kp LSHFT>
    ;

I am attempting to create a macro that will run the VSCode format keyboard shortcut, which entails chording 3 keys together, I added my macro as:

macro_vscode_format: macro_vscode_format {
    label = "macro_vscode_format";
    compatible = "zmk,behavior-macro";
    #binding-cells = <0>;
    bindings
        = <&macro_press &kp LSHFT &kp LALT &kp F>
        , <&macro_pause_for_release>
        , <&macro_release &kp LSHFT &kp LALT &kp F>
        ;
};

And got the above referenced build error.

What am I doing wrong?

@arogulin
Copy link

@mpentecost I had exact same issue trying to create macros to execute CMD+c and CMD+v actions. I tried the following code and it failed exactly as yours:

  macro_cmd_c: macro_cmd_c {
    label = "macro_cmd_c";
    compatible = "zmk,behavior-macro";
    #binding-cells = <0>;
    bindings
        = <&macro_press &kp LGUI>
        , <&macro_tap &kp C>
        , <&macro_release &kp LGUI>
        ;
  };

  macro_cmd_v: macro_cmd_v {
    label = "macro_cmd_v";
    compatible = "zmk,behavior-macro";
    #binding-cells = <0>;
    bindings
        = <&macro_press &kp LGUI>
        , <&macro_tap &kp V>
        , <&macro_release &kp LGUI>
        ;
  };

Not sure what the root cause is, but I noticed Kinesis uses key codes like LS(something) in their macros.dtsi and I assumed LS could mean LSHIFT, which turned out to be true: https://zmk.dev/docs/codes#modifiers. That meant I don't even need a macro definition anymore, so I simply used &kp LG(C) and &kp LG(V) in adv360.keymap (see this commit), where LG means LGUI.
I think they could be stackable, so your macro could probably be replaced with something like &kp LS(LA(F)). Try it and see if it works.

@KinesisCorporation
Copy link
Owner

@arogulin is correct to the best of our knowledge.

@arogulin
Copy link

I should have read the whole documentation page instead of making my assumptions: these are called modifier functions and they are indeed stackable, that page I linked above has this example at the bottom:

* They can be combined:
  * &kp LC(RA(B)) = LEFT_CONTROL+RIGHT_ALT+B

@ringil-forge
Copy link
Author

@arogulin Thank you, those modifier functions work out well for my use case.

@ringil-forge
Copy link
Author

I can confirm that macro syntax like:

bindings
    = <&macro_press &kp LSHFT>
    , <&macro_tap &kp Z &kp M &kp K>
    , <&macro_release &kp LSHFT>
    ;

Works w/ the new V2.0-beta branch.

ed-flanagan added a commit to ed-flanagan/Adv360-Pro-ZMK that referenced this issue Sep 27, 2022
jonatan-branting pushed a commit to jonatan-branting/Adv360-Pro-ZMK that referenced this issue Feb 1, 2024
# This is the 1st commit message:

Updated keymap
# The commit message KinesisCorporation#2 will be skipped:

# Updated keymap

# The commit message KinesisCorporation#3 will be skipped:

# feat: Add basic changes to make me feel more at home

# The commit message KinesisCorporation#4 will be skipped:

# Updated adv360.keymap

# The commit message KinesisCorporation#5 will be skipped:

# Updated adv360.keymap

# The commit message KinesisCorporation#6 will be skipped:

# Updated adv360.keymap

# The commit message KinesisCorporation#7 will be skipped:

# Updated adv360.keymap

# The commit message KinesisCorporation#8 will be skipped:

# Updated adv360.keymap

# The commit message KinesisCorporation#9 will be skipped:

# Updated adv360.keymap

# The commit message KinesisCorporation#10 will be skipped:

# Reduce brightness of leds

# The commit message KinesisCorporation#11 will be skipped:

# Updated adv360.keymap

# The commit message KinesisCorporation#12 will be skipped:

# Updated adv360.keymap

# The commit message KinesisCorporation#13 will be skipped:

# Updated adv360.keymap

# The commit message KinesisCorporation#14 will be skipped:

# Updated adv360.keymap

# The commit message KinesisCorporation#15 will be skipped:

# Updated adv360.keymap

# The commit message KinesisCorporation#16 will be skipped:

# Updated adv360.keymap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants