@@ -49,15 +49,15 @@ enum decision_moment {
49
49
HT_OTHER_KEY_DOWN ,
50
50
HT_OTHER_KEY_UP ,
51
51
HT_TIMER_EVENT ,
52
- HT_QUICK_TAP ,
52
+ HT_IMMEDIATE_TAP ,
53
53
};
54
54
55
55
struct behavior_hold_tap_config {
56
56
int tapping_term_ms ;
57
57
char * hold_behavior_dev ;
58
58
char * tap_behavior_dev ;
59
59
int quick_tap_ms ;
60
- bool global_quick_tap ;
60
+ int min_prior_ms ;
61
61
enum flavor flavor ;
62
62
bool retro_tap ;
63
63
int32_t hold_trigger_key_positions_len ;
@@ -96,7 +96,9 @@ struct last_tapped {
96
96
int64_t timestamp ;
97
97
};
98
98
99
- struct last_tapped last_tapped = {INT32_MIN , INT64_MIN };
99
+ // Set time stamp to large negative number initially for test suites, but not
100
+ // int64 min since it will overflow if -1 is added
101
+ struct last_tapped last_tapped = {INT32_MIN , INT32_MIN };
100
102
101
103
static void store_last_tapped (int64_t timestamp ) {
102
104
if (timestamp > last_tapped .timestamp ) {
@@ -110,11 +112,12 @@ static void store_last_hold_tapped(struct active_hold_tap *hold_tap) {
110
112
last_tapped .timestamp = hold_tap -> timestamp ;
111
113
}
112
114
113
- static bool is_quick_tap (struct active_hold_tap * hold_tap ) {
114
- if (hold_tap -> config -> global_quick_tap || last_tapped . position == hold_tap -> position ) {
115
- return ( last_tapped . timestamp + hold_tap -> config -> quick_tap_ms ) > hold_tap -> timestamp ;
115
+ static bool is_immediate_tap (struct active_hold_tap * hold_tap ) {
116
+ if (( last_tapped . timestamp + hold_tap -> config -> min_prior_ms ) > hold_tap -> timestamp ) {
117
+ return true ;
116
118
} else {
117
- return false;
119
+ return (last_tapped .position == hold_tap -> position ) &&
120
+ (last_tapped .timestamp + hold_tap -> config -> quick_tap_ms ) > hold_tap -> timestamp ;
118
121
}
119
122
}
120
123
@@ -247,7 +250,7 @@ static void decide_balanced(struct active_hold_tap *hold_tap, enum decision_mome
247
250
case HT_TIMER_EVENT :
248
251
hold_tap -> status = STATUS_HOLD_TIMER ;
249
252
return ;
250
- case HT_QUICK_TAP :
253
+ case HT_IMMEDIATE_TAP :
251
254
hold_tap -> status = STATUS_TAP ;
252
255
return ;
253
256
default :
@@ -263,7 +266,7 @@ static void decide_tap_preferred(struct active_hold_tap *hold_tap, enum decision
263
266
case HT_TIMER_EVENT :
264
267
hold_tap -> status = STATUS_HOLD_TIMER ;
265
268
return ;
266
- case HT_QUICK_TAP :
269
+ case HT_IMMEDIATE_TAP :
267
270
hold_tap -> status = STATUS_TAP ;
268
271
return ;
269
272
default :
@@ -283,7 +286,7 @@ static void decide_tap_unless_interrupted(struct active_hold_tap *hold_tap,
283
286
case HT_TIMER_EVENT :
284
287
hold_tap -> status = STATUS_TAP ;
285
288
return ;
286
- case HT_QUICK_TAP :
289
+ case HT_IMMEDIATE_TAP :
287
290
hold_tap -> status = STATUS_TAP ;
288
291
return ;
289
292
default :
@@ -302,7 +305,7 @@ static void decide_hold_preferred(struct active_hold_tap *hold_tap, enum decisio
302
305
case HT_TIMER_EVENT :
303
306
hold_tap -> status = STATUS_HOLD_TIMER ;
304
307
return ;
305
- case HT_QUICK_TAP :
308
+ case HT_IMMEDIATE_TAP :
306
309
hold_tap -> status = STATUS_TAP ;
307
310
return ;
308
311
default :
@@ -348,8 +351,8 @@ static inline const char *decision_moment_str(enum decision_moment decision_mome
348
351
return "other-key-down" ;
349
352
case HT_OTHER_KEY_UP :
350
353
return "other-key-up" ;
351
- case HT_QUICK_TAP :
352
- return "quick-tap " ;
354
+ case HT_IMMEDIATE_TAP :
355
+ return "immediate " ;
353
356
case HT_TIMER_EVENT :
354
357
return "timer" ;
355
358
default :
@@ -527,8 +530,8 @@ static int on_hold_tap_binding_pressed(struct zmk_behavior_binding *binding,
527
530
LOG_DBG ("%d new undecided hold_tap" , event .position );
528
531
undecided_hold_tap = hold_tap ;
529
532
530
- if (is_quick_tap (hold_tap )) {
531
- decide_hold_tap (hold_tap , HT_QUICK_TAP );
533
+ if (is_immediate_tap (hold_tap )) {
534
+ decide_hold_tap (hold_tap , HT_IMMEDIATE_TAP );
532
535
}
533
536
534
537
// if this behavior was queued we have to adjust the timer to only
@@ -696,7 +699,8 @@ static int behavior_hold_tap_init(const struct device *dev) {
696
699
.hold_behavior_dev = DT_LABEL(DT_INST_PHANDLE_BY_IDX(n, bindings, 0)), \
697
700
.tap_behavior_dev = DT_LABEL(DT_INST_PHANDLE_BY_IDX(n, bindings, 1)), \
698
701
.quick_tap_ms = DT_INST_PROP(n, quick_tap_ms), \
699
- .global_quick_tap = DT_INST_PROP(n, global_quick_tap), \
702
+ .min_prior_ms = DT_INST_PROP(n, global_quick_tap) ? DT_INST_PROP(n, quick_tap_ms) \
703
+ : DT_INST_PROP(n, min_prior_ms), \
700
704
.flavor = DT_ENUM_IDX(DT_DRV_INST(n), flavor), \
701
705
.retro_tap = DT_INST_PROP(n, retro_tap), \
702
706
.hold_trigger_key_positions = DT_INST_PROP(n, hold_trigger_key_positions), \
0 commit comments