HLE/gameinput: a pad an all-zero receiver answers for is not a device #839

Merged
CwWwWwW merged 1 commit from upstream-pr/839 into main 2026-11-29 08:16:58 +00:00
CwWwWwW commented 2026-11-28 07:34:45 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by CwWwWwW on 2026-11-28T07:34:45Z.


Ported to trustno1-coder/VIctory-NVIDIA from the same change submitted to fxceless/victory-fork as PR #1464 (head 8b883b5bf7, author CwWwWwW). The fork's own line was dropped when it rebased onto 959dcaf (5dbf5ce), so this is submitted here directly. The description below is the original one; its 'Verification' numbers refer to the fork tree. Rebased onto main 63b902f.

The problem

Some XInput wireless receivers answer XInputGetState with success and an all-zero XINPUT_STATE while their pad is switched off. The HLE's Host::pad (crates/victory-hle/src/modules/gameinput.rs:1136-1162) returns that state as a pad, and State::poll (:457) counted any Some pad as present:

  • any_pad became true, so the keyboard's stand-in pad (FALLBACK) was disconnected (:461);
  • the title got a gamepad device that never produces input, while the keyboard is reported on the separate keyboard device (KEYBOARD), which gameplay does not poll.

Result on an affected setup: the title ignores the keyboard entirely (its start screen waits for a pad press that never comes), with nothing telling the user why.

Evidence for the receiver behaviour: this is a documented XInput class (the base project's input layer has a report for exactly it). The code-level path is confirmed by the new test, which on the old code turns a single all-zero pad report into two device events 鈥?device 0 connects and the stand-in disconnects.

The change

State keeps, per host slot, whether that slot has ever shown input (shown_input). In poll a reported pad is a device only once it has shown some input; a pad at rest after it was used stays connected; a slot the host no longer answers for forgets it. any_pad counts only these devices, so the stand-in stays while only phantom pads are reported.

No code is taken from anywhere; the rule is implemented in this tree's poll/state model.

Evidence

New test gameinput::tests::an_all_zero_pad_is_not_a_device_the_title_can_use:

  • old code: the first poll after an all-zero pad report gives [(4, 3, 0), (0, 3, 0), (4, 0, 3)] 鈥?the stand-in (4) is connected, then the all-zero pad connects (0) and the stand-in disconnects;
  • new code: the stand-in stays, the pad connects only after it reports input, stays connected at rest, and the stand-in returns when the slot stops answering.

The existing unregistering_waits_for_a_running_callback test used an all-zero pad to make a device appear; it now gives the pad input (it needs a connect callback to run).

Verification (base 9a9091d):

  • cargo test -p victory-hle --lib --locked -- --test-threads=1 鈥?104 passed, 0 failed
  • cargo clippy -p victory-hle --all-targets --locked -- -D warnings 鈥?clean
  • cargo clippy -p victory-hle --all-targets --locked --all-features -- -D warnings 鈥?clean
  • git diff --check clean; no new fmt diff (pre-existing crate fmt diffs only).

Scope, overlap, residual risk

One file, crates/victory-hle/src/modules/gameinput.rs (+70/-2). Open PRs in this area do not cover the zero-state rule: #74 supplements the keyboard onto the first connected pad but leaves any_pad as it is, #359 is an env override, #1175 moves where the stand-in is reported. They touch the same poll function, so textual conflicts are possible; the defect is distinct.

Residual: a receiver that keeps answering all-zero after the pad is switched off mid-run keeps that slot connected (at rest) as before; this change fixes the boot case (no device until real input) and does not add a disconnect heuristic for a permanently-zero answering slot.

Limitation: no XInput hardware in this environment; hardware confirmation of the receiver behaviour was not possible here. The platform behaviour is documented externally; the code-level behaviour is covered by the unit test.

Verification on this tree (base 63b902f, 2026-11-27)

  • cargo check --workspace --all-targets --locked: pass (Rust 1.98.1, the version pinned in rust-toolchain.toml)
  • cargo check --workspace --all-targets --all-features --locked: pass
  • cargo clippy --workspace --all-targets --locked -- -D warnings (and --all-features): this change adds no clippy finding. The only failures are on unmodified lines of main (clippy::manual_is_multiple_of at crates/victory-gpu/src/shadow.rs:1708 and crates/victory-gpu/src/descriptor.rs:1234, clippy::let_and_return at crates/victory-shader/src/emit/mod.rs:2768); CI run 46104876336 on 63b902f failed on those before this change.
  • cargo test was not run in the author's environment (Windows VM without an MSVC toolchain; test binaries could not be linked there). CI on Windows and a run on the card should confirm.

Hardware verification suggested

  • Only changes behaviour with VICTORY_ONE_PAD=0 (default one-pad mode stays as before); the all-zero-receiver rule is a heuristic that wants one run on affected hardware.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5537938132 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/839). Originally posted by [CwWwWwW](https://github.com/CwWwWwW) on 2026-11-28T07:34:45Z. --- Ported to trustno1-coder/VIctory-NVIDIA from the same change submitted to fxceless/victory-fork as PR #1464 (head 8b883b5bf7d2613b216499516e477f22b405b934, author CwWwWwW). The fork's own line was dropped when it rebased onto 959dcaf (5dbf5ce), so this is submitted here directly. The description below is the original one; its 'Verification' numbers refer to the fork tree. Rebased onto main 63b902f. ## The problem Some XInput wireless receivers answer `XInputGetState` with success and an all-zero `XINPUT_STATE` while their pad is switched off. The HLE's `Host::pad` (`crates/victory-hle/src/modules/gameinput.rs:1136-1162`) returns that state as a pad, and `State::poll` (`:457`) counted any `Some` pad as present: - `any_pad` became true, so the keyboard's stand-in pad (`FALLBACK`) was disconnected (`:461`); - the title got a gamepad device that never produces input, while the keyboard is reported on the separate keyboard device (`KEYBOARD`), which gameplay does not poll. Result on an affected setup: the title ignores the keyboard entirely (its start screen waits for a pad press that never comes), with nothing telling the user why. Evidence for the receiver behaviour: this is a documented XInput class (the base project's input layer has a report for exactly it). The code-level path is confirmed by the new test, which on the old code turns a single all-zero pad report into two device events 鈥?device 0 connects and the stand-in disconnects. ## The change `State` keeps, per host slot, whether that slot has ever shown input (`shown_input`). In `poll` a reported pad is a device only once it has shown some input; a pad at rest after it was used stays connected; a slot the host no longer answers for forgets it. `any_pad` counts only these devices, so the stand-in stays while only phantom pads are reported. No code is taken from anywhere; the rule is implemented in this tree's poll/state model. ## Evidence New test `gameinput::tests::an_all_zero_pad_is_not_a_device_the_title_can_use`: - old code: the first poll after an all-zero pad report gives `[(4, 3, 0), (0, 3, 0), (4, 0, 3)]` 鈥?the stand-in (4) is connected, then the all-zero pad connects (0) and the stand-in disconnects; - new code: the stand-in stays, the pad connects only after it reports input, stays connected at rest, and the stand-in returns when the slot stops answering. The existing `unregistering_waits_for_a_running_callback` test used an all-zero pad to make a device appear; it now gives the pad input (it needs a connect callback to run). Verification (base `9a9091d`): - `cargo test -p victory-hle --lib --locked -- --test-threads=1` 鈥?104 passed, 0 failed - `cargo clippy -p victory-hle --all-targets --locked -- -D warnings` 鈥?clean - `cargo clippy -p victory-hle --all-targets --locked --all-features -- -D warnings` 鈥?clean - `git diff --check` clean; no new fmt diff (pre-existing crate fmt diffs only). ## Scope, overlap, residual risk One file, `crates/victory-hle/src/modules/gameinput.rs` (+70/-2). Open PRs in this area do not cover the zero-state rule: #74 supplements the keyboard onto the first connected pad but leaves `any_pad` as it is, #359 is an env override, #1175 moves where the stand-in is reported. They touch the same `poll` function, so textual conflicts are possible; the defect is distinct. Residual: a receiver that keeps answering all-zero after the pad is switched off mid-run keeps that slot connected (at rest) as before; this change fixes the boot case (no device until real input) and does not add a disconnect heuristic for a permanently-zero answering slot. Limitation: no XInput hardware in this environment; hardware confirmation of the receiver behaviour was not possible here. The platform behaviour is documented externally; the code-level behaviour is covered by the unit test. ## Verification on this tree (base 63b902f, 2026-11-27) - cargo check --workspace --all-targets --locked: pass (Rust 1.98.1, the version pinned in rust-toolchain.toml) - cargo check --workspace --all-targets --all-features --locked: pass - cargo clippy --workspace --all-targets --locked -- -D warnings (and --all-features): this change adds no clippy finding. The only failures are on unmodified lines of main (clippy::manual_is_multiple_of at crates/victory-gpu/src/shadow.rs:1708 and crates/victory-gpu/src/descriptor.rs:1234, clippy::let_and_return at crates/victory-shader/src/emit/mod.rs:2768); CI run 46104876336 on 63b902f failed on those before this change. - cargo test was not run in the author's environment (Windows VM without an MSVC toolchain; test binaries could not be linked there). CI on Windows and a run on the card should confirm. ## Hardware verification suggested - Only changes behaviour with VICTORY_ONE_PAD=0 (default one-pad mode stays as before); the all-zero-receiver rule is a heuristic that wants one run on affected hardware.
Dukestar69 commented 2026-11-28 07:47:33 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Dukestar69 on 2026-11-28T07:47:33Z.

Review: APPROVED


Tested locally merged onto main (63b902f).

  • Merge & Policy: Clean merge; cargo xtask policy passed (294 files ok).
  • Tests: cargo test -p victory-hle --lib gameinput passed (27 passed; 0 failed; 1 ignored, including the new an_all_zero_pad_is_not_a_device_the_title_can_use test) with 0 compiler warnings.

Good guard preventing phantom/all-zero wireless receiver devices from being exposed to titles. LGTM.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:review:6096614484 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/839#pullrequestreview-6096614484). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-28T07:47:33Z. **Review:** APPROVED --- Tested locally merged onto `main` (`63b902f`). - **Merge & Policy**: Clean merge; `cargo xtask policy` passed (`294 files ok`). - **Tests**: `cargo test -p victory-hle --lib gameinput` passed (`27 passed; 0 failed; 1 ignored`, including the new `an_all_zero_pad_is_not_a_device_the_title_can_use` test) with 0 compiler warnings. Good guard preventing phantom/all-zero wireless receiver devices from being exposed to titles. LGTM. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
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
trustno1-coder/VIctory-NVIDIA!839
No description provided.