Input: fix AZERTY scancode mapping, focus reset, GameInput QI validation, and UnregisterCallback race #99
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/100"
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?
Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-23T11:11:21Z.
Summary
Fixes keyboard layout mapping, focus-loss input decay, config gating, COM
QueryInterfaceIID checks, and a callback unregistration UAF race incrates/xcl/src/hle/{kbm.rs, gameinput.rs}:Physical scancode mapping for WASD / Q / E (
kbm.rs):0x57/0x41/0x53/0x44/0x51/0x45) with AT Set 1 physical scancodes (0x11,0x1E,0x1F,0x20,0x10,0x12) translated viaMapVirtualKeyExW(..., MAPVK_VSC_TO_VK_EX, layout)using the foreground window's active keyboard layout (falling back to QWERTY VK if unmapped). Fixes movement and Q/A collisions on AZERTY/Dvorak/Colemak layouts.Focus-loss mouse velocity & wheel reset (
kbm.rs):Mouse::reset/reset_mouse_state()clearingDX,DY,WHEEL,velocity,wheel, andwheel_reston!focusedandWM_ACTIVATEdeactivation so stale camera/bumper motion does not replay on refocus.gameinput::poll()respectingconfig().keyboard_mouse = false(gameinput.rs):keyboard()andkbm::apply()whenkeyboard_mouseis disabled while preservingXCL_PRESS_AT/XCL_PRESS_A_ATscripted inputs.Strict
QueryInterfaceIID validation (gameinput.rs):IGameInput,IGameInputDevice,IGameInputReading,IUnknown) against the Windows SDKGameInput.h.E_POINTERon nullout,S_OK(withAddRefforReading) only forIID_IUnknownor the object's own IID, andE_NOINTERFACEwith*out = nullfor unknown/null IIDs (instead of unconditionally returningS_OK).UnregisterCallback/StopCallbacksynchronization (gameinput.rs):register_device_callbackthreads withArc<CallbackEntry>(stopped,in_flight,running_threads,Condvar) and RAIICallbackGuard.UnregisterCallbacknow waits up totimeout_usfor in-flight invocations on other threads to finish (without self-deadlocking on re-entrant unregistration), eliminating UAF when callers freecontextafterUnregisterCallbackreturnstrue.Testing
2inhle::kbm::tests,6inhle::gameinput::tests) coveringMapVirtualKeyExWscancode translation, focus-loss reset,keyboard_mouse = falsegating,QueryInterfaceIID checks on all 3 interfaces, and multi-threadedUnregisterCallbackwait/timeout/re-entrancy synchronization (stress-tested 5× back-to-back with 0 failures).origin/main(60599a9):cargo build --workspaceandcargo test --workspace -- --test-threads=4pass (467 passed, 0 failed, 36 ignored, 0 new warnings).Imported from ivall/xcl. Originally posted by ivall on 2026-11-23T11:25:45Z.
Merged. One addition (
02d1302): sinceQueryInterfacenow refuses IIDs other than the v0 ones, each refused IID is logged once – a title built against a newer GameInput would ask that way, and before it simply got the v0 object. Your gating merged cleanly with the controller changes onmain(connect / disconnect logging, slot search once a second). Merged together with #95–#102 and checked on Windows 11 with an RX 9070:cargo test --workspacegreen with the retail samples (shader pack, console DLLs, texture archive), lib tests also withXCL_SPLIT_WAVE64=1; XDefiant (title screen, a scripted A reaches its "Xbox network unavailable" dialog), Unicorn Overlord and Minecraft run. Thanks!