[PR #1559] gameinput: queue only events a callback wants, so a later pad's connect is not stuck behind a backlog (RT-GAMEINPUT-LATE-PAD) #1583

Open
opened 2026-11-26 20:21:45 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1559
Author: @kawaii-shakal
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: gameinput-hotplug


📝 Commits (2)

  • a05f1f3 gameinput: queue only events a callback wants, so a later pad's connect is not stuck behind a backlog (RT-GAMEINPUT-LATE-PAD)
  • f7e422e Merge upstream main into gameinput-hotplug

📊 Changes

3 files changed (+94 additions, -3 deletions)

View changed files

📝 docs/gameinput.md (+5 -1)
📝 runtime/shims/gameinput.cpp (+29 -2)
📝 runtime/test/gameinput_test.cpp (+60 -0)

📄 Description

Claim: RT-GAMEINPUT-LATE-PAD. The coordination issue #14 no longer takes comments (over 2,500), so the claim is this PR itself.

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 47 press lines), 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 that open_pad queues for IGameInputDispatcher::Dispatch. queue_event queued 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_event drops an event that no registered callback matches. GameInput has no callback to run for it, so nothing should be queued.
  • Logging, to confirm the path on the next retail boot: the first 8 RegisterDeviceCallback calls (device or all, kind, status filter, enumeration mode), and the first CreateDispatcher and Dispatch calls (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 new RegisterDeviceCallback lines 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_dispatcher in runtime/test/gameinput_test.cpp:

  • With no pad present, the "title" holds a dispatcher and registers a device callback with blocking enumeration.
  • One virtual pad moves its stick on every poll, with no reading callback registered.
  • After 50 frames of 4 polls and one Dispatch(0), a DualSense-like pad with sensors is attached.
  • Its connect must reach the callback within 10 frames, and its A press must read through the device that callback handed over.

Results:

  • Without the shim change: 371 checks, 2 fail (the late pad's connect and its A press).
  • With it: 371 checks, 0 fail.
  • ctest -C RelWithDebInfo -R gameinput: gameinput, gameinput_host and gameinput_script pass (Windows 11 Pro 26300, MSVC 19.50, SDL3 3.4.20). gta6rt builds.

#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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1559 **Author:** [@kawaii-shakal](https://github.com/kawaii-shakal) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `gameinput-hotplug` --- ### 📝 Commits (2) - [`a05f1f3`](https://github.com/ubiquitarianism/leonida/commit/a05f1f3cdbb534d3261f8c557f39b637ac240ca8) gameinput: queue only events a callback wants, so a later pad's connect is not stuck behind a backlog (RT-GAMEINPUT-LATE-PAD) - [`f7e422e`](https://github.com/ubiquitarianism/leonida/commit/f7e422ee8a307ced9a41e11fb02330b4cb7abdaa) Merge upstream main into gameinput-hotplug ### 📊 Changes **3 files changed** (+94 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `docs/gameinput.md` (+5 -1) 📝 `runtime/shims/gameinput.cpp` (+29 -2) 📝 `runtime/test/gameinput_test.cpp` (+60 -0) </details> ### 📄 Description Claim: RT-GAMEINPUT-LATE-PAD. The coordination issue #14 no longer takes comments (over 2,500), so the claim is this PR itself. ### 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 47 `press` lines), 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 that `open_pad` queues for `IGameInputDispatcher::Dispatch`. `queue_event` queued **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_event` drops an event that no registered callback matches. GameInput has no callback to run for it, so nothing should be queued. - Logging, to confirm the path on the next retail boot: the first 8 `RegisterDeviceCallback` calls (device or all, kind, status filter, enumeration mode), and the first `CreateDispatcher` and `Dispatch` calls (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 new `RegisterDeviceCallback` lines 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_dispatcher` in `runtime/test/gameinput_test.cpp`: - With no pad present, the "title" holds a dispatcher and registers a device callback with blocking enumeration. - One virtual pad moves its stick on every poll, with no reading callback registered. - After 50 frames of 4 polls and one `Dispatch(0)`, a DualSense-like pad with sensors is attached. - Its connect must reach the callback within 10 frames, and its A press must read through the device that callback handed over. Results: - Without the shim change: 371 checks, 2 fail (the late pad's connect and its A press). - With it: 371 checks, 0 fail. - `ctest -C RelWithDebInfo -R gameinput`: `gameinput`, `gameinput_host` and `gameinput_script` pass (Windows 11 Pro 26300, MSVC 19.50, SDL3 3.4.20). `gta6rt` builds. #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](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#1583
No description provided.