mnk: recover from a poisoned mouse lock, and retry bindings that failed to load #1876

Closed
github-bot wants to merge 1 commit from github-bot/gh-1876 into main AGit
Owner

@⁠P1ayer-1 on GitHub · 2026-11-29 01:16 UTC · original
P1ayer-1:mnk-lock-and-reload → main · +2 −2 · 1 files · 1 commits · closed without merging

Relevant to #1283 (the reload half of it) and to #1180. No issue tracked this exact path, so nothing is closed by this.

What it changes

Two ways mouse and keyboard (VICTORY_MNK=1) could stay dead for the rest of a run.

A poisoned mouse lock. mouse() took the shared Mouse state with lock().unwrap(). One panic under sample() poisons that mutex, and every later poll then panics on the input thread, so the stand-in pad stops updating until the game is restarted. The rest of the crate recovers from poisoning — config() in this same file, and gameinput.rs's lock() — so this one now recovers the same way.

A bindings file that failed once never reloaded. config() only reloaded from the arm Some(Some(_)) if c.0 != changed. A first load that failed is stored as Some(None), which nothing but the _ arm matches, so a later MNK_BINDINGS_CHANGED could never reload: F1's KEY BINDINGS would write a valid file and enabled() would stay false, with the menu still saying "Enable MnK to change keybinds", for the rest of the process. The arm now matches Some(_), so a file that failed once is read again when the menu saves it.

Nothing changes when the bindings load normally on the first try. Editing bindings.ini by hand still needs a restart: only F1's editor moves MNK_BINDINGS_CHANGED.

On #1283: if the first load of bindings.ini succeeded, this changes nothing for that report — their F1 edits would already reload. It is the case where the first load failed (an invalid line, a hand-edited file) that this fixes, which matches "the changes get saved to bindings.ini, but the game still uses the old bindings".

How it was tested

  • GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): RTX 3060 Ti 8 GB, Windows 11 (build 26300), Series X profile, 2560x1440, DLSS Quality, frame generation off, ray tracing off
  • Before: d4b5d51 plus this patch
  • After: cargo build --release -p victory → exit 0; cargo test -p victory-hle --lib gameinput → 28 passed; 0 failed; 1 ignored
  • For shader changes, the wave sizes tested (32 and/or 64 lanes): n/a, no shader changes
  • cargo test passed for the crates it touches: yes, victory-hle

One caveat, so nothing here is oversold: I could not confirm either path by playing. On this machine a build of d4b5d51 started with VICTORY_MNK=1 stops with 0xC0000005 before the first frame — and so does the same binary with MnK off, and neither is this patch's doing (see #1900, where the same source-build crash is reported at a later offset). The released v2026.11.28.03 runs on this machine for hours, which is how the two paths below were reached. Both changes are covered by reading and by the tests, not by a run.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #1791, #1739, #1610, #1570, #1393 — all touch mnk.rs or the input path; none of them changes config() or mouse(). #1393 fixes a different cause of the same symptom (the script launcher passing VICTORY_MNK=1 without VICTORY_MNK_BINDINGS).
**@⁠P1ayer-1** on GitHub · 2026-11-29 01:16 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1876) `P1ayer-1:mnk-lock-and-reload` → `main` · +2 −2 · 1 files · 1 commits · closed without merging Relevant to #1283 (the reload half of it) and to #1180. No issue tracked this exact path, so nothing is closed by this. ## What it changes Two ways mouse and keyboard (`VICTORY_MNK=1`) could stay dead for the rest of a run. **A poisoned mouse lock.** `mouse()` took the shared `Mouse` state with `lock().unwrap()`. One panic under `sample()` poisons that mutex, and every later poll then panics on the input thread, so the stand-in pad stops updating until the game is restarted. The rest of the crate recovers from poisoning — `config()` in this same file, and `gameinput.rs`'s `lock()` — so this one now recovers the same way. **A bindings file that failed once never reloaded.** `config()` only reloaded from the arm `Some(Some(_)) if c.0 != changed`. A first load that failed is stored as `Some(None)`, which nothing but the `_` arm matches, so a later `MNK_BINDINGS_CHANGED` could never reload: F1's KEY BINDINGS would write a valid file and `enabled()` would stay false, with the menu still saying "Enable MnK to change keybinds", for the rest of the process. The arm now matches `Some(_)`, so a file that failed once is read again when the menu saves it. Nothing changes when the bindings load normally on the first try. Editing `bindings.ini` by hand still needs a restart: only F1's editor moves `MNK_BINDINGS_CHANGED`. On #1283: if the first load of `bindings.ini` succeeded, this changes nothing for that report — their F1 edits would already reload. It is the case where the first load *failed* (an invalid line, a hand-edited file) that this fixes, which matches "the changes get saved to `bindings.ini`, but the game still uses the old bindings". ## How it was tested - GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): RTX 3060 Ti 8 GB, Windows 11 (build 26300), Series X profile, 2560x1440, DLSS Quality, frame generation off, ray tracing off - Before: `d4b5d51` plus this patch - After: `cargo build --release -p victory` → exit 0; `cargo test -p victory-hle --lib gameinput` → `28 passed; 0 failed; 1 ignored` - For shader changes, the wave sizes tested (32 and/or 64 lanes): n/a, no shader changes - `cargo test` passed for the crates it touches: yes, `victory-hle` One caveat, so nothing here is oversold: I could not confirm either path by playing. On this machine a build of `d4b5d51` started with `VICTORY_MNK=1` stops with `0xC0000005` before the first frame — and so does the same binary with MnK off, and neither is this patch's doing (see #1900, where the same source-build crash is reported at a later offset). The released `v2026.11.28.03` runs on this machine for hours, which is how the two paths below were reached. Both changes are covered by reading and by the tests, not by a run. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #1791, #1739, #1610, #1570, #1393 — all touch `mnk.rs` or the input path; none of them changes `config()` or `mouse()`. #1393 fixes a different cause of the same symptom (the script launcher passing `VICTORY_MNK=1` without `VICTORY_MNK_BINDINGS`).
Two ways mouse and keyboard could stay dead for the rest of a run.

`mouse()` took the shared state with `lock().unwrap()`, so one panic under
`sample()` poisoned the mutex and every later poll panicked on the input
thread. The rest of the crate recovers from poisoning (`config()` in this
same file, and `gameinput.rs`'s `lock()`), so this one recovers too.

`config()` reloaded bindings only when it already held `Some(Some(_))`. A
first load that failed is stored as `Some(None)`, so no later
`MNK_BINDINGS_CHANGED` could match: F1's KEY BINDINGS wrote a good file and
`enabled()` stayed false until the game was restarted. The arm now matches
`Some(_)` and retries the load when the file changes.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 01:18:38 +00:00
github-bot force-pushed github-bot/gh-1876 from 70bf9f68ad to 3c89f5d6ff 2026-11-29 02:17:49 +00:00 Compare
Author
Owner

@⁠trustno1-coder on GitHub · 2026-11-29 08:28 UTC · original

Thank you! An earlier version of this pull request was merged into main with its original commits and is part of v2026.11.29.01, where you are credited. GitHub does not show it as merged because new commits were pushed here after that merge. It stays open so those newer commits can be looked at next.

**@⁠trustno1-coder** on GitHub · 2026-11-29 08:28 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1876#issuecomment-7253128224) Thank you! An earlier version of this pull request was merged into main with its original commits and is part of [v2026.11.29.01](https://github.com/trustno1-coder/VIctory-NVIDIA/releases/tag/v2026.11.29.01), where you are credited. GitHub does not show it as merged because new commits were pushed here after that merge. It stays open so those newer commits can be looked at next.
github-bot closed this pull request 2026-11-29 17:39:17 +00:00
Author
Owner

@⁠P1ayer-1 on GitHub · 2026-11-29 17:35 UTC · original

Merged upstream already: e52b8fbe brought this in through wave-6, and the bindings half was then rewritten as 234456f2 (a refresh() helper with a test, keeping the last bindings when a later read fails) — a better shape than mine. mouse() on main is lock().unwrap_or_else(|e| e.into_inner()), and config() recovers the same way, so both paths are closed. Closing as merged; nothing here is left to apply.

**@⁠P1ayer-1** on GitHub · 2026-11-29 17:35 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1876#issuecomment-7259813995) Merged upstream already: `e52b8fbe` brought this in through wave-6, and the bindings half was then rewritten as `234456f2` (a `refresh()` helper with a test, keeping the last bindings when a later read fails) — a better shape than mine. `mouse()` on main is `lock().unwrap_or_else(|e| e.into_inner())`, and `config()` recovers the same way, so both paths are closed. Closing as merged; nothing here is left to apply.

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