GameInput: match presented frames to scripted input rules #2637
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2637
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2637"
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?
@KDenKC on GitHub · 2026-11-26 03:45 UTC · original
KDenKC:frame-input-rules→main· +485 −2 · 7 files · 3 commits · openHead:
de2292ead5eebcae972a967d697d8e4dbbe84173, based on mainb49be1836844fe0b0cdb3211dce3cb7fb4e21ac7. Includes eager host-path loading before VFS initialization, a 6.5-second warning countdown wait, and a three-second terms-screen transition wait in the local-reference example.Test runs of the retail title get through first-run and legal screens by timed presses. Cache state changes load time, so agents lose runs to stuck screens or toggled checkboxes. This adds frame-matched virtual-pad rules and JSON events that automated launch scripts can wait on.
What is in it
XCL_INPUT_RULES=<local TOML file>, with references resolved beside that file. Rules and reference thumbnails load once at host startup before VFS hooks remap host drive paths. RequiresXCL_FRAME_DUMP(use2for responsive matching). Uses the existing presented-frame readback and existing TOML/JSON dependencies.A 64×36 grayscale matcher, normalized region and mean absolute difference threshold. One active sequence; ordered rules; once or repeat with cooldown. Missing references disable their rule and fallback. No game image ships in the repository.
examples/retail-input-rules.tomland the README recipe: timed A through 54 seconds; fallback A from 57 seconds until the legal-screen match; DOWN, wait 6.5 seconds, DOWN, A, then privacy/terms/confirmation. The README also describes an optional second terms-frame rule to gate that transition. References and thresholds must be calibrated locally.Related: #609 (hold duration), #1765 (retain presses until read), #2449 (live input file); #42 supplied the test-report workflow. This retains the existing 200 ms pulse semantics and does not implement input acknowledgement.
Schema (TOML):
Automated use:
Capture with
XCL_FRAME_DUMP=2; keep your own Legal Notices frame with Copyright selected asreferences/legal-notices.bmp. Never commit game output.Copy the example rules file beside
references/. Check target/non-target distances locally; threshold 5 is a starting point, not a measurement of the new matcher on the title.Set
XCL_NETWORK=0,XCL_FRAME_DUMP=2,XCL_INPUT_RULES=<rules file>andXCL_PRESS_AT=6:A,9:A,12:A,15:A,18:A,21:A,24:A,27:A,30:A,33:A,36:A,39:A,42:A,45:A,48:A,51:A,54:A. Run with the usual timeout; parse JSON afterGameInput: input_ruleand wait forevent=completed,rule=legal-notices.Example event (illustrative, not a measured run):
Other events are
pressed(button),completed, anddisabled(reason). Pulses last 200 ms. An unmatched reference never starts a rule. Config errors disable all rules; an unreadable reference disables its rule and fallback. Frame dumping adds overhead, so comparison arms need identical settings.Tested
Second review fix
0eb8005a(luckyteagirl's handoff review): when a matching rule's first press is the button the fallback is holding, the rule waits until the fallback pulse ends plus the same 0.1 s release margin; a different first button still starts at once. The extendedsequence_timing_once_and_fallback_handofftest failed on the previous head at 57.11 s (A instead of neutral; 9 passed, 1 failed) and passes with the fix (10 passed, 0 failed, including neutral polls through 57.29 s and the rule's A at 57.31 s).cargo build --workspacepassed.Whole suite at
0eb8005a(RTX 5090,--no-fail-fast --test-threads=4,XCL_NETWORK=0): 1,441 passed, 4 failed (the knownfuzz_validate_and_gpu_0..3), 47 ignored, 26 SKIPPED.Review fix
70bc71a8(luckyteagirl's review: repeated presses of one button with no release gap). The parser now rejects a repeated press of the same button that starts less than 0.3 s after the previous one (a 0.2 s pulse plus a 0.1 s release margin).cargo +stable-x86_64-pc-windows-msvc test -p xcl --lib input_rules: on the previous head, with the new tests, 8 passed, 2 failed (the two new regressions: the 0.19/0.20/0.21 s poll shows no button-up, and the parser acceptsA, wait 0.2, A); with the fix, 10 passed, 0 failed.cargo build --workspacepassed. The whole suite and the functional in-title runs below are fromde2292ea; the fix only adds the parser check, its tests and a README line. The regression smoke pair below ismainagainst this head0eb8005a(200 s each, same recipe). The shipped example (presses 0.8 s apart) is unaffected.cargo +stable-x86_64-pc-windows-msvc build --workspacepassed.cargo +stable-x86_64-pc-windows-msvc test -p xcl --lib input_rules: 7 passed, 0 failed, 0 ignored, 0 skipped, 1336 filtered out. Tests were written before implementation; the first execution was deferred until the rig build window. No red test run has been claimed.cargo +stable-x86_64-pc-windows-msvc test --workspace --no-fail-fast -- --test-threads=4, withXCL_NETWORK=0: 1,438 passed, 4 failed, 47 ignored across 37 result blocks; 26 explicitSKIPPEDdiagnostics (subchecks, not additional test cases). Exit 101. Library: 1,312 passed, 4 failed, 27 ignored. Every other target passed. The four failures aregpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3, seeds 70/545/1019/1507,CreateComputePipelineStateout of memory (0x8007000E). They also fail onmainb49be18on this rig, tracked by #1905. Skips include unavailable wave64, unsupported f16 variants, no heap windows, and driver-cache disabling requiring Windows Developer Mode. Skipped checks are not coverage.Hardware available: Windows 11, Ryzen 7 9800X3D, 62 GB RAM, RTX 5090. Targeted tests use only synthetic data and do not initialize the GPU.
The workspace build, seven filtered tests and whole suite were repeated after the eager-load change: identical totals and the same four fuzz failures. Current head changes only the example TOML and README after that tested runtime revision.
Functional check (Claude Code, Claude Opus 5.5), run 3 with this head's example: passed. Frame dumps show Privacy checked at 101.6 s, Terms checked at 103.4 s, Confirm pressed at 104.8 s, and the title proceeding into loading. Host-path loading and frame matching worked. The 6.5-second wait accounts for Next becoming enabled only about 5.0–5.3 seconds after the first DOWN on this rig. TOML parsing and the exact sequence were checked without rebuilding (runtime unchanged). This is one successful functional run, not a guarantee across machines or frame rates.
Match differences in runs 1–3 were 0.76, 0.68 and 4.29, against threshold 5 (checked in each run's log). Earlier local-screen measurements put other screens at 26 or more; these are calibration observations, not synthetic-test results or a bound for all machines.
Tested by others (thank you):
de2292ea: whole suite 1442 passed, 0 failed, 47 ignored; the 7 new tests pass; skips the same as onmain. No title run. #2637Not tested
AMD/Intel, other resolutions/HDR, repeat-rule behavior in-title and the optional second frame-gated terms rule have not been tested. No references or output dumped from a title are included. Input still must be polled during the pulse, as with
XCL_PRESS_AT; the example's countdown timing can need adjustment on other rigs.Run 3 matched at 4.29, close to the threshold; if the rule does not fire on your machine, raise threshold toward 10 (other screens measured 26 or more in earlier local measurements). Check your own target and non-target screens before adopting that threshold.
Regression run
main:This PR (
de2292e):Both: the retail title,
-Seconds 200, the same scripted input, RTX 5090. These runs don't setXCL_INPUT_RULES, so they are a regression check of the default path; the rules were checked in the functional run under Tested.Edge cases we would like tested
Use a copy of the example rules file and your normal launcher with
XCL_NETWORK=0.| Scenario | Configuration / command before launching | What to look for |
| --- | --- | --- |
| Missing reference | Set
reference='missing.bmp'in the local rules file. |event=disabledfor that rule; no rule or fallback presses. ExistingXCL_PRESS_ATis independent. || Two rules match one frame | Duplicate a matching rule with a different name, both
once=true. | First rule in file starts alone. The second can start only on a later sampled frame after the first completes. || Never matches, fallback active | Use a valid reference from a different screen and
threshold=0.0. |$fallbackpressed events at start + n×interval, no rule completion; launcher timeout still applies. || Frame dumps off |
Remove-Item Env:XCL_FRAME_DUMP -ErrorAction SilentlyContinue|$configdisabled warning; no rule or fallback presses. || Different resolution / HDR | Capture references using the same launcher settings; compare with and without
XCL_FRAME_DUMP_FULL=1. | Matching on intended screens only; check diff and unsupported decoded formats. Recalibrate threshold if needed. || Slower or faster load | Repeat the same launcher/env recipe with different cache warmth and a suitable run timeout. | Match follows the intended screen rather than a fixed start time; all checkboxes and Confirm must be verified in frames. If the match occurs before 54 s, remaining independent
XCL_PRESS_ATpresses can overlap the sequence: shorten/remove that setup schedule for the faster run. A slower warning countdown may need a longer wait or further frame gating. |These are requested title-level checks, not results. Synthetic tests cover ordering, missing-reference fail-safe, cooldown, sequence timing, JSON events and BMP orientation/padding.
AI use
Codex (GPT-6.1-Sol) wrote the implementation, the tests, the docs and the description, and ran the workspace build, the filtered tests and the whole suite.
Claude Code (Claude Opus 5.5) reviewed the diff, ran the functional runs in the retail title and the regression runs, and checked the logs. No code was imported from another project.
🤖 Generated with Claude Code
@KDenKC on GitHub · 2026-11-26 03:52 UTC · original
Just a simple testing framework to help with automation on test runs 🙂
@luckyteagirl on GitHub · 2026-11-26 04:45 UTC · original · reviewed
A, wait 0.2, Ais accepted, but each A pulse occupies a 0.2-second window, so the two windows touch:[0, 0.2)and[0.2, 0.4).Engine::buttonsreturns A across the boundary and can emit twopressedevents, while GameInput's callback poller sees no button-up state and therefore one continuous hold. Could the parser reject or coalesce consecutive same-button presses with no release interval (or document that this sequence is a hold)? A small synthetic test polling at 0.19, 0.20, and 0.21 seconds would show the missing release. This is source review only; the default 0.8-second spacing and the supplied example are unaffected.@sage-sage on GitHub · 2026-11-26 07:05 UTC · original
Test report: passes on NVIDIA. Exact head
de2292ea(its base is currentmainb49be18, so head = merged).Tested
cargo test --workspace -- --test-threads=4: 1442 passed, 0 failed, 47 ignored; the 7 new tests passmainon this machine): 21 wave64 tests (NVIDIA is wave32 only), 3 per-lane wave32 f16/f32 forms (refused), 3 D3D12 debug layer (d3d12SDKLayers.dllnot installed), 1no heap windows, 1pso_measurement_compiles_an_exact_synthetic_record(Developer Mode off)Not tested
Claude Code (Claude Opus 5.5) ran the tests and wrote this report.
@Gevroska on GitHub · 2026-11-26 08:43 UTC · original
I tested the two matching once-only rules on
de2292eawith a synthetic frame and a different button assigned to each rule. I ran the same test in both file orders. In each case, the first rule in the file produced the first button press.Frame 17 started the first sequence. Frame 18 arrived while that sequence was active. After the sequence completed and the button mask returned to neutral, presenting frame 18 again produced no action. Fresh frame 19 triggered the second rule. Once both rules had completed, another matching frame triggered neither.
I added this case locally alongside the seven existing input-rule tests. All eight passed on Windows, with zero failures, ignores, or skips. This verifies rule ordering and the fresh-frame requirement in the CPU engine. Live frame capture and in-game button delivery remain untested.
I used Codex GPT-6.2 Sol for the fixture and a separate GPT-6.2 Sol agent to review it and rerun the compiled tests.
I reviewed and approved this comment before posting.
@KDenKC on GitHub · 2026-11-26 08:47 UTC · original
Thanks @luckyteagirl, good catch. Fixed in
70bc71a8: the parser now rejects a repeated press of the same button that starts less than 0.3 s after the previous one (the 0.2 s pulse plus a 0.1 s release margin), with an error that names the 0.3 s.A, wait 0.3, Ais accepted and shows button-up at 0.20 s. Tests, written first:A, wait 0.299, a;On the previous head they gave 8 passed, 2 failed (the two regressions); with the fix, 10 passed. The README notes the rule, and the example file is unchanged.
AI use: Codex (GPT-6.1-Sol) wrote the fix and tests and ran them; Claude Code (Claude Opus 5.5) checked the diff and logs and wrote this reply.
@luckyteagirl on GitHub · 2026-11-26 09:19 UTC · original · reviewed
On
70bc71a, the new release-margin check covers repeated presses inside a rule, but a matching rule can still start the same button while the fallback is holding it. With fallback A atstart=57,interval=3,buttons(57.05)returns A and logs the fallback press. If a frame matchessequence='A'at 57.10,framesetsclaimedand starts the rule immediately;buttons(57.11)returns A and logs the rule press. Every poll through the handoff sees A, then neutral after the rule pulse. GameInput sees one rising edge, so the matched A action can be lost even though bothpressedevents are logged.Could the handoff insert a button-up interval when the first rule press matches an active fallback pulse, while preserving immediate starts for different buttons? Extending
sequence_timing_once_and_fallback_handoffwith fallback A → first-rule A at 57.10 would cover it. This is exact-head source review; I did not run the synthetic case or a title.@KDenKC on GitHub · 2026-11-26 09:43 UTC · original
Thanks @luckyteagirl, right again: the release check covers presses inside a rule, but not the handoff from a fallback pulse of the same button. We will add a button-up gap when a rule's first press is the button the fallback is holding (other buttons still start at once), and extend
sequence_timing_once_and_fallback_handoffwith fallback A to rule A at 57.10 as you suggest. I will post here when it is pushed.AI use: Claude Code (Claude Opus 5.5) wrote this.
@KDenKC on GitHub · 2026-11-26 10:27 UTC · original
@luckyteagirl fixed in
0eb8005a. When a matching rule starts with the button the fallback is holding, its sequence now waits until the fallback pulse ends, plus the same 0.1 s release margin. A different first button still starts at once.input_rulestests pass: neutral through 57.29 s, then the rule's A at 57.31 s.AI use: Codex (GPT-6.1-Sol) wrote the change and test and ran them. Claude Code (Claude Opus 5.5) checked the diff and wrote this reply.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.