feat(behaviors): On-release option for positional-hold-taps

This commit is contained in:
Robert U
2023-03-12 12:24:00 -04:00
committed by GitHub
parent 8904407983
commit 6cb42a8060
21 changed files with 209 additions and 2 deletions

View File

@@ -60,6 +60,7 @@ struct behavior_hold_tap_config {
bool global_quick_tap;
enum flavor flavor;
bool retro_tap;
bool hold_trigger_on_release;
int32_t hold_trigger_key_positions_len;
int32_t hold_trigger_key_positions[];
};
@@ -587,9 +588,11 @@ static int position_state_changed_listener(const zmk_event_t *eh) {
}
// Store the position of pressed key for positional hold-tap purposes.
if ((ev->state) // i.e. key pressed (not released)
if ((undecided_hold_tap->config->hold_trigger_on_release !=
ev->state) // key has been pressed and hold_trigger_on_release is not set, or key
// has been released and hold_trigger_on_release is set
&& (undecided_hold_tap->position_of_first_other_key_pressed ==
-1) // i.e. no other key has been pressed yet
-1) // no other key has been pressed yet
) {
undecided_hold_tap->position_of_first_other_key_pressed = ev->position;
}
@@ -703,6 +706,7 @@ static int behavior_hold_tap_init(const struct device *dev) {
.global_quick_tap = DT_INST_PROP(n, global_quick_tap), \
.flavor = DT_ENUM_IDX(DT_DRV_INST(n), flavor), \
.retro_tap = DT_INST_PROP(n, retro_tap), \
.hold_trigger_on_release = DT_INST_PROP(n, hold_trigger_on_release), \
.hold_trigger_key_positions = DT_INST_PROP(n, hold_trigger_key_positions), \
.hold_trigger_key_positions_len = DT_INST_PROP_LEN(n, hold_trigger_key_positions), \
}; \