Input: the keyboard also drives the first connected pad #240

Open
github-bot wants to merge 1 commit from github-bot/gh-240 into main AGit
Owner

@⁠MamaLeVrai on GitHub · 2026-11-26 08:39 UTC · original
MamaLeVrai:keys-with-pad → main · +77 −5 · 2 files · 1 commits · open

What

The keyboard's stand-in pad (WASD, Enter, arrows, ...; README "Input") worked only while no pad was connected. Any XInput pad in a slot took it away, even an idle one. Now, while a pad is connected, the keyboard also drives the first connected pad:

  • buttons: the pad's and the keys' together;
  • triggers: the larger of the two values;
  • each stick axis: the keys' value while one of its keys is held, the pad's otherwise.

With no key held, the pad reads exactly as before. With no pad connected, nothing changes: the stand-in pad is still its own device. Other pads are not touched, and the keyboard device itself is unchanged.

Files: gameinput.rs (State::poll, new with_keys, module doc), README (Input).

Why

A wired pad left plugged into the host made the keyboard do nothing in the game. That happened here when playing over remote desktop (Parsec) with no pad at hand: Windows still saw a wired pad in XInput slot 0 (USB VID 146B, PID 0609), and the log showed input device device=0 connected=true with no stand-in (device 4). A virtual XInput pad, such as one made by ViGEm-based tools, would have the same effect (not tried).

Tests

New test keys_also_drive_the_first_connected_pad, with pads in slots 1 and 2:

  • with no key held, slot 1 reads as the host pad;
  • with Enter, W, Z and C held, slot 1 has A as well as the pad's own B, left stick Y 1.0 (left X stays the pad's), both triggers at 1.0 (left was 0.75);
  • slot 2 is unchanged, and the stand-in device stays disconnected.

With the merge taken out of State::poll, this test fails (left: PadState { buttons: 8, left_trigger: 0.75, ... }, right: PadState { buttons: 12, left_trigger: 1.0, ... }).

cargo test --release -p victory-hle --lib on this branch: 98 passed, 5 failed, 1 ignored. The 5 failures are the xmem tests that already fail on main on this host (issue #2, fixed by #93). All 9 gameinput tests pass. cargo clippy --release -p victory-hle --all-targets --no-deps reports one warning, in xmem.rs (as on main), and none in gameinput.rs. The branch merges cleanly with #66, which also touches gameinput.rs.

Host: RX 6950 XT, Windows 11.

Not tested

  • Not yet played in the game with this change (the build is ready on the machine).
  • If the pad and the keys move the same stick axis at once, the keys win on that axis.

AI-assisted (Claude Code); no game data.

🤖 Generated with Claude Code

**@⁠MamaLeVrai** on GitHub · 2026-11-26 08:39 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/240) `MamaLeVrai:keys-with-pad` → `main` · +77 −5 · 2 files · 1 commits · open ## What The keyboard's stand-in pad (WASD, Enter, arrows, ...; README "Input") worked only while no pad was connected. Any XInput pad in a slot took it away, even an idle one. Now, while a pad is connected, the keyboard also drives the first connected pad: - buttons: the pad's and the keys' together; - triggers: the larger of the two values; - each stick axis: the keys' value while one of its keys is held, the pad's otherwise. With no key held, the pad reads exactly as before. With no pad connected, nothing changes: the stand-in pad is still its own device. Other pads are not touched, and the keyboard device itself is unchanged. Files: `gameinput.rs` (`State::poll`, new `with_keys`, module doc), README (Input). ## Why A wired pad left plugged into the host made the keyboard do nothing in the game. That happened here when playing over remote desktop (Parsec) with no pad at hand: Windows still saw a wired pad in XInput slot 0 (USB VID 146B, PID 0609), and the log showed `input device device=0 connected=true` with no stand-in (device 4). A virtual XInput pad, such as one made by ViGEm-based tools, would have the same effect (not tried). ## Tests New test `keys_also_drive_the_first_connected_pad`, with pads in slots 1 and 2: - with no key held, slot 1 reads as the host pad; - with Enter, W, Z and C held, slot 1 has A as well as the pad's own B, left stick Y 1.0 (left X stays the pad's), both triggers at 1.0 (left was 0.75); - slot 2 is unchanged, and the stand-in device stays disconnected. With the merge taken out of `State::poll`, this test fails (`left: PadState { buttons: 8, left_trigger: 0.75, ... }`, `right: PadState { buttons: 12, left_trigger: 1.0, ... }`). `cargo test --release -p victory-hle --lib` on this branch: 98 passed, 5 failed, 1 ignored. The 5 failures are the `xmem` tests that already fail on main on this host (issue #2, fixed by #93). All 9 `gameinput` tests pass. `cargo clippy --release -p victory-hle --all-targets --no-deps` reports one warning, in `xmem.rs` (as on main), and none in `gameinput.rs`. The branch merges cleanly with #66, which also touches `gameinput.rs`. Host: RX 6950 XT, Windows 11. ## Not tested - Not yet played in the game with this change (the build is ready on the machine). - If the pad and the keys move the same stick axis at once, the keys win on that axis. AI-assisted (Claude Code); no game data. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A pad left plugged in, or a virtual one, took the keyboard's stand-in
pad away. The keyboard now also drives the first connected pad: buttons
of either, the further trigger, and the keys on each stick axis while
they are held. With no key held the pad reads as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:39:17 +00:00
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-26 08:39 UTC · original · reviewed

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-26 08:39 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/240#pullrequestreview-6070836436) · **reviewed** Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-26 08:57 UTC · original

Note: the default branch is now rx9070xt, and there this is already handled differently. VICTORY_ONE_PAD (on by default) shows the title one pad that is always there, fed by the keyboard and every host pad (merged, State::poll). So this PR only matters for main. If main is no longer maintained, it can be closed.

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-26 08:57 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/240#issuecomment-7187236767) Note: the default branch is now `rx9070xt`, and there this is already handled differently. `VICTORY_ONE_PAD` (on by default) shows the title one pad that is always there, fed by the keyboard and every host pad (`merged`, `State::poll`). So this PR only matters for `main`. If `main` is no longer maintained, it can be closed. AI-assisted (Claude Code); no game data.
Author
Owner

@⁠gut0to on GitHub · 2026-11-26 16:17 UTC · original · reviewed

AI-assisted review. I inspected the new input merge and its unit test statically; I did not run tests or the game. This review suggests one focused state-transition case.

**@⁠gut0to** on GitHub · 2026-11-26 16:17 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/240#pullrequestreview-6077421628) · **reviewed** AI-assisted review. I inspected the new input merge and its unit test statically; I did not run tests or the game. This review suggests one focused state-transition case.
@ -1594,0 +1651,4 @@
..Default::default()
}
);
release(r);
Author
Owner

@⁠gut0to on GitHub · 2026-11-26 16:17 UTC · original

AI-assisted review; I did not run tests. Could this test release the keys after the held-key assertions, poll again, and verify slot 1 returns exactly to idle while the fallback stays disconnected? The current test covers the initial and key-down states, but the key-up transition must restore the pad stick axes and remove keyboard button/trigger contributions.

**@⁠gut0to** on GitHub · 2026-11-26 16:17 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/240#discussion_r4711000010) AI-assisted review; I did not run tests. Could this test release the keys after the held-key assertions, poll again, and verify slot 1 returns exactly to `idle` while the fallback stays disconnected? The current test covers the initial and key-down states, but the key-up transition must restore the pad stick axes and remove keyboard button/trigger contributions.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/240/head:github-bot/gh-240'
git switch 'github-bot/gh-240'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-240'
git switch 'github-bot/gh-240'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-240'
git switch 'github-bot/gh-240'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-240'
git switch 'main'
git merge --squash 'github-bot/gh-240'
git switch 'main'
git merge --ff-only 'github-bot/gh-240'
git switch 'main'
git merge 'github-bot/gh-240'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.