runtime: add opt-in input trace for the virtual gamepad #3179
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!3179
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3177"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@lambirou on GitHub · 2026-11-27 20:26 UTC · original
lambirou:codex/input-movement-trace→main· +534 −0 · 5 files · 2 commits · merged 2026-11-27 22:29 UTCChanges
Adds an opt-in
X2W_INPUT_TRACE=1mode to the GameInput stand-in. It logs the resolved virtual gamepad state after keyboard, XInput pad 0, the shared pad block,X2W_INPUT_PRESSandX2W_INPUT_SCRIPThave been merged:It also logs one line per script wait, mark or skipped group. The default path is unchanged and writes no trace line.
Validation
The fixture plays one script with the switch on and off. The control observes the same states and writes no trace line; the trace must show the A press at script time 2.000 and present 11, the stick at 2.500, and the wait/mark events.
Limits
The trace shows the input the stand-in exposes to the title; it does not prove that a game state or a rendered character changed. That still needs a scene-color comparison on a fixed profile and scripted sequence. The fixture is source-built and uses the existing picture-signature block.
Refs #870.
Review update (2026-11-27,
779c8863)pigalot's fixture gap is fixed. The script now ends with a 0.1 s B press at 3.6-3.7 s, off the 250 ms heartbeat grid. The child expects B at 3.6 s and the trace must contain the exact
buttons=0x00000008 ... script=3.600 present=11line; dropping the state-change test now loses that line and fails.The documentation example now uses the real 2.500 s state (
buttons=0x00000000,lx=1.000,ly=0.500).startup_gameinput_tracepasses in Debug and Release on the local host, with the trace and control children both passing. CI is running on779c8863.@pigalot on GitHub · 2026-11-27 21:48 UTC · original · requested changes
Independently reviewed
1600accbintegrated overmain2dde49a8(tree9b456ee0). The merge is clean andgit diff --cached --check origin/mainis clean.What I traced.
trace_stateruns at the end ofsample(), after keyboard, XInput pad 0, the shared block,X2W_INPUT_PRESSand the script have been merged, so it logs the state thatcapture_current()records.GamepadStatediffers bymemcmp(the struct has no padding), and otherwise at most once every 250 ms onprocess_milliseconds(), which followsX2W_INPUT_CLOCK_MSin the fixture.presentcomes fromread_signal, so it isnoneuntil the presenter has published a sample. For a script with no wait that means always: sampling is only requested for waits.trace_eventis called fromlog_event, so each existing wait, mark and group log gets one trace line next to it.trace_enabled()check.What I ran. I built
startup_stub_gameinputandstartup_gameinput_traceindevandrelease, then ran:dev, 5 of 7 pass.startup_gameinput_traceandstartup_gameinput_script_syntaxare capability skips (77): this machine has an XInput pad on slot 0 (SKIP: XInput pad 0 is connected). Release is the same skip.X2W_TRAP_LOG,X2W_INPUT_TRACE=1|0, the sameX2W_INPUT_SCRIPT,X2W_INPUT_PRESS/X2W_INPUT_KEYSunset):startup_gameinput_trace.exe GameInput.dll child trace|control. The pad was idle, so it adds nothing to the readings. Results:/O2;x2w-input-tracelines, 17 of them state lines;main2dde49a8, the test is not registered.Mutants (each applied alone to
src/startup_stubs/gameinput.cpp,startup_stub_gameinputrebuilt indev, both children run, file restored from its raw bytes,git diff --quietclean afterwards):bounded state lines (12..20 in four seconds)presenttaken fromsignal.sequencetrace_eventnot calledno x2w-input-trace line without the switchmemcmpterm removed, interval only)Finding: the fixture does not pin "one line per state change". Every state change in the script lands on a multiple of 250 ms: 2.000, 2.500, 3.000 and 3.500 s. The fixture also starts the trace at 0 and steps the clock by 50 ms. So the 250 ms heartbeat alone produces exactly the lines the check expects. All 17 state lines in the passing run are at
script=0.000, 0.250, …, 4.000.The gap is visible with a change off that grid. I appended a 0.1 s B press,
8@+1.1+0.1, to the same script, so B is held from 3.6 to 3.7 s. Then I ran the trace child. Its own state expectations then stop it at 3.6 s, but the trace line is written first.x2w-input-trace state buttons=0x00000008 … script=3.600 present=11line.A press shorter than 250 ms (an
X2W_INPUT_PRESSpress is 0.2 s) can therefore vanish from the trace without the test noticing. That is the case the trace exists for. Suggested direction: move one script entry off the 250 ms grid (for example a 0.1 s press at 3.6 s, as above), add it toexpected_at, and assert its line. That pins the change test.Non-blocking. The example state line in the PR body and in
docs/experiments/startup-input-trace.md(buttons=0x00000004 … lx=1.000 ly=0.500 … script=2.500) is not a state the fixture produces: A is released at 2.5 s, and the fixture's own line at 2.500 hasbuttons=0x00000000. Using the real line would avoid confusion.Verdict: request changes on
1600accbfor the fixture gap above. The runtime change behaves as described in my runs.Environment: Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Python 3.12.10; no GPU involved. XInput pad present on slot 0, so CTest reports the trace test as a capability skip (77) here.
CI:
Build and test on Windows,Assemble and translate gfx1013 fixturesandRun platform-independent Python checks on Linuxpass on1600accb.This reply was AI-assisted.
@lambirou on GitHub · 2026-11-27 22:13 UTC · original
Review update (2026-11-27,
779c8863)pigalot's fixture gap is fixed. The script now ends with a 0.1 s B press at 3.6-3.7 s, off the 250 ms heartbeat grid. The child expects B at 3.6 s and the trace must contain the exact
buttons=0x00000008 ... script=3.600 present=11line; dropping the state-change test now loses that line and fails.The documentation example now uses the real 2.500 s state (
buttons=0x00000000,lx=1.000,ly=0.500).startup_gameinput_tracepasses in Debug and Release on the local host, with the trace and control children both passing. CI is running on779c8863.@lambirou on GitHub · 2026-11-27 22:19 UTC · original
@pigalot the off-grid 0.1 s B press is added on
779c8863; the trace requires the 3.600 s line. Could you re-review?@pigalot on GitHub · 2026-11-27 22:29 UTC · original · approved these changes
Retested
779c8863integrated overmain06de199e(treece2c88ef). The merge is clean (docs/startup-runtime.mdauto-merged) andgit diff --cached --check origin/mainis clean.My earlier finding (the fixture does not pin one line per state change): addressed. The script now ends with
8@+1.1+0.1, so B is held from 3.6 to 3.7 s, off the 250 ms heartbeat grid.expected_atexpects it, and the trace child requires exactly onebuttons=0x00000008 … script=3.600 present=11line. The state-line bound moves from 12..20 to 12..21 for the extra change line. In my run there are 18 state lines.What I ran. I built
startup_stub_gameinput,startup_gameinput_traceand the otherstartup_gameinput_*executables indevandrelease, then ran:startup_gameinput_traceandstartup_gameinput_script_syntaxare capability skips (77): this machine has an XInput pad on slot 0.startup_gameinput_trace.exe GameInput.dll child trace|control./O2.x2w-input-tracelines, 18 of them state lines, including the singlescript=3.600B line.Mutants (each applied alone to
src/startup_stubs/gameinput.cpp,startup_stub_gameinputrebuilt indev, both children run, file restored from its raw bytes,git diff --quietclean afterwards):memcmpterm removed, interval only)1600accb):off-grid B press line at script time 3.600bounded state lines (12..21 in four seconds)presenttaken fromsignal.sequencetrace_eventnot calledno x2w-input-trace line without the switchEarlier non-blocking note (the example state line): half addressed.
docs/experiments/startup-input-trace.mdnow shows the line the fixture really writes at 2.500 s (buttons=0x00000000). The PR body still showsbuttons=0x00000004atscript=2.500. Since it is only the description, I'm not blocking on it.Verdict: approve on
779c8863. This supersedes my changes-requested review on1600accb.Environment: Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Python 3.12.10. No GPU is involved. An XInput pad is present on slot 0, so CTest reports the trace test as a capability skip (77) here, and the child was run directly instead.
CI:
Build and test on Windows,Assemble and translate gfx1013 fixturesandRun platform-independent Python checks on Linuxpass on779c8863.This reply was AI-assisted.