Skip to content

Commit

Permalink
Add a flag for caps_word to discontinue when a mod is pressed
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel2887 committed Jun 22, 2024
1 parent a6e6f75 commit e3dee05
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/dts/bindings/behaviors/zmk,behavior-caps-word.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ properties:
type: int
timeout:
type: int
break-on-mod:
type: boolean
4 changes: 3 additions & 1 deletion app/src/behaviors/behavior_caps_word.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ struct behavior_caps_word_config {
zmk_mod_flags_t mods;
uint8_t index;
uint8_t timeout;
bool break_on_mod;
uint8_t continuations_count;
struct caps_word_continue_item continuations[];
};
Expand Down Expand Up @@ -166,7 +167,7 @@ static int caps_word_keycode_state_changed_listener(const zmk_event_t *eh) {
caps_word_enhance_usage(config, ev);

if (!caps_word_is_alpha(ev->keycode) && !caps_word_is_numeric(ev->keycode) &&
!is_mod(ev->usage_page, ev->keycode) &&
!(is_mod(ev->usage_page, ev->keycode) && !config->break_on_mod) &&
!caps_word_is_caps_includelist(config, ev->usage_page, ev->keycode,
ev->implicit_modifiers)) {
LOG_DBG("Deactivating caps_word for 0x%02X - 0x%02X", ev->usage_page, ev->keycode);
Expand Down Expand Up @@ -221,6 +222,7 @@ static int behavior_caps_word_init(const struct device *dev) {
.continuations = {LISTIFY(DT_INST_PROP_LEN(n, continue_list), BREAK_ITEM, (, ), n)}, \
.continuations_count = DT_INST_PROP_LEN(n, continue_list), \
.timeout = DT_INST_PROP_OR(n, timeout, 0), \
.break_on_mod = DT_INST_PROP(n, break_on_mod), \
}; \
BEHAVIOR_DT_INST_DEFINE(n, behavior_caps_word_init, NULL, &behavior_caps_word_data_##n, \
&behavior_caps_word_config_##n, POST_KERNEL, \
Expand Down

0 comments on commit e3dee05

Please sign in to comment.