forza-trigger: drop pedal-off early-returns (root cause of "no reaction")

Live diagnostic on yarn revealed the daemon was receiving 324-byte FH5
packets correctly (5.7MB on the systemd socket; strace showed steady
recvfrom + write to /dev/hidraw7) but writing trigger mode 0x05
(no-resistance) on nearly every tick. Cause: `accel` and `brake` are
0 most of the time during normal play (off-throttle on straight
sections, off-brake when not braking). Both handlers had:

  if accel/255 <= THROTTLE_INPUT_THRESHOLD: effect.off(); return
  if brake/255 <= BRAKE_INPUT_THRESHOLD:    effect.off(); return

Every off-pedal packet set the trigger to OFF. Brief pedal-on moments
set vibration. The result: rapidly oscillating off↔vibration state,
imperceptible at 60 Hz packet rate.

These early-returns were holdovers from the previous Race-Element 1:1
port (variant A), which IS designed to be silent unless slipping.
Variant D's whole point is "always feels something" — Cosmii has no
pedal-off gate, and its baseline branch produces feedback even at
brake=0/accel=0 with strength clamped to MIN.

Fix: remove both early-returns. Foot-off-pedal flows through the
baseline branch and produces feedback(strength=MIN_*_RESISTANCE). The
user feels light constant resistance instead of silence. Trigger only
returns to physical-rest when out-of-race (run-loop's reset_triggers).

Also drop the now-dead BRAKE_INPUT_THRESHOLD / THROTTLE_INPUT_THRESHOLD
constants. Two tests renamed and updated to assert MIN-strength
baseline feedback instead of effect.off() on zero pedal.

54/54 tests pass. Build clean.
This commit is contained in:
2026-05-07 14:18:47 -04:00
parent e159f4d90f
commit 11d283585c
2 changed files with 16 additions and 18 deletions

View File

@@ -205,12 +205,16 @@ class TestIsRaceOn(unittest.TestCase):
class TestHandleThrottle(unittest.TestCase):
def test_zero_pedal_turns_off(self):
def test_zero_pedal_baseline_min_feedback(self):
# Foot off throttle should NOT turn the trigger off — variant D's
# design is "always feels something". Baseline mode still fires
# with strength = MIN_THROTTLE_RESISTANCE so the user feels light
# constant resistance under the finger. The run-loop is the only
# place that calls effect.off() (out-of-race idle reset).
c = FakeController()
s = ft.DaemonState()
ft.handle_throttle(c, FakePacket(accel=0.0), s)
self.assertEqual(c.calls, [("R2", "off")])
self.assertEqual(c.calls, [("R2", "feedback", 0, ft.MIN_THROTTLE_RESISTANCE)])
def test_baseline_under_normal_acceleration(self):
c = FakeController()
s = ft.DaemonState()
@@ -276,11 +280,12 @@ class TestHandleThrottle(unittest.TestCase):
class TestHandleBrake(unittest.TestCase):
def test_zero_pedal_turns_off(self):
def test_zero_pedal_baseline_min_feedback(self):
# Same as throttle — foot off brake = light constant resistance, not off.
c = FakeController()
s = ft.DaemonState()
ft.handle_brake(c, FakePacket(brake=0.0), s)
self.assertEqual(c.calls, [("L2", "off")])
self.assertEqual(c.calls, [("L2", "feedback", 0, ft.MIN_BRAKE_RESISTANCE)])
def test_baseline_under_normal_braking(self):
c = FakeController()