sane-input-handler: fix unrecoverable terminal state

bonsai is prone to miss inputs during high CPU load.
This commit is contained in:
Colin 2024-05-24 04:29:34 +00:00
parent a6b10244eb
commit 309797fe23

View File

@ -36,11 +36,14 @@ let
in assert terminal -> events == []; events;
# trigger ${button}_hold_N every `holdTime` ms until ${button} is released
recurseHold = button: { count ? 1, maxHolds ? 3, holdTime ? 1000 }@opts: lib.optionalAttrs (count <= maxHolds) {
"${button}_released".terminal = true; # end the hold -> back to root state
ms = holdTime;
recurseHold = button: { count ? 1, maxHolds ? 3, holdTime ? 1000 }@opts: {
trigger = "${button}_hold_${builtins.toString count}";
ms = holdTime;
} // lib.optionalAttrs (count < maxHolds) {
timeout = recurseHold button (opts // { count = count+1; });
# end the hold -> back to root state
# take care to omit this on the last hold though, so that there's always a strictly delay-driven path back to root
"${button}_released".terminal = true;
};
in
{