diff options
author | jding <jding@roblox.com> | 2021-11-06 21:31:23 +0000 |
---|---|---|
committer | Pete Johanson <peter@peterjohanson.com> | 2021-11-09 01:07:05 -0500 |
commit | 4e62319982ea258741eca2b79cf952fe7b8d6b3b (patch) | |
tree | 9bdf9b45b65d4a05942e6f0f6458d6645f898b48 /app/src/behaviors/behavior_hold_tap.c | |
parent | f2e0642291621611f3abce69f73a22c33b1ce801 (diff) |
feat: hold/tap flavor tap-unless-interrupted
Implements new hold/tap flavor, tap-unless-interrupted
Adds tests
Adds docs
Diffstat (limited to 'app/src/behaviors/behavior_hold_tap.c')
-rw-r--r-- | app/src/behaviors/behavior_hold_tap.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/app/src/behaviors/behavior_hold_tap.c b/app/src/behaviors/behavior_hold_tap.c index 1871df7..548d6ef 100644 --- a/app/src/behaviors/behavior_hold_tap.c +++ b/app/src/behaviors/behavior_hold_tap.c @@ -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) { |