Fix modifier loss bug

This commit is contained in:
Allen Webster 2019-10-11 20:41:30 -07:00
parent 8a82e8185c
commit 79dce39db7
2 changed files with 19 additions and 20 deletions

View File

@ -60,10 +60,10 @@ setup_default_mapping(Mapping *mapping){
BindMouseMove(click_set_cursor_if_lbutton); BindMouseMove(click_set_cursor_if_lbutton);
Bind(delete_char, KeyCode_Delete); Bind(delete_char, KeyCode_Delete);
Bind(backspace_char, KeyCode_Backspace); Bind(backspace_char, KeyCode_Backspace);
Bind(move_up, KeyCode_V, KeyCode_Up); Bind(move_up, KeyCode_Up);
Bind(move_down, KeyCode_V, KeyCode_Down); Bind(move_down, KeyCode_Down);
Bind(move_left, KeyCode_V, KeyCode_Left); Bind(move_left, KeyCode_Left);
Bind(move_right, KeyCode_V, KeyCode_Right); Bind(move_right, KeyCode_Right);
Bind(seek_end_of_line, KeyCode_End); Bind(seek_end_of_line, KeyCode_End);
Bind(seek_beginning_of_line, KeyCode_Home); Bind(seek_beginning_of_line, KeyCode_Home);
Bind(page_up, KeyCode_PageUp); Bind(page_up, KeyCode_PageUp);

View File

@ -1,4 +1,3 @@
/* /*
* Mr. 4th Dimention - Allen Webster * 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; Input_Modifier_Set_Fixed *mods = &win32vars.input_chunk.pers.modifiers;
Control_Keys *controls = &win32vars.input_chunk.pers.controls;
switch (wParam){ switch (wParam){
case VK_CONTROL:case VK_LCONTROL:case VK_RCONTROL: case VK_CONTROL:case VK_LCONTROL:case VK_RCONTROL:
case VK_MENU:case VK_LMENU:case VK_RMENU: 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){ if (wParam != 255){
switch (wParam){ switch (wParam){
case VK_SHIFT:
{
set_modifier(mods, KeyCode_Shift, down);
}break;
case VK_CONTROL: case VK_CONTROL:
{ {
if (is_right){ if (is_right){
@ -982,19 +976,24 @@ win32_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
} }
}break; }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; }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]; Key_Code key = keycode_lookup_table[(u8)wParam];
if (down){ if (down){
if (key != 0){ if (key != 0){