Mouse look: hold the stick for as long as the flick was owed (fixes sharp moves doing nothing) #1195

Closed
github-bot wants to merge 4 commits from github-bot/gh-1195 into main AGit
Owner

@⁠Alxspb on GitHub · 2026-11-28 15:18 UTC · original
Alxspb:feat/mouse-look-hold → main · +629 −18 · 5 files · 4 commits · closed without merging

Stacked on #989 (the mouse-camera feature) and #1149 (the F1 sensitivity row); contains both, review the last commit.

Symptom (from players of the keyboard-and-mouse stand-in, #989)

A sharp mouse move turned the camera not at all, while a slow drag worked - but exactly like a gamepad stick. The faster the move, the less it registered.

Why

The pad is a state device, not a delta one: XINPUT_GAMEPAD "describes the current state of the controller" (GDKX, reference/input/xinputongameinput/structs/xinput_gamepad.md), and GameInput axes carry a dead zone around the center position (GDKX, reference/input/gameinput/deprecated/structs/gameinputcontrolleraxisinfo.md, deadZone). The mapper pushed the stick with each poll's motion and let it fall back with a 45 ms half-life. The title samples the pad at its own frame times - and it draws a few frames a second at busy moments. A flick lasting well under a frame time was on the stick and settled back to the centre between two of the title's reads: the title never saw it. A slow drag was still held at every read, which is why exactly that case worked and felt like a stick.

Fix

Hold the deflection, unchanged, for a time that grows with the distance the mouse moved: 0.3 ms of hold per pixel at sensitivity 1, capped at 180 ms, then a fast 20 ms fall-off. A held deflection is read by as many of the title's frames as the distance is owed, and each of them turns at the stick's rate - so the angle adds up to the mouse distance whatever the title's frame rate. Quick moves and slow moves behave alike, which is what "the mouse works like a mouse in an action game" means on top of a pad-only title.

A reversal puts the stick the other way at once and turns the remaining hold with it. The same-way pile-up (fast continuous drags still reach the full stick), the sensitivity scale, the one-pixel-at-low-sensitivity case and the settle-to-centre are all kept; the existing tests pass unchanged and one new test pins the hold model.

Tuning

HOLD_MS_PER_PX (0.3) and MAX_HOLD_MS (180) are the two knobs; they scale with VICTORY_MOUSE_SENS / the F1 sensitivity row (#1149). Related: #1002 (the original sensitivity variable).

**@⁠Alxspb** on GitHub · 2026-11-28 15:18 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1195) `Alxspb:feat/mouse-look-hold` → `main` · +629 −18 · 5 files · 4 commits · closed without merging Stacked on #989 (the mouse-camera feature) and #1149 (the F1 sensitivity row); contains both, review the last commit. ## Symptom (from players of the keyboard-and-mouse stand-in, #989) A sharp mouse move turned the camera **not at all**, while a slow drag worked - but exactly like a gamepad stick. The faster the move, the less it registered. ## Why The pad is a state device, not a delta one: `XINPUT_GAMEPAD` "describes the current state of the controller" (GDKX, `reference/input/xinputongameinput/structs/xinput_gamepad.md`), and GameInput axes carry a dead zone around the center position (GDKX, `reference/input/gameinput/deprecated/structs/gameinputcontrolleraxisinfo.md`, `deadZone`). The mapper pushed the stick with each poll's motion and let it fall back with a 45 ms half-life. The title samples the pad at its own frame times - and it draws a few frames a second at busy moments. A flick lasting well under a frame time was on the stick and settled back to the centre **between two of the title's reads**: the title never saw it. A slow drag was still held at every read, which is why exactly that case worked and felt like a stick. ## Fix Hold the deflection, unchanged, for a time that grows with the distance the mouse moved: 0.3 ms of hold per pixel at sensitivity 1, capped at 180 ms, then a fast 20 ms fall-off. A held deflection is read by as many of the title's frames as the distance is owed, and each of them turns at the stick's rate - so the angle adds up to the mouse distance **whatever the title's frame rate**. Quick moves and slow moves behave alike, which is what "the mouse works like a mouse in an action game" means on top of a pad-only title. A reversal puts the stick the other way at once and turns the remaining hold with it. The same-way pile-up (fast continuous drags still reach the full stick), the sensitivity scale, the one-pixel-at-low-sensitivity case and the settle-to-centre are all kept; the existing tests pass unchanged and one new test pins the hold model. ## Tuning `HOLD_MS_PER_PX` (0.3) and `MAX_HOLD_MS` (180) are the two knobs; they scale with `VICTORY_MOUSE_SENS` / the F1 sensitivity row (#1149). Related: #1002 (the original sensitivity variable).
On some PCs the title registers device callbacks for keyboards (0x10) and
gamepads (0x40000) only, never mice (0x20), so the mouse device never reaches
it and the camera does not follow the mouse. With VICTORY_KBM_GTA=1 the mouse
reaches it as the stand-in pad instead: captured motion (lifecycle's
VICTORY_MOUSE_CAPTURE path, warping by default) turns the right stick, with
a 45 ms half-life back to centre; LMB = RT, RMB = LT, MMB = R3. Keys follow
GTA V's PC layout (GTA_BUTTONS), by place as the default table; I/J/K/L
still turn the camera. Only while the window is in front, the F1 menu is
closed and the stand-in is the title's pad. Off by default; F1 row added.

Ported from VIctory's c485827 (PR #295), on this fork's capture.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With VICTORY_KBM_GTA=1 the cursor was clipped and warped whenever the game was
in front, so the window could not be moved nor its title bar reached. The
capture now holds the mouse only while locked: locked from the start (the log
says F2 releases the mouse), F2 or ` / ~ toggles it, losing the front unlocks
it, and only F2 or a left click in the client area locks it again (title bar
and border clicks are non-client messages and never lock). Unlocked: no clip,
no warp, the cursor shown, no motion on the right stick.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The keyboard-and-mouse look read its multiplier once at the start
(gameinput.rs), so matching the feel meant restarting the game. The
value now lives in one atomic the input module reads at each poll and
the settings menu writes; the menu row changes it at once.
A sharp mouse move turned nothing while a slow one worked: the deflection
piled up and fell back with a 45 ms half-life, and a title drawing a few
frames a second read the stick only after the flick had already settled -
it never saw the flick at all, only the slow drags that were still on the
stick at its frame. A held deflection reads over as many of the title's
frames as the moved distance is owed (0.3 ms of hold a pixel, capped at
180 ms), and each frame inside it turns at the rate asked - so the angle
adds up to the distance whatever the frame rate, and quick moves and
slow ones behave alike. A reversal puts the stick the other way at once
and turns the hold with it. The same-way pile-up, the sensitivity scale
and the settle-to-centre are kept.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 15:22:23 +00:00
github-bot closed this pull request 2026-11-30 16:33:43 +00:00

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!1195
No description provided.