Skip to content

Latest commit

 

History

History
72 lines (55 loc) · 4.86 KB

AGENTS.md

File metadata and controls

72 lines (55 loc) · 4.86 KB

AGENTS.md

Reads Forza Horizon's UDP telemetry (port 5300) and drives DualSense adaptive triggers over raw HID. Rumble bytes are left alone so Steam Input keeps handling rumble. Python 3.13+, uv, Windows + Linux. Shipped as one file, fhds.zuv.py, built with zuv.

Run and build

cd src; uv run main.py                                   # dev, from source
uvx --from "zuv~=0.6.1" zuv src -o app/fhds.zuv.py       # bundle, same as CI (from the repo root)
$env:ZUV_AUTO_UPDATE="0"; uv run app/fhds.zuv.py         # run it without the update check
.\win_start.bat                                          # what users run (Linux: ./linux_start.sh)

In game: Settings -> HUD and Gameplay -> Data Out ON, IP 127.0.0.1, port 5300 (the app's udp_host / udp_port; IPv6: ::1, another PC: 0.0.0.0 or ::).

Always test before reporting or merging

  1. From source: cd src; uv run main.py, plus --headless or --tui if you touched those paths.
  2. As a bundle: build with the command above, run it from a scratch folder with ZUV_AUTO_UPDATE=0.
  3. Release or update changes: push to dev with prerelease in the commit message, download the prerelease (releases/download/v999.0.0/fhds.zuv.py) and run it. Only then merge to main.

Releases (.github/workflows/release.yml)

trigger result
push with prerelease in the commit subject, or the Run workflow button prerelease at src/pyproject.toml's version if it's ahead of the latest stable (2.0.0 over v1.6.2 -> v2.0.0), else the next patch; also uploaded to the rolling v999.0.0 prerelease
push to main with release vX.Y.Z in the subject, or a vX.Y.Z tag stable vX.Y.Z

The workflow sets version in src/pyproject.toml from the tag. Stable bundles update from releases/latest, prerelease bundles from v999.0.0. Launchers download from the same place (PRERELEASE=true for the prerelease channel).

Bundle layout (zuv 0.6)

app/fhds.zuv.py unpacks to app/.zuv/fhds/ (= paths.ROOT). Its volume data/ (= paths.VOLUME, user_preferences.json) survives updates. zuv passes ZUV_SETTINGS = app/.zuv/fhds.json; the System tab's update toggle sets auto_update in it (preferences.apply_update_check). ZUV_AUTO_UPDATE=1|0 overrides the toggle.

Code map

want to... open
change a tunable or switch an effect off src/modules/config/settings.py (all tunables live here)
change persistence / profiles src/modules/config/preferences.py, profiles.py; paths in paths.py
change how an effect feels src/modules/dualsense/adaptive_trigger.py (primitives; the unused ones and the preview are kept on purpose), src/modules/forzahorizon/trigger_effects.py (game logic)
touch raw HID bytes src/modules/dualsense/device.py (report() builds every output report)
add a telemetry field src/modules/forzahorizon/telemetry.py (parse_packet maps the whole packet; UDPListener receives and forwards)
per-packet loop src/modules/loop.py; exit-with-game in forzahorizon/game_watch.py
haptics (game sound -> actuators, USB and Bluetooth) src/modules/dualsense/haptics.py; report 0x32 in dualsense/device.py (haptics_report)
DSX mode src/modules/dsx/: trigger_to_dsx.py (trigger frames -> DSX packets), client.py (UDP; resends every 3 s because DSX drops mod changes ~60 s after the last packet; reads DSX answers and port file)
backend start / stop / hot-swap, saving a setting src/modules/session.py (shared by GUI, TUI, --headless)
what a settings screen shows src/modules/config/schema.py (shared by GUI and TUI)
UI src/modules/gui/ (Qt) and src/modules/tui/ (Textual): each app.py + pages.py + widgets.py
add or translate a language src/lang/<code>.json (name + strings, keyed by English); from src: python -m lang [code] syncs them with the code (new strings as blanks, a new code makes its file); the Language tab switches live
CLI / startup src/main.py

Frame: UDP 5300 -> parse_packet -> TriggerEffects.update -> (left, right) -> DualSense.set (on change only). Trigger frame = (mode, params): M_OFF 0x05, M_RIGID 0x01 force, M_VIBRATE 0x06 buzz, M_RIGID_ZONES 0x21, M_VIBRATE_ZONES 0x26.

Rules

  • KISS: no abstraction for one caller. All tunables in settings.py.
  • Globals stay global: add to preferences.GLOBAL_FIELDS, never copy into per-profile dicts.
  • Never touch rumble bits; the HID writer only flips trigger bits in valid_flag0.
  • Always drain UDP with recv_latest(); write to the controller only when (left, right) changed.
  • HidHide: never call HidHideCLI.exe. hidhide.is_detected() only probes the filesystem; when it's true the I/O loop keeps the HID handle open (persistent mode) so cloaking mid-session can't drop it.
  • UTF-8 files. No em dashes anywhere: plain hyphens only.