Input: mouse look, mouse buttons and key rebinding for keyboard play #82

Open
3cvil wants to merge 1 commit from upstream-pr/82 into main
3cvil commented 2026-11-26 16:28:10 +00:00 (Migrated from github.com)

Imported from DexNom/VIctory. Originally posted by 3cvil on 2026-11-26T16:28:10Z.


What

GTA VI reads a gamepad and a keyboard and never asks GameInput for a mouse. Keyboard play goes through the keyboard's stand-in pad, which had no mouse and used I/J/K/L for the camera. This makes that pad behave more like PC controls.

  • Mouse look: mouse movement turns the right stick. While the stand-in pad is in use and the title's window has focus, the cursor is held in the middle of the window. Each 8 ms poll's movement fades over the next few polls, so a title that reads less often than we poll still sees it. VICTORY_MOUSE_LOOK=0 turns it off. VICTORY_MOUSE_SENSITIVITY scales it.
  • Mouse buttons: right button = left trigger (aim), left button = right trigger (fire). Z and C still work.
  • Rebinding: VICTORY_KEYBINDS=Space=X,LShift=A,Mouse4=LB,Enter=None maps keys and mouse buttons to pad buttons or triggers. Each entry replaces what that key did. An entry that can't be read is left out with a warning.
  • A connected XInput or DualSense pad still replaces the stand-in pad, and the mouse is then left alone.

docs/keyboard-and-mouse.md lists the layout and settings.

What it does not do

The prompts the title draws stay gamepad prompts. The title picks its own glyphs and has no keyboard/mouse mode to switch to.

Tests

  • New: mouse_buttons_pull_the_triggers_and_movement_turns_the_right_stick, keybinds_replace_what_a_key_did. All 14 gameinput tests pass.
  • cargo clippy --all-targets -D warnings is clean with and without diagnostics. cargo xtask policy is OK.
  • Vendor-neutral: input only, no GPU code.
  • Not yet checked in game. I'll add a comment after a run on an RTX 4060 Laptop 8 GB / i5-12500H / 16 GB RAM / Windows 11.

🤖 Generated with Claude Code

<!-- greyfinch-sync:DexNom/VIctory:issue:5513672812 --> Imported from [DexNom/VIctory](https://github.com/DexNom/VIctory/pull/82). Originally posted by [3cvil](https://github.com/3cvil) on 2026-11-26T16:28:10Z. --- ## What GTA VI reads a gamepad and a keyboard and never asks GameInput for a mouse. Keyboard play goes through the keyboard's stand-in pad, which had no mouse and used I/J/K/L for the camera. This makes that pad behave more like PC controls. - **Mouse look:** mouse movement turns the right stick. While the stand-in pad is in use and the title's window has focus, the cursor is held in the middle of the window. Each 8 ms poll's movement fades over the next few polls, so a title that reads less often than we poll still sees it. `VICTORY_MOUSE_LOOK=0` turns it off. `VICTORY_MOUSE_SENSITIVITY` scales it. - **Mouse buttons:** right button = left trigger (aim), left button = right trigger (fire). Z and C still work. - **Rebinding:** `VICTORY_KEYBINDS=Space=X,LShift=A,Mouse4=LB,Enter=None` maps keys and mouse buttons to pad buttons or triggers. Each entry replaces what that key did. An entry that can't be read is left out with a warning. - A connected XInput or DualSense pad still replaces the stand-in pad, and the mouse is then left alone. `docs/keyboard-and-mouse.md` lists the layout and settings. ## What it does not do The prompts the title draws stay gamepad prompts. The title picks its own glyphs and has no keyboard/mouse mode to switch to. ## Tests - New: `mouse_buttons_pull_the_triggers_and_movement_turns_the_right_stick`, `keybinds_replace_what_a_key_did`. All 14 `gameinput` tests pass. - `cargo clippy --all-targets -D warnings` is clean with and without `diagnostics`. `cargo xtask policy` is OK. - Vendor-neutral: input only, no GPU code. - **Not yet checked in game.** I'll add a comment after a run on an RTX 4060 Laptop 8 GB / i5-12500H / 16 GB RAM / Windows 11. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
andrewDoing commented 2026-11-26 22:59:43 +00:00 (Migrated from github.com)

Imported from DexNom/VIctory. Originally posted by andrewDoing on 2026-11-26T22:59:43Z.


I reproduced a stale camera deflection when returning to mouse input after a long interval without polling at eb54094. In the actual Host::mouse path, the ≥100 ms gap suppresses new mouse delta but retains self.look. With focused/window-centered cursor queries fixed in a test fixture, a prior (1, -0.5) look and a simulated 10-second gap produced (0.5, -0.25) despite a centered, motionless cursor. The fallback is not polled while the physical pad is active (gameinput.rs:591), so switching back can preserve the old look.

In a scratch control, clearing self.look in the ≥100 ms/no-last-poll branch made this regression and all 12 default-feature gameinput-filtered tests pass. No physical controller or cursor was manipulated, and gameplay was not tested.

Verification was AI-assisted with GPT-6.2 Astra.

<!-- greyfinch-sync:DexNom/VIctory:comment:7205162335 --> Imported from [DexNom/VIctory](https://github.com/DexNom/VIctory/pull/82#issuecomment-7205162335). Originally posted by [andrewDoing](https://github.com/andrewDoing) on 2026-11-26T22:59:43Z. --- I reproduced a stale camera deflection when returning to mouse input after a long interval without polling at `eb54094`. In the actual `Host::mouse` path, the ≥100 ms gap suppresses new mouse delta but retains `self.look`. With focused/window-centered cursor queries fixed in a test fixture, a prior `(1, -0.5)` look and a simulated 10-second gap produced `(0.5, -0.25)` despite a centered, motionless cursor. The fallback is not polled while the physical pad is active (`gameinput.rs:591`), so switching back can preserve the old look. In a scratch control, clearing `self.look` in the ≥100 ms/no-last-poll branch made this regression and all 12 default-feature `gameinput`-filtered tests pass. No physical controller or cursor was manipulated, and gameplay was not tested. Verification was AI-assisted with GPT-6.2 Astra.
Yoshi-233 commented 2026-11-27 01:11:55 +00:00 (Migrated from github.com)

Imported from DexNom/VIctory. Originally posted by Yoshi-233 on 2026-11-27T01:11:55Z.


I checked a second camera case on eb54094 while comparing the mouse-look behavior with CGBJ #7. The existing long-gap report starts with a carried deflection. This one starts with a neutral stick and two polls just 8 ms apart.

With the focused window initially centered at (400, 300), the first poll establishes that center. For the second poll I left the cursor at (400, 300) and changed only the window center to (440, 300). The real Host::mouse and look bodies returned (-1.0, 0.0) at sensitivity 1. Shifting the center 40 px left, up or down also saturated the corresponding stick axis. With a stationary window, no motion produced (0, 0) and a real 5 px move to the right produced (0.25, 0) as expected.

The delta currently uses the new window center as its origin. Keeping the previous successful recenter coordinates as the origin, then recentering on the new window center, gave zero in all four stationary-pointer cases. It also preserved +0.25 when a real 5 px move and a 40 px center shift happened together. A resize or reposition while polling is a useful native Windows regression case.

I ran the PR’s Rust control flow in a Linux harness with the Win32 cursor/window queries and clock supplied by the fixture. No physical window or game was driven in this check.

<!-- greyfinch-sync:DexNom/VIctory:comment:7207093313 --> Imported from [DexNom/VIctory](https://github.com/DexNom/VIctory/pull/82#issuecomment-7207093313). Originally posted by [Yoshi-233](https://github.com/Yoshi-233) on 2026-11-27T01:11:55Z. --- I checked a second camera case on `eb54094` while comparing the mouse-look behavior with [CGBJ #7](https://github.com/carlm125/cool_fox/pull/7). The existing long-gap report starts with a carried deflection. This one starts with a neutral stick and two polls just 8 ms apart. With the focused window initially centered at `(400, 300)`, the first poll establishes that center. For the second poll I left the cursor at `(400, 300)` and changed **only** the window center to `(440, 300)`. The real `Host::mouse` and `look` bodies returned `(-1.0, 0.0)` at sensitivity 1. Shifting the center 40 px left, up or down also saturated the corresponding stick axis. With a stationary window, no motion produced `(0, 0)` and a real 5 px move to the right produced `(0.25, 0)` as expected. The delta currently uses the *new* window center as its origin. Keeping the previous successful recenter coordinates as the origin, then recentering on the new window center, gave zero in all four stationary-pointer cases. It also preserved `+0.25` when a real 5 px move and a 40 px center shift happened together. A resize or reposition while polling is a useful native Windows regression case. I ran the PR’s Rust control flow in a Linux harness with the Win32 cursor/window queries and clock supplied by the fixture. No physical window or game was driven in this check.
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/82:upstream-pr/82'
git switch 'upstream-pr/82'

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