From 79dce39db7cee24ccaf3daa3f3a824580bb4850c Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Fri, 11 Oct 2019 20:41:30 -0700 Subject: [PATCH] Fix modifier loss bug --- custom/generated/remapping.h | 8 ++++---- platform_win32/win32_4ed.cpp | 31 +++++++++++++++---------------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/custom/generated/remapping.h b/custom/generated/remapping.h index 4e8fe97e..5e707e7f 100644 --- a/custom/generated/remapping.h +++ b/custom/generated/remapping.h @@ -60,10 +60,10 @@ setup_default_mapping(Mapping *mapping){ BindMouseMove(click_set_cursor_if_lbutton); Bind(delete_char, KeyCode_Delete); Bind(backspace_char, KeyCode_Backspace); - Bind(move_up, KeyCode_V, KeyCode_Up); - Bind(move_down, KeyCode_V, KeyCode_Down); - Bind(move_left, KeyCode_V, KeyCode_Left); - Bind(move_right, KeyCode_V, KeyCode_Right); + Bind(move_up, KeyCode_Up); + Bind(move_down, KeyCode_Down); + Bind(move_left, KeyCode_Left); + Bind(move_right, KeyCode_Right); Bind(seek_end_of_line, KeyCode_End); Bind(seek_beginning_of_line, KeyCode_Home); Bind(page_up, KeyCode_PageUp); diff --git a/platform_win32/win32_4ed.cpp b/platform_win32/win32_4ed.cpp index 62917165..3c7f82fc 100644 --- a/platform_win32/win32_4ed.cpp +++ b/platform_win32/win32_4ed.cpp @@ -1,4 +1,3 @@ - /* * Mr. 4th Dimention - Allen Webster * @@ -951,18 +950,13 @@ win32_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){ Input_Modifier_Set_Fixed *mods = &win32vars.input_chunk.pers.modifiers; + Control_Keys *controls = &win32vars.input_chunk.pers.controls; switch (wParam){ case VK_CONTROL:case VK_LCONTROL:case VK_RCONTROL: case VK_MENU:case VK_LMENU:case VK_RMENU: - case VK_SHIFT:case VK_LSHIFT:case VK_RSHIFT: { - Control_Keys *controls = &win32vars.input_chunk.pers.controls; if (wParam != 255){ switch (wParam){ - case VK_SHIFT: - { - set_modifier(mods, KeyCode_Shift, down); - }break; case VK_CONTROL: { if (is_right){ @@ -982,19 +976,24 @@ win32_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){ } }break; } - - b8 ctrl = (controls->r_ctrl || (controls->l_ctrl && !controls->r_alt)); - b8 alt = (controls->l_alt || (controls->r_alt && !controls->l_ctrl)); - if (win32vars.lctrl_lalt_is_altgr && controls->l_alt && controls->l_ctrl){ - ctrl = false; - alt = false; - } - set_modifier(mods, KeyCode_Control, ctrl); - set_modifier(mods, KeyCode_Alt, alt); } }break; } + b8 ctrl = (controls->r_ctrl || (controls->l_ctrl && !controls->r_alt)); + b8 alt = (controls->l_alt || (controls->r_alt && !controls->l_ctrl)); + if (win32vars.lctrl_lalt_is_altgr && controls->l_alt && controls->l_ctrl){ + ctrl = false; + alt = false; + } + set_modifier(mods, KeyCode_Control, ctrl); + set_modifier(mods, KeyCode_Alt, alt); + + { + b8 shift = ((GetKeyState(VK_SHIFT) & bit_16) != 0); + set_modifier(mods, KeyCode_Shift, shift); + } + Key_Code key = keycode_lookup_table[(u8)wParam]; if (down){ if (key != 0){