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

Check for combos exceeding CONFIG_ZMK_COMBO_MAX_COMBOS_PER_KEY at compile time. #2551

Open
amacleod opened this issue Oct 13, 2024 · 4 comments

Comments

@amacleod
Copy link
Contributor

As a quality of life feature, it would be nice to have a way to automatically detect excess combos and issue a compile time warning. Or possibly even use that detection to implicitly increase the combo-per-key limit within reason.

Currently, if I overload a key with more combos than CONFIG_ZMK_COMBO_MAX_COMBOS_PER_KEY allows, it seems I silently lose the use of one or more of those combos. Rather than discovering this when I try to use that combo, I would prefer to have an error or warning when I (or the GH Action) go to build the firmware.

@amacleod
Copy link
Contributor Author

To be clear, I consider this an extremely minor nice-to-have. At some point I might take a crack at a PR for it, but only after learning more about ZMK internals 😄

@joelspadin
Copy link
Collaborator

joelspadin commented Oct 13, 2024

If it's possible to calculate the number of combos using each key at compile time in order to check if it exceeds the max, then it should also be possible to just calculate what the max should be and eliminate the need for the setting entirely.

(That said, the typical method of getting the max of a list of numbers with C macros increases exponentially in complexity with the size of the list, so we would need to be sure such a solution is feasible on large keyboards.)

@urob
Copy link
Contributor

urob commented Oct 13, 2024

Could one overload west build with a custom west command that's a shallow Python wrapper around the original one?

One could run the config through the preprocessor first and then use python to parse and automate various settings.

One might also do the same to improve error messages. E.g., showing the code corresponding to problematic columns after all macros have been expanded.

@angweekiat
Copy link
Contributor

I took a stab at this, and have a POC branch for adding static asserts to introduce compilation errors for excessive combos, here: angweekiat#1

I also tried to see if it's possible to calculate CONFIG_ZMK_COMBO_MAX_KEYS_PER_COMBO at compile time, and while I was able to get the list of combo key positions, I wasn't able to find a nice and scalable way to find the max value of the list at compile time :/

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

4 participants