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

Further restrict layer names #270

Open
samtay opened this issue Nov 17, 2024 · 1 comment
Open

Further restrict layer names #270

samtay opened this issue Nov 17, 2024 · 1 comment

Comments

@samtay
Copy link

samtay commented Nov 17, 2024

The editor currently allows a-zA-Z0-9,._+- when renaming layers. However using a hyphen e.g. SYM-1 fails to build for me with this error:

devicetree error: /tmp/zmk-config/config/corne.keymap:236 (column 11): parse error: expected '{', '=', or ';'
@nickcoutsos
Copy link
Owner

Hah, that's something!

Interestingly, layer names can be hyphenated, per the devicetree spec:

Valid characters for node names

Character Description
0-9 digit
a-z lowercase letter
A-Z uppercase letter
, comma
. period
_ underscore
+ plus sign
- dash

The node-name shall start with a lower or uppercase character and should describe the general class of device.

What's happening here is SYM-1 includes a pre-processor identifier. This gets evaluated before the devicetree compiler so you end up with a layer named 2-1 which isn't valid. I think in this case even SYM would be an invalid layer name for the same reason.

My advice would be to think about whether or not you'd prefer to use these identifiers. When parsing the keymap I do a small amount of evaluation but that's to deal with identifiers used in bindings (e.g. &mo SYM). This helps the app to handle the initial loading of the keymap, but when saving changes it won't attempt to map layer indices to potential layer identifiers.

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

2 participants