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

Open
fylzzz wants to merge 1 commit from upstream-pr/2095 into main
fylzzz commented 2026-11-25 04:44:06 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fylzzz on 2026-11-25T04:44:06Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5485323962 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2095). Originally posted by [fylzzz](https://github.com/fylzzz) on 2026-11-25T04:44:06Z. --- 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.
DenRakEiw commented 2026-11-25 04:49:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T04:49:56Z.

Review: APPROVED


Verified locally merged onto origin/main (940d32f, Windows 11 x64, Rust 1.98.1 MSVC):

  • cargo test -p victory-hle --lib gameinput:: — 9 passed, 0 failed
  • cargo clippy -p victory-hle --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean trigger rumble support via Windows.Gaming.Input with fallback to XInput and updated README.md. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6052017169 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2095#pullrequestreview-6052017169). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T04:49:56Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (`940d32f`, Windows 11 x64, Rust 1.98.1 MSVC): - `cargo test -p victory-hle --lib gameinput::` — 9 passed, 0 failed - `cargo clippy -p victory-hle --all-targets` — 0 warnings - `cargo xtask policy` — ok (`183 files ok`) Clean trigger rumble support via `Windows.Gaming.Input` with fallback to XInput and updated `README.md`. Looks good. AI-assisted (Gemini 4 Neon).
catminou4 commented 2026-11-25 05:02:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T05:02:21Z.

Review: COMMENTED


Static review only: victory-hle is Windows-only — nothing compiles or runs on macOS; source review of the diff.

Rumble via Windows.Gaming.Input instead of XInput — newer input path; note the crate is still Windows-only so this stays static on macOS.

<!-- greyfinch-sync:Marvisak/VIctory:review:6052105063 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2095#pullrequestreview-6052105063). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T05:02:21Z. **Review:** COMMENTED --- Static review only: victory-hle is Windows-only — nothing compiles or runs on macOS; source review of the diff. Rumble via Windows.Gaming.Input instead of XInput — newer input path; note the crate is still Windows-only so this stays static on macOS.
Marvisak commented 2026-11-25 11:05:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T10:36:00Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7159915830 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2095#issuecomment-7159915830). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T10:36:00Z. --- <!-- 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)_
fuzeofficlal commented 2026-11-26 01:04:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T00:55:26Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7179249731 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2095#issuecomment-7179249731). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T00:55:26Z. --- 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.
kilolimaVI commented 2026-11-26 21:57:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-26T21:57:59Z.


Comparison of the four open trigger-rumble PRs (README: "Trigger rumble"), each merged onto current main 63bcca4. Windows 11, toolchain 1.98.1; no pad here, so unit tests and CI's clippy checks only.

PR merge onto main cargo test -p victory-hle --lib -- gameinput clippy -D warnings (default / --all-features)
#1357 conflict in gameinput.rs - -
#1761 conflict in gameinput.rs - -
#1958 clean 18 passed (8 new) clean / clean
#2095 clean 10 passed (no new tests) clean / clean

#1958 and #2095 are separate implementations of the same Windows.Gaming.Input trigger path. #1958 also carries three input changes besides rumble (device methods answering as devices, a manual-dispatch dispatcher, QueryInterface by interface id) and tests for them; #2095 is rumble only, smaller, without tests. Taking one should close the other three. Both add "Gaming_Input" to victory-hle's windows features, so whichever goes second will need a one-line rebase there.

AI-assisted (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7204229910 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2095#issuecomment-7204229910). Originally posted by [kilolimaVI](https://github.com/kilolimaVI) on 2026-11-26T21:57:59Z. --- Comparison of the four open trigger-rumble PRs (README: "Trigger rumble"), each merged onto current main 63bcca4. Windows 11, toolchain 1.98.1; no pad here, so unit tests and CI's clippy checks only. | PR | merge onto main | `cargo test -p victory-hle --lib -- gameinput` | clippy `-D warnings` (default / `--all-features`) | |---|---|---|---| | #1357 | conflict in `gameinput.rs` | - | - | | #1761 | conflict in `gameinput.rs` | - | - | | #1958 | clean | 18 passed (8 new) | clean / clean | | #2095 | clean | 10 passed (no new tests) | clean / clean | #1958 and #2095 are separate implementations of the same Windows.Gaming.Input trigger path. #1958 also carries three input changes besides rumble (device methods answering as devices, a manual-dispatch dispatcher, QueryInterface by interface id) and tests for them; #2095 is rumble only, smaller, without tests. Taking one should close the other three. Both add `"Gaming_Input"` to victory-hle's `windows` features, so whichever goes second will need a one-line rebase there. AI-assisted (Claude).
kilolimaVI commented 2026-11-27 10:41:51 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-27T10:41:51Z.


Addendum to the comparison above, on the point fuzeofficial raised on #1357 (XInput slot used as the Gamepad.Gamepads index):

  • #1958 counts the connected slots before the one asked for (connected[..slot]) and uses that as the Windows.Gaming.Input index, so a gap like slot 0 leaving while slot 1 stays is handled. With several pads it still relies on both APIs listing them in the same order, which neither promises (its own // shortcut: comment says the triggers of another pad may answer).
  • #2095 only uses Windows.Gaming.Input when exactly one XInput slot is connected and the list holds exactly one pad; with several pads the triggers stay still, and no wrong pad is driven.
    With one pad both behave the same.

AI-assisted (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7216196164 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2095#issuecomment-7216196164). Originally posted by [kilolimaVI](https://github.com/kilolimaVI) on 2026-11-27T10:41:51Z. --- Addendum to the comparison above, on the point fuzeofficial raised on #1357 (XInput slot used as the `Gamepad.Gamepads` index): - #1958 counts the connected slots before the one asked for (`connected[..slot]`) and uses that as the Windows.Gaming.Input index, so a gap like slot 0 leaving while slot 1 stays is handled. With several pads it still relies on both APIs listing them in the same order, which neither promises (its own `// shortcut:` comment says the triggers of another pad may answer). - #2095 only uses Windows.Gaming.Input when exactly one XInput slot is connected and the list holds exactly one pad; with several pads the triggers stay still, and no wrong pad is driven. With one pad both behave the same. AI-assisted (Claude).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2095:upstream-pr/2095'
git switch 'upstream-pr/2095'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2095'
git switch 'upstream-pr/2095'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2095'
git switch 'upstream-pr/2095'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2095'
git switch 'main'
git merge --squash 'upstream-pr/2095'
git switch 'main'
git merge --ff-only 'upstream-pr/2095'
git switch 'main'
git merge 'upstream-pr/2095'
git push origin 'main'
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
Marvisak/VIctory!2093
No description provided.