Isolate controller-only modes from M&K and native mouse (#2836, #2505, #2489) #2866

Open
steven-seagull27 wants to merge 1 commit from upstream-pr/2866 into main
steven-seagull27 commented 2026-11-29 18:21:44 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by steven-seagull27 on 2026-11-29T18:21:44Z.


Related: #2836, #2505, #2489, #2537

Summary

Ensures explicit controller-only modes (VICTORY_CONTROLS=gamepad and VICTORY_CONTROLS=dualsense) completely isolate controller input from leftover mouse-and-keyboard settings (VICTORY_MNK=1 / VICTORY_MNK_BINDINGS), while preserving AUTO-mode keyboard fallback (Enter -> A on the stand-in pad when no gamepad is connected):

  • Controller-only modes cleanly disable M&K, native mouse, and mouse capture (crates/victory-hle/src/modules/{gameinput,mnk,lifecycle}.rs, crates/victory-hle/src/mousehook.rs):
    • mnk_allowed_for(controls) gates mnk::enabled(), mnk::sample(), NATIVE_MOUSE_ON (native_mouse_enabled_for), and xinput_suppressed_for, so a leftover VICTORY_MNK=1 never hijacks the mouse cursor/camera hook or suppresses XInput gamepads in CONTROLS=gamepad mode (while DUALSENSE continues to suppress XInput in favor of native DualSense HID).
    • Host::keys() gates live keyboard polling (GetAsyncKeyState) on live_keyboard_enabled_for(controls(), mnk_on()) (!matches!(controls, Controls::Gamepad | Controls::DualSense)), suppressing live keyboard polling in explicit GAMEPAD / DUALSENSE modes while keeping AUTO-mode keyboard fallback (Enter -> A on the fallback pad when no pad is connected) and KEYBOARD mode working.
    • lifecycle::mouse_capture_enabled() checks !gameinput::pads_only() so legacy cursor capture never traps the pointer in controller-only or default AUTO (M&K off) modes.
  • Launcher parity for default bindings.ini attachment (apps/victory/src/play.rs, scripts/play-foxhound.ps1):
    • Extracted should_emit_mnk_bindings in play.rs and updated scripts/play-foxhound.ps1 so default VICTORY_MNK_BINDINGS is never attached when VICTORY_CONTROLS is gamepad or dualsense.

(Note: Prompt-hook changes from an earlier revision of this PR were superseded by 3222c1eb on main and dropped during the rebase onto cec481f4.)

Verification

All checks run with --locked and synthetic unit tests only:

  • cargo test --locked -j 2 -p victory-hle --lib -- gameinput --test-threads=1 — 88 passed, 0 failed, 2 ignored (includes unit tests for controller-only M&K/native-mouse/XInput policy, live keyboard polling policy including AUTO fallback, and pads-only State::poll device isolation + fallback pad behavior).
  • cargo test --locked -j 2 -p victory --bin victory -- --test-threads=1 — 80 passed, 0 failed (includes should_emit_mnk_bindings unit test in play.rs).
  • cargo clippy --locked -j 2 -p victory-hle -p victory --bins --tests — 0 new warnings in touched files.
  • git diff --check — clean.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5553695976 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2866). Originally posted by [steven-seagull27](https://github.com/steven-seagull27) on 2026-11-29T18:21:44Z. --- Related: #2836, #2505, #2489, #2537 ## Summary Ensures explicit controller-only modes (`VICTORY_CONTROLS=gamepad` and `VICTORY_CONTROLS=dualsense`) completely isolate controller input from leftover mouse-and-keyboard settings (`VICTORY_MNK=1` / `VICTORY_MNK_BINDINGS`), while preserving `AUTO`-mode keyboard fallback (`Enter` -> A on the stand-in pad when no gamepad is connected): - **Controller-only modes cleanly disable M&K, native mouse, and mouse capture** (`crates/victory-hle/src/modules/{gameinput,mnk,lifecycle}.rs`, `crates/victory-hle/src/mousehook.rs`): - `mnk_allowed_for(controls)` gates `mnk::enabled()`, `mnk::sample()`, `NATIVE_MOUSE_ON` (`native_mouse_enabled_for`), and `xinput_suppressed_for`, so a leftover `VICTORY_MNK=1` never hijacks the mouse cursor/camera hook or suppresses XInput gamepads in `CONTROLS=gamepad` mode (while `DUALSENSE` continues to suppress XInput in favor of native DualSense HID). - `Host::keys()` gates live keyboard polling (`GetAsyncKeyState`) on `live_keyboard_enabled_for(controls(), mnk_on())` (`!matches!(controls, Controls::Gamepad | Controls::DualSense)`), suppressing live keyboard polling in explicit `GAMEPAD` / `DUALSENSE` modes while keeping `AUTO`-mode keyboard fallback (`Enter` -> A on the fallback pad when no pad is connected) and `KEYBOARD` mode working. - `lifecycle::mouse_capture_enabled()` checks `!gameinput::pads_only()` so legacy cursor capture never traps the pointer in controller-only or default `AUTO` (M&K off) modes. - **Launcher parity for default `bindings.ini` attachment** (`apps/victory/src/play.rs`, `scripts/play-foxhound.ps1`): - Extracted `should_emit_mnk_bindings` in `play.rs` and updated `scripts/play-foxhound.ps1` so default `VICTORY_MNK_BINDINGS` is never attached when `VICTORY_CONTROLS` is `gamepad` or `dualsense`. *(Note: Prompt-hook changes from an earlier revision of this PR were superseded by `3222c1eb` on `main` and dropped during the rebase onto `cec481f4`.)* ## Verification All checks run with `--locked` and synthetic unit tests only: - `cargo test --locked -j 2 -p victory-hle --lib -- gameinput --test-threads=1` — **88 passed, 0 failed, 2 ignored** (includes unit tests for controller-only M&K/native-mouse/XInput policy, live keyboard polling policy including `AUTO` fallback, and pads-only `State::poll` device isolation + fallback pad behavior). - `cargo test --locked -j 2 -p victory --bin victory -- --test-threads=1` — **80 passed, 0 failed** (includes `should_emit_mnk_bindings` unit test in `play.rs`). - `cargo clippy --locked -j 2 -p victory-hle -p victory --bins --tests` — **0 new warnings** in touched files. - `git diff --check` — clean.
steven-seagull27 commented 2026-11-29 20:12:15 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by steven-seagull27 on 2026-11-29T20:12:15Z.


Rebased onto cec481f4 (cb11b17d):

  • Dropped the superseded apps/victory/src/run.rs and README.md prompt-hook hunks in favor of 3222c1eb already on main.
  • Fixed live_keyboard_enabled_for in crates/victory-hle/src/modules/gameinput.rs so live keyboard polling stays active in Controls::Auto | Controls::Keyboard (preserving keyboard fallback such as Enter -> A on the stand-in pad in default AUTO mode when no pad is connected) and is suppressed only in explicit controller-only modes (Controls::Gamepad | Controls::DualSense).
  • Kept the controller-only M&K / native-mouse / XInput isolation across gameinput.rs, mnk.rs, lifecycle.rs, mousehook.rs, play.rs, and play-foxhound.ps1.

Re-verified with synthetic unit tests (victory-hle gameinput: 88 passed / 0 failed / 2 ignored; victory bin: 80 passed / 0 failed), cargo clippy (0 new warnings in touched files), and git diff --check.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7261890309 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2866#issuecomment-7261890309). Originally posted by [steven-seagull27](https://github.com/steven-seagull27) on 2026-11-29T20:12:15Z. --- Rebased onto `cec481f4` (`cb11b17d`): - Dropped the superseded `apps/victory/src/run.rs` and `README.md` prompt-hook hunks in favor of `3222c1eb` already on `main`. - Fixed `live_keyboard_enabled_for` in `crates/victory-hle/src/modules/gameinput.rs` so live keyboard polling stays active in `Controls::Auto | Controls::Keyboard` (preserving keyboard fallback such as `Enter` -> A on the stand-in pad in default `AUTO` mode when no pad is connected) and is suppressed only in explicit controller-only modes (`Controls::Gamepad | Controls::DualSense`). - Kept the controller-only M&K / native-mouse / XInput isolation across `gameinput.rs`, `mnk.rs`, `lifecycle.rs`, `mousehook.rs`, `play.rs`, and `play-foxhound.ps1`. Re-verified with synthetic unit tests (`victory-hle` `gameinput`: 88 passed / 0 failed / 2 ignored; `victory` bin: 80 passed / 0 failed), `cargo clippy` (0 new warnings in touched files), and `git diff --check`.
steven-seagull27 commented 2026-11-30 18:40:16 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by steven-seagull27 on 2026-11-30T18:40:16Z.


Rebased cleanly onto latest main (e1251c31), updating the launcher guard to scripts/play-nvidia.ps1, extending the controller-only mnk guard to cover bound_buttons and prompt_keys, and harmonizing with #2583 (XInputRoute) and #2734 (InputRouting). Re-verified victory-hle lib tests, victory binary tests, Clippy, and xtask policy --staged.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7288192947 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2866#issuecomment-7288192947). Originally posted by [steven-seagull27](https://github.com/steven-seagull27) on 2026-11-30T18:40:16Z. --- Rebased cleanly onto latest `main` (`e1251c31`), updating the launcher guard to `scripts/play-nvidia.ps1`, extending the controller-only `mnk` guard to cover `bound_buttons` and `prompt_keys`, and harmonizing with `#2583` (`XInputRoute`) and `#2734` (`InputRouting`). Re-verified `victory-hle` lib tests, `victory` binary tests, Clippy, and `xtask policy --staged`.
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/2866:upstream-pr/2866'
git switch 'upstream-pr/2866'

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/2866'
git switch 'upstream-pr/2866'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2866'
git switch 'upstream-pr/2866'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2866'
git switch 'main'
git merge --squash 'upstream-pr/2866'
git switch 'main'
git merge --ff-only 'upstream-pr/2866'
git switch 'main'
git merge 'upstream-pr/2866'
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
trustno1-coder/VIctory-NVIDIA!2866
No description provided.