mnk: a held mouse button counts through both GetAsyncKeyState and GetKeyState, so LT and RT can be held together #1949
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!1949
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1949"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@SXM081115 on GitHub · 2026-11-29 04:00 UTC · original
SXM081115:mnk-mouse-buttons→main· +66 −3 · 2 files · 2 commits · merged 2026-11-30 14:12 UTCThe problem
With
LT/RTbound to mouse buttons (the shipped default:RT = Mouse1,LT = Mouse2), the two triggers cannot be held together. Each one works alone, so the mapping itself is right; holding the first one, the second one press does not make both triggers read as pressed.Why
crates/victory-hle/src/modules/mnk.rspolls the bindings every 8 ms and, while the title has focus, re-centres the cursor withrecenter()in the same tick to read the look delta. A mouse button read only throughGetAsyncKeyState(the global, asynchronous state) can miss a press that lands around that re-centre, and the missed button then reads as released while the other one is held. Keyboard keys are unaffected because they are not the ones the cursor movement races with.The change
A held input counts as down when either reader says so:
GetKeyStatereports the calling thread's own view of the key (the same thread that pumps the window), so it catches the press the asynchronous read raced with. Nothing else changes: the axes are still computed asany(held)over each axis' keys,left_trigger/right_triggerstay independent, and keyboard bindings behave exactly as before (GetAsyncKeyStatealready covered them).Testing
RT = Mouse1+LT = Mouse2— hold left, press right: the left trigger drops, so L2+R2 never both register.Diff is one function,
9 +/2 -inmnk.rs. It applies onmain(568c5e5) cleanly and needs no other change.Note: the same fix is in the low-VRAM fork I maintain (
SXM081115/Victory-LowVRAM) alongside other open-PR merges; this PR carries only the input fix.@SXM081115 on GitHub · 2026-11-29 04:01 UTC · original
AI assistance disclosure
For transparency, since this change was found and drafted with AI help:
mnk.rs(there-centre racing the mouse read), the first draft of the
GetAsyncKeyState || GetKeyStatechange, and this PR's write-up were produced with an AI codingassistant working on my machine.
Laptop 8 GB, Ryzen 9 8940HX, Windows 11, Series S picture), chose the fix,
built and ran the patched binary, and verified that
LT = Mouse2+RT = Mouse1can be held together while a keyboard-only profile behaves exactly asbefore. The AI did not run the game or validate the patch; I did.
crates/victory-hle/src/modules/mnk.rs(+9/-2). No behaviour changes outside the held-key read; axes are still
any(held)per axis andleft_trigger/right_triggerstay independent.this repository's code, and the commit is GPL-3.0-or-later like the project.
the diff is small and self-contained, and I am happy to adjust it (for example
to enable the second read for mouse buttons only, or to put it behind a
switch) if you prefer a narrower shape.
I also maintain a low-VRAM fork of this project where the same fix ships
alongside merges of other open pull requests; this PR carries only the input
change so it can be reviewed on its own.
@SXM081115 on GitHub · 2026-11-29 04:06 UTC · original
Not a duplicate, and one known conflict point
I checked the open pull requests before writing this: none of them address this
fault.
mainstill reads a held key withGetAsyncKeyStatealone, and themouse/keyboard PRs I could find are about different things (wheel bindings
#1791, a poisoned mouse lock #1876, re-reading the file after KEY BINDINGS
#1185, removing input smoothing #1913, the look's flick remainder #1195).
The one overlap is textual: #1791 rewrites the same
let held = ...closure to add
WheelUp/WheelDown. The two changes are compatible — a wheelhas no held state, a mouse button does — so whichever lands first, the other
just needs a rebase. Happy to rebase this one onto #1791 if you prefer to take
that first.
This took a while to find because each trigger works on its own and the fault
only shows when one is held while the other is pressed, so it reads as "the
second button is ignored" rather than as an input-mapping mistake.
@ANDREANIADS on GitHub · 2026-11-29 04:08 UTC · original
At
5b932b2,Hub::startcallshub.poll()once on its caller, then spawns a worker that sleeps and polls every 8 ms (gameinput.rs). That recurring fallback can reachmnk::sample()on the worker. The graphics window pumps messages on the separatevictory-windowthread (host.rs). Could the description clarify which queue the fallback reads? Microsoft documents thatGetKeyStateadvances as the calling thread reads key messages. GetKeyState remarksThe same
heldpredicate handles keyboard bindings in bothb.axesandb.buttons. With injected states, async-up/queued-down still reports held until both are up. I tested the predicate in isolation; whether release is delayed on Windows remains unverified. If the intended change is mouse-only, limiting the extra read to mouse-button VKs would preserve the previous keyboard behavior. A native press-both/release-one check in both orders would complement the reported hold test.@SXM081115 on GitHub · 2026-11-29 04:14 UTC · original
You are right on the queue, and I have replaced the approach in
64e5b7drather than argue for it.What was wrong. The poll runs on the worker
Hub::startspawns (gameinput.rs:519-524, 8 ms), andmnk::sample()is reached from there (gameinput.rs:217) — not on the thread that pumps the window's messages.GetKeyStatethere reflects a queue nothing advances, so the extra read was effectively empty and the OR degenerated into the previous read. Thank you for catching it before it went in as "fixed".What the branch does now.
lifecycle.rsthat already runscapture_mouse/english_input, i.e. the thread that pumps — records everyWM_LBUTTONDOWN/UP,WM_RBUTTONDOWN/UP,WM_MBUTTONDOWN/UPandWM_XBUTTONDOWN/UP(high word picks Mouse4/Mouse5) into anAtomicU32, one bit per virtual-key code.mnk::sample()readsGetAsyncKeyState(vk)or that bit, for mouse VKs only (1..=6). Keyboard bindings inb.axesandb.buttonskeep exactly the single read they had, so the previous keyboard behaviour is preserved, as you suggested.WM_KILLFOCUS/WM_NCDESTROYclears the mask: when the focus is gone there is no up message to come.CallWindowProcWas before); nothing is swallowed.On release timing. The concern was that OR-ing two sources could delay a release. Here the release is not a queue's read progress but the actual
WM_*BUTTONUP, which the pump always receives for a captured window;GetAsyncKeyStateonly adds an "up" earlier, never later, because a bit is cleared on the real up and on focus loss. So a held-then-released button cannot stay stuck. The one case worth watching is a button released while the window is not captured and never gets the message — cleared by the focus-loss path above.Tests I will add (in this branch, native, Windows): press both, then release them one at a time in both orders, asserting the reported trigger pair after each step, and the frame at which each release shows up. Plus the existing hold-both test. If you would rather keep the change mouse-only and without the pump mask, say so and I will instead drop the extra read and open the press-both case as its own issue with those measurements.
@ANDREANIADS on GitHub · 2026-11-29 04:35 UTC · original
One case for the planned Windows test at
64e5b7d: in windowed mode withVICTORY_MOUSE_CAPTUREoff, hold Mouse1 inside the window, open F1, move outside the client area without changing focus, release there, then close F1 by keyboard. Check which window owns mouse capture, whether the title receivedWM_LBUTTONUP, and the first RT sample after closing. Repeat for Mouse2/LT.F1 returns a neutral pad before recentering, but resetting
Mouseleaves the separate button mask intact. In a CPU replay with async-up, local release and focus loss each cleared the bit for both buttons. Omitting the local release and focus loss left the bit set after closing F1. Native message delivery remains to be checked: the optionalClipCursorconfines the pointer, while mouse capture determines where an outside release is delivered. Microsoft: WM_LBUTTONUP