Skip to content

GameInput: next and previous readings of a disconnected device fail - #428

Open
marquezinii wants to merge 1 commit into
Marvisak:mainfrom
marquezinii:fix/gameinput-walk-disconnected
Open

marquezinii wants to merge 1 commit into
Marvisak:mainfrom
marquezinii:fix/gameinput-walk-disconnected

Conversation

@marquezinii

Copy link
Copy Markdown
Contributor

GetNextReading and GetPreviousReading with a device filter kept walking a device's history after it was unplugged. Both reference pages say the call "Returns a NULL value and failure HRESULT if [...] a device filter is provided for a disconnected device", and GetCurrentReading here already returns GAMEINPUT_E_DEVICE_DISCONNECTED in that case.

With the old code, Next returned GAMEINPUT_E_READING_NOT_FOUND and Previous an old reading. The polling loop on those pages keeps going on READING_NOT_FOUND and resets only on another failure, so a title written that way never noticed the pad was gone.

relative now fails with DEVICE_DISCONNECTED when a device is given and its slot is not connected, as current_reading does. Without a device filter nothing changes.

Tested with a new test that walks forward and back from a pad's reading after the fake host drops the pad: before the change it gets READING_NOT_FOUND, now DEVICE_DISCONNECTED both ways. cargo test -p victory-hle passes and clippy reports nothing new. Not tried with a real pad being unplugged.

https://learn.microsoft.com/gaming/gdk/docs/reference/input/gameinput/interfaces/igameinput/methods/igameinput_getnextreading

GetNextReading and GetPreviousReading document a failure when a device
filter names a disconnected device, as GetCurrentReading already gives.
Walking from such a device's reading returned READING_NOT_FOUND (or an
old reading), so a title following the documented polling loop kept
waiting on a pad that was gone.
@DaviTostes

Copy link
Copy Markdown

Verified a312333 on Arch Linux x86_64 with the Windows build under Wine 11.22 (cargo xwin, x86_64-pc-windows-msvc, release, rustc 1.98.1):

Not covered: a physical pad disconnect during polling, and title behaviour (no game data on this machine).

@mercuryVM mercuryVM left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested a312333 on Windows 11, RTX 5070, MSVC: cargo test --workspace --no-fail-fast passes (265 passed, 0 failed).

  • The new check runs after the device == reference.device check, so index is the filtered device's slot. The DEVICE_DISCONNECTED result matches what current_reading already returns for a disconnected filter device.
  • Unfiltered walks (device null) are unchanged and can still walk the history of an unplugged device, which seems right since the docs only describe the filtered case.

No issues found.

AI-assisted (Claude Code).

mercuryVM added a commit to mercuryVM/VIctory that referenced this pull request Nov 24, 2026
… of a disconnected device fail

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Needs rebase. This pull request conflicts with main (conflicting: crates/victory-hle/src/modules/gameinput.rs). It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

@andrewpozdnakov7-jpg

Copy link
Copy Markdown

I rebased your disconnected-device fix on current main (940d32f) in f023c6c. The conflict was around the history scan changed by #361. Your guard and regression are preserved, along with your Git author. The disconnected-pad test passes on Windows.

The rebase also exposed a separate case. A reference reading marks a position in the stream. A caller can filter the returned readings to a device, as documented in GameInput readings. With two synthetic pads sampled in one poll, 940d32f and f023c6c both return E_INVALIDARG when the filter names the other pad. The separate 366ca98 selects readings from the requested pad in both directions. The original disconnected-pad test still passes.

The combined branch passes all 10 GameInput tests and all 145 victory-hle library tests on native Windows, plus strict Clippy and staged asset policy. You can take f023c6c by itself if you want to keep this PR focused on disconnects. If you fold in the separate filter change, please retain Co-authored-by: andrewpozdnakov7-jpg <andrewpozdnakov7-jpg@users.noreply.github.com>.

Filter coordination claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants