Input: the mouse as the stand-in pad's camera (VICTORY_MOUSE) #1157

Open
h0useadv wants to merge 1 commit from upstream-pr/1157 into main
h0useadv commented 2026-11-24 16:18:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by h0useadv on 2026-11-24T16:18:02Z.


The keyboard's stand-in gamepad has no way to look around smoothly: I/J/K/L only give the right stick full deflection or none. This adds the mouse to that pad, opt-in.

What

  • VICTORY_MOUSE (1, or a sensitivity such as 0.5 or 2; unset, empty or 0 is off). While the title's window has focus, the mouse adds to the stand-in pad:
    • movement since the last poll turns the right stick (camera); 20 px per 8 ms poll is full deflection at sensitivity 1;
    • left button → right trigger, right button → left trigger.
  • Mouse and keys add up (the stick is clamped to ±1, the triggers take the larger value).
  • To read relative movement, the cursor is held in the window's centre while the window has focus. Losing focus releases it, and the first poll after gaining focus only centres it, so there's no jump.
  • A real pad still replaces the stand-in pad entirely, mouse included, as the keyboard already does.

How

  • Source::mouse(), a default method returning no mouse, so the test fake and the non-Windows host are unchanged.
  • with_mouse(pad, mouse), a pure function applied to the stand-in pad in State::poll.
  • The Windows host: GetWindowRect of the focused window, GetCursorPos, then SetCursorPos back to the centre; buttons through GetAsyncKeyState (VK_LBUTTON, VK_RBUTTON). Only windows-sys features the crate already enables.
  • README: one paragraph under the keyboard table.

Tested

  • cargo test -p victory-hle --lib: 96 passed. Two new tests: with_mouse (adding, clamping, buttons, no mouse leaves the pad unchanged), and through the hub with the fake host (the mouse reaches the stand-in pad, and is gone once a real pad connects).
  • cargo clippy -p victory-hle --all-targets: no warnings. cargo xtask policy: 154 files OK. rustfmt: the new code is formatted; the file's three existing rustfmt differences are untouched.
  • In the title's menus (RX 9070 XT, Windows 11, release build, VICTORY_MOUSE=1): focus on the title's window, cursor held exactly at its centre, menus at 30 fps; the cursor is free again once the title closes. I didn't get as far as a scene where the camera could be checked visually; the world doesn't render on my card yet.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:6586313176 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1157). Originally posted by [h0useadv](https://github.com/h0useadv) on 2026-11-24T16:18:02Z. --- The keyboard's stand-in gamepad has no way to look around smoothly: I/J/K/L only give the right stick full deflection or none. This adds the mouse to that pad, opt-in. ## What - **`VICTORY_MOUSE`** (`1`, or a sensitivity such as `0.5` or `2`; unset, empty or `0` is off). While the title's window has focus, the mouse adds to the stand-in pad: - movement since the last poll turns the **right stick** (camera); 20 px per 8 ms poll is full deflection at sensitivity 1; - **left button** → right trigger, **right button** → left trigger. - Mouse and keys add up (the stick is clamped to ±1, the triggers take the larger value). - To read relative movement, the cursor is held in the window's centre while the window has focus. Losing focus releases it, and the first poll after gaining focus only centres it, so there's no jump. - A real pad still replaces the stand-in pad entirely, mouse included, as the keyboard already does. ## How - `Source::mouse()`, a default method returning no mouse, so the test fake and the non-Windows host are unchanged. - `with_mouse(pad, mouse)`, a pure function applied to the stand-in pad in `State::poll`. - The Windows host: `GetWindowRect` of the focused window, `GetCursorPos`, then `SetCursorPos` back to the centre; buttons through `GetAsyncKeyState` (`VK_LBUTTON`, `VK_RBUTTON`). Only `windows-sys` features the crate already enables. - README: one paragraph under the keyboard table. ## Tested - `cargo test -p victory-hle --lib`: 96 passed. Two new tests: `with_mouse` (adding, clamping, buttons, no mouse leaves the pad unchanged), and through the hub with the fake host (the mouse reaches the stand-in pad, and is gone once a real pad connects). - `cargo clippy -p victory-hle --all-targets`: no warnings. `cargo xtask policy`: 154 files OK. rustfmt: the new code is formatted; the file's three existing rustfmt differences are untouched. - In the title's menus (RX 9070 XT, Windows 11, release build, `VICTORY_MOUSE=1`): focus on the title's window, cursor held exactly at its centre, menus at 30 fps; the cursor is free again once the title closes. I didn't get as far as a scene where the camera could be checked visually; the world doesn't render on my card yet. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Zipettte commented 2026-11-24 18:06:13 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T18:01:08Z.


Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at d67e37d: cargo test -p victory-hle passes, 97 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7140037960 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1157#issuecomment-7140037960). Originally posted by [Zipettte](https://github.com/Zipettte) on 2026-11-24T18:01:08Z. --- Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at d67e37d: `cargo test -p victory-hle` passes, 97 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed). _Tested with AI assistance (Claude)._
Marvisak commented 2026-11-25 02:05:50 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:17:50Z.


Automated triage for the maintainers.

Needs rebase. This pull request conflicts with main (conflicting: crates/victory-hle/src/modules/gameinput.rs). It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149403412 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1157#issuecomment-7149403412). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:17:50Z. --- <!-- victory-triage v1 head=d67e37dcd97efe4be28c9dfc144598a7ed7e4a35 verdict=needs-rebase at=2026-11-25T01:17:50Z --> Automated triage for the maintainers. **Needs rebase.** This pull request conflicts with `main` (conflicting: `crates/victory-hle/src/modules/gameinput.rs`). It will be reviewed once it is rebased onto the current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
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/1157:upstream-pr/1157'
git switch 'upstream-pr/1157'

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