Input: add opt-in GTA V PC-style keyboard and mouse mapping (VICTORY_KBM_GTA) #295

Manually merged
github merged 1 commit from github-bot/gh-295 into a-publier 2026-11-27 00:57:57 +00:00 AGit
Owner

@⁠zhu1025960209-web on GitHub · 2026-11-26 19:23 UTC · original
zhu1025960209-web:input/gta5-kbm → a-publier · +575 −13 · 3 files · 3 commits · merged 2026-11-26 22:30 UTC

Summary

Adds an optional GTA V PC-style keyboard and mouse control scheme for the GameInput stand-in gamepad behind VICTORY_KBM_GTA=1 (disabled by default so existing keyboard bindings and tests remain unchanged).

Works alongside VICTORY_ONE_PAD (default on) and can be enabled via scripts\play.ps1 -More @{VICTORY_KBM_GTA='1'}.

Controls (VICTORY_KBM_GTA=1)

Input Mapped Xbox Control Role (GTA V PC layout)
W A S D Left Stick Move / steer
Mouse move (F2 or ` / ~ to lock) / I J K L Right Stick Camera / aim
LMB / RMB RT / LT Shoot / gas, aim / brake-reverse
Shift / Enter A Sprint / menu confirm
Space / X X Jump / climb / vault
R / Backspace B Reload / melee / menu back
F Y Enter / exit vehicle
Tab LB Weapon wheel
Q RB Take cover / handbrake
Ctrl L3 Crouch / stealth / horn
C / MMB / CapsLock / H R3 Look behind / special
E / Right, Up / M, Down / Z, Left / G D-pad Interact, phone, minimap / character wheel, left
V View Change camera perspective
Esc / P Menu Pause menu / map (also auto-unlocks mouse look)

Environment Variables

  • VICTORY_KBM_GTA=1: Enables the GTA V PC keyboard + mouse layout on the stand-in pad.
  • VICTORY_MOUSE_SENS: Mouse camera sensitivity multiplier (default 1.0).
  • VICTORY_MOUSE_INVERT_Y=1: Inverts the vertical mouse axis.

Implementation Details

  • Safe mouse-look lock: Starts unlocked so menus and window switching are never trapped. Press F2 or ` (~) to toggle capture; pressing Esc, P, or losing window focus automatically unlocks the cursor.
  • Low-FPS smoothing (MouseLook): Applies time-aware exponential decay (45 ms half-life) with deadzone snapping so quick flicks remain visible across low-framerate 3D frames and settle cleanly to zero when stationary.
  • DPI-safe recentering: Reads back the actual cursor position after SetCursorPos as the next delta anchor, avoiding phantom camera drift under fractional Windows DPI scaling.
  • Client-area button gating: When unlocked, mouse button clicks are only forwarded while the cursor is inside the game window's client area (excluding the title bar and window frame).
  • Zero new dependencies: Uses existing windows-sys features (Win32_Foundation, Win32_UI_Input_KeyboardAndMouse, Win32_UI_WindowsAndMessaging) and documents the new switches in README.md.

Testing

  • cargo test -p victory-hle --locked --lib gameinput (9 passed, 0 failed)
  • cargo test -p victory-hle --all-features --locked --lib gameinput (9 passed, 0 failed)
  • cargo test -p xtask --locked (9 passed, 0 failed, including repository_passes_policy and documented_switches_are_read)
**@⁠zhu1025960209-web** on GitHub · 2026-11-26 19:23 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/295) `zhu1025960209-web:input/gta5-kbm` → `a-publier` · +575 −13 · 3 files · 3 commits · merged 2026-11-26 22:30 UTC ## Summary Adds an optional GTA V PC-style keyboard and mouse control scheme for the GameInput stand-in gamepad behind `VICTORY_KBM_GTA=1` (disabled by default so existing keyboard bindings and tests remain unchanged). Works alongside `VICTORY_ONE_PAD` (default on) and can be enabled via `scripts\play.ps1 -More @{VICTORY_KBM_GTA='1'}`. ### Controls (`VICTORY_KBM_GTA=1`) | Input | Mapped Xbox Control | Role (GTA V PC layout) | |-------|---------------------|------------------------| | `W` `A` `S` `D` | Left Stick | Move / steer | | Mouse move (`F2` or `` ` `` / `~` to lock) / `I` `J` `K` `L` | Right Stick | Camera / aim | | `LMB` / `RMB` | `RT` / `LT` | Shoot / gas, aim / brake-reverse | | `Shift` / `Enter` | `A` | Sprint / menu confirm | | `Space` / `X` | `X` | Jump / climb / vault | | `R` / `Backspace` | `B` | Reload / melee / menu back | | `F` | `Y` | Enter / exit vehicle | | `Tab` | `LB` | Weapon wheel | | `Q` | `RB` | Take cover / handbrake | | `Ctrl` | `L3` | Crouch / stealth / horn | | `C` / `MMB` / `CapsLock` / `H` | `R3` | Look behind / special | | `E` / `Right`, `Up` / `M`, `Down` / `Z`, `Left` / `G` | D-pad | Interact, phone, minimap / character wheel, left | | `V` | `View` | Change camera perspective | | `Esc` / `P` | `Menu` | Pause menu / map (also auto-unlocks mouse look) | ### Environment Variables - `VICTORY_KBM_GTA=1`: Enables the GTA V PC keyboard + mouse layout on the stand-in pad. - `VICTORY_MOUSE_SENS`: Mouse camera sensitivity multiplier (default `1.0`). - `VICTORY_MOUSE_INVERT_Y=1`: Inverts the vertical mouse axis. ### Implementation Details - **Safe mouse-look lock**: Starts unlocked so menus and window switching are never trapped. Press `F2` or `` ` `` (`~`) to toggle capture; pressing `Esc`, `P`, or losing window focus automatically unlocks the cursor. - **Low-FPS smoothing (`MouseLook`)**: Applies time-aware exponential decay (45 ms half-life) with deadzone snapping so quick flicks remain visible across low-framerate 3D frames and settle cleanly to zero when stationary. - **DPI-safe recentering**: Reads back the actual cursor position after `SetCursorPos` as the next delta anchor, avoiding phantom camera drift under fractional Windows DPI scaling. - **Client-area button gating**: When unlocked, mouse button clicks are only forwarded while the cursor is inside the game window's client area (excluding the title bar and window frame). - **Zero new dependencies**: Uses existing `windows-sys` features (`Win32_Foundation`, `Win32_UI_Input_KeyboardAndMouse`, `Win32_UI_WindowsAndMessaging`) and documents the new switches in `README.md`. ## Testing - `cargo test -p victory-hle --locked --lib gameinput` (9 passed, 0 failed) - `cargo test -p victory-hle --all-features --locked --lib gameinput` (9 passed, 0 failed) - `cargo test -p xtask --locked` (9 passed, 0 failed, including `repository_passes_policy` and `documented_switches_are_read`)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:49:07 +00:00
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-26 20:45 UTC · original

Tested on an RX 6950 XT 16 GB (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release, at ad0e5d5: cargo test --release -p victory-hle --lib 160 passed, 0 failed, 2 ignored (cd8dfc0: 159 passed). Not played in the game.

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-26 20:45 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/295#issuecomment-7203048082) Tested on an RX 6950 XT 16 GB (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release, at `ad0e5d5`: `cargo test --release -p victory-hle --lib` 160 passed, 0 failed, 2 ignored (`cd8dfc0`: 159 passed). Not played in the game. AI-assisted (Claude Code); no game data.
github manually merged commit d18b9aae29 into a-publier 2026-11-27 00:57:57 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.