Input: GTA PC controls and a smoothed mouse camera on the stand-in pad (VICTORY_KBM_GTA=1, opt-in; depends on #4105) #4260

Closed
github-bot wants to merge 5 commits from github-bot/gh-4259 into main AGit
Owner

@⁠kongmuqiu on GitHub · 2026-11-30 17:53 UTC · original
kongmuqiu:kbm-gta-pr → main · +1713 −25 · 11 files · 5 commits · closed without merging

Fixes # (no open issue; an opt-in feature). Depends on #4105 (the input method fix), which this branch is built on, because these controls use its dialog guard (xgameui::text_entry_open). Until #4105 is merged, the diff here also shows its 4 commits; the change of this PR is the last commit only.

What it changes

This is an opt-in alternative to MOUSE AND KEYBOARD. It is for players who want GTA PC-style keys and a mouse camera that turns the view through the pad's right stick, smoothed, rather than through the native 1:1 hook. Off by default: without VICTORY_KBM_GTA=1 nothing changes.

With VICTORY_KBM_GTA=1:

  • Keys: a GTA PC key table on the stand-in pad, read by physical position, so it works on any keyboard layout. Shift sprints, Space jumps, F enters vehicles, Tab opens the weapon wheel, Q takes cover and E interacts. LMB is RT, RMB is LT and MMB is R3.
  • Mouse camera: a smoothed velocity with a 45 ms half-life on the right stick, with the cursor locked and hidden in the window.
    • The key at ` / ~'s place toggles the lock, and Esc or P release it.
    • It is not F2, because the WHAT LIMITS FPS box takes F2.
  • The existing drivers stand aside, so nothing drives the camera twice: the keys' fallback pad, MouseLook, the native mouse hook (it is not placed), the MnK bindings, VICTORY_MOUSE_CAPTURE and PadOverlay. With VICTORY_MNK=1 also set, a warning says MOUSE AND KEYBOARD is ignored.
  • The title gets a pad only, so it shows pad prompts, and the keyboard-prompt hook is skipped. VICTORY_KBM_RAW_DEVICES=1 gives it the keyboard and mouse devices again.
  • Gating: no key or mouse input reaches the title, and the cursor is free, while F1 is open, while one of our dialogs is up, or in the GAMEPAD/DUALSENSE modes. A key held during that time is ignored until it is released, so the Esc or Enter that closed F1 or a dialog does not press MENU or A.
  • The lock follows the title's own windows only, so it never takes a legacy console window or one of our dialogs, and it is not taken while the window is dragged by its frame.

Variables:

  • VICTORY_KBM_GTA: turns this on.
  • VICTORY_KBM_MOUSE_SENS: a sensitivity multiplier, default 1.0. It is separate from VICTORY_MOUSE_SENS, whose scales differ.
  • VICTORY_MOUSE_INVERT_Y: shared with the existing input.
  • VICTORY_KBM_PHYSICAL_KEYS (on), VICTORY_KBM_RAW_DEVICES (off) and VICTORY_KBM_TRACE_MOVE (off).

The PC key bindings and the smoothed mouse-look are adapted from Belobug/VIctory-Belobug-AMD (GPL-3.0).

How it was tested

  • GPU and profile: RTX 4070 Laptop 8 GB, Windows 11. Series S, 1920x1080 output, with and without DLSS, no frame generation, ray tracing on (software and DXR). It was used for several dozen scripted runs on v2026.11.29.05 and v2026.11.30.01, in which the character walks and the camera turns with the mouse.

  • Before: the keyboard drove the stand-in pad through FALLBACK_BUTTONS or the MnK bindings, and the mouse through MouseLook or the native hook.

  • After: the log shows our GTA PC controls are in charge and native mouse aiming not placed; the character walks and the camera turns.

  • Not exercised by those runs: driving, aiming and the radial wheel.

  • Known differences from MOUSE AND KEYBOARD:

    • With the native hook off, the vehicle camera auto-centres as stock.
    • Throttle is LMB (RT), not W.
    • The cursor is re-centred every 8 ms rather than clipped, so a very fast flick could briefly leave the window.
  • For shader changes, the wave sizes tested: no shader changes.

  • cargo test passed for the crates it touches: yes for victory-hle (gameinput, lifecycle, mnk, xgameui, mousehook: 144 passed, 0 failed, 2 ignored that need real pads). The tests cover:

    • default-off leaving the existing paths unchanged;
    • the sensitivity variable;
    • gating while F1, a dialog or a pads-only mode is on;
    • stand-in tracking with VICTORY_ONE_PAD=0;
    • the raw mouse device;
    • physical key positions on a Dvorak layout;
    • the capture choice across focus changes.

    Rebased onto 5fabb46e (with #4105): cargo clippy -p victory -p victory-hle --all-targets adds no warning, and the release build passes. The bindings.ini change to the MnK path in ba69a9b6 does not reach this mode, which takes the keyboard instead of MnK.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #3635 (mouse and keyboard on-foot and car controls with prompts, the closest one), #2894 (mouse and keyboard feeding the stand-in pad under CONTROLS=gamepad), #2809 (the title's window answering WM_SETCURSOR), #4105 (the base of this PR). This one does not replace MOUSE AND KEYBOARD; it stays a separate, opt-in mode.

🤖 Generated with Claude Code

**@⁠kongmuqiu** on GitHub · 2026-11-30 17:53 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4259) `kongmuqiu:kbm-gta-pr` → `main` · +1713 −25 · 11 files · 5 commits · closed without merging Fixes # (no open issue; an opt-in feature). **Depends on #4105** (the input method fix), which this branch is built on, because these controls use its dialog guard (`xgameui::text_entry_open`). Until #4105 is merged, the diff here also shows its 4 commits; the change of this PR is the last commit only. ## What it changes This is an opt-in alternative to MOUSE AND KEYBOARD. It is for players who want GTA PC-style keys and a mouse camera that turns the view through the pad's right stick, smoothed, rather than through the native 1:1 hook. **Off by default**: without `VICTORY_KBM_GTA=1` nothing changes. With `VICTORY_KBM_GTA=1`: - **Keys:** a GTA PC key table on the stand-in pad, read by physical position, so it works on any keyboard layout. Shift sprints, Space jumps, F enters vehicles, Tab opens the weapon wheel, Q takes cover and E interacts. LMB is RT, RMB is LT and MMB is R3. - **Mouse camera:** a smoothed velocity with a 45 ms half-life on the right stick, with the cursor locked and hidden in the window. - The key at `` ` `` / `~`'s place toggles the lock, and Esc or P release it. - It is not F2, because the WHAT LIMITS FPS box takes F2. - **The existing drivers stand aside,** so nothing drives the camera twice: the keys' fallback pad, MouseLook, the native mouse hook (it is not placed), the MnK bindings, `VICTORY_MOUSE_CAPTURE` and PadOverlay. With `VICTORY_MNK=1` also set, a warning says MOUSE AND KEYBOARD is ignored. - **The title gets a pad only,** so it shows pad prompts, and the keyboard-prompt hook is skipped. `VICTORY_KBM_RAW_DEVICES=1` gives it the keyboard and mouse devices again. - **Gating:** no key or mouse input reaches the title, and the cursor is free, while F1 is open, while one of our dialogs is up, or in the GAMEPAD/DUALSENSE modes. A key held during that time is ignored until it is released, so the Esc or Enter that closed F1 or a dialog does not press MENU or A. - **The lock follows the title's own windows only,** so it never takes a legacy console window or one of our dialogs, and it is not taken while the window is dragged by its frame. Variables: - `VICTORY_KBM_GTA`: turns this on. - `VICTORY_KBM_MOUSE_SENS`: a sensitivity multiplier, default 1.0. It is separate from `VICTORY_MOUSE_SENS`, whose scales differ. - `VICTORY_MOUSE_INVERT_Y`: shared with the existing input. - `VICTORY_KBM_PHYSICAL_KEYS` (on), `VICTORY_KBM_RAW_DEVICES` (off) and `VICTORY_KBM_TRACE_MOVE` (off). The PC key bindings and the smoothed mouse-look are adapted from Belobug/VIctory-Belobug-AMD (GPL-3.0). ## How it was tested - GPU and profile: RTX 4070 Laptop 8 GB, Windows 11. Series S, 1920x1080 output, with and without DLSS, no frame generation, ray tracing on (software and DXR). It was used for several dozen scripted runs on v2026.11.29.05 and v2026.11.30.01, in which the character walks and the camera turns with the mouse. - Before: the keyboard drove the stand-in pad through FALLBACK_BUTTONS or the MnK bindings, and the mouse through MouseLook or the native hook. - After: the log shows `our GTA PC controls are in charge` and `native mouse aiming not placed`; the character walks and the camera turns. - Not exercised by those runs: driving, aiming and the radial wheel. - Known differences from MOUSE AND KEYBOARD: - With the native hook off, the vehicle camera auto-centres as stock. - Throttle is LMB (RT), not W. - The cursor is re-centred every 8 ms rather than clipped, so a very fast flick could briefly leave the window. - For shader changes, the wave sizes tested: no shader changes. - `cargo test` passed for the crates it touches: yes for `victory-hle` (`gameinput`, `lifecycle`, `mnk`, `xgameui`, `mousehook`: 144 passed, 0 failed, 2 ignored that need real pads). The tests cover: - default-off leaving the existing paths unchanged; - the sensitivity variable; - gating while F1, a dialog or a pads-only mode is on; - stand-in tracking with `VICTORY_ONE_PAD=0`; - the raw mouse device; - physical key positions on a Dvorak layout; - the capture choice across focus changes. Rebased onto 5fabb46e (with #4105): `cargo clippy -p victory -p victory-hle --all-targets` adds no warning, and the release build passes. The bindings.ini change to the MnK path in ba69a9b6 does not reach this mode, which takes the keyboard instead of MnK. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #3635 (mouse and keyboard on-foot and car controls with prompts, the closest one), #2894 (mouse and keyboard feeding the stand-in pad under CONTROLS=gamepad), #2809 (the title's window answering WM_SETCURSOR), #4105 (the base of this PR). This one does not replace MOUSE AND KEYBOARD; it stays a separate, opt-in mode. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
With a Chinese, Japanese or Korean input method on, W, A, S and D
started a composition whose candidate box showed at the window's top
left, and the player had to switch the input method to English first.
Games detach the input method from their window; so does this now:
every window the title creates is detached at creation
(ImmAssociateContextEx with no context) and again when activated or
focused, and WM_IME_SETCONTEXT reaches the title with every UI flag
cleared. Keys reach the title as before (it polls them).

Unlike the other window and input switches this one is on unless
VICTORY_IME_OFF=0 (also INPUT METHOD in the F1 menu), as games do it
without being asked. The title's text entry asks in a dialog of its
own thread, which keeps the input method for Chinese text.

Checked in the game with Microsoft Pinyin (Windows 11 26300): before,
W showed Pinyin's candidate window at (9, 34) in Chinese mode; after,
none in Chinese or English mode, and the character walks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
From a review of public solutions (SDL3, Godot, Chromium, Qt, Moonlight,
totk-pc-recomp, the DirectX "IME in a game" article, scrcpy and
better-genshin-impact reports):

- A window is detached only if it has an input context, and a composition
  in progress is cancelled first (ImmNotifyIME CPS_CANCEL), as SDL and
  Chromium do; the change's own WM_IME_SETCONTEXT does not detach again.
- A new input language (WM_INPUTLANGCHANGE, Win+Space) detaches again.
- A composition that still reaches the title's window means something
  attached the input method again: it is cancelled and detached, and the
  title never sees WM_IME_START/COMPOSITION/ENDCOMPOSITION (SDL PR #15052:
  Microsoft Pinyin ignores the cleared WM_IME_SETCONTEXT flags). At most
  256 times, so an overlay is never fought for good.
- VICTORY_IME_OFF=thread also disables the input method for the thread of
  the title's window (ImmDisableIME(0) before its first top-level window),
  for input methods or remote sessions where a per-window detach was
  reported not to hold. Its windows then get no input method window.
- The fallback presenter window's thread gets no input method either.
- Keys and mouse buttons typed into the title's text entry dialog no
  longer reach the game (they moved the character while typing).

Checked in the game with Microsoft Pinyin on Windows 11 26300: no
candidate window in Chinese or English mode, after switching the input
language away and back, and after Alt+Tab; the character walks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The XGameUi button chooser (dialog::choose: Enter picks the default,
Esc cancels) was not counted as one of our dialogs being up, so with keys
or the mouse on (our GTA controls, MnK) the Enter that answered it also
reached the game. It now counts like the text entry does, through one
guard (DialogUp) both use.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With VICTORY_MNK=1 the native mouse camera's overlay decided its capture
from the window in front and the title's menus only: while the title's
text entry (or the button chooser) was up, the cursor stayed captured and
the mouse buttons still pressed the pad's triggers. The dialog now counts
as a menu there, as it already does for the keys and the MnK bindings.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
An opt-in alternative to MOUSE AND KEYBOARD for players who want GTA PC
style keys and a mouse camera that turns the view through the pad's right
stick, smoothed, rather than the native 1:1 hook. Off by default: without
VICTORY_KBM_GTA=1 nothing changes.

What is in charge when
- VICTORY_KBM_GTA unset (or not exactly 1): the existing drivers, unchanged:
  the keys' stand-in pad (FALLBACK_BUTTONS by place, or the MnK bindings),
  the mouse stick (MouseLook with VICTORY_MOUSE_CAPTURE=1), the native mouse
  hook (VICTORY_MNK=1) and PadOverlay.
- VICTORY_KBM_GTA=1: these controls alone make the stand-in pad from the
  keyboard and the mouse. A new Source::pc_controls gives Hub::poll the pad
  (GTA_BUTTONS by physical key position on any layout, plus the mouse
  camera: a smoothed velocity with a 45 ms half-life on the right stick,
  LMB RT, RMB LT, MMB R3, the cursor locked and hidden in the window). The
  key at ` / ~'s place toggles the lock, Esc and P release it, and
  CaptureChoice remembers that across focus changes. Not F2: the WHAT LIMITS
  FPS box takes F2 on every present, and one key would flip both.
  State::poll takes it as the stand-in pad (KbmDriver::Pc) and MouseLook
  stands aside; Source::overlay is not called. native_mouse_enabled() is
  false, so the native hook is not placed (no radians added on top of the
  stick) and its capture, raw input, F8/F9/[ ] keys and cursor handling
  stand aside with it. The MnK bindings are off (XInput stays in slot 0),
  and lifecycle's VICTORY_MOUSE_CAPTURE clip and hide is off. The first read
  logs at info that these controls are in charge; with VICTORY_MNK=1 (or
  VICTORY_MNK_BINDINGS) also set, a warning says MOUSE AND KEYBOARD is
  ignored.

PadOverlay is not used with these controls. Its mouse buttons would double
the LMB/RMB triggers, and its radial-wheel trigger pulses and vehicle-seat
remaps depend on the native hook's memory reads, which do not run then (the
seat would always read None). The key table keeps its own vehicle keys.

Devices and gating, following pads_only()/controls()
- The title gets the pad only (no keyboard or mouse device, and lifecycle
  passes it no key or mouse window message), so it shows pad prompts.
  VICTORY_KBM_RAW_DEVICES=1 gives it both devices again. GAMEPAD and
  DUALSENSE stay pads only.
- No key or mouse input reaches the title, and the cursor is free, while F1
  is open, while the title's text entry (or another of our dialogs) is open,
  or while CONTROLS is GAMEPAD/DUALSENSE. F1 releases the mouse until the
  next ` press (as Esc and P do); a dialog releases it only while it is up.
  A key held while one of these lasted is not the game's until it is
  released, so the Esc or Enter that closed F1 or a dialog does not press
  MENU or A.
- Keys are read, and the lock is taken and kept, only while a window the
  title made is in front (lifecycle::titles_window): not the console (a
  legacy one counts as this process's) nor our own dialogs and message
  boxes.
- With VICTORY_ONE_PAD=0 the mouse camera is armed only while the title is
  shown the stand-in pad, counted the way State::poll counts host pads.
- The lock is not taken while the window is dragged by its frame (the
  primary button, swapped or not), and a lock already held is never broken
  by that.
- The keyboard-prompt hook (apps/victory run.rs) is skipped with these
  controls: the title is given a pad, and the hook would show the stock
  bindings' keys.

Variables
- VICTORY_KBM_GTA=1 (off by default).
- VICTORY_KBM_MOUSE_SENS: a sensitivity multiplier (default 1.0). It is not
  VICTORY_MOUSE_SENS, whose scales differ (stick per pixel for the mouse
  stick, radians per count for the native hook).
- VICTORY_MOUSE_INVERT_Y=1 is shared, with the same meaning.
- VICTORY_KBM_PHYSICAL_KEYS (default on), VICTORY_KBM_RAW_DEVICES (default
  off), VICTORY_GAMEPAD_MOUSE (default on; only for the raw mouse device),
  VICTORY_KBM_TRACE_MOVE (default off).

lifecycle: the existing WM_SETCURSOR branches run first, these after. They
show the arrow while F1 is open and hide the cursor while the lock holds;
on the first WM_SETCURSOR after a release the title sets its own cursor, or
gets the arrow if it sets none.

Tests: default-off leaves the existing paths, the sensitivity variable,
gating while F1, a dialog or a pads-only mode is on, stand-in tracking with
VICTORY_ONE_PAD=0, the raw mouse device, physical key positions on a Dvorak
layout, and the capture choice across focus changes.

PC bindings and smoothed mouse-look adapted from Belobug/VIctory-Belobug-AMD
(GPL-3.0).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 18:09:35 +00:00
github-bot force-pushed github-bot/gh-4259 from caa4c2c138 to 1106ffbf76 2026-12-01 08:32:40 +00:00 Compare
github-bot closed this pull request 2026-12-01 18:50:18 +00:00
Author
Owner

@⁠trustno1-coder on GitHub · 2026-12-01 18:44 UTC · original

Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

**@⁠trustno1-coder** on GitHub · 2026-12-01 18:44 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4259#issuecomment-7321464786) Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

Pull request closed

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/trustno1-coder--VIctory-NVIDIA!4260
No description provided.