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

Closed
P1ayer-1 wants to merge 1 commit from upstream-pr/1876 into main
P1ayer-1 commented 2026-11-29 01:16:14 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by P1ayer-1 on 2026-11-29T01:16:14Z.


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).
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5546355633 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1876). Originally posted by [P1ayer-1](https://github.com/P1ayer-1) on 2026-11-29T01:16:14Z. --- 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`).
trustno1-coder commented 2026-11-29 08:28:34 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-11-29T08:28:34Z.


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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7253128224 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1876#issuecomment-7253128224). Originally posted by [trustno1-coder](https://github.com/trustno1-coder) on 2026-11-29T08:28:34Z. --- 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.
P1ayer-1 commented 2026-11-29 17:35:44 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by P1ayer-1 on 2026-11-29T17:35:44Z.


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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7259813995 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1876#issuecomment-7259813995). Originally posted by [P1ayer-1](https://github.com/P1ayer-1) on 2026-11-29T17:35:44Z. --- 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

Sign in to join this conversation.
No reviewers
No labels
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.

Reference
trustno1-coder/VIctory-NVIDIA!1876
No description provided.