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

Open
github-bot wants to merge 1 commit from github-bot/gh-1157 into main AGit
Owner

@⁠h0useadv on GitHub · 2026-11-24 16:18 UTC · original
h0useadv:input/mouse-camera → main · +175 −5 · 2 files · 1 commits · open

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

**@⁠h0useadv** on GitHub · 2026-11-24 16:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/1157) `h0useadv:input/mouse-camera` → `main` · +175 −5 · 2 files · 1 commits · open 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)
With VICTORY_MOUSE set (1, or a sensitivity such as 0.5 or 2) the mouse
adds to the keyboard's stand-in gamepad while the title's window has
focus: its movement since the last poll turns the right stick, the left
button pulls the right trigger and the right button the left one. The
cursor is held in the window's centre to read relative movement; losing
focus releases it, and the first poll after gaining it only centres it.
Off by default. A real pad still replaces the stand-in pad entirely.

`with_mouse` is pure and tested; `Source::mouse` defaults to no mouse, so
fakes and non-Windows hosts are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:21:33 +00:00
Author
Owner

@⁠Zipettte on GitHub · 2026-11-24 18:01 UTC · original

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).

**@⁠Zipettte** on GitHub · 2026-11-24 18:01 UTC · [original](https://github.com/Marvisak/VIctory/pull/1157#issuecomment-7140037960) 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)._
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:17 UTC · original

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

**@⁠Marvisak** on GitHub · 2026-11-25 01:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/1157#issuecomment-7149403412) <!-- 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 has changes conflicting with the target branch.
  • crates/victory-hle/src/modules/gameinput.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1157/head:github-bot/gh-1157'
git switch 'github-bot/gh-1157'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1157'
git switch 'github-bot/gh-1157'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1157'
git switch 'github-bot/gh-1157'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1157'
git switch 'main'
git merge --squash 'github-bot/gh-1157'
git switch 'main'
git merge --ff-only 'github-bot/gh-1157'
git switch 'main'
git merge 'github-bot/gh-1157'
git push origin 'main'
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/Marvisak--VIctory!1157
No description provided.