input/mnk: emit keystrokes so XamInputGetKeystroke returns input#311
input/mnk: emit keystrokes so XamInputGetKeystroke returns input#311Zorkats wants to merge 4 commits intorexglue:mainfrom
Conversation
tomcl7
left a comment
There was a problem hiding this comment.
I did confirm that EnqueueKeystroke had no callers, but this fix only covers part of what the issue describes though.
- No repeat events.
EmitKeystrokesonly emits on rising and falling edges, but nativeXInputGetKeystrokefiresXINPUT_KEYSTROKE_REPEATafter an initial delay and at a repeat rate. Issue #310 calls out "360 dashboard style menus", which need repeats for hold to scroll. After this PR a "Press Start" prompt advances, but a hold to scroll menu ticks once per press from MnK and scrolls continuously from a real pad. - Edge detection at
GetStatetime drops fast taps. A press and release that begins and ends between twoGetStatecalls leaves the buttons field at 0 in both samples and emits nothing. The transitions are visible inOnKeyDownandOnKeyUp, which is where edge detection wants to live. EmitKeystrokesis only called fromGetState. A title that polls onlyXamInputGetKeystroke, or polls keystrokes much more often than state, won't see anything from MnK.OnLostFocusresetsprev_*but doesn't drainkeystroke_queue_. Before this PR the queue was always empty so this was moot. Now anything queued just before focus loss sits there and gets delivered after focus returns.- The right stick comment frames the alternative as impossible ("would flood the queue"). It's a tradeoff. Worth saying so, since this silently breaks any title that uses right stick keystrokes for menu navigation.
|
I have added your feedback to the fork. Left it commented with clear explanations in case you have any doubts. Tested it and Built it, still works with TiP-Recomp. |
tomcl7
left a comment
There was a problem hiding this comment.
The bug at #310 is real, but the PR body describes a different fix than what's in the diff. It says GetState "diffs the freshly computed buttons, triggers, and left-stick direction against tracked previous-frame state" and invokes "a new EmitKeystrokes(buttons, lt, rt, lx, ly)." There is no such function in the diff. KEYDOWN/KEYUP edges actually come from OnKeyDown / OnKeyUp / OnMouseDown / OnMouseUp calling EmitButtonChange directly
rexglue-sdk/src/input/mnk/mnk_input_driver.cpp
Lines 489 to 504 in fe51f7f
GetState only ticks repeats and the opt-in right stick rexglue-sdk/src/input/mnk/mnk_input_driver.cpp
Lines 223 to 232 in fe51f7f
EmitButtonChange rexglue-sdk/src/input/mnk/mnk_input_driver.cpp
Lines 325 to 350 in fe51f7f
Rewrite the PR description to match what the code actually does and I'll take another look.
Closes #310
Input
MnkInputDriversoXamInputGetKeystroke/XamInputGetKeystrokeExreturn input from keyboard and mouse.GetStatenow diffs the freshly computed buttons, triggers, and left-stick direction against tracked previous-frame state and enqueues the matchingVirtualKey::kXInputPad*code per transition. Right stick (mouse-driven and continuous) is intentionally skipped to avoid flooding the queue; Guide button is omitted because it has noVK_PADcode in the standard XInput keystroke spec.Fixes
MnkInputDriverkeystroke queue.EnqueueKeystrokewas defined but never called from any event handler, leavingkeystroke_queue_permanently empty and causingXamInputGetKeystroke/XamInputGetKeystrokeExto always returnX_ERROR_EMPTYwhenever MnK was the input source. The bug was silent on most gameplay (state polling viaXamInputGetStateworked correctly, so WASD movement, intro skipping, and in-game button input all functioned) but broke any title screen or menu that consumed edge-triggered input — "Press Start" prompts appeared unresponsive even though intros could be skipped fine.GetStatenow invokes a newEmitKeystrokes(buttons, lt, rt, lx, ly)after computing the gamepad state, inside the existingstate_mutex_lock. The method table-drives the button bit →kXInputPad*mapping (D-pad, Start, Back, A/B/X/Y, both shoulders, both thumb-presses), thresholds triggers digitally (any nonzero deflection emitskXInputPadLTrigger/kXInputPadRTrigger, sufficient because MnK only ever produces 0 or 0xFF), and classifies the left stick into a 9-state direction enum where diagonals win over cardinals when both axes deflect.OnLostFocusresets the new prev-state members alongside the existingkey_down_reset so resumed focus does not replay stale keystrokes. Tested against TiP-Recomp on 0.7.4 and forward-applied to 0.7.6 (mnk driver files byte-identical between those versions).