hle/gameinput: rebindable keyboard+mouse and the player's keys in prompts (VICTORY_MNK=1) #119

Open
github-bot wants to merge 4 commits from github-bot/gh-118 into main AGit
Owner

@⁠SovietBearz0r on GitHub · 2026-12-05 13:17 UTC · original
SovietBearz0r:sixmoon-mnk → main · +8220 −572 · 62 files · 50 commits · open

Rebindable keyboard and mouse, and the player's own keys in the title's button prompts: VICTORY_MNK=1 (opt-in; unset/0 keeps the built-in stand-in keys).

What

  • bindings.ini at %LOCALAPPDATA%\revictory\bindings.ini (override VICTORY_MNK_BINDINGS=<path>, shipped defaults generated on first start, never overwritten): action = key, key, ... lines for every pad control, mouse buttons (Mouse1..5), wheel as pseudo keys (WheelUp/Down), key aliases/named keys/0xNN, modifier families (either-side Shift/Ctrl/Alt, or a specific side), Sensitivity (0.135 reproduces the old feel). File read once per run; invalid lines/duplicates handled with warnings.
  • The bindings drive main's existing stand-in-pad hub (no parallel input path): WASD move, I/J/K/L camera, 1:1 non-accelerated mouse look to the right stick, mouse buttons/wheel bound like keys, controller input untouched. Mouse look is on while no controller is connected, F2/` toggles, Esc/P releases the cursor with the pause menu; with a pad in use it stays off until asked for.
  • Prompt redraw: the title's icon-movie prompts are redrawn with the player's keys via main's previously-unused use_bound_keys hook (all 24 controls supplied, unbound actions fall back to the built-in keys; wheel gets W↑/W↓ caps). Prompt style is unchanged unless the launcher already says Keyboard.
  • VICTORY_KBM_GTA=1 keeps the old fixed layout exactly (deprecated) so existing users do not silently change behaviour.
  • Docs/README updated; generated default file embedded and written on first start.

Verification

  • cargo test -p victory-hle --lib: 283 passed, 1 ignored (10 new bindings tests + a stand-in-pad integration test; existing gameinput tests green).
  • cargo test -p victory prompts: 60 passed (updated bound-key caps).
  • cargo check -p victory, cargo xtask policy, clippy (no new warnings): clean.
  • Needs in-game: on-foot movement/mouse look/invert, wheel notches, prompt redraw with launcher "Button prompts = Keyboard", F1/freecam/phone/alt-tab focus interplay, controller parity, VICTORY_MNK=0/VICTORY_KBM_GTA=1/custom path/missing-file paths. Known gaps: stick emulation (not native PC aim), no auto vehicle throttle on W/S, file applied on next start (no F1 Controls editor yet), mouse clicks on window chrome are not edge-captured.

Deliberately not ported: sixmoon's native mousehook.rs camera hook (same category as the xmem native-input candidate, which the report shows is distinct, not a dedupe: title-side RAGE input hooking, native vehicle throttle, frontend mouse cursor; deferred as its own later item).

Source: srmooon/sixmoon tip 79d7529 (mnk.rs, bindings.ini, mousehook excluded), prompts commit 7d2ea2092.

**@⁠SovietBearz0r** on GitHub · 2026-12-05 13:17 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/118) `SovietBearz0r:sixmoon-mnk` → `main` · +8220 −572 · 62 files · 50 commits · open Rebindable keyboard and mouse, and the player's own keys in the title's button prompts: `VICTORY_MNK=1` (opt-in; unset/0 keeps the built-in stand-in keys). ## What - `bindings.ini` at `%LOCALAPPDATA%\revictory\bindings.ini` (override `VICTORY_MNK_BINDINGS=<path>`, shipped defaults generated on first start, never overwritten): `action = key, key, ...` lines for every pad control, mouse buttons (`Mouse1..5`), wheel as pseudo keys (`WheelUp/Down`), key aliases/named keys/`0xNN`, modifier families (either-side Shift/Ctrl/Alt, or a specific side), `Sensitivity` (0.135 reproduces the old feel). File read once per run; invalid lines/duplicates handled with warnings. - The bindings drive main's existing stand-in-pad hub (no parallel input path): WASD move, I/J/K/L camera, 1:1 non-accelerated mouse look to the right stick, mouse buttons/wheel bound like keys, controller input untouched. Mouse look is on while no controller is connected, `F2`/`` ` `` toggles, `Esc`/`P` releases the cursor with the pause menu; with a pad in use it stays off until asked for. - Prompt redraw: the title's icon-movie prompts are redrawn with the player's keys via main's previously-unused `use_bound_keys` hook (all 24 controls supplied, unbound actions fall back to the built-in keys; wheel gets `W↑`/`W↓` caps). Prompt style is unchanged unless the launcher already says Keyboard. - `VICTORY_KBM_GTA=1` keeps the old fixed layout exactly (deprecated) so existing users do not silently change behaviour. - Docs/README updated; generated default file embedded and written on first start. ## Verification - `cargo test -p victory-hle --lib`: **283 passed, 1 ignored** (10 new bindings tests + a stand-in-pad integration test; existing gameinput tests green). - `cargo test -p victory prompts`: 60 passed (updated bound-key caps). - `cargo check -p victory`, `cargo xtask policy`, clippy (no new warnings): clean. - **Needs in-game**: on-foot movement/mouse look/invert, wheel notches, prompt redraw with launcher "Button prompts = Keyboard", F1/freecam/phone/alt-tab focus interplay, controller parity, `VICTORY_MNK=0`/`VICTORY_KBM_GTA=1`/custom path/missing-file paths. Known gaps: stick emulation (not native PC aim), no auto vehicle throttle on W/S, file applied on next start (no F1 Controls editor yet), mouse clicks on window chrome are not edge-captured. Deliberately not ported: sixmoon's native `mousehook.rs` camera hook (same category as the xmem native-input candidate, which the report shows is **distinct**, not a dedupe: title-side RAGE input hooking, native vehicle throttle, frontend mouse cursor; deferred as its own later item). Source: srmooon/sixmoon tip `79d7529` (`mnk.rs`, `bindings.ini`, `mousehook` excluded), prompts commit `7d2ea2092`.
Port sixmoon's keyboard and mouse layer (T2-2). A user-editable
%LOCALAPPDATA%\revictory\bindings.ini drives the keyboard's stand-in
gamepad in place of the fixed tables; VICTORY_MNK_BINDINGS reads another
file, VICTORY_MNK=0 turns the layer and the file off, and a file that is
not there is written with the defaults (sixmoon's) on the first start.

- Buttons, sticks and triggers are bound to keyboard keys, mouse buttons
  (Mouse1..Mouse5) and the wheel as pseudo keys (each notch one short
  press), with left/right modifier families; the camera's keys (I/J/K/L)
  and movement (WASD) come from the file, and the defaults keep the
  arrow/Enter/Esc menu meanings.
- Mouse look is 1:1 on the right stick, with the file's Sensitivity
  (0.135 = the old layer's 1.0) times VICTORY_MOUSE_SENS; it is on by
  itself while no controller is connected, F2/ toggles it and Esc/P lets
  the cursor go with the pause menu. With a pad in use it stays off, and
  controller input is untouched.
- The title's prompts (VICTORY_PROMPTS=keyboard) now draw the player's own
  keys through the use_bound_keys hook that was present but never called;
  the wheel gets key caps too.
- VICTORY_KBM_GTA=1 keeps the old fixed layout and mouse look exactly as
  they were (deprecated: unset it to use bindings.ini).

Pure parsing/matching tests cover the file, key aliases, duplicates,
modifier sides, wheel pulses, prompt-key mapping and the generated
defaults; gameinput's existing tests still pass on the built-in tables.
Reading the previous commits: the layer defaulted on, but mouse capture with
no controller connected changes the first-run experience; upstream keeps new
input paths opt-in. Unset or 0 now keeps the built-in stand-in keys, and the
docs/README say how to turn it on.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-05 13:19:53 +00:00
Author
Owner

@⁠ReTerryDavis on GitHub · 2026-12-05 17:39 UTC · original

Super clean rebindable M+K + prompt integration! Marking as draft for two small input edge-case fixes before merge:

  1. Pause-unlock immediately re-locks after F2 (crates/victory-hle/src/modules/gameinput.rs, Host::bindings_look_toggle): Pressing F2/` sets self.user_lock = Some(true). Pressing Esc or P then sets self.pause_unlocked = true and self.mouse_locked = false without clearing self.user_lock, so a few lines later in the same poll let want = self.user_lock.unwrap_or(...) evaluates to true and immediately re-locks the cursor (same loop if recenter_cursor fails in mouse_look_step). Clearing self.user_lock = None on Esc/P (and on recenter_cursor failure) fixes both.
  2. Window-chrome click leak (Host::mouse_keys): Polling GetAsyncKeyState(0x01..=0x06) whenever focused() without in_client or self.mouse_buttons.update(...) edge-gating (unlike gta_mouse_pad) allows clicks on the title bar/borders or closing F1 to fire RT/LT into the game.

Mark ready once those two are fixed and we'll merge!

**@⁠ReTerryDavis** on GitHub · 2026-12-05 17:39 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/118#issuecomment-7442371644) Super clean rebindable M+K + prompt integration! Marking as draft for two small input edge-case fixes before merge: 1. **Pause-unlock immediately re-locks after `F2` (`crates/victory-hle/src/modules/gameinput.rs`, `Host::bindings_look_toggle`):** Pressing `F2`/`` ` `` sets `self.user_lock = Some(true)`. Pressing `Esc` or `P` then sets `self.pause_unlocked = true` and `self.mouse_locked = false` without clearing `self.user_lock`, so a few lines later in the same poll `let want = self.user_lock.unwrap_or(...)` evaluates to `true` and immediately re-locks the cursor (same loop if `recenter_cursor` fails in `mouse_look_step`). Clearing `self.user_lock = None` on `Esc`/`P` (and on `recenter_cursor` failure) fixes both. 2. **Window-chrome click leak (`Host::mouse_keys`):** Polling `GetAsyncKeyState(0x01..=0x06)` whenever `focused()` without `in_client` or `self.mouse_buttons.update(...)` edge-gating (unlike `gta_mouse_pad`) allows clicks on the title bar/borders or closing F1 to fire `RT`/`LT` into the game. Mark ready once those two are fixed and we'll merge!
Esc/P with the pause menu left F2's user_lock at Some(true), so the automatic choice re-locked the cursor in the same poll; a failed cursor recenter kept the same stale choice. Both paths now forget it through one helper, and a pure test pins the lock transition.

Polling the mouse buttons whenever the window had focus also let clicks on the title bar, borders, or a closing F1 overlay reach the bound triggers. The buttons now go through MouseButtons (edge-captured, five buttons) and count only while the cursor is inside the client area; tests cover the in-client predicate and the five-button edge capture.

The shipped bindings template moves from bindings.ini to bindings.example.txt because the asset-policy allowlist has no ini extension; the runtime file keeps its name.
Author
Owner

@⁠SovietBearz0r on GitHub · 2026-12-05 18:52 UTC · original

Both input edge cases fixed: Esc/P (and a recenter_cursor failure) now clear user_lock so the same-poll want cannot re-lock the cursor; mouse_keys requires foreground + in-client press start (edge-gated, 5 buttons, shared with the fixed-GTA path), so title-bar/border/F1 clicks no longer fire RT/LT. Pure tests for both. Marking ready.

**@⁠SovietBearz0r** on GitHub · 2026-12-05 18:52 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/118#issuecomment-7443507316) Both input edge cases fixed: `Esc`/`P` (and a `recenter_cursor` failure) now clear `user_lock` so the same-poll `want` cannot re-lock the cursor; `mouse_keys` requires foreground + in-client press start (edge-gated, 5 buttons, shared with the fixed-GTA path), so title-bar/border/F1 clicks no longer fire RT/LT. Pure tests for both. Marking ready.
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 origin '+refs/pull/119/head:github-bot/gh-118'
git switch 'github-bot/gh-118'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-118'
git switch 'github-bot/gh-118'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-118'
git switch 'github-bot/gh-118'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-118'
git switch 'main'
git merge --squash 'github-bot/gh-118'
git switch 'main'
git merge --ff-only 'github-bot/gh-118'
git switch 'main'
git merge 'github-bot/gh-118'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.