From 4e8e271cfdbdc35c9268e24d3b9b6db00a32b33c Mon Sep 17 00:00:00 2001 From: Peter Johanson Date: Mon, 12 Aug 2024 11:57:56 -0600 Subject: [PATCH] feat: Add config settings for sticky keys/hold-tap * Add new Kconfig symbols to config max held sticky-keys/hold-taps and for max captured events during hold-tap resolution. --- app/CMakeLists.txt | 4 +-- app/Kconfig.behaviors | 38 +++++++++++++++++++++++++ app/src/behaviors/behavior_hold_tap.c | 4 +-- app/src/behaviors/behavior_sticky_key.c | 2 +- docs/docs/config/behaviors.md | 13 +++++++++ 5 files changed, 56 insertions(+), 5 deletions(-) diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index ab2e1502..5e19713a 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -47,8 +47,8 @@ if ((NOT CONFIG_ZMK_SPLIT) OR CONFIG_ZMK_SPLIT_ROLE_CENTRAL) target_sources_ifdef(CONFIG_ZMK_MOUSE app PRIVATE src/mouse.c) target_sources(app PRIVATE src/behaviors/behavior_key_press.c) target_sources_ifdef(CONFIG_ZMK_BEHAVIOR_KEY_TOGGLE app PRIVATE src/behaviors/behavior_key_toggle.c) - target_sources(app PRIVATE src/behaviors/behavior_hold_tap.c) - target_sources(app PRIVATE src/behaviors/behavior_sticky_key.c) + target_sources_ifdef(CONFIG_ZMK_BEHAVIOR_HOLD_TAP app PRIVATE src/behaviors/behavior_hold_tap.c) + target_sources_ifdef(CONFIG_ZMK_BEHAVIOR_STICKY_KEY app PRIVATE src/behaviors/behavior_sticky_key.c) target_sources(app PRIVATE src/behaviors/behavior_caps_word.c) target_sources(app PRIVATE src/behaviors/behavior_key_repeat.c) target_sources_ifdef(CONFIG_ZMK_BEHAVIOR_MACRO app PRIVATE src/behaviors/behavior_macro.c) diff --git a/app/Kconfig.behaviors b/app/Kconfig.behaviors index d3f4537e..adada062 100644 --- a/app/Kconfig.behaviors +++ b/app/Kconfig.behaviors @@ -40,6 +40,29 @@ endchoice endif + +config ZMK_BEHAVIOR_HOLD_TAP + bool + default y + depends on DT_HAS_ZMK_BEHAVIOR_HOLD_TAP_ENABLED + +if ZMK_BEHAVIOR_HOLD_TAP + +config ZMK_BEHAVIOR_HOLD_TAP_MAX_HELD + int "Hold Tap Max Held" + default 10 + help + Max number of simultaneously held hold-taps + + +config ZMK_BEHAVIOR_HOLD_TAP_MAX_CAPTURED_EVENTS + int "Hold Tap Max Captured Events" + default 40 + help + Max number of captured system events while waiting to resolve hold taps + +endif + config ZMK_BEHAVIOR_KEY_TOGGLE bool default y @@ -51,6 +74,21 @@ config ZMK_BEHAVIOR_MOUSE_KEY_PRESS depends on DT_HAS_ZMK_BEHAVIOR_MOUSE_KEY_PRESS_ENABLED imply ZMK_MOUSE +config ZMK_BEHAVIOR_STICKY_KEY + bool + default y + depends on DT_HAS_ZMK_BEHAVIOR_STICKY_KEY_ENABLED + +if ZMK_BEHAVIOR_STICKY_KEY + +config ZMK_BEHAVIOR_STICKY_KEY_MAX_HELD + int "Sticky Key Max Held" + default 10 + help + Max number of simultaneously held sticky keys + +endif + config ZMK_BEHAVIOR_SOFT_OFF bool default y diff --git a/app/src/behaviors/behavior_hold_tap.c b/app/src/behaviors/behavior_hold_tap.c index 1c050c44..c45ee803 100644 --- a/app/src/behaviors/behavior_hold_tap.c +++ b/app/src/behaviors/behavior_hold_tap.c @@ -24,8 +24,8 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) -#define ZMK_BHV_HOLD_TAP_MAX_HELD 10 -#define ZMK_BHV_HOLD_TAP_MAX_CAPTURED_EVENTS 40 +#define ZMK_BHV_HOLD_TAP_MAX_HELD CONFIG_ZMK_BEHAVIOR_HOLD_TAP_MAX_HELD +#define ZMK_BHV_HOLD_TAP_MAX_CAPTURED_EVENTS CONFIG_ZMK_BEHAVIOR_HOLD_TAP_MAX_CAPTURED_EVENTS // increase if you have keyboard with more keys. #define ZMK_BHV_HOLD_TAP_POSITION_NOT_USED 9999 diff --git a/app/src/behaviors/behavior_sticky_key.c b/app/src/behaviors/behavior_sticky_key.c index d1299c78..6016fc2d 100644 --- a/app/src/behaviors/behavior_sticky_key.c +++ b/app/src/behaviors/behavior_sticky_key.c @@ -26,7 +26,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #define KEY_PRESS DEVICE_DT_NAME(DT_INST(0, zmk_behavior_key_press)) -#define ZMK_BHV_STICKY_KEY_MAX_HELD 10 +#define ZMK_BHV_STICKY_KEY_MAX_HELD CONFIG_ZMK_BEHAVIOR_STICKY_KEY_MAX_HELD #define ZMK_BHV_STICKY_KEY_POSITION_FREE UINT32_MAX diff --git a/docs/docs/config/behaviors.md b/docs/docs/config/behaviors.md index 28abdf27..11ad0002 100644 --- a/docs/docs/config/behaviors.md +++ b/docs/docs/config/behaviors.md @@ -51,6 +51,13 @@ Creates a custom behavior that triggers one behavior when a key is held or a dif See the [hold-tap behavior](../behaviors/hold-tap.mdx) documentation for more details and examples. +### Kconfig + +| Config | Type | Description | Default | +| -------------------------------------------------- | ---- | --------------------------------------------------------------------------------------------- | ------- | +| `CONFIG_ZMK_BEHAVIOR_HOLD_TAP_MAX_HELD` | int | Maximum number of simultaneous held hold-taps. | 10 | +| `CONFIG_ZMK_BEHAVIOR_HOLD_TAP_MAX_CAPTURED_EVENTS` | int | Maximum number of system events to capture while deferring a hold or tap decision resolution. | 40 | + ### Devicetree Definition file: [zmk/app/dts/bindings/behaviors/zmk,behavior-hold-tap.yaml](https://github.com/zmkfirmware/zmk/blob/main/app/dts/bindings/behaviors/zmk%2Cbehavior-hold-tap.yaml) @@ -227,6 +234,12 @@ Creates a custom behavior that triggers a behavior and keeps it pressed it until See the [sticky key behavior](../behaviors/sticky-key.md) and [sticky layer behavior](../behaviors/sticky-layer.md) documentation for more details and examples. +### Kconfig + +| Config | Type | Description | Default | +| ----------------------------------------- | ---- | ------------------------------------------------ | ------- | +| `CONFIG_ZMK_BEHAVIOR_STICKY_KEY_MAX_HELD` | int | Maximum number of simultaneous held sticky keys. | 10 | + ### Devicetree Definition file: [zmk/app/dts/bindings/behaviors/zmk,behavior-sticky-key.yaml](https://github.com/zmkfirmware/zmk/blob/main/app/dts/bindings/behaviors/zmk%2Cbehavior-sticky-key.yaml)