forked from kofal.net/zmk
refactor(behaviors): Giving global-quick-tap its own term
Detaching the global-quick-tap functionality from the quick-tap term. This makes way for two improvements: 1. This functionality can be added to combos under a unified name 'global-quick-tap-ms'. 2. This allows users to set a lower term for the 'global-quick-tap' (typically ~100ms), and a higher term for the regular quick-tap (typically ~200ms) This deprecates the global-quick-tap option, however if it is set, the quick-tap-ms value will be copied to global-quick-tap-ms.
This commit is contained in:
committed by
Pete Johanson
parent
aa4cb143bf
commit
2f6abff3bc
@@ -57,7 +57,7 @@ struct behavior_hold_tap_config {
|
||||
char *hold_behavior_dev;
|
||||
char *tap_behavior_dev;
|
||||
int quick_tap_ms;
|
||||
bool global_quick_tap;
|
||||
int global_quick_tap_ms;
|
||||
enum flavor flavor;
|
||||
bool retro_tap;
|
||||
bool hold_trigger_on_release;
|
||||
@@ -97,7 +97,9 @@ struct last_tapped {
|
||||
int64_t timestamp;
|
||||
};
|
||||
|
||||
struct last_tapped last_tapped = {INT32_MIN, INT64_MIN};
|
||||
// Set time stamp to large negative number initially for test suites, but not
|
||||
// int64 min since it will overflow if -1 is added
|
||||
struct last_tapped last_tapped = {INT32_MIN, INT32_MIN};
|
||||
|
||||
static void store_last_tapped(int64_t timestamp) {
|
||||
if (timestamp > last_tapped.timestamp) {
|
||||
@@ -112,10 +114,11 @@ static void store_last_hold_tapped(struct active_hold_tap *hold_tap) {
|
||||
}
|
||||
|
||||
static bool is_quick_tap(struct active_hold_tap *hold_tap) {
|
||||
if (hold_tap->config->global_quick_tap || last_tapped.position == hold_tap->position) {
|
||||
return (last_tapped.timestamp + hold_tap->config->quick_tap_ms) > hold_tap->timestamp;
|
||||
if ((last_tapped.timestamp + hold_tap->config->global_quick_tap_ms) > hold_tap->timestamp) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
return (last_tapped.position == hold_tap->position) &&
|
||||
(last_tapped.timestamp + hold_tap->config->quick_tap_ms) > hold_tap->timestamp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -703,7 +706,9 @@ static int behavior_hold_tap_init(const struct device *dev) {
|
||||
.hold_behavior_dev = DT_PROP(DT_INST_PHANDLE_BY_IDX(n, bindings, 0), label), \
|
||||
.tap_behavior_dev = DT_PROP(DT_INST_PHANDLE_BY_IDX(n, bindings, 1), label), \
|
||||
.quick_tap_ms = DT_INST_PROP(n, quick_tap_ms), \
|
||||
.global_quick_tap = DT_INST_PROP(n, global_quick_tap), \
|
||||
.global_quick_tap_ms = DT_INST_PROP(n, global_quick_tap) \
|
||||
? DT_INST_PROP(n, quick_tap_ms) \
|
||||
: DT_INST_PROP(n, global_quick_tap_ms), \
|
||||
.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), \
|
||||
|
||||
Reference in New Issue
Block a user