Input: trigger rumble through Windows.Gaming.Input #2095

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

@⁠fylzzz on GitHub · 2026-11-25 04:44 UTC · original
fylzzz:input/trigger-rumble → main · +107 −19 · 3 files · 1 commits · open

The title sends four motor levels to the device's rumble slot (0x50); the last two, the trigger motors, were dropped because XInput has none. This drives all four through Windows.Gaming.Input (the windows crate's Gaming_Input feature) when exactly one pad is connected, and falls back to XInput otherwise, since the two APIs share no pad identity. A pad that stops being driven this way has its vibration cleared.

Windows.Gaming.Input ignores the process while none of its windows is in front, so in the background the body motors stop too (XInput used to keep them going).

Tested on Windows 11 with an Xbox One pad over USB: all four motors respond with our window in front. I checked this with a hand-run test I've left out of this PR and can add if you want it.

**@⁠fylzzz** on GitHub · 2026-11-25 04:44 UTC · [original](https://github.com/Marvisak/VIctory/pull/2095) `fylzzz:input/trigger-rumble` → `main` · +107 −19 · 3 files · 1 commits · open The title sends four motor levels to the device's rumble slot (0x50); the last two, the trigger motors, were dropped because XInput has none. This drives all four through Windows.Gaming.Input (the windows crate's Gaming_Input feature) when exactly one pad is connected, and falls back to XInput otherwise, since the two APIs share no pad identity. A pad that stops being driven this way has its vibration cleared. Windows.Gaming.Input ignores the process while none of its windows is in front, so in the background the body motors stop too (XInput used to keep them going). Tested on Windows 11 with an Xbox One pad over USB: all four motors respond with our window in front. I checked this with a hand-run test I've left out of this PR and can add if you want it.
The title sends four motor levels to slot 0x50 (low and high frequency,
left and right trigger); XInput has no trigger motors, so the last two
were dropped. The `windows` crate is already a dependency, so its
`Gaming_Input` feature gives the WinRT `Gamepad.Vibration` outside
diagnostics builds.

When one XInput slot is connected and Windows.Gaming.Input lists one
pad, all four motors go to that pad; otherwise the body motors go
through XInput as before. The two APIs share no pad identity, so with
several pads the triggers stay still (a shortcut, noted). A pad that
stops being driven this way has its vibration cleared first.
Windows.Gaming.Input ignores the process while none of its windows is
in front, so in the background the body motors stop too.

Levels are clamped to 0..1 with NaN as off, and `Source::rumble` takes
all four as `Motors`.

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

@⁠Marvisak on GitHub · 2026-11-25 10:36 UTC · original

Automated triage for the maintainers.

gameinput.rs set_rumble (slot 0x50) now passes all four motor levels. When exactly one XInput slot and one Windows.Gaming.Input pad are connected, host::Host::rumble drives them through Gamepad::SetVibration; otherwise it falls back to XInput for the body motors as before, and it clears a pad it stops driving. The only build change is the Gaming_Input feature of the windows crate victory-hle already uses. This replaces the shortcut comment in main. The test covers clamping and NaN. CI passes, and the author reports testing with an Xbox One pad.

Worth a maintainer's look: the disclosed trade-off that Windows.Gaming.Input stops all rumble while the window is in the background, which XInput did not. Gamepad::Gamepads() is also queried on every rumble call.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 10:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/2095#issuecomment-7159915830) <!-- victory-triage v1 head=266f49ea9d08d38602003f7b9e393bdc8d6726d4 verdict=merge-candidate at=2026-11-25T10:35:47Z --> Automated triage for the maintainers. `gameinput.rs` `set_rumble` (slot 0x50) now passes all four motor levels. When exactly one XInput slot and one Windows.Gaming.Input pad are connected, `host::Host::rumble` drives them through `Gamepad::SetVibration`; otherwise it falls back to XInput for the body motors as before, and it clears a pad it stops driving. The only build change is the `Gaming_Input` feature of the `windows` crate `victory-hle` already uses. This replaces the `shortcut` comment in main. The test covers clamping and NaN. CI passes, and the author reports testing with an Xbox One pad. Worth a maintainer's look: the disclosed trade-off that Windows.Gaming.Input stops all rumble while the window is in the background, which XInput did not. `Gamepad::Gamepads()` is also queried on every rumble call. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 00:55 UTC · original

Code review and Windows 11 verification at head 266f49ea9d08 merged cleanly onto main (63bcca43c6a0):

  • Code review (crates/victory-hle/src/modules/gameinput.rs:328-329, 1314-1340):
    • set_rumble filters NaN, negatives, and > 1.0 cleanly via if level > 0.0 { level.min(1.0) } else { 0.0 }.
    • Host::rumble .take()s self.driven[slot] first and zeros vibration (GamepadVibration::default()) on the previous Gamepad whenever the device disconnects or switches before falling back to XInputSetState, avoiding stuck trigger rumble.
    • Two minor non-blocking notes (both fall back safely to XInput): (1) if the calling thread hasn't initialized COM/WinRT, Gamepad::Gamepads() returns CO_E_NOTINITIALIZED and falls back to XInput without trigger motors; (2) on the very first call before an initial pad() poll populates empty_until, connected(s) reports true for all 4 slots so the first rumble falls back to XInput.
  • Verified (Windows 11, Rust 1.98.1):
    • cargo xtask policy: 191 files ok; cargo clippy -p victory-hle --all-targets -- -D warnings: 0 warnings
    • victory-hle --lib -- input: 10/10 passed (full lib skipping unrelated concurrent test a_page_list_filled_after_its_request_starts which passes solo: 151/151 passed).

LGTM.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 00:55 UTC · [original](https://github.com/Marvisak/VIctory/pull/2095#issuecomment-7179249731) Code review and Windows 11 verification at head `266f49ea9d08` merged cleanly onto `main` (`63bcca43c6a0`): - **Code review (`crates/victory-hle/src/modules/gameinput.rs:328-329, 1314-1340`)**: - `set_rumble` filters `NaN`, negatives, and `> 1.0` cleanly via `if level > 0.0 { level.min(1.0) } else { 0.0 }`. - `Host::rumble` `.take()`s `self.driven[slot]` first and zeros vibration (`GamepadVibration::default()`) on the previous `Gamepad` whenever the device disconnects or switches before falling back to `XInputSetState`, avoiding stuck trigger rumble. - Two minor non-blocking notes (both fall back safely to XInput): (1) if the calling thread hasn't initialized COM/WinRT, `Gamepad::Gamepads()` returns `CO_E_NOTINITIALIZED` and falls back to XInput without trigger motors; (2) on the very first call before an initial `pad()` poll populates `empty_until`, `connected(s)` reports true for all 4 slots so the first rumble falls back to XInput. - **Verified (Windows 11, Rust 1.98.1)**: - `cargo xtask policy`: `191 files ok`; `cargo clippy -p victory-hle --all-targets -- -D warnings`: 0 warnings - `victory-hle --lib -- input`: **10/10 passed** (full lib skipping unrelated concurrent test `a_page_list_filled_after_its_request_starts` which passes solo: **151/151 passed**). LGTM.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/2095/head:github-bot/gh-2095'
git switch 'github-bot/gh-2095'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2095'
git switch 'github-bot/gh-2095'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2095'
git switch 'github-bot/gh-2095'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2095'
git switch 'main'
git merge --squash 'github-bot/gh-2095'
git switch 'main'
git merge --ff-only 'github-bot/gh-2095'
git switch 'main'
git merge 'github-bot/gh-2095'
git push origin 'main'
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!2095
No description provided.