GameInput: a scripted stick drives a title's movement and camera #887

Open
mikebuckets171 wants to merge 1 commit from upstream-pr/893 into main
mikebuckets171 commented 2026-11-24 07:52:00 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by mikebuckets171 on 2026-11-24T07:52:00Z.


What

XCL_PRESS_AT / XCL_PRESS_A_AT walk a title's menus with scripted button presses, and kbm maps
keyboard and mouse onto the gamepad — but the keyboard path needs the XCL window to have the focus
(keyboard() checks GetForegroundWindow, and a background run drops keys that arrive while the window
is not ours), and the right stick is the mouse, which deflects only while it keeps moving. So a run with
nobody at the controls — a Wine host, a CI-launched title, a scripted repro — can press buttons but
cannot hold a thumbstick, which is what a title uses for movement and the camera. There is no way to
script a stick today: GamepadState carries left_x/left_y/right_x/right_y and only a real XInput
controller or kbm ever writes them.

XCL_STICK_AT=s:x/y,… (left stick) and XCL_LOOK_AT=s:x/y,… (right) hold a deflection from that second
until the next entry: XCL_STICK_AT=20:0.0/0.9,60:0.0/0.0 walks forward for 40 s and then stops.
Coordinates are split with / so one entry stays one comma-separated item, as in XCL_PRESS_AT; values
clamp to the stick's −1.0…1.0; an entry that does not parse is named and the rest of the track still
applies; a nan or inf coordinate — which parses as a float — is refused like a garbled item instead of
reaching the title; each entry logs once
(GameInput: scripted left stick 0.00,0.90 held from 20.0 s) so a long run
can be read back against what the title did. Applied after kbm's mapping in poll(), so while a scripted
deflection holds it is not fought by a key that happens to be down — the way a scripted button press already
works. (#606 is complementary and different: inside kbm it gives Page Up / Page Down the right stick and
resolves that against the mouse deflection by magnitude, which still needs the window to have the focus.)

Independent of #609 (which lengthens scripted button presses) and #606 (which gives the right stick to
Page Up/Page Down through kbm, so still needs the window focused): none of the three covers what the
others do, and if either lands first I will rebase onto it. I cross-built both heads and ran their tests
under Wine in this bench as they stand today — counts in my comments there.

What is in it

  • crates/xcl/src/hle/gameinput.rs (+111 / −0): the two variables documented in the module header,
    parse_stick_track, stick_at (hold-until-next), log_stick_entry (once per entry), scripted_sticks
    called from poll() after merge_host_inputs, and three CPU-only unit tests.

Tested

  • Host: macOS 27.2 (Apple silicon, M5 Pro), CrossOver 26 bottle, D3DMetal; cross target
    x86_64-pc-windows-gnullvm with LLVM-MinGW 20261117 as the linker; cargo build --workspace --locked
    and cargo test --no-run --release --locked green for main at 1ec4c98 and for this head (16 test
    executables; one fetch_update deprecation warning that main already prints).
  • The head is 09aa37e rebased onto 1ec4c98 (07e2a6c), then refined once — refusing a nan/inf
    coordinate instead of letting clamp pass it through — as 81cdf8f, still one commit, still +111 / −0.
    The xcl-smoke block and both Wine test filters below were run on 81cdf8f; the 150 s title pair below was
    run on the same patch before that refinement, which changes only what an unparsable entry does.
  • Unit tests under Wine, in this head's lib unit binary: filter stick → 4 passed, 0 failed, 0
    ignored
    ; filter gameinput → 12 passed, 0 failed, including
    keyboard_mouse_config_gates_keyboard_and_kbm_but_keeps_scripted and the existing reading-callback
    tests, so nothing that already read the gamepad changed behaviour.
  • What a scripted stick does to a real title, measured as a pair rather than by eye. On the Mac port of
    #258 (mac-on-main-wip at db065d8) with #541 applied and this same patch, 150 s cold, two fresh data
    roots, XCL_FRAME_DUMP on every 30th presented frame, each dump compared with the one before it (~1 s
    apart, ~20k sampled pixels):
sticks scripted same build, nothing scripted
exit 0x0 0x0
frames presented 2380 2345
translated draws reached 41,258 41,864
refusals / watchdog / crashes / removals 0 / 0 / 0 / 0 0 / 0 / 0 / 0
scripted entries the polled state carried 6: left 0.00,0.90 from 60 s → released 95 s → 0.00,-0.90 from 105 s → released 125 s; right 0.70,0.00 from 130 s → released 145 s 0
dump pairs whose picture changed 1 of 74 (t≈66 s, 97.6 % of pixels) 1 of 73 (t≈63 s, same magnitude)
mean luminance of the picture after that 42, unchanged to the end 42, unchanged to the end

The deflection reaches the gamepad state the title polls and the run stays clean, but the presented
picture is the same as the control's: the single change in each column is the title's own loading
sequence, which also happens with no input at all. Movement and camera are not demonstrated by this
patch on this host.
What is demonstrated is that the sticks can be driven from a script without a
window having the focus — the prerequisite for a run that is meant to show them.

Regression run

xcl-smoke blocks from this Mac host, 60 s each, same title and bottle, a fresh data root per side.

xcl-smoke v1
commit: 1ec4c98cda119432a4b3f205e146fba2d6f8379a
gpu: AMD Compatibility Mode
title: retail (Xbox Series X|S package, private drive)
seconds: 60
exit: 0x0
frames shown: 0 (PresentX 0)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 0 MB
xcl-smoke v1
commit: 81cdf8fba01bf59a58430961240e6f6ea4b1cf97
gpu: AMD Compatibility Mode
title: retail (Xbox Series X|S package, private drive)
seconds: 60
exit: 0x0
frames shown: 0 (PresentX 0)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 0 MB

Read them honestly: plain main does not run this title on a Wine host at all (it stops ~2 s in with 0
presents, 0 draws and no PSO work — #258), so both sides show 0 frames. What the pair does establish is
that this change removes nothing and crashes nothing on the path a Wine host takes; the port numbers above
are the run that does present frames.

Not tested

  • Windows: this bench has no Windows machine, which is also the only host where a real XInput pad could be
    compared against a scripted stick. The whole-suite counts CONTRIBUTING item 2 asks for are therefore
    missing: @Kalmarv offered Windows xcl-smoke pairs for the Mac bench's fixes in #258 (04:34) — this head
    plus cargo test --workspace -- --test-threads=4 would close this PR's open item.
  • kbm and the scripted sticks in the same run (a keyboard held down while a scripted deflection holds):
    the override order is unit-tested, not run against a title.
  • A title that shows movement on a Wine host: on this host the port presents a still picture, so this patch
    cannot be shown to move anything here (see the pair above).

AI use

  • GPT-6 Luna, for the patch, its tests and this description, from a macOS/Wine bench. The diff was read
    line by line and every number above comes from a run on the hardware named.
<!-- greyfinch-sync:ivall/xcl:issue:5468234522 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/893). Originally posted by [mikebuckets171](https://github.com/mikebuckets171) on 2026-11-24T07:52:00Z. --- ## What `XCL_PRESS_AT` / `XCL_PRESS_A_AT` walk a title's menus with scripted button presses, and `kbm` maps keyboard and mouse onto the gamepad — but the keyboard path needs the XCL window to have the focus (`keyboard()` checks `GetForegroundWindow`, and a background run drops keys that arrive while the window is not ours), and the right stick is the mouse, which deflects only while it keeps moving. So a run with nobody at the controls — a Wine host, a CI-launched title, a scripted repro — can press buttons but cannot *hold* a thumbstick, which is what a title uses for movement and the camera. There is no way to script a stick today: `GamepadState` carries `left_x/left_y/right_x/right_y` and only a real XInput controller or `kbm` ever writes them. `XCL_STICK_AT=s:x/y,…` (left stick) and `XCL_LOOK_AT=s:x/y,…` (right) hold a deflection from that second until the next entry: `XCL_STICK_AT=20:0.0/0.9,60:0.0/0.0` walks forward for 40 s and then stops. Coordinates are split with `/` so one entry stays one comma-separated item, as in `XCL_PRESS_AT`; values clamp to the stick's −1.0…1.0; an entry that does not parse is named and the rest of the track still applies; a `nan` or `inf` coordinate — which parses as a float — is refused like a garbled item instead of reaching the title; each entry logs once (`GameInput: scripted left stick 0.00,0.90 held from 20.0 s`) so a long run can be read back against what the title did. Applied after `kbm`'s mapping in `poll()`, so while a scripted deflection holds it is not fought by a key that happens to be down — the way a scripted button press already works. (#606 is complementary and different: inside `kbm` it gives Page Up / Page Down the right stick and resolves that against the mouse deflection by magnitude, which still needs the window to have the focus.) Independent of #609 (which lengthens scripted *button* presses) and #606 (which gives the *right* stick to Page Up/Page Down through `kbm`, so still needs the window focused): none of the three covers what the others do, and if either lands first I will rebase onto it. I cross-built both heads and ran their tests under Wine in this bench as they stand today — counts in my comments there. **What is in it** - `crates/xcl/src/hle/gameinput.rs` (+111 / −0): the two variables documented in the module header, `parse_stick_track`, `stick_at` (hold-until-next), `log_stick_entry` (once per entry), `scripted_sticks` called from `poll()` after `merge_host_inputs`, and three CPU-only unit tests. **Tested** - Host: macOS 27.2 (Apple silicon, M5 Pro), CrossOver 26 bottle, D3DMetal; cross target `x86_64-pc-windows-gnullvm` with LLVM-MinGW 20261117 as the linker; `cargo build --workspace --locked` and `cargo test --no-run --release --locked` green for `main` at `1ec4c98` and for this head (16 test executables; one `fetch_update` deprecation warning that `main` already prints). - The head is `09aa37e` rebased onto `1ec4c98` (`07e2a6c`), then refined once — refusing a `nan`/`inf` coordinate instead of letting `clamp` pass it through — as `81cdf8f`, still one commit, still +111 / −0. The `xcl-smoke` block and both Wine test filters below were run on `81cdf8f`; the 150 s title pair below was run on the same patch before that refinement, which changes only what an unparsable entry does. - Unit tests under Wine, in this head's lib unit binary: filter `stick` → **4 passed, 0 failed, 0 ignored**; filter `gameinput` → **12 passed, 0 failed**, including `keyboard_mouse_config_gates_keyboard_and_kbm_but_keeps_scripted` and the existing reading-callback tests, so nothing that already read the gamepad changed behaviour. - What a scripted stick does to a real title, measured as a pair rather than by eye. On the Mac port of #258 (`mac-on-main-wip` at `db065d8`) with #541 applied and this same patch, 150 s cold, two fresh data roots, `XCL_FRAME_DUMP` on every 30th presented frame, each dump compared with the one before it (~1 s apart, ~20k sampled pixels): | | sticks scripted | same build, nothing scripted | |---|---|---| | exit | 0x0 | 0x0 | | frames presented | 2380 | 2345 | | translated draws reached | 41,258 | 41,864 | | refusals / watchdog / crashes / removals | 0 / 0 / 0 / 0 | 0 / 0 / 0 / 0 | | scripted entries the polled state carried | 6: left `0.00,0.90` from 60 s → released 95 s → `0.00,-0.90` from 105 s → released 125 s; right `0.70,0.00` from 130 s → released 145 s | 0 | | dump pairs whose picture changed | 1 of 74 (t≈66 s, 97.6 % of pixels) | 1 of 73 (t≈63 s, same magnitude) | | mean luminance of the picture after that | 42, unchanged to the end | 42, unchanged to the end | The deflection reaches the gamepad state the title polls and the run stays clean, but the presented picture is the same as the control's: the single change in each column is the title's own loading sequence, which also happens with no input at all. **Movement and camera are not demonstrated by this patch on this host.** What is demonstrated is that the sticks can be driven from a script without a window having the focus — the prerequisite for a run that is meant to show them. **Regression run** `xcl-smoke` blocks from this Mac host, 60 s each, same title and bottle, a fresh data root per side. ``` xcl-smoke v1 commit: 1ec4c98cda119432a4b3f205e146fba2d6f8379a gpu: AMD Compatibility Mode title: retail (Xbox Series X|S package, private drive) seconds: 60 exit: 0x0 frames shown: 0 (PresentX 0) presents per 2 s (last 3): 0 0 0 device removals: 0 crashes: 0 peak commit: 0 MB ``` ``` xcl-smoke v1 commit: 81cdf8fba01bf59a58430961240e6f6ea4b1cf97 gpu: AMD Compatibility Mode title: retail (Xbox Series X|S package, private drive) seconds: 60 exit: 0x0 frames shown: 0 (PresentX 0) presents per 2 s (last 3): 0 0 0 device removals: 0 crashes: 0 peak commit: 0 MB ``` Read them honestly: plain `main` does not run this title on a Wine host at all (it stops ~2 s in with 0 presents, 0 draws and no PSO work — #258), so both sides show 0 frames. What the pair does establish is that this change removes nothing and crashes nothing on the path a Wine host takes; the port numbers above are the run that does present frames. **Not tested** - Windows: this bench has no Windows machine, which is also the only host where a real XInput pad could be compared against a scripted stick. The whole-suite counts CONTRIBUTING item 2 asks for are therefore missing: @Kalmarv offered Windows `xcl-smoke` pairs for the Mac bench's fixes in #258 (04:34) — this head plus `cargo test --workspace -- --test-threads=4` would close this PR's open item. - `kbm` and the scripted sticks in the same run (a keyboard held down while a scripted deflection holds): the override order is unit-tested, not run against a title. - A title that shows movement on a Wine host: on this host the port presents a still picture, so this patch cannot be shown to move anything here (see the pair above). **AI use** - GPT-6 Luna, for the patch, its tests and this description, from a macOS/Wine bench. The diff was read line by line and every number above comes from a run on the hardware named.
mikebuckets171 commented 2026-11-24 08:03:54 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by mikebuckets171 on 2026-11-24T08:02:57Z.


One refinement since filing, on the parser: nan and inf parse as f32, so an entry like 15:nan/0.5 used to survive clamp and put a NaN deflection into the state the title reads. They are now refused the way a garbled entry is, with the entry named in the log, and the clamp test carries that case. Wine re-run on the new head 81cdf8f: filter stick → 4 passed / 0 failed (a_stick_track_is_ordered_and_clamped_to_the_stick logs GameInput: XCL_LOOK_AT entry "15:nan/0.5" not understood (seconds:x/y) and passes), filter gameinput → 12 passed / 0 failed; the 60 s xcl-smoke block in the description is from 81cdf8f.

<!-- greyfinch-sync:ivall/xcl:comment:7125664509 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/893#issuecomment-7125664509). Originally posted by [mikebuckets171](https://github.com/mikebuckets171) on 2026-11-24T08:02:57Z. --- One refinement since filing, on the parser: `nan` and `inf` parse as `f32`, so an entry like `15:nan/0.5` used to survive `clamp` and put a NaN deflection into the state the title reads. They are now refused the way a garbled entry is, with the entry named in the log, and the clamp test carries that case. Wine re-run on the new head `81cdf8f`: filter `stick` → 4 passed / 0 failed (`a_stick_track_is_ordered_and_clamped_to_the_stick` logs `GameInput: XCL_LOOK_AT entry "15:nan/0.5" not understood (seconds:x/y)` and passes), filter `gameinput` → 12 passed / 0 failed; the 60 s `xcl-smoke` block in the description is from `81cdf8f`.
SlopTart commented 2026-11-24 10:04:45 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-24T09:34:16Z.


Linux / AMD RDNA3 datapoint.

Merged state: head 81cdf8f onto main 09940bb, clean merge.

Full suite, cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4: 708 passed, 11 failed, 41 ignored; failures are the known Wine-lane set from my #42 rows plus this rig's title-textures flake family (see #718). GameInput scripted-stick tests green; mirror-upload flake hit.

Not tested: retail titles (none here), Windows, RDNA4.
Counts only, no game data.

Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross x86_64-pc-windows-gnu, XCL_NETWORK=0, release profile, --test-threads=4. My Linux rows: #42 / #718.

AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.

<!-- greyfinch-sync:ivall/xcl:comment:7127596252 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/893#issuecomment-7127596252). Originally posted by [SlopTart](https://github.com/SlopTart) on 2026-11-24T09:34:16Z. --- Linux / AMD RDNA3 datapoint. **Merged state:** head `81cdf8f` onto main `09940bb`, clean merge. **Full suite, `cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4`:** **708 passed, 11 failed, 41 ignored**; failures are the known Wine-lane set from my #42 rows plus this rig's title-textures flake family (see #718). GameInput scripted-stick tests green; mirror-upload flake hit. **Not tested:** retail titles (none here), Windows, RDNA4. Counts only, no game data. **Machine:** RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross `x86_64-pc-windows-gnu`, `XCL_NETWORK=0`, release profile, `--test-threads=4`. My Linux rows: #42 / #718. AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.
DavidM1911 commented 2026-11-25 10:10:35 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T09:41:57Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7158681946 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/893#issuecomment-7158681946). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T09:41:57Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
github-actions[bot] commented 2026-11-28 20:17:26 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-28T20:17:26Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7245177174 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/893#issuecomment-7245177174). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-28T20:17:26Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 04:25:48 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T04:25:48Z.


Triage (#1607) – head 81cdf8f

No open or merged PR scripts the thumbsticks; main has only button scripting (XCL_PRESS_AT / XCL_PRESS_A_AT).
One nit in gameinput.rs: the module doc and parse_stick_track say 20:0.9/0.0 "walks forward", but that deflects the left stick along x (to the right). The PR description's 20:0.0/0.9 is the forward one.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7300725693 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/893#issuecomment-7300725693). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T04:25:48Z. --- **Triage (#1607)** – head 81cdf8f No open or merged PR scripts the thumbsticks; main has only button scripting (`XCL_PRESS_AT` / `XCL_PRESS_A_AT`). One nit in `gameinput.rs`: the module doc and `parse_stick_track` say `20:0.9/0.0` "walks forward", but that deflects the left stick along x (to the right). The PR description's `20:0.0/0.9` is the forward one. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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/893:upstream-pr/893'
git switch 'upstream-pr/893'

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/893'
git switch 'upstream-pr/893'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/893'
git switch 'upstream-pr/893'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/893'
git switch 'main'
git merge --squash 'upstream-pr/893'
git switch 'main'
git merge --ff-only 'upstream-pr/893'
git switch 'main'
git merge 'upstream-pr/893'
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
xcl-dev/xcl!887
No description provided.