GameInput: look up only devices already seen by the process #2510

Open
andrewpozdnakov7-jpg wants to merge 2 commits from upstream-pr/2512 into main
andrewpozdnakov7-jpg commented 2026-11-25 15:04:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T15:04:10Z.


FindDeviceFromId currently searches every preallocated pad slot. An ID saved by the application can therefore resolve at startup before any pad has appeared in that slot.

Only resolve IDs for slots that have produced an input reading. The history keeps the ID usable for a device this process has already seen after it disconnects.

The synthetic GameInput test gets S_OK for a never-connected pad on the original base, 940d32f. With this fix and #1430 from current main, a never-seen pad and a slot with only an initial all-zero report both return DEVICE_NOT_FOUND and a null output. A button report establishes the ID, which remains usable through idle and disconnect. The existing rumble test now starts with a button report as well.

Both focused tests and all 153 HLE library tests passed on current main 63bcca43, in both default and diagnostics builds. Strict HLE Clippy in both builds and staged asset policy passed.

GameInput lookup behavior · Coordination claim

Please retain the Git author when cherry-picking or rebasing. If you fold the change into another commit, please add:

Co-authored-by: andrewpozdnakov7-jpg [email protected]

AI-assisted with Codex.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5493883182 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2512). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-25T15:04:10Z. --- FindDeviceFromId currently searches every preallocated pad slot. An ID saved by the application can therefore resolve at startup before any pad has appeared in that slot. Only resolve IDs for slots that have produced an input reading. The history keeps the ID usable for a device this process has already seen after it disconnects. The synthetic GameInput test gets S_OK for a never-connected pad on the original base, 940d32f. With this fix and #1430 from current main, a never-seen pad and a slot with only an initial all-zero report both return DEVICE_NOT_FOUND and a null output. A button report establishes the ID, which remains usable through idle and disconnect. The existing rumble test now starts with a button report as well. Both focused tests and all 153 HLE library tests passed on current main 63bcca43, in both default and diagnostics builds. Strict HLE Clippy in both builds and staged asset policy passed. [GameInput lookup behavior](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/input/gameinput/interfaces/igameinput/methods/igameinput_finddevicefromid) · [Coordination claim](https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7166120442) Please retain the Git author when cherry-picking or rebasing. If you fold the change into another commit, please add: Co-authored-by: andrewpozdnakov7-jpg <[email protected]> AI-assisted with Codex.
Marvisak commented 2026-11-25 16:09:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:53:30Z.


Automated triage for the maintainers.

Verdict: merge candidate (unchanged). The new head merges main (with #1430) and changes only the tests. #1430 keeps a host pad disconnected until it reports non-rest input. So find_by_id in crates/victory-hle/src/modules/gameinput.rs, which requires a non-empty slot history, now finds a pad from its first real input. That is the same point at which the title sees it connect, so the lookup and the connection events agree. lookup_by_id_only_finds_devices_that_have_been_seen covers four cases: never seen, an all-zero first report (still not found), a button report, and then the ID staying found through idle, disconnect and reconnect. The rumble test now starts with a button report, as it needs to under #1430. The lock is held only for the lookup; callbacks are delivered after poll drops it.

CI: passing (check).


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7167404247 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2512#issuecomment-7167404247). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T15:53:30Z. --- <!-- victory-triage v1 head=12986bb6c4292b9c08ee190a6953465e32f56f2a verdict=merge-candidate at=2026-11-26T03:23:06Z --> Automated triage for the maintainers. **Verdict: merge candidate (unchanged).** The new head merges `main` (with #1430) and changes only the tests. #1430 keeps a host pad disconnected until it reports non-rest input. So `find_by_id` in `crates/victory-hle/src/modules/gameinput.rs`, which requires a non-empty slot history, now finds a pad from its first real input. That is the same point at which the title sees it connect, so the lookup and the connection events agree. `lookup_by_id_only_finds_devices_that_have_been_seen` covers four cases: never seen, an all-zero first report (still not found), a button report, and then the ID staying found through idle, disconnect and reconnect. The rumble test now starts with a button report, as it needs to under #1430. The lock is held only for the lookup; callbacks are delivered after `poll` drops it. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
andrewpozdnakov7-jpg commented 2026-11-25 16:09:41 +00:00 (Migrated from github.com)

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


Following up on the documentation check. The reference page explicitly says that an identifier with no matching known GameInput device object yields a null output pointer. Microsoft Learn — IGameInput::FindDeviceFromId

The device overview documents stable IDs across reconnects, and the interface reference says a device object already held by an application stays valid after disconnect. Returning DEVICE_NOT_FOUND for a never-seen slot and keeping a previously seen slot findable are VIctory's choices; the synthetic test at 42dae70 covers both. GameInput device IDs · GameInput device lifetime

<!-- greyfinch-sync:Marvisak/VIctory:comment:7167528721 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2512#issuecomment-7167528721). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-25T16:01:45Z. --- Following up on the [documentation check](https://github.com/Marvisak/VIctory/pull/2512#issuecomment-7167404247). The reference page explicitly says that an identifier with no matching known GameInput device object yields a null output pointer. [Microsoft Learn — `IGameInput::FindDeviceFromId`](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/input/gameinput/interfaces/igameinput/methods/igameinput_finddevicefromid?view=gdk-2604#remarks) The device overview documents stable IDs across reconnects, and the interface reference says a device object already held by an application stays valid after disconnect. Returning `DEVICE_NOT_FOUND` for a never-seen slot and keeping a previously seen slot findable are VIctory's choices; the synthetic test at `42dae70` covers both. [GameInput device IDs](https://learn.microsoft.com/en-us/gaming/gdk/docs/features/common/input/overviews/input-devices?view=gdk-2604#device-ids) · [GameInput device lifetime](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/input/gameinput/interfaces/igameinputdevice/igameinputdevice?view=gdk-2604#remarks)
fuzeofficlal commented 2026-11-26 02:05:43 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T02:05:43Z.

Review: COMMENTED


Reviewed and tested merged against current main (63bcca43) on Windows 11. Although git merge-tree reports zero text conflicts, merging into current main causes 2 unit tests in victory-hle to fail due to a semantic interaction with fd94726e (#1430, which now ignores all-zero XInput PadState slots in State::poll until they report non-zero input):

  • Because find_by_id (crates/victory-hle/src/modules/gameinput.rs:924-926) now requires !state.slots[device.index].history.is_empty(), any test that connects a pad with Some(PadState::default()) leaves history empty and receives DEVICE_NOT_FOUND (-2088108030) instead of S_OK (0):
    1. New test modules::gameinput::tests::lookup_by_id_only_finds_devices_that_have_been_seen (gameinput.rs:1756-1759) fails (left: -2088108030, right: 0).
    2. Existing test modules::gameinput::tests::devices_are_found_by_id_and_rumble_reaches_the_host (gameinput.rs:1767, 1778) fails with the same error.
  • Fix needed: rebase onto main and feed a non-default initial PadState (e.g., with a button bit set) when first connecting the test pads in those two tests, then assert find_by_id still finds the device after returning to idle / disconnect.

(Local verification on merged 63bcca43: cargo test --locked -p victory-hle: 151 passed, 2 failed; clippy default & --all-features and xtask policy passed.)

<!-- greyfinch-sync:Marvisak/VIctory:review:6067593535 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2512#pullrequestreview-6067593535). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T02:05:43Z. **Review:** COMMENTED --- Reviewed and tested merged against current `main` (`63bcca43`) on Windows 11. Although `git merge-tree` reports zero text conflicts, **merging into current `main` causes 2 unit tests in `victory-hle` to fail** due to a semantic interaction with `fd94726e` (#1430, which now ignores all-zero XInput `PadState` slots in `State::poll` until they report non-zero input): - Because `find_by_id` (`crates/victory-hle/src/modules/gameinput.rs:924-926`) now requires `!state.slots[device.index].history.is_empty()`, any test that connects a pad with `Some(PadState::default())` leaves `history` empty and receives `DEVICE_NOT_FOUND` (`-2088108030`) instead of `S_OK` (`0`): 1. New test `modules::gameinput::tests::lookup_by_id_only_finds_devices_that_have_been_seen` (`gameinput.rs:1756-1759`) fails (`left: -2088108030, right: 0`). 2. Existing test `modules::gameinput::tests::devices_are_found_by_id_and_rumble_reaches_the_host` (`gameinput.rs:1767, 1778`) fails with the same error. - **Fix needed**: rebase onto `main` and feed a non-default initial `PadState` (e.g., with a button bit set) when first connecting the test pads in those two tests, then assert `find_by_id` still finds the device after returning to idle / disconnect. *(Local verification on merged `63bcca43`: `cargo test --locked -p victory-hle`: 151 passed, 2 failed; `clippy` default & `--all-features` and `xtask policy` passed.)*
futurepro62 commented 2026-11-26 02:07:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T01:42:58Z.


Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head 42dae70 (on its base 940d32f).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 697 passed, 0 failed, 10 ignored.
  • The new tests ran and passed: lookup_by_id_only_finds_devices_that_have_been_seen.
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7180052022 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2512#issuecomment-7180052022). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-26T01:42:58Z. --- Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head `42dae70` (on its base `940d32f`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **697 passed, 0 failed, 10 ignored**. - The new tests ran and passed: `lookup_by_id_only_finds_devices_that_have_been_seen`. - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
andrewpozdnakov7-jpg commented 2026-11-26 03:05:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T02:17:46Z.


I reproduced both failures with 42dae70 merged into 63bcca43. 12986bb gives both fixtures a button report before expecting a known ID. The lookup test also checks the initial all-zero report is ignored, then checks the ID remains known through idle and disconnect.

Both focused tests passed. All 153 victory-hle library tests passed in each of the default and diagnostics builds. Strict Clippy with both feature sets and asset policy passed.

Review

<!-- greyfinch-sync:Marvisak/VIctory:comment:7180660306 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2512#issuecomment-7180660306). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-26T02:17:46Z. --- I reproduced both failures with 42dae70 merged into 63bcca43. [12986bb](https://github.com/Marvisak/VIctory/commit/12986bb6c4292b9c08ee190a6953465e32f56f2a) gives both fixtures a button report before expecting a known ID. The lookup test also checks the initial all-zero report is ignored, then checks the ID remains known through idle and disconnect. Both focused tests passed. All 153 victory-hle library tests passed in each of the default and diagnostics builds. Strict Clippy with both feature sets and asset policy passed. [Review](https://github.com/Marvisak/VIctory/pull/2512#pullrequestreview-6067593535)
cloph-dsp commented 2026-11-26 22:58:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-26T22:58:19Z.


Independent local verification (Windows, Rust 1.100.0/MSVC, cargo test --locked, CARGO_BUILD_JOBS=2, per-worktree CARGO_TARGET_DIR):

  • cargo test --locked -p victory-hle --lib -- --exact modules::gameinput::tests::lookup_by_id_only_finds_devices_that_have_been_seen -> 1 passed, 0 failed, 152 filtered.
  • git diff --check origin/main HEAD -> clean.
  • Negative control: the new test name is absent from origin/main (git grep exit 1).

No game data or DRM involved; synthetic Windows host scenario only. AI-assisted (Hy4 flash). GPU/driver: N/A (CPU-only HLE test).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7205142917 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2512#issuecomment-7205142917). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-26T22:58:19Z. --- Independent local verification (Windows, Rust 1.100.0/MSVC, `cargo test --locked`, `CARGO_BUILD_JOBS=2`, per-worktree `CARGO_TARGET_DIR`): - `cargo test --locked -p victory-hle --lib -- --exact modules::gameinput::tests::lookup_by_id_only_finds_devices_that_have_been_seen` -> 1 passed, 0 failed, 152 filtered. - `git diff --check origin/main HEAD` -> clean. - Negative control: the new test name is absent from `origin/main` (`git grep` exit 1). No game data or DRM involved; synthetic Windows host scenario only. AI-assisted (Hy4 flash). GPU/driver: N/A (CPU-only HLE test).
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/2512:upstream-pr/2512'
git switch 'upstream-pr/2512'

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/2512'
git switch 'upstream-pr/2512'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2512'
git switch 'upstream-pr/2512'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2512'
git switch 'main'
git merge --squash 'upstream-pr/2512'
git switch 'main'
git merge --ff-only 'upstream-pr/2512'
git switch 'main'
git merge 'upstream-pr/2512'
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!2510
No description provided.