feat: hold/tap flavor tap-unless-interrupted

Implements new hold/tap flavor, tap-unless-interrupted
Adds tests
Adds docs
This commit is contained in:
jding
2021-11-06 21:31:23 +00:00
committed by Pete Johanson
parent f2e0642291
commit 4e62319982
40 changed files with 415 additions and 3 deletions

View File

@@ -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) {