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

Open
marquezinii wants to merge 1 commit from upstream-pr/428 into main
marquezinii commented 2026-11-24 03:15:45 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by marquezinii on 2026-11-24T03:15:45Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:issue:6573811294 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/428). Originally posted by [marquezinii](https://github.com/marquezinii) on 2026-11-24T03:15:45Z. --- `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
mercuryVM commented 2026-11-24 06:52:58 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T05:11:44Z.

Review: APPROVED


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).

<!-- greyfinch-sync:Marvisak/VIctory:review:6034041469 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/428#pullrequestreview-6034041469). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T05:11:44Z. **Review:** APPROVED --- 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).
DaviTostes commented 2026-11-24 06:55:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DaviTostes on 2026-11-24T03:32:50Z.


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):

  • victory-hle: 86 passed, 1 failed. The failure is modules::net::tests::only_loopback_is_reachable — the known Wine WSAConnectByList environment gap (#217), not this change.
  • The new walks_filtered_by_a_disconnected_pad_fail passes.
  • no_dll_planting: 1 passed.
  • No conflict with #312 (also edits gameinput.rs): git merge-tree --write-tree 191e335 a312333 merges cleanly.

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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7121199000 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/428#issuecomment-7121199000). Originally posted by [DaviTostes](https://github.com/DaviTostes) on 2026-11-24T03:32:50Z. --- 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): - `victory-hle`: **86 passed, 1 failed**. The failure is `modules::net::tests::only_loopback_is_reachable` — the known Wine `WSAConnectByList` environment gap (#217), not this change. - The new `walks_filtered_by_a_disconnected_pad_fail` passes. - `no_dll_planting`: **1 passed**. - No conflict with #312 (also edits `gameinput.rs`): `git merge-tree --write-tree 191e335 a312333` merges cleanly. Not covered: a physical pad disconnect during polling, and title behaviour (no game data on this machine).
Marvisak commented 2026-11-25 01:07:54 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:29:27Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148562927 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/428#issuecomment-7148562927). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:29:27Z. --- <!-- victory-triage v1 head=a312333c28ebfd4944d2943b8cb642f4a306469c verdict=needs-rebase at=2026-11-25T01:16:00Z --> 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](https://claude.ai/code)_
andrewpozdnakov7-jpg commented 2026-11-25 10:07:55 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T10:01:38Z.


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 <[email protected]>.

Filter coordination claim

<!-- greyfinch-sync:Marvisak/VIctory:comment:7159122819 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/428#issuecomment-7159122819). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-25T10:01:38Z. --- I rebased your disconnected-device fix on current main (`940d32f`) in [`f023c6c`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/f023c6ceb63b0425272cfc8c9f7ceaef7a70a5ce). 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](https://learn.microsoft.com/en-us/gaming/gdk/docs/features/common/input/overviews/input-readings?view=gdk-2610). 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`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/366ca983c0f8a71b753dc6edd512acd8f172ba17) 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 <[email protected]>`. [Filter coordination claim](https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7159011052)
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/428:upstream-pr/428'
git switch 'upstream-pr/428'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/428'
git switch 'upstream-pr/428'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/428'
git switch 'upstream-pr/428'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/428'
git switch 'main'
git merge --squash 'upstream-pr/428'
git switch 'main'
git merge --ff-only 'upstream-pr/428'
git switch 'main'
git merge 'upstream-pr/428'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
Marvisak/VIctory!428
No description provided.