Skip to content

Commit

Permalink
feat: Add config settings for sticky keys/hold-tap
Browse files Browse the repository at this point in the history
* Add new Kconfig symbols to config max held sticky-keys/hold-taps
  and for max captured events during hold-tap resolution.
  • Loading branch information
petejohanson committed Aug 12, 2024
1 parent 2eff266 commit 4e8e271
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
38 changes: 38 additions & 0 deletions app/Kconfig.behaviors
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/src/behaviors/behavior_hold_tap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/src/behaviors/behavior_sticky_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 13 additions & 0 deletions docs/docs/config/behaviors.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 4e8e271

Please sign in to comment.