VICTORY_KEYS never reaches pad slot 0 when no pad is plugged in #1167

Open
opened 2026-11-26 03:58:47 +00:00 by github-bot · 2 comments
Owner

@⁠MoonYueya on GitHub · 2026-11-25 22:25 UTC · original

Commit tested: c36971b.

  • Machine: Windows 11 (build 26300), Ryzen 7 7700, NVIDIA RTX 3080 10 GB, driver 32.0.16.1742.
  • Build: cargo build --profile diag -p victory --features diagnostics, toolchain 1.98.1.
  • Input: fully automated. No SendInput, no window focus, no manual pad use. The only input
    channel is the in-process VICTORY_KEYS schedule. A XInput dwPacketNumber check ran
    throughout and never saw a change while no scripted key was held.
  • AI assistance: the runs, log parsing and this write-up were done by an AI agent on the
    author's machine.

What happens

With no gamepad plugged in, VICTORY_KEYS presses do not reach pad slot 0. A screen that only
reads slot 0 therefore ignores every scripted key, even though the keys are being held.

crates/victory-hle/src/modules/gameinput.rs, impl Source for Host, fn pad:

fn pad(&mut self, slot: usize) -> Option<PadState> {
    ...
    if unsafe { XInputGetState(slot as u32, &mut state) } != 0 {
        self.empty_until[slot] = Some(Instant::now() + EMPTY_SLOT_RECHECK);
        return None;                        // <- returns before the scripted keys are looked at
    }
    ...
    #[cfg(feature = "diagnostics")]
    if slot == 0 {
        for vk in scripted() {              // <- the code that merges VICTORY_KEYS into slot 0
            if let Some(&(_, button)) = super::FALLBACK_BUTTONS.iter().find(|(key, _)| *key == vk) {
                pad.buttons |= button;
            }
        }
    }
    Some(pad)
}

The comment above that block says the keys are merged into the first pad "with a real pad
connected the stand-in is not there, and a title that listens to the pad saw nothing" — so the
merge is clearly meant to cover the no-stand-in case. But an empty slot 0 is a third case,
and it returns early: nothing is merged, and the scripted keys only ever appear on the stand-in
device (device 4) and on the keyboard device (device 5).

Why it matters here

The first-run flow of the title has a page that lists the local profiles. On this machine that
list draws entirely black (its frame is 33/255 mean with only 7 of 576 sampled blocks lit — the
bottom hint bar is all that shows), and the page only answers to the pad's buttons. With
VICTORY_KEYS driving the run there was no way past it: 300 s of a scripted schedule
(Y, Down, Enter repeated 8 times at 12 s intervals) changed the picture exactly zero times.

What made it pass (local diagnostic patch, not proposed as a fix)

Making slot 0 answer with a pad that carries the scripted buttons whenever XInput reports no pad
there — i.e. giving it a pad that is there the whole time, not one that appears only while a
key is held:

if slot == 0 && std::env::var_os("VICTORY_PAD0_SCRIPTS").is_some() {
    let mut pad = PadState::default();
    for vk in scripted() {
        if let Some(&(_, button)) = super::FALLBACK_BUTTONS.iter().find(|(key, _)| *key == vk) {
            pad.buttons |= button;
        }
    }
    return Some(pad);
}

Result, same VICTORY_KEYS schedule, same data directory, same title build: the profile page
was passed at +13 s after process start, the world's archives opened at +24.0 s, and the first frame below 5 fps
came at +39.0 s.

The pad has to be there the whole time. A first form that offered the pad only while a key was
held made the device connect and disconnect repeatedly; the title behaved as if a pad had been
unplugged and the picture never moved.

Repro

  1. Build with --features diagnostics (the scripted() path is behind that feature).
  2. Do not plug in a gamepad.
  3. Run the title with a VICTORY_KEYS schedule that presses Enter every few seconds.
  4. Observe victory_hle::modules::gameinput reporting input device device=4 connected=true and
    device=5 connected=true, with no slot 0.
  5. A screen that reads only slot 0 ignores the schedule.
**@⁠MoonYueya** on GitHub · 2026-11-25 22:25 UTC · [original](https://github.com/fxceless/victory-fork/issues/1167) Commit tested: `c36971b`. - Machine: Windows 11 (build 26300), Ryzen 7 7700, NVIDIA RTX 3080 10 GB, driver 32.0.16.1742. - Build: `cargo build --profile diag -p victory --features diagnostics`, toolchain 1.98.1. - Input: **fully automated**. No SendInput, no window focus, no manual pad use. The only input channel is the in-process `VICTORY_KEYS` schedule. A XInput `dwPacketNumber` check ran throughout and never saw a change while no scripted key was held. - AI assistance: the runs, log parsing and this write-up were done by an AI agent on the author's machine. ## What happens With no gamepad plugged in, `VICTORY_KEYS` presses do not reach pad slot 0. A screen that only reads slot 0 therefore ignores every scripted key, even though the keys are being held. `crates/victory-hle/src/modules/gameinput.rs`, `impl Source for Host`, `fn pad`: ```rust fn pad(&mut self, slot: usize) -> Option<PadState> { ... if unsafe { XInputGetState(slot as u32, &mut state) } != 0 { self.empty_until[slot] = Some(Instant::now() + EMPTY_SLOT_RECHECK); return None; // <- returns before the scripted keys are looked at } ... #[cfg(feature = "diagnostics")] if slot == 0 { for vk in scripted() { // <- the code that merges VICTORY_KEYS into slot 0 if let Some(&(_, button)) = super::FALLBACK_BUTTONS.iter().find(|(key, _)| *key == vk) { pad.buttons |= button; } } } Some(pad) } ``` The comment above that block says the keys are merged into the first pad "with a real pad connected the stand-in is not there, and a title that listens to the pad saw nothing" — so the merge is clearly meant to cover the no-stand-in case. But an **empty slot 0** is a third case, and it returns early: nothing is merged, and the scripted keys only ever appear on the stand-in device (device 4) and on the keyboard device (device 5). ## Why it matters here The first-run flow of the title has a page that lists the local profiles. On this machine that list draws entirely black (its frame is 33/255 mean with only 7 of 576 sampled blocks lit — the bottom hint bar is all that shows), and the page only answers to the pad's buttons. With `VICTORY_KEYS` driving the run there was no way past it: 300 s of a scripted schedule (`Y`, `Down`, `Enter` repeated 8 times at 12 s intervals) changed the picture exactly zero times. ## What made it pass (local diagnostic patch, not proposed as a fix) Making slot 0 answer with a pad that carries the scripted buttons whenever XInput reports no pad there — i.e. giving it a pad that is **there the whole time**, not one that appears only while a key is held: ```rust if slot == 0 && std::env::var_os("VICTORY_PAD0_SCRIPTS").is_some() { let mut pad = PadState::default(); for vk in scripted() { if let Some(&(_, button)) = super::FALLBACK_BUTTONS.iter().find(|(key, _)| *key == vk) { pad.buttons |= button; } } return Some(pad); } ``` Result, same `VICTORY_KEYS` schedule, same data directory, same title build: the profile page was passed at +13 s after process start, the world's archives opened at **+24.0 s**, and the first frame below 5 fps came at **+39.0 s**. **The pad has to be there the whole time.** A first form that offered the pad only while a key was held made the device connect and disconnect repeatedly; the title behaved as if a pad had been unplugged and the picture never moved. ## Repro 1. Build with `--features diagnostics` (the `scripted()` path is behind that feature). 2. Do **not** plug in a gamepad. 3. Run the title with a `VICTORY_KEYS` schedule that presses `Enter` every few seconds. 4. Observe `victory_hle::modules::gameinput` reporting `input device device=4 connected=true` and `device=5 connected=true`, with no slot 0. 5. A screen that reads only slot 0 ignores the schedule.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:58:47 +00:00
Author
Owner

@⁠Tanju42 on GitHub · 2026-11-25 23:43 UTC · original

Confirmed on a third machine (RTX 5060 Laptop 8 GB, Win 11, 31 GB RAM, main 2950915 + --features diagnostics) and fixed locally — the profile list does respond once slot 0 gets the merged pad.

Frame log before the fix: flat 30.0 fps forever (start screen), no VICTORY_KEYS effect. After the fix below: 14.7 → 30.0 ×8 → 0.1-0.9 fps, i.e. the scripted Enter passed the profile list and the title loaded into the world. Same machine, same save dir, only pad() changed.

The merge block in pad() only runs after XInputGetState succeeded; with no pad attached the early return None skips it, exactly as you wrote. My patch turns the empty-slot-0 case into the stand-in pad the block was meant to feed:

if unsafe { XInputGetState(slot as u32, &mut state) } != 0 {
    // An empty slot 0 would hide the scripted keys (`VICTORY_KEYS`)
    // from a title that reads the pad only — the profile list and
    // the start screen. Merge them into a stand-in pad instead.
    #[cfg(feature = "diagnostics")]
    if slot == 0 && !scripted().is_empty() {
        let mut pad = PadState::default();
        for vk in scripted() {
            if let Some(&(_, button)) =
                super::FALLBACK_BUTTONS.iter().find(|(key, _)| *key == vk)
            {
                pad.buttons |= button;
            }
        }
        self.empty_until[slot] = None;
        return Some(pad);
    }
    self.empty_until[slot] = Some(Instant::now() + EMPTY_SLOT_RECHECK);
    return None;
}

One caveat I cannot rule out from outside: the title may poll slot 0 with XInputGetState through the HLE in places too (I only see GameInput traffic in my logs), and a permanently-present slot 0 could change what a title assumes about a connected pad outside diagnostics runs — hence keeping it behind diagnostics and gated on a non-empty schedule. Happy to open a PR if useful.

**@⁠Tanju42** on GitHub · 2026-11-25 23:43 UTC · [original](https://github.com/fxceless/victory-fork/issues/1167#issuecomment-7177968947) Confirmed on a third machine (RTX 5060 Laptop 8 GB, Win 11, 31 GB RAM, main `2950915` + `--features diagnostics`) and fixed locally — the profile list does respond once slot 0 gets the merged pad. Frame log before the fix: flat `30.0 fps` forever (start screen), no `VICTORY_KEYS` effect. After the fix below: `14.7 → 30.0 ×8 → 0.1-0.9 fps`, i.e. the scripted `Enter` passed the profile list and the title loaded into the world. Same machine, same save dir, only `pad()` changed. The merge block in `pad()` only runs after `XInputGetState` succeeded; with no pad attached the early `return None` skips it, exactly as you wrote. My patch turns the empty-slot-0 case into the stand-in pad the block was meant to feed: ```rust if unsafe { XInputGetState(slot as u32, &mut state) } != 0 { // An empty slot 0 would hide the scripted keys (`VICTORY_KEYS`) // from a title that reads the pad only — the profile list and // the start screen. Merge them into a stand-in pad instead. #[cfg(feature = "diagnostics")] if slot == 0 && !scripted().is_empty() { let mut pad = PadState::default(); for vk in scripted() { if let Some(&(_, button)) = super::FALLBACK_BUTTONS.iter().find(|(key, _)| *key == vk) { pad.buttons |= button; } } self.empty_until[slot] = None; return Some(pad); } self.empty_until[slot] = Some(Instant::now() + EMPTY_SLOT_RECHECK); return None; } ``` One caveat I cannot rule out from outside: the title may poll slot 0 with `XInputGetState` through the HLE in places too (I only see GameInput traffic in my logs), and a permanently-present slot 0 could change what a title assumes about a connected pad outside diagnostics runs — hence keeping it behind `diagnostics` and gated on a non-empty schedule. Happy to open a PR if useful.
Author
Owner

@⁠FordMustang0288 on GitHub · 2026-11-26 03:48 UTC · original

Confirmed the same on our machine, and Tanju42's diagnosis is right.

Our build is a detached checkout of main (3973179) with the same pad() structure: an empty slot 0 return Nones before the scripted-key merge, so every screen that reads the pad ignores the keys. On our host the title sat at a prompt indefinitely; Tanju42's observations match ours exactly.

We fixed it the same way on our checkout: in the empty-slot-0 case, return a stand-in PadState from the scripted keys instead of None, and clear empty_until[slot]. That unblocked the title immediately. On an RTX 3080 10 GB the title went from sitting at a prompt for 25+ minutes to loading through first-boot screens, menus, key art, a 3D loading frame, and into the world.

One thing Tanju42's patch gets right that ours missed: gating it on !scripted().is_empty() so the stand-in pad only appears when there is actually a key held. Without that check, the title sees a permanently connected pad between key presses, which may cause other titles to behave differently.

We had the same caveat: the title may also poll XInputGetState through the HLE in places where a permanently present pad could change behaviour. We are running under Wine/vkd3d-proton on Linux, so that path may differ from native. We have not seen it cause problems in our run, but it has only been tested on one title.

Happy to test any further changes on this machine if it is useful. Linux/Wine/vkd3d-proton, RTX 3080 10 GB, driver 615.78.08.

**@⁠FordMustang0288** on GitHub · 2026-11-26 03:48 UTC · [original](https://github.com/fxceless/victory-fork/issues/1167#issuecomment-7182039329) Confirmed the same on our machine, and Tanju42's diagnosis is right. Our build is a detached checkout of `main` (`3973179`) with the same `pad()` structure: an empty slot 0 `return None`s before the scripted-key merge, so every screen that reads the pad ignores the keys. On our host the title sat at a prompt indefinitely; Tanju42's observations match ours exactly. We fixed it the same way on our checkout: in the empty-slot-0 case, return a stand-in `PadState` from the scripted keys instead of `None`, and clear `empty_until[slot]`. That unblocked the title immediately. On an RTX 3080 10 GB the title went from sitting at a prompt for 25+ minutes to loading through first-boot screens, menus, key art, a 3D loading frame, and into the world. One thing Tanju42's patch gets right that ours missed: gating it on `!scripted().is_empty()` so the stand-in pad only appears when there is actually a key held. Without that check, the title sees a permanently connected pad between key presses, which may cause other titles to behave differently. We had the same caveat: the title may also poll `XInputGetState` through the HLE in places where a permanently present pad could change behaviour. We are running under Wine/vkd3d-proton on Linux, so that path may differ from native. We have not seen it cause problems in our run, but it has only been tested on one title. Happy to test any further changes on this machine if it is useful. Linux/Wine/vkd3d-proton, RTX 3080 10 GB, driver 615.78.08.
This discussion has been locked. Commenting is limited to contributors.
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/fxceless--victory-fork#1167
No description provided.