gameinput: auto-drive right stick from mouse when LOOK_PULL is idle (minigames) #525

Open
aowu wants to merge 1 commit from aowu/Darner:pr/minigame-mouse-right-stick into Main
First-time contributor

Problem

In native 1:1 mouse mode, camera look is injected via mousehook's LOOK_PULL hook. During minigames that read the right stick directly instead of running normal camera updates (such as lockpicking, safe dials, hotwiring, or object inspection), LOOK_PULL stops running, so moving the mouse has no effect and players have to fall back to keyboard keys.

Fix

  • Record a timestamp (gameinput::note_look_pull()) whenever look_entered / look_returned runs.
  • During captured gameplay when the radial wheel is closed and LOOK_PULL has been idle for >= 200 ms, consume raw mouse deltas (RAW_DX / RAW_DY) through a smoothed IdleRightStick mapper (right_x / right_y, honoring DARNER_MOUSE_INVERT_Y and decaying cleanly to zero after 50 ms without motion).
  • Reset IDLE_RIGHT_STICK immediately whenever LOOK_PULL resumes or when entering F1 menu, Pause menu, Map, or radial wheel.

Verification

  • Added unit test idle_look_pull_drives_right_stick_and_decays.
  • cargo test -p darner-hle --lib gameinput passes (117/117).
  • Verified in-game during vehicle hotwiring / lockpicking minigames: moving the mouse smoothly turns the right-stick dial without interfering with normal 1:1 camera look.
### Problem In native 1:1 mouse mode, camera look is injected via `mousehook`'s `LOOK_PULL` hook. During minigames that read the right stick directly instead of running normal camera updates (such as lockpicking, safe dials, hotwiring, or object inspection), `LOOK_PULL` stops running, so moving the mouse has no effect and players have to fall back to keyboard keys. ### Fix - Record a timestamp (`gameinput::note_look_pull()`) whenever `look_entered` / `look_returned` runs. - During captured gameplay when the radial wheel is closed and `LOOK_PULL` has been idle for `>= 200 ms`, consume raw mouse deltas (`RAW_DX` / `RAW_DY`) through a smoothed `IdleRightStick` mapper (`right_x` / `right_y`, honoring `DARNER_MOUSE_INVERT_Y` and decaying cleanly to zero after 50 ms without motion). - Reset `IDLE_RIGHT_STICK` immediately whenever `LOOK_PULL` resumes or when entering F1 menu, Pause menu, Map, or radial wheel. ### Verification - Added unit test `idle_look_pull_drives_right_stick_and_decays`. - `cargo test -p darner-hle --lib gameinput` passes (117/117). - Verified in-game during vehicle hotwiring / lockpicking minigames: moving the mouse smoothly turns the right-stick dial without interfering with normal 1:1 camera look.
First-time contributor

#429 (draft, waiting on #364) covers the same minigames with explicit hold keys, so I read the two together. Two things came up, from the code only (I haven't run this branch):

  1. Both take the same mouse counts. The idle path swaps RAW_DX / RAW_DY in overlay(), which runs before poll(). While a #429 hold key is down, poll() swaps the same counters to move the held stick or trigger. In a minigame (LOOK_PULL idle) the idle path would take the counts first, so the held control would not move, and the result is merged with further() anyway. Proposed fix: the idle path stands down while a hold key is down (with #429 merged that is HOLDING.load(Ordering::Relaxed); I can add that guard on #429's side if this lands first).
  2. Speed, not position. The stick follows how fast the mouse moves and goes back to the middle 50 ms after the mouse stops. That suits a dial the stick turns. It can't hold a stick at a point, which hotwiring asks for (both sticks held at points of a circle). That is why #429 places the stick where the mouse leaves it and covers the left stick and both triggers too.

So I see them as complementary: this one needs no key for right-stick-only minigames, and #429 is for the ones that need a stick held at a point, two sticks, or a trigger part way. Only item 1 needs a change.

#429 (draft, waiting on #364) covers the same minigames with explicit hold keys, so I read the two together. Two things came up, from the code only (I haven't run this branch): 1. **Both take the same mouse counts.** The idle path swaps `RAW_DX` / `RAW_DY` in `overlay()`, which runs before `poll()`. While a #429 hold key is down, `poll()` swaps the same counters to move the held stick or trigger. In a minigame (`LOOK_PULL` idle) the idle path would take the counts first, so the held control would not move, and the result is merged with `further()` anyway. Proposed fix: the idle path stands down while a hold key is down (with #429 merged that is `HOLDING.load(Ordering::Relaxed)`; I can add that guard on #429's side if this lands first). 2. **Speed, not position.** The stick follows how fast the mouse moves and goes back to the middle 50 ms after the mouse stops. That suits a dial the stick turns. It can't hold a stick at a point, which hotwiring asks for (both sticks held at points of a circle). That is why #429 places the stick where the mouse leaves it and covers the left stick and both triggers too. So I see them as complementary: this one needs no key for right-stick-only minigames, and #429 is for the ones that need a stick held at a point, two sticks, or a trigger part way. Only item 1 needs a change.
Author
First-time contributor

@EmberReD Thanks for taking the time to read through this and check how it interacts with #429!

Completely agree on both points — zero-key automatic right-stick rotation for dial/lockpicking minigames and #429's explicit hold-key positioning for two-stick / held-angle / partial-trigger minigames (like hotwiring) complement each other nicely.

Happy to coordinate on the RAW_DX / RAW_DY guard whichever lands first: if #429 merges first, I'll rebase and add the HOLDING stand-down check here; if #525 lands first, adding it on #429's side sounds great!

@EmberReD Thanks for taking the time to read through this and check how it interacts with #429! Completely agree on both points — zero-key automatic right-stick rotation for dial/lockpicking minigames and #429's explicit hold-key positioning for two-stick / held-angle / partial-trigger minigames (like hotwiring) complement each other nicely. Happy to coordinate on the `RAW_DX` / `RAW_DY` guard whichever lands first: if #429 merges first, I'll rebase and add the `HOLDING` stand-down check here; if #525 lands first, adding it on #429's side sounds great!
Owner

Test needed — commit 8c292969; what to check: the change described above

Evidence to post: card + driver, settings, commit tested, before/after (switch off vs on, two runs each), fps median and p99, and one line saying you looked at the picture.

Reply testing to take this run; it's free again after 24 h with no results.

**Test needed** — commit `8c292969`; what to check: the change described above Evidence to post: card + driver, settings, commit tested, before/after (switch off vs on, two runs each), fps median and p99, and one line saying you looked at the picture. Reply `testing` to take this run; it's free again after 24 h with no results.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'pr/minigame-mouse-right-stick:aowu-pr/minigame-mouse-right-stick'
git switch 'aowu-pr/minigame-mouse-right-stick'

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 'aowu-pr/minigame-mouse-right-stick'
git switch 'aowu-pr/minigame-mouse-right-stick'
git rebase 'Main'
git switch 'Main'
git merge --ff-only 'aowu-pr/minigame-mouse-right-stick'
git switch 'aowu-pr/minigame-mouse-right-stick'
git rebase 'Main'
git switch 'Main'
git merge --no-ff 'aowu-pr/minigame-mouse-right-stick'
git switch 'Main'
git merge --squash 'aowu-pr/minigame-mouse-right-stick'
git switch 'Main'
git merge --ff-only 'aowu-pr/minigame-mouse-right-stick'
git switch 'Main'
git merge 'aowu-pr/minigame-mouse-right-stick'
git push origin 'Main'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
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
TrustNo1/Darner!525
No description provided.