Input: ignore all-zero XInput slots until they report input #1430

Manually merged
github merged 1 commit from gh-pr/1430/head into gh-pr/1430/base 2026-11-26 04:31:26 +00:00
Owner

@⁠fuzeofficlal on GitHub · 2026-11-24 17:58 UTC · original
fuzeofficlal:fix/hle-gameinput-idle-xinput-fallback-729 → main · +136 −13 · 1 files · 1 commits · merged 2026-11-25 21:50 UTC

Refs #729.
Closes #845.

Summary

  • Track seen_input: [bool; PADS] per XInput slot connection in State so wireless receivers reporting an all-zero PadState::default() for a switched-off controller stay disconnected (None) rather than enumerating as an active IGameInputDevice ahead of the keyboard stand-in (FALLBACK).
  • Filter unactivated slots before merge_scripted (VICTORY_KEYS) and route scripted keys to FALLBACK when no physical pad has reported input, preventing scripted diagnostic keys from latching an idle wireless receiver slot.
  • Reset seen_input[slot] = false when the host slot disconnects (None), while keeping an activated physical pad connected when released back to neutral.

Testing

  • Added switched_off_receiver_does_not_hide_the_keyboard_stand_in covering idle wireless receiver filtering, keyboard and scripted stand-in routing, first-press connection transition, return-to-rest persistence, and unplug/replug reset.
  • cargo test -p victory-hle --all-features --locked, cargo clippy --workspace --all-targets --all-features -- -D warnings, and cargo xtask policy.
**@⁠fuzeofficlal** on GitHub · 2026-11-24 17:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/1430) `fuzeofficlal:fix/hle-gameinput-idle-xinput-fallback-729` → `main` · +136 −13 · 1 files · 1 commits · merged 2026-11-25 21:50 UTC Refs #729. Closes #845. ### Summary - Track `seen_input: [bool; PADS]` per XInput slot connection in `State` so wireless receivers reporting an all-zero `PadState::default()` for a switched-off controller stay disconnected (`None`) rather than enumerating as an active `IGameInputDevice` ahead of the keyboard stand-in (`FALLBACK`). - Filter unactivated slots *before* `merge_scripted` (`VICTORY_KEYS`) and route scripted keys to `FALLBACK` when no physical pad has reported input, preventing scripted diagnostic keys from latching an idle wireless receiver slot. - Reset `seen_input[slot] = false` when the host slot disconnects (`None`), while keeping an activated physical pad connected when released back to neutral. ### Testing - Added `switched_off_receiver_does_not_hide_the_keyboard_stand_in` covering idle wireless receiver filtering, keyboard and `scripted` stand-in routing, first-press connection transition, return-to-rest persistence, and unplug/replug reset. - `cargo test -p victory-hle --all-features --locked`, `cargo clippy --workspace --all-targets --all-features -- -D warnings`, and `cargo xtask policy`.
A wireless receiver with its controller switched off still answers
XInputGetState with an all-zero state, which connected the empty slot
and disconnected the keyboard stand-in pad.

Keep each host slot disconnected until its current connection reports
non-rest input, reset that flag on disconnect, and keep scripted
diagnostic keys on the stand-in while no host pad has reported input.

Fixes #845.

Co-authored-by: andrewpozdnakov7-jpg <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:31:25 +00:00
github manually merged commit 241c671b66 into gh-pr/1430/base 2026-11-26 04:31:26 +00:00
Author
Owner

@⁠pfhandler on GitHub · 2026-11-24 20:49 UTC · original

Local patches for two issues hit while running GTA VI 1.0.2.1 through VIctory on Linux (GE-Proton 11-14, vkd3d-proton 3.2.0, RTX 4060 Ti 8 GB):

  • VICTORY_NO_HOST_PAD=1 — a connected host pad (e.g. DualShock appearing as XInput pad 0) keeps the keyboard stand-in pad from being enumerated. Hiding the host pad lets VICTORY_KEYS drive the title again.
  • VICTORY_MODE=1920x1080 — the DXGI output mode list is fixed at the console's 3840x2160. Reporting 1920x1080 instead keeps the title's render targets and VRAM use down on smaller hosts (Series S profile + 1080p settled around 3.5 GB VRAM here).

Both are local uncommitted diffs, posted here for reuse. Tested only on the configuration above.

diff --git a/crates/victory-gpu/src/dxgi.rs b/crates/victory-gpu/src/dxgi.rs
index c7f7c45..2535b68 100644
--- a/crates/victory-gpu/src/dxgi.rs
+++ b/crates/victory-gpu/src/dxgi.rs
@@ -219,6 +219,19 @@ struct Mode {
 }
 const _: () = assert!(size_of::<Mode>() == 32);
 
+/// The console's fixed output mode, overridable for hosts smaller than the
+/// console's 4K target: `VICTORY_MODE=1920x1080` reports that instead.
+fn mode_size() -> (u32, u32) {
+    const DEFAULT: (u32, u32) = (3840, 2160);
+    let Some(text) = std::env::var_os("VICTORY_MODE") else {
+        return DEFAULT;
+    };
+    let text = text.to_string_lossy();
+    text.split_once('x')
+        .and_then(|(w, h)| Some((w.trim().parse().ok()?, h.trim().parse().ok()?)))
+        .unwrap_or(DEFAULT)
+}
+
 /// The console's mode list: one 4K mode at 60 Hz (Grand Theft Auto VI looks
 /// for a 120 Hz one to allow 120 Hz frame intervals).
 /// shortcut: fixed mode, not the host display's; report the host's rates if
@@ -242,9 +255,10 @@ extern "system" fn modes(
         return MORE_DATA;
     }
     *count = 1;
+    let (width, height) = mode_size();
     let mode = Mode {
-        width: 3840,
-        height: 2160,
+        width,
+        height,
         refresh: [60, 1],
         format: 0,
         scanlines: 1, // progressive
diff --git a/crates/victory-hle/src/modules/gameinput.rs b/crates/victory-hle/src/modules/gameinput.rs
index a411bd0..da8d66c 100644
--- a/crates/victory-hle/src/modules/gameinput.rs
+++ b/crates/victory-hle/src/modules/gameinput.rs
@@ -1134,6 +1134,11 @@ mod host {
 
     impl Source for Host {
         fn pad(&mut self, slot: usize) -> Option<PadState> {
+            // The keyboard stand-in pad only exists while no host pad is
+            // connected; this hides a host pad the title mis-handles.
+            if std::env::var_os("VICTORY_NO_HOST_PAD").is_some() {
+                return None;
+            }
             if self.empty_until[slot].is_some_and(|until| Instant::now() < until) {
                 return None;
             }
**@⁠pfhandler** on GitHub · 2026-11-24 20:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/1430#issuecomment-7144110102) Local patches for two issues hit while running GTA VI 1.0.2.1 through VIctory on Linux (GE-Proton 11-14, vkd3d-proton 3.2.0, RTX 4060 Ti 8 GB): - `VICTORY_NO_HOST_PAD=1` — a connected host pad (e.g. DualShock appearing as XInput pad 0) keeps the keyboard stand-in pad from being enumerated. Hiding the host pad lets `VICTORY_KEYS` drive the title again. - `VICTORY_MODE=1920x1080` — the DXGI output mode list is fixed at the console's 3840x2160. Reporting 1920x1080 instead keeps the title's render targets and VRAM use down on smaller hosts (Series S profile + 1080p settled around 3.5 GB VRAM here). Both are local uncommitted diffs, posted here for reuse. Tested only on the configuration above. ```diff diff --git a/crates/victory-gpu/src/dxgi.rs b/crates/victory-gpu/src/dxgi.rs index c7f7c45..2535b68 100644 --- a/crates/victory-gpu/src/dxgi.rs +++ b/crates/victory-gpu/src/dxgi.rs @@ -219,6 +219,19 @@ struct Mode { } const _: () = assert!(size_of::<Mode>() == 32); +/// The console's fixed output mode, overridable for hosts smaller than the +/// console's 4K target: `VICTORY_MODE=1920x1080` reports that instead. +fn mode_size() -> (u32, u32) { + const DEFAULT: (u32, u32) = (3840, 2160); + let Some(text) = std::env::var_os("VICTORY_MODE") else { + return DEFAULT; + }; + let text = text.to_string_lossy(); + text.split_once('x') + .and_then(|(w, h)| Some((w.trim().parse().ok()?, h.trim().parse().ok()?))) + .unwrap_or(DEFAULT) +} + /// The console's mode list: one 4K mode at 60 Hz (Grand Theft Auto VI looks /// for a 120 Hz one to allow 120 Hz frame intervals). /// shortcut: fixed mode, not the host display's; report the host's rates if @@ -242,9 +255,10 @@ extern "system" fn modes( return MORE_DATA; } *count = 1; + let (width, height) = mode_size(); let mode = Mode { - width: 3840, - height: 2160, + width, + height, refresh: [60, 1], format: 0, scanlines: 1, // progressive diff --git a/crates/victory-hle/src/modules/gameinput.rs b/crates/victory-hle/src/modules/gameinput.rs index a411bd0..da8d66c 100644 --- a/crates/victory-hle/src/modules/gameinput.rs +++ b/crates/victory-hle/src/modules/gameinput.rs @@ -1134,6 +1134,11 @@ mod host { impl Source for Host { fn pad(&mut self, slot: usize) -> Option<PadState> { + // The keyboard stand-in pad only exists while no host pad is + // connected; this hides a host pad the title mis-handles. + if std::env::var_os("VICTORY_NO_HOST_PAD").is_some() { + return None; + } if self.empty_until[slot].is_some_and(|until| Instant::now() < until) { return None; } ```
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:27 UTC · original · edited 2026-11-25 09:17 UTC

Automated triage for the maintainers.

Merge candidate. Re-checked on 241c671b: its tree is identical to the previously reviewed 1530f018; only the commit message changed (a Co-authored-by trailer crediting the #845 reporter, as requested in the thread). The earlier reading stands: in crates/victory-hle/src/modules/gameinput.rs, State::poll keeps a host XInput slot disconnected until its current connection reports non-rest input (seen_input, cleared when the slot reads None), so a receiver answering for a switched-off pad no longer hides the keyboard stand-in (FALLBACK); an activated pad stays connected at rest, and the three existing tests that seeded an all-zero pad now press a button. Two small points for the maintainer remain: on the real host Host::keys already includes the VICTORY_KEYS keys in diagnostics builds, so the extra merge_pad(.., fallback(scripted)) for the stand-in only matters for the test fake; and Closes #729 would also close that issue's unrelated Windows 10 root-signature report, so "Refs #729" may be the better link. No other open PR covers the idle-receiver case except integration/bundle branches. Recommending a look, not approving.

Thanks for the attribution update; the amended commit carries the trailer and no code change.

CI: passing (check).


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/1430#issuecomment-7149571991) · edited 2026-11-25 09:17 UTC <!-- victory-triage v1 head=241c671b6666f04c9aa66e2f679367a557d3ab03 verdict=merge-candidate at=2026-11-25T09:17:40Z --> Automated triage for the maintainers. **Merge candidate.** Re-checked on `241c671b`: its tree is identical to the previously reviewed `1530f018`; only the commit message changed (a `Co-authored-by` trailer crediting the #845 reporter, as requested in the thread). The earlier reading stands: in `crates/victory-hle/src/modules/gameinput.rs`, `State::poll` keeps a host XInput slot disconnected until its current connection reports non-rest input (`seen_input`, cleared when the slot reads `None`), so a receiver answering for a switched-off pad no longer hides the keyboard stand-in (`FALLBACK`); an activated pad stays connected at rest, and the three existing tests that seeded an all-zero pad now press a button. Two small points for the maintainer remain: on the real host `Host::keys` already includes the `VICTORY_KEYS` keys in diagnostics builds, so the extra `merge_pad(.., fallback(scripted))` for the stand-in only matters for the test fake; and `Closes #729` would also close that issue's unrelated Windows 10 root-signature report, so "Refs #729" may be the better link. No other open PR covers the idle-receiver case except integration/bundle branches. Recommending a look, not approving. Thanks for the attribution update; the amended commit carries the trailer and no code change. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 05:00 UTC · original

Updated on 940d32f (1530f018) to also cover #845 at the device-enumeration level: XInput slots reporting only PadState::default() (such as a wireless receiver for a switched-off pad) now stay unenumerated until their current connection reports non-rest input, and VICTORY_KEYS scripted inputs route through FALLBACK when no physical pad is active rather than latching an idle receiver slot.

**@⁠fuzeofficlal** on GitHub · 2026-11-25 05:00 UTC · [original](https://github.com/Marvisak/VIctory/pull/1430#issuecomment-7153367978) Updated on `940d32f` (`1530f018`) to also cover #845 at the device-enumeration level: XInput slots reporting only `PadState::default()` (such as a wireless receiver for a switched-off pad) now stay unenumerated until their current connection reports non-rest input, and `VICTORY_KEYS` scripted inputs route through `FALLBACK` when no physical pad is active rather than latching an idle receiver slot.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-25 07:52 UTC · original

The device-enumeration test now covers the unplug and neutral reconnect case I reported and supplied a regression for in #845. The original follow-up commit records that contribution.

Could you retain the attribution for that specific follow-up in the commit that lands?

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

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 07:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/1430#issuecomment-7156345321) The device-enumeration test now covers the unplug and neutral reconnect case I reported and supplied a regression for in [#845](https://git.gtahub.st/github/Marvisak--VIctory/issues/845). [The original follow-up commit](https://github.com/Numbers-iwnl/VIctory/commit/c8ab89c57d376acfd1cd2afe6680ab3dfa0dce1e) records that contribution. Could you retain the attribution for that specific follow-up in the commit that lands? Co-authored-by: andrewpozdnakov7-jpg <[email protected]>
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 08:18 UTC · original

Thanks @⁠andrewpozdnakov7-jpg — the unplug and neutral-reconnect case in the device-enumeration test comes from your #845 report and regression. I amended the commit to credit you (241c671b, Co-authored-by trailer); the code is unchanged.

**@⁠fuzeofficlal** on GitHub · 2026-11-25 08:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/1430#issuecomment-7156872006) Thanks @⁠andrewpozdnakov7-jpg — the unplug and neutral-reconnect case in the device-enumeration test comes from your #845 report and regression. I amended the commit to credit you (`241c671b`, `Co-authored-by` trailer); the code is unchanged.
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1430
No description provided.