mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 16:10:36 +00:00
MODIFIER_STATE_CHANGED never fired for a modifier released while WoW was in the background: WM_KEY* messages are only delivered to the focused window, so the WH_GETMESSAGE hook never saw the release and the cached bit stayed stuck down (also leaving IsLeft/RightShiftKeyDown etc. wrong). Add a WH_CALLWNDPROC thread hook to catch WM_ACTIVATEAPP (sent, not posted, so invisible to WH_GETMESSAGE). On app activation, resync the cached 6-bit mask from GetAsyncKeyState (global physical key state, unaffected by focus), firing MODIFIER_STATE_CHANGED for any bit that drifted while WoW was away. Both the keyboard path and the resync now funnel through a shared SetBit helper so the "only transitions fire" invariant holds regardless of source. Caveat (documented): the engine's native IsShiftKeyDown/IsControlKeyDown/ IsAltKeyDown bottom out at synchronous GetKeyState and share the blind spot; they are not reconciled here — only ClassicAPI's L/R functions and the event reflect the corrected state.