From c239ab1353da0cb687a922962ff73dd94b3d665d Mon Sep 17 00:00:00 2001 From: snoyer Date: Sun, 9 Oct 2022 04:11:02 +0000 Subject: [PATCH] fix verbiage and docs --- app/dts/behaviors/capslock.dtsi | 4 +- .../behaviors/zmk,behavior-capslock.yaml | 2 +- app/src/behaviors/behavior_capslock.c | 6 +- docs/docs/behaviors/caps-word.md | 20 ++++ docs/docs/behaviors/capslock.md | 98 ++++++------------- 5 files changed, 54 insertions(+), 76 deletions(-) create mode 100644 docs/docs/behaviors/caps-word.md diff --git a/app/dts/behaviors/capslock.dtsi b/app/dts/behaviors/capslock.dtsi index c0662a7b..d2558787 100644 --- a/app/dts/behaviors/capslock.dtsi +++ b/app/dts/behaviors/capslock.dtsi @@ -39,8 +39,8 @@ #binding-cells = <0>; bindings = <&kp CAPSLOCK>; enable-on-press; - disable-on-second-press; - disable-on-keys = ; + disable-on-next-release; + disable-on-keys = ; }; }; }; diff --git a/app/dts/bindings/behaviors/zmk,behavior-capslock.yaml b/app/dts/bindings/behaviors/zmk,behavior-capslock.yaml index fa4a476f..9f5d75b1 100644 --- a/app/dts/bindings/behaviors/zmk,behavior-capslock.yaml +++ b/app/dts/bindings/behaviors/zmk,behavior-capslock.yaml @@ -12,7 +12,7 @@ properties: type: boolean disable-on-release: type: boolean - disable-on-second-press: + disable-on-next-release: type: boolean disable-on-keys: type: array diff --git a/app/src/behaviors/behavior_capslock.c b/app/src/behaviors/behavior_capslock.c index 28300a96..0ae387ef 100644 --- a/app/src/behaviors/behavior_capslock.c +++ b/app/src/behaviors/behavior_capslock.c @@ -35,7 +35,7 @@ struct behavior_capslock_config { struct zmk_behavior_binding capslock_binding; bool enable_on_press; bool disable_on_release; - bool disable_on_second_press; + bool disable_on_next_release; uint8_t disable_on_keys_count; struct capslock_key_item disable_on_keys[]; }; @@ -104,7 +104,7 @@ static int on_capslock_binding_released(struct zmk_behavior_binding *binding, const struct behavior_capslock_config *config = dev->config; struct behavior_capslock_data *data = dev->data; - if (config->disable_on_release || (config->disable_on_second_press && !data->just_activated)) { + if (config->disable_on_release || (config->disable_on_next_release && !data->just_activated)) { deactivate_capslock(dev); } @@ -201,7 +201,7 @@ static int behavior_capslock_init(const struct device *dev) { .capslock_binding = _TRANSFORM_ENTRY(0, n), \ .enable_on_press = DT_INST_PROP(n, enable_on_press), \ .disable_on_release = DT_INST_PROP(n, disable_on_release), \ - .disable_on_second_press = DT_INST_PROP(n, disable_on_second_press), \ + .disable_on_next_release = DT_INST_PROP(n, disable_on_next_release), \ .disable_on_keys = {UTIL_LISTIFY(DT_INST_PROP_LEN(n, disable_on_keys), BREAK_ITEM, n)}, \ .disable_on_keys_count = DT_INST_PROP_LEN(n, disable_on_keys), \ }; \ diff --git a/docs/docs/behaviors/caps-word.md b/docs/docs/behaviors/caps-word.md new file mode 100644 index 00000000..99b67843 --- /dev/null +++ b/docs/docs/behaviors/caps-word.md @@ -0,0 +1,20 @@ +--- +title: Caps Word Behavior +sidebar_label: Caps Word +--- + +## Summary + +The caps word behavior behaves similar to a caps lock, but will automatically deactivate when any key in a word separator list is pressed, or if the caps word key is pressed again. + +### Behavior Binding + +- Reference: `&caps_word` + +Example: + +``` +&caps_word +``` + +See [caps lock](/docs/behaviors/capslock) diff --git a/docs/docs/behaviors/capslock.md b/docs/docs/behaviors/capslock.md index e751b0c2..46a68285 100644 --- a/docs/docs/behaviors/capslock.md +++ b/docs/docs/behaviors/capslock.md @@ -5,96 +5,54 @@ sidebar_label: Caps Lock ## Summary -This set of behaviors offers enhahced versions of the caps lock key. - - -## Caps On - -Enables caps lock when pressed, regarless of the current caps lock state. +The caps lock behavior provides an improved caps lock key. +Pressing the regular caps lock key toggles the state of caps lock on the host machine, this behavior offers more control on how and when caps lock get activated and deactivated, regardless of the current status on the host machine. ### Behavior Binding -- Reference: `&caps_on` -Example: +Four pre-configured instances are provided: -``` -&caps_on -``` - - -## Caps Off - -Disables caps lock when released, regarless of the current caps lock state. - -### Behavior Binding -- Reference: `&caps_off` - -Example: - -``` -&caps_off -``` - - -## Caps Hold - -Enables caps lock when pressed, and disables it when released. - -### Behavior Binding -- Reference: `&caps_hold` - -Example: - -``` -&caps_hold -``` - - -## Caps Word - -Enables caps lock when pressed, and deactivate it when any key in the break list is pressed, or if the caps word key is pressed again. - -### Behavior Binding -- Reference: `&caps_word` - -Example: - -``` -&caps_word -``` +- `&caps_on` enables caps lock +- `&caps_off` disables caps lock +- `&caps_hold` enables caps lock while held, and disables it when released +- `&caps_word` enables caps lock, and disables it when a word separator is typed or the key is pressed again ### Configuration -#### Word Separators +The following options allow to customize the caps lock behavior: -By default, the caps word will remain active until space (`SPACE`), tab (`TAB`), enter (`ENTER`), or escape (`ESCAPE`) is pressed. If you would like to override this, you can set a new array of keys in the `disable-on-keys` property in your keymap: +- `enable-on-press`: whether to enable caps lock when the key is pressed +- `disable-on-release`: whether to disable caps lock when the key is released +- `disable-on-next-release`: whether to disable caps lock when the key is released a second time +- `disable-on-keys`: list of keys after which caps lock is disabled + +### Examples + +The pre-configured `caps_word` enables caps lock when pressed, and disables it when `SPACE`, `TAB`, or `ENTER` is pressed, or the key is pressed again. ``` -&caps_word { - disable-on-keys = ; -}; - -/ { - keymap { - ... - }; +caps_word: behavior_caps_word { + compatible = "zmk,behavior-capslock"; + label = "CAPS_WORD"; + #binding-cells = <0>; + bindings = <&kp CAPSLOCK>; + enable-on-press; + disable-on-next-release; + disable-on-keys = ; }; ``` -### Multiple Caps Words - -If you want to use multiple caps words with different word separators, you can add additional caps word instances to use in your keymap: +A key to activate caps lock and disable it only after typing a whole line can be defined as: ``` / { - prog_caps: behavior_prog_caps_word { + prog_caps: caps_line { compatible = "zmk,behavior-capslock"; - label = "CAPS_WORD"; + label = "CAPS_LINE"; #binding-cells = <0>; bindings = <&kp CAPSLOCK>; enable-on-press; - disable-on-second-press; - disable-on-keys = ; + disable-on-keys = ; }; keymap {