From 209085da7338c83f7053f79c95fe41439f0383ac Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Tue, 25 Feb 2025 12:12:27 -0700 Subject: [PATCH] refactor(behaviors): Add max-held tap-dance config (#2838) refactor(behaviors): Add max-held tap-dance config Add new `CONFIG_ZMK_BEHAVIOR_TAP_DANCE_MAX_HELD` config for reducing RAM usage on more constrained devices. refactor(behaviors): Move defaults to Kconfig.defaults --- app/CMakeLists.txt | 2 +- app/Kconfig.behaviors | 18 +++++++++++++++--- app/Kconfig.defaults | 26 ++++++++++++++++++++++++++ app/src/behaviors/behavior_tap_dance.c | 2 +- docs/docs/config/behaviors.md | 6 ++++++ 5 files changed, 49 insertions(+), 5 deletions(-) diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 072d56729..123935402 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -67,7 +67,7 @@ if ((NOT CONFIG_ZMK_SPLIT) OR CONFIG_ZMK_SPLIT_ROLE_CENTRAL) target_sources_ifdef(CONFIG_ZMK_BEHAVIOR_STUDIO_UNLOCK app PRIVATE src/behaviors/behavior_studio_unlock.c) target_sources_ifdef(CONFIG_ZMK_BEHAVIOR_INPUT_TWO_AXIS app PRIVATE src/behaviors/behavior_input_two_axis.c) target_sources(app PRIVATE src/combo.c) - target_sources(app PRIVATE src/behaviors/behavior_tap_dance.c) + target_sources_ifdef(CONFIG_ZMK_BEHAVIOR_TAP_DANCE app PRIVATE src/behaviors/behavior_tap_dance.c) target_sources(app PRIVATE src/behavior_queue.c) target_sources(app PRIVATE src/conditional_layer.c) target_sources(app PRIVATE src/endpoints.c) diff --git a/app/Kconfig.behaviors b/app/Kconfig.behaviors index 5002bcac4..da9bcc41a 100644 --- a/app/Kconfig.behaviors +++ b/app/Kconfig.behaviors @@ -51,13 +51,11 @@ 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 @@ -82,7 +80,6 @@ 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 @@ -93,6 +90,21 @@ config ZMK_BEHAVIOR_SOFT_OFF default y depends on DT_HAS_ZMK_BEHAVIOR_SOFT_OFF_ENABLED && ZMK_PM_SOFT_OFF + +config ZMK_BEHAVIOR_TAP_DANCE + bool + default y + depends on DT_HAS_ZMK_BEHAVIOR_TAP_DANCE_ENABLED + +if ZMK_BEHAVIOR_TAP_DANCE + +config ZMK_BEHAVIOR_TAP_DANCE_MAX_HELD + int "Tap-Dance Max Held" + help + Max number of simultaneously held taps-dances + +endif + config ZMK_BEHAVIOR_INPUT_TWO_AXIS bool default y diff --git a/app/Kconfig.defaults b/app/Kconfig.defaults index 02d845f1b..5105eefb1 100644 --- a/app/Kconfig.defaults +++ b/app/Kconfig.defaults @@ -12,6 +12,32 @@ endif config ZMK_HID_CONSUMER_REPORT_SIZE default 6 +# Behaviors + +if ZMK_BEHAVIOR_HOLD_TAP + +config ZMK_BEHAVIOR_HOLD_TAP_MAX_HELD + default 10 + +config ZMK_BEHAVIOR_HOLD_TAP_MAX_CAPTURED_EVENTS + default 40 + +endif + +if ZMK_BEHAVIOR_STICKY_KEY + +config ZMK_BEHAVIOR_STICKY_KEY_MAX_HELD + default 10 + +endif + +if ZMK_BEHAVIOR_TAP_DANCE + +config ZMK_BEHAVIOR_TAP_DANCE_MAX_HELD + default 10 + +endif + # Underglow if ZMK_RGB_UNDERGLOW diff --git a/app/src/behaviors/behavior_tap_dance.c b/app/src/behaviors/behavior_tap_dance.c index 5423f93f7..bbc301f1e 100644 --- a/app/src/behaviors/behavior_tap_dance.c +++ b/app/src/behaviors/behavior_tap_dance.c @@ -21,7 +21,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) -#define ZMK_BHV_TAP_DANCE_MAX_HELD 10 +#define ZMK_BHV_TAP_DANCE_MAX_HELD CONFIG_ZMK_BEHAVIOR_TAP_DANCE_MAX_HELD #define ZMK_BHV_TAP_DANCE_POSITION_FREE UINT32_MAX diff --git a/docs/docs/config/behaviors.md b/docs/docs/config/behaviors.md index 7df6d1766..6a6837df7 100644 --- a/docs/docs/config/behaviors.md +++ b/docs/docs/config/behaviors.md @@ -325,6 +325,12 @@ Creates a custom behavior that triggers a different behavior corresponding to th See the [tap dance behavior](../keymaps/behaviors/tap-dance.mdx) documentation for more details and examples. +### Kconfig + +| Config | Type | Description | Default | +| ---------------------------------------- | ---- | ---------------------------------------------- | ------- | +| `CONFIG_ZMK_BEHAVIOR_TAP_DANCE_MAX_HELD` | int | Maximum number of simultaneous held tap-dances | 10 | + ### Devicetree Definition file: [zmk/app/dts/bindings/behaviors/zmk,behavior-tap-dance.yaml](https://github.com/zmkfirmware/zmk/blob/main/app/dts/bindings/behaviors/zmk%2Cbehavior-tap-dance.yaml)