Repository navigation
GameInput: a scripted stick drives a title's movement and camera - #893
mikebuckets171 wants to merge 1 commit into
Conversation
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.
07e2a6c to
81cdf8f
Compare
|
One refinement since filing, on the parser: |
|
Linux / AMD RDNA3 datapoint. Merged state: head Full suite, Not tested: retail titles (none here), Windows, RDNA4. 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 AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting. |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
What
XCL_PRESS_AT/XCL_PRESS_A_ATwalk a title's menus with scripted button presses, andkbmmapskeyboard and mouse onto the gamepad — but the keyboard path needs the XCL window to have the focus
(
keyboard()checksGetForegroundWindow, and a background run drops keys that arrive while the windowis 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:
GamepadStatecarriesleft_x/left_y/right_x/right_yand only a real XInputcontroller or
kbmever writes them.XCL_STICK_AT=s:x/y,…(left stick) andXCL_LOOK_AT=s:x/y,…(right) hold a deflection from that seconduntil the next entry:
XCL_STICK_AT=20:0.0/0.9,60:0.0/0.0walks forward for 40 s and then stops.Coordinates are split with
/so one entry stays one comma-separated item, as inXCL_PRESS_AT; valuesclamp 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
nanorinfcoordinate — which parses as a float — is refused like a garbled item instead ofreaching the title; each entry logs once
(
GameInput: scripted left stick 0.00,0.90 held from 20.0 s) so a long runcan be read back against what the title did. Applied after
kbm's mapping inpoll(), so while a scripteddeflection 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
kbmit gives Page Up / Page Down the right stick andresolves 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 theothers 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_stickscalled from
poll()aftermerge_host_inputs, and three CPU-only unit tests.Tested
x86_64-pc-windows-gnullvmwith LLVM-MinGW 20261117 as the linker;cargo build --workspace --lockedand
cargo test --no-run --release --lockedgreen formainat1ec4c98and for this head (16 testexecutables; one
fetch_updatedeprecation warning thatmainalready prints).09aa37erebased onto1ec4c98(07e2a6c), then refined once — refusing anan/infcoordinate instead of letting
clamppass it through — as81cdf8f, still one commit, still +111 / −0.The
xcl-smokeblock and both Wine test filters below were run on81cdf8f; the 150 s title pair below wasrun on the same patch before that refinement, which changes only what an unparsable entry does.
stick→ 4 passed, 0 failed, 0ignored; filter
gameinput→ 12 passed, 0 failed, includingkeyboard_mouse_config_gates_keyboard_and_kbm_but_keeps_scriptedand the existing reading-callbacktests, so nothing that already read the gamepad changed behaviour.
macOS (Apple Silicon, CrossOver + D3DMetal): the newer retail game reaches its first-run menus at 30 fps #258 (
mac-on-main-wipatdb065d8) 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 dataroots,
XCL_FRAME_DUMPon every 30th presented frame, each dump compared with the one before it (~1 sapart, ~20k sampled pixels):
0.00,0.90from 60 s → released 95 s →0.00,-0.90from 105 s → released 125 s; right0.70,0.00from 130 s → released 145 sThe 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-smokeblocks from this Mac host, 60 s each, same title and bottle, a fresh data root per side.Read them honestly: plain
maindoes not run this title on a Wine host at all (it stops ~2 s in with 0presents, 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
compared against a scripted stick. The whole-suite counts CONTRIBUTING item 2 asks for are therefore
missing: @Kalmarv offered Windows
xcl-smokepairs 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 headplus
cargo test --workspace -- --test-threads=4would close this PR's open item.kbmand 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.
cannot be shown to move anything here (see the pair above).
AI use
line by line and every number above comes from a run on the hardware named.