Repository navigation
gameinput: queue only events a callback wants, so a later pad's connect is not stuck behind a backlog (RT-GAMEINPUT-LATE-PAD) - #1559
Conversation
…ct is not stuck behind a backlog (RT-GAMEINPUT-LATE-PAD) A pad connected after the title started was seen by the shim but not by the title, while pads present at start worked. Pads present at start reach a title through blocking enumeration, which runs synchronously in RegisterDeviceCallback. A later pad reaches it only through a queued connect event. queue_event queued every reading and guide change whether or not any callback listened. With a dispatcher held, a title that runs one item a frame (Dispatch(0), the pattern Microsoft's Dispatch page suggests) falls further behind every frame, because a moving stick or a sensor pad's 125 Hz stream queues items faster. The later pad's connect event then never comes out of the queue. queue_event now drops an event no registered callback matches, as GameInput has no work to dispatch then. The first few RegisterDeviceCallback calls and the first CreateDispatcher and Dispatch calls are logged, so a retail run shows whether the title holds a dispatcher (not yet confirmed for the retail title). Test: test_late_pad_behind_dispatcher. A title with a dispatcher registers its device callback with no pad, a first pad moves on every poll, and a pad attached later must reach the callback within ten frames of Dispatch(0). Without the fix it fails (2 of 371 checks); with it, 371 checks pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Reviewed a05f1f3: read the shim and test on both trees; gameinput_test needs Windows+SDL+MSVC, so it was not run here. A model of matches()/queue_event/deliver_within(0) replaying test_late_pad_behind_dispatcher matches the commit message: on main the late pad's connect sits behind 150+ readings no callback asked for and its 2 checks fail; with the fix it reaches the callback in the first frame after attach and nothing stale is dispatched. All five queue_event call sites run under the state lock, dropped events keep the refcount balanced (push_reading lends its pointer), and the async- and blocking-enumeration paths are unaffected. Note the (documented) behaviour change: an event that arrives with no matching callback is dropped rather than replayed to a later-registered callback, which matches real GameInput, where registration's enumeration is what reports current state. AI-assisted review. Recommendation: Merge |
|
Hi @kawaii-shakal, thanks for this pull request. CONTRIBUTING.md asks contributors to claim their work in the coordination issue ("Coordinating who works on what", currently #1608) before opening a pull request: post The claim matters because "it is claimed in the coordination issue by the pull request's author" is the first item on the maintainers' checklist for a mergeable pull request, and because it lets others see that the work is taken before they write it a second time. Could you post the claim in #1608 and add the ID to the pull request description? If you already claimed it in another form, a link to your comment is enough. AI-assisted (Claude Code, Claude Opus 5.5). |
|
Thanks, claimed now: #2570 (comment) (the coordination thread moved on from #1608 to #2570 today). The ID is in the title and the first line of the description. The branch still merges cleanly into main 4a54aed. Generated by Claude Code |
Item: RT-GAMEINPUT-LATE-PAD (claimed in #2570).
What and why
On the retail boot (RTX 5070 Ti, DualSense), a pad connected after the title started was seen by the shim (
connected DualSense Wireless Controller (..., player 2, ...), then 47presslines), but the title did not react. A pad present at start worked, and so did one that dropped out and came back as the same device.A pad present at start reaches the title through blocking enumeration, which runs synchronously inside
RegisterDeviceCallback. A pad that connects later reaches it only through the connect event thatopen_padqueues forIGameInputDispatcher::Dispatch.queue_eventqueued every event, whether or not any callback wanted it, including the reading events the poll loop makes for a moving stick and a DualSense's 125 Hz sensor stream. A title that holds a dispatcher and runs one item a frame (Dispatch(0), as Microsoft's guidance suggests) falls further behind every frame, and the late pad's connect event never comes out.runtime/shims/gameinput.cpp:queue_eventdrops an event that no registered callback matches. GameInput has no callback to run for it, so nothing should be queued.RegisterDeviceCallbackcalls (device or all, kind, status filter, enumeration mode), and the firstCreateDispatcherandDispatchcalls (with the quota).docs/gameinput.md: both, in "How it runs".Not yet confirmed on the retail title. I have not booted this branch with a pad plugged in late. If that boot logs no
CreateDispatcher, this backlog is not what kept the pad from the title, and the newRegisterDeviceCallbacklines are where to look next. I checked the other candidates in the code and none of them explains it. Null-device reads aggregate over all pads. Status and kind filters treat a live connect the same as an enumeration event. The player slot only drives the LEDs. Offline, every device belongs to the one user.Test
test_late_pad_behind_dispatcherinruntime/test/gameinput_test.cpp:Dispatch(0), a DualSense-like pad with sensors is attached.Results:
ctest -C RelWithDebInfo -R gameinput:gameinput,gameinput_hostandgameinput_scriptpass (Windows 11 Pro 26300, MSVC 19.50, SDL3 3.4.20).gta6rtbuilds.#1528 (keyboard pad on by default) and #1510 touch the same files; either may need a trivial rebase after the other.
AI-assisted: yes (Claude Code, Claude Opus 5.5).
🤖 Generated with Claude Code