Problem (syntax errors) using `hexCodeOf($macroArg.1)`

Following very interesting hints here I tried the following:

ifShift {
tapKey A-keypadPlus
delayUntil 100
suppressMods tapKeySeq backspace backspace backspace backspace hexCodeOf($macroArg.2) enter
}
else {
tapKey A-keypadPlus
delayUntil 100
tapKeySeq backspace backspace backspace backspace hexCodeOf($macroArg.1) enter
}

and on saving the configuration to kbd got the following syntax errors:

Error at Unicode NotShift-Shift 1/4/78: Expected closing parenthesis at the end of parameter list.
> 4 |  suppressMods tapKeySeq backspace backspace backspace backspace hexCodeOf($macroArg.2) enter
>   |                                                                              ^
Error at Unicode NotShift-Shift 1/4/79: Unrecognized key abbreviation: roArg.2)
> 4 |  suppressMods tapKeySeq backspace backspace backspace backspace hexCodeOf($macroArg.2) enter
>   |                                                                               ^
Error at Unicode NotShift-Shift 1/9/65: Expected closing parenthesis at the end of parameter list.
> 9 |  tapKeySeq backspace backspace backspace backspace hexCodeOf($macroArg.1) enter
>   |                                                                 ^
Error at Unicode NotShift-Shift 1/9/66: Unrecognized key abbreviation: roArg.1)
> 9 |  tapKeySeq backspace backspace backspace backspace hexCodeOf($macroArg.1) enter
>   |                                                                  ^
Error at Unicode NotShift-Shift 1/4/78: Expected closing parenthesis at the end of parameter list.
> 4 |  suppressMods tapKeySeq backspace backspace backspace backspace hexCodeOf($macroArg.2) ente

Agent is 10.1.0, firmware LHS is 17.2.0, RHS is 17.0.0.

I don’t have time to help with the macros ATM, but honestly, you should probably wait until you get your firmware flashed properly to the same version on each half.

hexCodeOf expects literally an ascii char and does not accept variables at the moment, so you need to force the expansion via hexCodeOf(&macroArg.2).

Ok. Syntax issue turned out to be:

Not accepted:

suppressMods tapKeySeq backspace backspace hexCodeOf(&macroArg.2) enter

Was accepted:

suppressMods tapKeySeq backspace backspace hexCodeOf(&macroArg.2)
tapKey enter

For some reason enter wasn’t accepted after the hexCodeOf(...).

Also I switched to & from $ - not sure what the difference is or if I needed to switch.

So what’s going on here, in case you wanted to know: I can’t get the Windows hex input for Unicode characters to work, even with the proper registry key. For example, Notepad takes Alt-Np+ and pops up a “insert hyperlink” dialog (which is very odd, as that shortcut is not documented and the actual documented shortcut C-k doesn’t work). And other programs also do random things on Alt-Np+.

So instead I’m using an old program unicodeinput (not open source) that you run (at login) and it grabs, at the system level, the key Alt-Np+ and opens up a window with a text edit you can type your unicode hexcode into, and the you hit the Send button and it sends it. This works ok except it has a couple of problems:

a) It takes a little bit of time to pop up and start grabbing keystrokes to its window - so you need to insert a delay
b) When you pop it up it hasn’t cleared the text edit field of its previous entry, and it doesn’t understand C-a to select all characters in the field, so I have to send 4 backspaces to clear the old entry

Anyway, I now have a macro that takes 2 parameters: A unicode character to send on unshifted keystroke, and a unicode character to send on shifted keystroke. I map it to a bunch of keys on a new layer and I can type (preselected) unicode characters pretty easily. I currently have the superscript/subscript digits mapped, and also some unicode “lookalike” substitutes for :, ?, / which can’t be used in filenames on Windows but which I want to put in filenames (to properly name academic papers which frequently have these characters in the title.

The macro looks like:

ifShift {
 tapKey A-keypadPlus
 delayUntil 100
 suppressMods tapKeySeq backspace backspace backspace backspace hexCodeOf(&macroArg.2)
 suppressMods tapKeySeq tab enter
}
else {
 tapKey A-keypadPlus
 delayUntil 100
 tapKeySeq backspace backspace backspace backspace hexCodeOf(&macroArg.1)  
 tapKeySeq tab enter
}

and an example mapping looks like:

1 Like

Can’t look into it now, but filed it here so that it doesn’t get forgotten :wink: : Templating bug · Issue #1600 · UltimateHackingKeyboard/firmware · GitHub

Indeed, nice catch!

Fixed at Fix tapkeyseq hexcode · UltimateHackingKeyboard/firmware@76626ce · GitHub

This is - from a user perspective - an incomprehensible detail of the macro language. I have a PR (code change) pending for the firmware that should take care of a number of those “variations” and allow the use of $macroArg consistently.

$ expands variables. I.e., it can substitute just a single legal value in a strictly guarded context.
& expands as macro text without any guards. I.e., can be used to construct macro code.