#Creating a macro for SQT but not DQT

1 messages · Page 1 of 1 (latest)

covert basalt
#

I'm trying to program the following macro for double quotes that would put me in between the quotes when the macro is complete.

macro_dquotes: macro_dquotes{
compatible = "zmk,behavior-macro";
label = "macro_dquotes";
#binding-cells = <0>;
wait-ms = <1>;
bindings = <&kp DQT>, <&kp DQT>, <&kp LEFT>;
};

My problem is that I can only get it to work if I enable the same macro for single quotes, but I don't want a macro for single quotes. I'm also having the same problem enabling a similar macro for parenthesis, where I have to have a macro for 90 that would put me in the middle of the 9 and the 0 when the macro is complete.

I've been too busy with work to dive into why this isn't working, and I'm hoping someone can help me solve it here. The only other thing I've tried is using the GUI that comes with the Kinesis Advantage 360 Pro to program the macro, but it's somehow more confusing than editing the dtsi file.

alpine raptor
#

I'm not sure what you mean about "enabling" the macro you don't want. what does your dtsi file look like?

covert basalt
#

Yup. I can see how that was utterly confusing. So what I'm saying is that the macro only seems to work if I also have a similar macro to macro_dquotes that uses single quotes instead of double quotes.

macro_ctrl_b: macro_ctrl_b{
compatible = "zmk,behavior-macro";
label = "macro_ctrl_b";
#binding-cells = <0>;
wait-ms = <1>;
bindings = <&macro_press &kp RCTRL>
        , <&macro_tap &kp B>
        , <&macro_release &kp RCTRL>
        ;
};
macro_dquotes: macro_dquotes{
compatible = "zmk,behavior-macro";
label = "macro_dquotes";
#binding-cells = <0>;
wait-ms = <1>;
bindings = <&kp DQT>, <&kp DQT>, <&kp LEFT>;
};
macro_braces: macro_braces{
compatible = "zmk,behavior-macro";
label = "macro_braces";
#binding-cells = <0>;
wait-ms = <1>;
bindings = <&kp LBRC>, <&kp RBRC>, <&kp LEFT>;
};
macro_parens: macro_parens{
compatible = "zmk,behavior-macro";
label = "macro_parens";
#binding-cells = <0>;
wait-ms = <1>;
bindings = <&kp LPAR>, <&kp RPAR>, <&kp LEFT>;
};
macro_brackets: macro_brackets{
compatible = "zmk,behavior-macro";
label = "macro_brackets";
#binding-cells = <0>;
wait-ms = <1>;
bindings = <&kp LBKT>, <&kp RBKT>, <&kp LEFT>;
};
macro_kinesis: macro_kinesis{
compatible = "zmk,behavior-macro";
label = "macro_kinesis";
#binding-cells = <0>;
bindings = <&kp LS(K)>, <&kp I>, <&kp N>, <&kp E>, <&kp S>, <&kp I>, <&kp S>;
}; 
alpine raptor
#

"works" as in the macro executes as expected, or as in build failure/success?

covert basalt
#

Build is a success. But the macro doesn't take.

#

When I install the firmware, all the other macros work accept for macro_dquotes and macro_parens.

#

And by that I mean... there doesn't seem to be any macro connected to the key at all when I press it. It's just a &kp of "

alpine raptor
#

that's really weird

covert basalt
#

But if I add a similar macro using single quotes that attempts the same behavior I want but with single quotes, both work.

macro_squotes: macro_squotes{
compatible = "zmk,behavior-macro";
label = "macro_squotes";
#binding-cells = <0>;
wait-ms = <1>;
bindings = <&kp SQT>, <&kp SQT>, <&kp LEFT>;
};

But when I press ', all I want is one '.

alpine raptor
#

what do the bindings in your keymap look like? I mean, would it be enough maybe to just not bind macro_squotes to any key?

covert basalt
#

Interesting. So basically, have the macro in place in my dtsi file, but don't include it in the actual keymap?

alpine raptor
#

potentially, yeah, but I'm curious as to what's going on in there currently

covert basalt
#

I just have &kp SQT in there. Now I'm wondering if I should replace that with the macro for double quotes.

alpine raptor
#

you could potentially use mod-morph to trigger &macro_dquotes on that key when pressed with a modifier

covert basalt
#

That sounds like more what I want. would that live in macros?

alpine raptor
#

no, I think it's gotta be its own behavior (I've never actually used it myself)

covert basalt
#

I have no clue where to put this but it does look exactly like what I want.

alpine raptor
#

basically you'd include something like this in your keymap file:

quotes: single_double_quotes {
    compatible = "zmk,behavior-mod-morph";
    label = "SINGLE_DOUBLE_QUOTES";
    #binding-cells = <0>;
    bindings = <&kp SQT>, <&macro_dquotes>;
    mods = <(MOD_LSFT|MOD_RSFT)>;
};

and then in the bindings you'd have &quotes instead of &kp SQT

covert basalt
#

ooooooo

#

Okay. Yeah. This makes a lot of sense and seems like the correct approach.

alpine raptor
#

again, haven't used it, but I think that's how mod-morph works

covert basalt
#

the keymap file is adv360.keymap, I'm assuming?

#

is .keymap the correct file extension for where I want to add this?

alpine raptor
#

yes

#

do you have it in a github repo you can link to?

covert basalt
alpine raptor
#

yeah, so in the adv360.keymap file you'd add that snippet right after line 33 where the homerow mods behavior is defined

covert basalt
#

amazing. You're a saint. Thank you so much

#

I know I'm being a bad SWE by not looking into this myself more before asking, I appreciate you helping me out!

alpine raptor
#

haha! it's kind of a lot to take in all at once, I get it

#

just note that if you make future edits with the editor from kinesis your behavior will be overwritten. my own editor (which its based on) doesn't handle custom behaviors perfectly but it should at least ignore it when saving changes http://nickcoutsos.github.io/keymap-editor

covert basalt
#

got it. That's good to know. Thank you!

#

One last question. Is there any sort of test suite you can use to test keybindings before going through the entire gh actions process? Not being able to create a test for this is driving me nuts.

alpine raptor
#

something like a linter to validate that the bindings are correct, or something more involved? I'm not aware of either, sadly

#

if you're willing to set up the build environment locally that may be faster, but I don't know if you can avoid the build step

covert basalt
#

Ain't nobody got time for that.

#

No worries, thanks anyways!

covert basalt
#

@alpine raptor that all worked perfectly. Thank you so much

covert meadow
#

i'm trying to do something similar, this was very useful...thank you both! @covert basalt @alpine raptor . Quick question, if i were to bind the mod-morph behavior along with home row mods, would that work? Essentially, will write the macro for double quotes, and the mod-morph behavior, and then in the key map, bind the key as:
&bhm RGUI &dqr
where dqr is the mod-morph behavior that calls the macro when used with shift

#

asking because i have no way to test it yet as i don't have a pcb yet 🙂

alpine raptor
#

it would probably be worth asking in a channel or new thread, I've never tried something like that. I think you might have an issue just with syntax, but it may be possible to work around

covert meadow
#

Ah you mean the double & for one key

alpine raptor
#

you might need to define bhm with bindings = <&kp>, <&dqr>; and then bind it in your keymap with &bhm RGUI 0 (or some other value that you mean to ignore)

covert meadow
#

Will try that…thank you!

#

Btw really like your editor…may use that to create a layout image for my key map 🙂

alpine raptor
#

see if it compiles, anyway. I don't know if dqr is going to complain about receiving a parameter

#

thanks! I need to be able to turn that into something that runs server-side to automatically generate keymap images, but rendering HTML/CSS to an image involves several cans of worms

covert meadow
#

I can imagine. It will still work for me if I can just take a screenshot for now