gameinput, xgameruntime, tools: add scripted input, profile auto-select, and game harness #517

Open
glovepost wants to merge 1 commit from upstream-pr/517 into main
glovepost commented 2026-11-29 18:53:08 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by glovepost on 2026-11-29T18:53:08Z.


Summary

Adds a live scripted input channel to gameinput, a paired profile auto-select trigger between xgameruntime and gameinput, and an automated game test harness (tools/game_harness.py):

  • Profile auto-select (runtime/xgameruntime, runtime/gameinput, docs/ENVIRONMENT.md): Arms a per-process manual-reset Win32 event (Local\TuxBoxAutoSelectProfile_<pid>) on the user_gamertag account prompt and disarms it on save enumeration when TUXBOX_AUTO_SELECT_PROFILE is set, driving periodic A pulses in gameinput's AutoConfirm helper while keeping hold(...) / missing grace windows intact.
  • Scripted input channel (runtime/gameinput/src/{lib.rs,sample.rs,tests/sample.rs}, docs/ENVIRONMENT.md): Adds ScriptedInput (TUXBOX_INPUT_SCRIPT) reading line-delimited commands (press, down, up, stick, trigger, wait, reset) from a file path or localhost TCP socket to inject controller state alongside live hardware/keyboard input.
  • Automated harness (tools/game_harness.py, tools/scenarios/scarlett_boot_to_gameplay.json, tests/test_game_harness.py): Launches the title via a launch script with scripted input scenarios, frame-hash stall detection, stderr/stdout log matching, and milestone reporting.

Prepared with AI assistance; all changes were reviewed and verified on host unit tests, Wine crate unit tests, and both NVIDIA and AMD GPUs.

Tested

Run the checks relevant to this change.

  • The checks relevant to this change passed
  • Changed or new behaviour is covered by a Lanes scenario, or the reason it cannot be is stated below
  • Where the table calls for AMD and NVIDIA, they passed on both. Otherwise, say which vendor still needs to run them:

This adds controller input injection, xgameruntime account-prompt signaling, and a launch harness rather than GPU shader or command-list rendering paths, so no new Lanes scenario applies. Behaviour is covered by the Wine unit tests in tuxbox-gameinput (10/10) and tuxbox-xgameruntime (6/6), tests/test_game_harness.py + tests/test_repository_hygiene.py, and the xgameruntime, guest-frame, and present verify suites on both NVIDIA and AMD.

GPU, driver and backend:

  • NVIDIA GeForce RTX 2070 SUPER (10de:1e84), driver 620.73.04, GE-Proton11-14 (vkd3d-proton)
  • AMD Ryzen 7 9800X3D iGPU (1002:13c0), RADV / Mesa 26.3.1, GE-Proton11-14 (vkd3d-proton)

Commands run and their results:

DXC=<dxc> python3 tuxbox.py check --no-gpu
  -> 7/7 passed (Python 701 tests OK; shader compiler 625 passed; DXBC 109 passed; XG layout 17 passed, 1 ignored; storage codec 18 passed; D3D12 Windows typecheck passed)

CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_RUNNER=wine cargo xwin test --locked --target x86_64-pc-windows-msvc -p tuxbox-gameinput -p tuxbox-xgameruntime --lib
  -> tuxbox-gameinput: 10/10 passed; tuxbox-xgameruntime: 6/6 passed

TUXBOX_CHECK_JOBS=4 python3 tuxbox.py verify --backend proton --adapter 10de:1e84 --only xgameruntime --only guest-frame --only present --output <out>
  -> 13/13 passed

TUXBOX_CHECK_JOBS=4 python3 tuxbox.py verify --backend proton --adapter 1002:13c0 --only xgameruntime --only guest-frame --only present --output <out>
  -> 13/13 passed

Checks

CI runs the Python unit tests, the shader compiler, DXBC, and XG layout tests, and a Windows typecheck of tuxbox-d3d12.

<!-- greyfinch-sync:brcly/TuxBox:issue:5553966015 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/517). Originally posted by [glovepost](https://github.com/glovepost) on 2026-11-29T18:53:08Z. --- ## Summary Adds a live scripted input channel to `gameinput`, a paired profile auto-select trigger between `xgameruntime` and `gameinput`, and an automated game test harness (`tools/game_harness.py`): - **Profile auto-select (`runtime/xgameruntime`, `runtime/gameinput`, `docs/ENVIRONMENT.md`):** Arms a per-process manual-reset Win32 event (`Local\TuxBoxAutoSelectProfile_<pid>`) on the `user_gamertag` account prompt and disarms it on save enumeration when `TUXBOX_AUTO_SELECT_PROFILE` is set, driving periodic `A` pulses in `gameinput`'s `AutoConfirm` helper while keeping `hold(...)` / `missing` grace windows intact. - **Scripted input channel (`runtime/gameinput/src/{lib.rs,sample.rs,tests/sample.rs}`, `docs/ENVIRONMENT.md`):** Adds `ScriptedInput` (`TUXBOX_INPUT_SCRIPT`) reading line-delimited commands (`press`, `down`, `up`, `stick`, `trigger`, `wait`, `reset`) from a file path or localhost TCP socket to inject controller state alongside live hardware/keyboard input. - **Automated harness (`tools/game_harness.py`, `tools/scenarios/scarlett_boot_to_gameplay.json`, `tests/test_game_harness.py`):** Launches the title via a launch script with scripted input scenarios, frame-hash stall detection, stderr/stdout log matching, and milestone reporting. Prepared with AI assistance; all changes were reviewed and verified on host unit tests, Wine crate unit tests, and both NVIDIA and AMD GPUs. ## Tested Run the [checks relevant to this change](../CONTRIBUTING.md#test-what-your-change-touches). - [x] The checks relevant to this change passed - [x] Changed or new behaviour is covered by a Lanes scenario, or the reason it cannot be is stated below - [x] Where the table calls for AMD and NVIDIA, they passed on both. Otherwise, say which vendor still needs to run them: This adds controller input injection, `xgameruntime` account-prompt signaling, and a launch harness rather than GPU shader or command-list rendering paths, so no new Lanes scenario applies. Behaviour is covered by the Wine unit tests in `tuxbox-gameinput` (`10/10`) and `tuxbox-xgameruntime` (`6/6`), `tests/test_game_harness.py` + `tests/test_repository_hygiene.py`, and the `xgameruntime`, `guest-frame`, and `present` verify suites on both NVIDIA and AMD. GPU, driver and backend: - NVIDIA GeForce RTX 2070 SUPER (`10de:1e84`), driver `620.73.04`, GE-Proton11-14 (`vkd3d-proton`) - AMD Ryzen 7 9800X3D iGPU (`1002:13c0`), RADV / Mesa `26.3.1`, GE-Proton11-14 (`vkd3d-proton`) Commands run and their results: ```text DXC=<dxc> python3 tuxbox.py check --no-gpu -> 7/7 passed (Python 701 tests OK; shader compiler 625 passed; DXBC 109 passed; XG layout 17 passed, 1 ignored; storage codec 18 passed; D3D12 Windows typecheck passed) CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_RUNNER=wine cargo xwin test --locked --target x86_64-pc-windows-msvc -p tuxbox-gameinput -p tuxbox-xgameruntime --lib -> tuxbox-gameinput: 10/10 passed; tuxbox-xgameruntime: 6/6 passed TUXBOX_CHECK_JOBS=4 python3 tuxbox.py verify --backend proton --adapter 10de:1e84 --only xgameruntime --only guest-frame --only present --output <out> -> 13/13 passed TUXBOX_CHECK_JOBS=4 python3 tuxbox.py verify --backend proton --adapter 1002:13c0 --only xgameruntime --only guest-frame --only present --output <out> -> 13/13 passed ``` ## Checks CI runs the Python unit tests, the shader compiler, DXBC, and XG layout tests, and a Windows typecheck of `tuxbox-d3d12`.
brcly commented 2026-11-30 04:12:24 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-30T04:12:24Z.


Heads-up: main just landed a large cleanup (up to e5d2e913), so this PR needs a rebase.

  • Formatting: the whole workspace is now formatted with rustfmt (see the new rustfmt.toml).
  • Lints: every crate denies unwrap(), lossy as casts and undocumented unsafe outside tests.
  • CI: it now also runs cargo fmt --check, rustdoc with warnings denied, and Miri on the providers' unit tests.

The least painful way is to format your branch first, so the rebase only shows real changes:

git fetch origin
git checkout origin/main -- rustfmt.toml
cargo fmt --all && git commit -am "rustfmt"
git rebase origin/main

Then run python tuxbox.py check --no-gpu, which now includes the format step.

If clippy flags something new:

  • A cast: use From for widening, TryFrom for narrowing, and a mask for bit fields.
  • An unwrap(): use ?, or expect with the reason it can't fail.
  • An unsafe block: it needs a // SAFETY: comment.

CONTRIBUTING's "Code checks" section lists the commands. Thanks!

<!-- greyfinch-sync:brcly/TuxBox:comment:7268563613 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/517#issuecomment-7268563613). Originally posted by [brcly](https://github.com/brcly) on 2026-11-30T04:12:24Z. --- Heads-up: main just landed a large cleanup (up to e5d2e913), so this PR needs a rebase. - **Formatting:** the whole workspace is now formatted with rustfmt (see the new `rustfmt.toml`). - **Lints:** every crate denies `unwrap()`, lossy `as` casts and undocumented `unsafe` outside tests. - **CI:** it now also runs `cargo fmt --check`, rustdoc with warnings denied, and Miri on the providers' unit tests. The least painful way is to format your branch first, so the rebase only shows real changes: ```sh git fetch origin git checkout origin/main -- rustfmt.toml cargo fmt --all && git commit -am "rustfmt" git rebase origin/main ``` Then run `python tuxbox.py check --no-gpu`, which now includes the format step. If clippy flags something new: - **A cast:** use `From` for widening, `TryFrom` for narrowing, and a mask for bit fields. - **An `unwrap()`:** use `?`, or `expect` with the reason it can't fail. - **An `unsafe` block:** it needs a `// SAFETY:` comment. CONTRIBUTING's "Code checks" section lists the commands. Thanks!
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/517:upstream-pr/517'
git switch 'upstream-pr/517'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/517'
git switch 'upstream-pr/517'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/517'
git switch 'upstream-pr/517'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/517'
git switch 'main'
git merge --squash 'upstream-pr/517'
git switch 'main'
git merge --ff-only 'upstream-pr/517'
git switch 'main'
git merge 'upstream-pr/517'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
brcly/TuxBox!517
No description provided.