5798caef37457aa8a59a2f5f7a7487c2578cd1f3
Strace post-deploy showed the daemon flipping every other packet between in-race state (mode 0x21 FEEDBACK + LED green) and out-of-race state (mode 0x05 OFF + LED black). 8 writes, 8 transitions in 5s — every HID OUT report a state change. Root cause: FH5 emits packets where the is_race_on field alternates True/False at packet rate during menu/loading/transition states. Cosmii's RPM_ACCUMULATOR debounce only handles the 'flag stuck True when we're really in a menu' case (quirk #1); it does nothing for 'flag flipping at packet rate' (quirk #2). Fix: split the read from the hysteresis. is_race_on now returns the raw flag with quirk #1 applied. commit_in_race applies a packet-count hysteresis (IN_RACE_HYSTERESIS_PACKETS = 30 ≈ 0.5s at 60Hz) — only after N consecutive packets of the new value does the committed in-race state flip. Alternation just keeps the pending counter oscillating near 0; it never reaches threshold and the run-loop sees a stable state. Architecture: hysteresis in a separate function (not in is_race_on) because the run-loop must update state.last_in_race AFTER side effects, not before — otherwise the elif transition-detection breaks. is_race_on stays pure read; commit_in_race is the gatekeeper; run-loop sets state.last_in_race once at end of packet handling. Tests grew 54→58. New TestCommitInRace covers: - stable input (no pending growth) - worst-case alternation (never commits) - N consecutive packets commit - matching raw resets pending counter TestIsRaceOn renamed to reflect new (narrower) responsibility.
My NixOS configs ✨
Hosts
- mreow: My personal Framework 13 laptop
- yarn: Machine I usually just play games on. Boots into SteamOS-like interface.
- muffin: Homeserver, runs various services.
Desktop/Laptop
What do I use?
Browser: Firefox 🦊 (actually Zen Browser :p)
Text Editor: Doom Emacs
Terminal: ghostty
Shell: fish with the pure prompt
WM: niri
Background
- Got my background from here and used the command
magick input.png -filter Point -resize 2880x1920! output.pngto upscale it bilinearly
Description
Languages
Nix
77.5%
Python
17.2%
Shell
3.5%
Emacs Lisp
1.8%