Repository navigation
Conversation
…nput with non-blocking worker and XInput fallback - Propagate all four `GameInputRumbleParams` motors (`low_frequency`, `high_frequency`, `left_trigger`, `right_trigger`) through a clamped finite `Rumble` struct and report `0xF` in `DeviceInfo::rumble_motors`. - Drive all four motors on Windows via dynamically loaded `combase.dll` WinRT `Windows.Gaming.Input.Gamepad` (`IGamepadStatics::get_Gamepads` + `IGamepad::put_Vibration`) with zero extra crate dependencies, falling back cleanly to 2-motor `XInputSetState` when WinRT or a matching gamepad is unavailable. - Dispatch rumble asynchronously via a dedicated coalescing `RumbleWorker` background thread (`Hub::rumble_sink`) so `SetRumbleState` never contends with `XInputGetState` polling or stalls the title's render/simulation thread on COM/WinRT/HID I/O. - Automatically zero active motors on pad disconnect, window unfocus, and worker teardown. Adds deterministic unit tests covering clamping/non-finite sanitization, disconnect zeroing, 4-motor delivery + 2-motor fallback + drop zeroing on `RumbleWorker`, and live WinRT probing/teardown safety.
|
Coordination: this overlaps #312 (open) and the older #26 / #1104, all of which change the same rumble plumbing.
I can test this on AMD/Wine (RX 9060 XT, Wine 11.22 + vkd3d 3.2) if a build is useful — though WinRT may be unavailable under Wine, so the XInput fallback is what would be exercised. |
|
Automated triage for the maintainers. Needs rebase. This pull request conflicts with Generated by Claude Code |
fuzeofficlal
left a comment
There was a problem hiding this comment.
Checked cdec26e9:
- Merging onto current
main(63bcca43) hits 4 merge conflicts incrates/victory-hle/src/modules/gameinput.rs(Sourcetrait,Hub::poll,FakeHost,Fake, due toVICTORY_KEYS/scripted_keys). Also note thatmain's all-zero XInput connection filter meansdisconnect_zeroes_active_rumble_for_that_slot(usingPadState::default()) will need a non-zero pad report after rebasing. - At
cdec26e9,cargo test --locked -p victory-hle --lib modules::gameinput::passes (10/10, default and--features diagnostics), and the new hunks arerustfmt-clean (clippyfails only on pre-existingxmem.rs:747at that older base).
The WinRT worker thread lifetime (RoInitialize/RoUninitialize pairing, release order before FreeLibrary, // SAFETY: coverage, and #[cfg(windows)] gating) is clean, but a few issues need changes:
- XInput slot index used directly as WinRT
Gamepad.Gamepadsindex (gameinput.rs:1323, 1478, 1581):Gamepad.Gamepadsis a dense list whose ordering does not track sparse XInput user slots0..3. If XInput slot0disconnects while slot1remains connected (now at WinRT index0), the disconnect zero for slot0stops the surviving controller while slot1goes out of range and falls back to 2-motor XInput (or drives the wrong device when multiple pads differ in order). Please associate devices rather than indexing WinRT by XInput slot. - Additional items to tighten during rebase:
HStringHeader([usize; 3])(1188) is only 12 bytes on 32-bit Windows where WinRT requires 20 bytes.- If
RoInitializereturnsRPC_E_CHANGED_MODE(1270), fall back to XInput instead of using WinRT on an STA thread without a message pump. - If
RumbleWorker::newfails to spawn (1444),Host::rumble_sinkstill returnsSome(...)and silently drops fallback XInput rumble. - Reporting
rumble_motors = 0xFunconditionally (254) advertises trigger motors even when falling back to 2-motor XInput, and focus-loss zeroing (1595) can be overwritten by subsequentSetRumbleStatecalls while unfocused.
Summary
GameInputRumbleParamsmotors (low_frequency,high_frequency,left_trigger,right_trigger) through a clamped finiteRumblestruct and reports0xFinDeviceInfo::rumble_motors.combase.dllWinRTWindows.Gaming.Input.Gamepad(IGamepadStatics::get_Gamepads+IGamepad::put_Vibration) with zero extra crate dependencies, falling back cleanly to 2-motorXInputSetStatewhen WinRT or a matching gamepad is unavailable.RumbleWorkerbackground thread (Hub::rumble_sink) soSetRumbleStatenever contends withXInputGetStatepolling or stalls the title's render/simulation thread.RumbleWorker, and live WinRT probing/teardown safety.Verification
cargo clippy --workspace --all-targets&-p victory --features diagnostics --all-targets— passed (0 new warnings)cargo test --workspace— passed (victory-hlegameinput: 10/10)cargo xtask policy— passed (151 files ok)