[ui, win32] Fixed char input and modifier keys

This commit is contained in:
martinfouilleul 2023-03-09 18:03:27 +01:00
parent 9accf4c666
commit cae8666561
3 changed files with 15 additions and 5 deletions

View File

@ -172,6 +172,11 @@ static void mp_update_key_state(mp_key_state* key, mp_key_action action)
}
}
static void mp_update_key_mods(mp_keymod_flags mods)
{
__mpApp.inputState.keyboard.mods = mods;
}
static void mp_update_mouse_move(f32 x, f32 y, f32 deltaX, f32 deltaY)
{
u64 frameCounter = __mpApp.inputState.frameCounter;

View File

@ -369,11 +369,6 @@ void mp_install_keyboard_layout_listener()
object:nil];
}
static void mp_update_key_mods(mp_keymod_flags mods)
{
__mpApp.inputState.keyboard.mods = mods;
}
//---------------------------------------------------------------
// Application and app delegate
//---------------------------------------------------------------

View File

@ -455,6 +455,9 @@ LRESULT WinProc(HWND windowHandle, UINT message, WPARAM wParam, LPARAM lParam)
event.key.code = mp_convert_win32_key(HIWORD(lParam) & 0x1ff);
event.key.mods = mp_get_mod_keys();
mp_queue_event(&event);
mp_update_key_mods(event.key.mods);
mp_update_key_state(&__mpApp.inputState.keyboard.keys[event.key.code], event.key.action);
} break;
case WM_KEYUP:
@ -467,6 +470,10 @@ LRESULT WinProc(HWND windowHandle, UINT message, WPARAM wParam, LPARAM lParam)
event.key.code = mp_convert_win32_key(HIWORD(lParam) & 0x1ff);
event.key.mods = mp_get_mod_keys();
mp_queue_event(&event);
mp_update_key_mods(event.key.mods);
mp_update_key_state(&__mpApp.inputState.keyboard.keys[event.key.code], event.key.action);
} break;
case WM_CHAR:
@ -478,6 +485,9 @@ LRESULT WinProc(HWND windowHandle, UINT message, WPARAM wParam, LPARAM lParam)
str8 seq = utf8_encode(event.character.sequence, event.character.codepoint);
event.character.seqLen = seq.len;
mp_queue_event(&event);
mp_update_text(event.character.codepoint);
} break;
case WM_DROPFILES: