urob / zmk-helpers

Convenience macros simplifying ZMK's keymap configuration
MIT License
235 stars 79 forks source link

ZMK_COMBO does not work with home row mod buttons #47

Closed angularsen closed 1 month ago

angularsen commented 1 month ago

I'm trying to get Norwegian/Danish unicode letters æøå working on the home row as combos instead of using a layer. Non-homerow keys work well, but home row mod buttons seem to conflict.

It it possible?

a+e=æ   (LGUI+RSHIFT)
o+e=ø   (RGUI+RSHIFT)
a+o=å   (LGUI+RGUI)

My setup, with unicode defined by unicode-chars/danish.dtsi:

ZMK_COMBO(combo_da_ae,  &da_ae,    LM4 RM2,     DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW) // BAD, a+e prints 'ae'
ZMK_COMBO(combo_da_oe,  &da_oe,    RM4 RM2,     DEF NAV NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST) // BAD, o+e prints 'oe'
ZMK_COMBO(combo_da_ao,  &da_aa,    LM4 RM4,     DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW) // OK, a+o prints 'å'

Interestingly, a+o (LGUI+RGUI) does work, probably due to both mapping to GUI. This is on Windows with WinCompose installed. Using v2 of zmk-helpers.

urob commented 1 month ago

I don't see any obvious issues. Just a wild guess, is CONFIG_ZMK_COMBO_MAX_COMBOS_PER_KEY set sufficiently large?

angularsen commented 1 month ago

I believe I have the ones from the examples, they should be large enough I think?

# Combo config, automated by build script
CONFIG_ZMK_COMBO_MAX_COMBOS_PER_KEY=6
CONFIG_ZMK_COMBO_MAX_KEYS_PER_COMBO=3

My config repo for reference: https://github.com/angularsen/zmk-config-corne5/tree/master/config

urob commented 1 month ago

Those values are set automatically by my build script to the smallest feasible number: https://github.com/urob/zmk-config/blob/cdf2be5ad2d7d5b8b5f8eaed38b23fa783a5f523/scripts/zmk_build.sh#L129-L149

Since you added additional combos, CONFIG_ZMK_COMBO_MAX_COMBOS_PER_KEY ends up being too small, resulting in the additional combos being ignored. For example, RM2 is part of 8 combos in your config, which is more than your setting that sets allows only a maximum of 6 combos per key.

You want to increase that number to whatever is the maximum number of combos per key in your config (at least 8 based on my superficial look, but could be more).

angularsen commented 1 month ago

Thanks a lot, that was totally it! I bumped it to 10 and now combos work 🎉

What is the downside to setting this to a high number?

urob commented 1 month ago

What is the downside to setting this to a high number?

AFAIK not much other than memory allocation.