Skip to content

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

Draft
mikebuckets171 wants to merge 1 commit into
xcl-dev:mainfrom
mikebuckets171:pr/stick-scripting
Draft

mikebuckets171 wants to merge 1 commit into
xcl-dev:mainfrom
mikebuckets171:pr/stick-scripting

Conversation

@mikebuckets171

@mikebuckets171 mikebuckets171 commented Nov 24, 2026 •

Copy link
Copy Markdown

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
    macOS (Apple Silicon, CrossOver + D3DMetal): the newer retail game reaches its first-run menus at 30 fps #258 (mac-on-main-wip at db065d8) with D3D12.X: a console MS in the AS slot is translated as the mesh shader it is #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 macOS (Apple Silicon, CrossOver + D3DMetal): the newer retail game reaches its first-run menus at 30 fps #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.

XCL_PRESS_AT walks a title's menus with buttons, but movement and the camera are thumbsticks: the
only way to deflect them today is a real controller or keyboard/mouse on a window that has the focus
(kbm), which a headless or background run - a Wine host in particular - does not have.

XCL_STICK_AT=s:x/y,... and XCL_LOOK_AT=s:x/y,... hold a deflection from that second until the next
entry (20:0.9/0.0,60:0.0/0.0 walks forward for 40 s, then stops), applied after kbm so a scripted
drive is not fought by a key that happens to be down. Out-of-range values clamp to the stick; a nan
or inf coordinate is refused like a garbled item rather than reaching the title; an entry that does
not parse is named and the rest of the track still applies; each entry logs once so a long run can be
read back against what the title did.
@mikebuckets171

Copy link
Copy Markdown
Author

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

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants