From fa62125e05b30f6a7df482af924aa8e552760f07 Mon Sep 17 00:00:00 2001 From: Manuel Lagang Date: Sat, 17 Jan 2015 22:40:01 -0800 Subject: [PATCH] Modifiers are unset on events for the modifier key itself This patch removes modifiers when processing key events for the particular modifier key. For example, previously a Shift keypress would register as a Shift + Shift modifier event. This would cause issues when a modifier key as the action key in the input map, because unpresses of the modifier key don't match as matching inputs for that action. E.g. if Shift is used as an action, the stored action event is Shift + Shift modifier (as indicated in the editor as "Shift + Shift". The unpress event does not have the Shift modifier set, so the event of unpressing Shift + no modifier doesn't match the action which has the modifier set. This patch removes the shift modifier on just pressing the Shift key down, so the action event is registered as just Shift with no modifier (as indicated in the editor as "Shift"), which matches the unpress event. --- platform/windows/os_windows.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index ce791336649..bb911a99a40 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -589,10 +589,11 @@ LRESULT OS_Windows::WndProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam) { ERR_BREAK(key_event_pos >= KEY_EVENT_BUFFER_SIZE); + // Make sure we don't include modifiers for the modifier key itself. KeyEvent ke; - ke.mod_state.shift=shift_mem; - ke.mod_state.alt=alt_mem; - ke.mod_state.control=control_mem; + ke.mod_state.shift= (wParam != VK_SHIFT) ? shift_mem : false; + ke.mod_state.alt= (! (wParam == VK_MENU && (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN))) ? alt_mem : false; + ke.mod_state.control= (wParam != VK_CONTROL) ? control_mem : false; ke.mod_state.meta=meta_mem; ke.uMsg=uMsg;