mirror of
https://github.com/zmkfirmware/zmk.git
synced 2026-03-20 04:55:20 -05:00
feat: hold/tap flavor tap-unless-interrupted
Implements new hold/tap flavor, tap-unless-interrupted Adds tests Adds docs
This commit is contained in:
@@ -34,6 +34,7 @@ enum flavor {
|
||||
FLAVOR_HOLD_PREFERRED,
|
||||
FLAVOR_BALANCED,
|
||||
FLAVOR_TAP_PREFERRED,
|
||||
FLAVOR_TAP_UNLESS_INTERRUPTED,
|
||||
};
|
||||
|
||||
enum status {
|
||||
@@ -258,6 +259,26 @@ static void decide_tap_preferred(struct active_hold_tap *hold_tap, enum decision
|
||||
}
|
||||
}
|
||||
|
||||
static void decide_tap_unless_interrupted(struct active_hold_tap *hold_tap,
|
||||
enum decision_moment event) {
|
||||
switch (event) {
|
||||
case HT_KEY_UP:
|
||||
hold_tap->status = STATUS_TAP;
|
||||
return;
|
||||
case HT_OTHER_KEY_DOWN:
|
||||
hold_tap->status = STATUS_HOLD_INTERRUPT;
|
||||
return;
|
||||
case HT_TIMER_EVENT:
|
||||
hold_tap->status = STATUS_TAP;
|
||||
return;
|
||||
case HT_QUICK_TAP:
|
||||
hold_tap->status = STATUS_TAP;
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void decide_hold_preferred(struct active_hold_tap *hold_tap, enum decision_moment event) {
|
||||
switch (event) {
|
||||
case HT_KEY_UP:
|
||||
@@ -285,6 +306,8 @@ static inline const char *flavor_str(enum flavor flavor) {
|
||||
return "balanced";
|
||||
case FLAVOR_TAP_PREFERRED:
|
||||
return "tap-preferred";
|
||||
case FLAVOR_TAP_UNLESS_INTERRUPTED:
|
||||
return "tap-unless-interrupted";
|
||||
default:
|
||||
return "UNKNOWN FLAVOR";
|
||||
}
|
||||
@@ -420,6 +443,9 @@ static void decide_hold_tap(struct active_hold_tap *hold_tap,
|
||||
case FLAVOR_TAP_PREFERRED:
|
||||
decide_tap_preferred(hold_tap, decision_moment);
|
||||
break;
|
||||
case FLAVOR_TAP_UNLESS_INTERRUPTED:
|
||||
decide_tap_unless_interrupted(hold_tap, decision_moment);
|
||||
break;
|
||||
}
|
||||
|
||||
if (hold_tap->status == STATUS_UNDECIDED) {
|
||||
|
||||
Reference in New Issue
Block a user