diff --git a/hosts/common/programs/sane-input-handler/default.nix b/hosts/common/programs/sane-input-handler/default.nix index acfe48d49..2f348cd8e 100644 --- a/hosts/common/programs/sane-input-handler/default.nix +++ b/hosts/common/programs/sane-input-handler/default.nix @@ -35,10 +35,16 @@ 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: { + # trigger ${button}_hold_N repeatedly for as long as ${button} is held. + # ${holdTimes[N]}: how long to wait after the N'th event before firing the event again. + # if the holdTimes list has fewer items than `maxHolds`, then the list is extended by duplicating its last item. + recurseHold = button: { count ? 1, maxHolds ? 5, holdTimes ? [ 500 3000 ] }@opts: { trigger = "${button}_hold_${builtins.toString count}"; - ms = holdTime; + ms = if count <= builtins.length holdTimes then + builtins.elemAt holdTimes (count - 1) + else + lib.last holdTimes + ; } // lib.optionalAttrs (count < maxHolds) { timeout = recurseHold button (opts // { count = count+1; }); # end the hold -> back to root state @@ -130,11 +136,11 @@ in # map: power (tap), power (tap) x2 power_pressed.power_released.trigger = "power_tap_1"; - power_pressed.power_released.timeout.ms = 600; # max time within which a second power press will be recognized + power_pressed.power_released.timeout.ms = 750; # max time within which a second power press will be recognized power_pressed.power_released.power_pressed.power_released.trigger = "power_tap_2"; # map power (hold), power tap -> hold: power_pressed.timeout.trigger = "power_hold"; - power_pressed.timeout.ms = 600; + power_pressed.timeout.ms = 500; power_pressed.power_released.power_pressed.timeout.trigger = "power_tap_1_hold"; power_pressed.power_released.power_pressed.timeout.ms = 750; # this is a long timeout because it's tied to the "kill window" action.