From ebc467f2120d8f182b017848094afe46be395594 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 2 Apr 2024 16:14:22 +0200 Subject: [PATCH] more fixup for native layout --- src/m_menu.c | 3 ++- src/sdl/i_video.c | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 2180c8e63..d047a2469 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3937,7 +3937,6 @@ boolean M_Responder(event_t *ev) case KEY_BACKSPACE: if ((currentMenu->menuitems[itemOn].status) == IT_CONTROL) { - menu_text_input = false; //never use native layout for control setup // detach any keys associated with the game control G_ClearControlKeys(setupcontrols, currentMenu->menuitems[itemOn].alphaKey); S_StartSound(NULL, sfx_shldls); @@ -12132,6 +12131,7 @@ static void M_DrawControl(void) char tmp[50]; INT32 x, y, i, max, cursory = 0, iter; INT32 keys[2]; + menu_text_input = false; //never use native layout for control setup x = currentMenu->x; y = currentMenu->y; @@ -12248,6 +12248,7 @@ static void M_ChangecontrolResponse(event_t *ev) INT32 control; INT32 found; INT32 ch = ev->data1; + menu_text_input = false; //never use native layout for control setup // ESCAPE cancels; dummy out PAUSE if (ch != KEY_ESCAPE && ch != KEY_PAUSE) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index f4d6c4f7a..ad2d03f86 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -401,6 +401,7 @@ static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Scancode code) static INT32 GetTypedChar(SDL_Scancode code, SDL_Keysym *sym) { SDL_Event next_event; + boolean Text_Input_Only = (chat_on || CON_Ready() || (menu_text_input && menuactive)); //only use this this if on chat or console or the current menu wants inputs from us (except if its the control setup menu ig) // Special cases, where we always return a fixed value. switch (sym->sym) @@ -411,10 +412,13 @@ static INT32 GetTypedChar(SDL_Scancode code, SDL_Keysym *sym) break; } - while (SDL_PollEvent(&next_event) && next_event.type == SDL_TEXTINPUT) + if (Text_Input_Only) { - if (next_event.text.text[1] == '\0') // limit to ASCII - return next_event.text.text[0]; + while (SDL_PollEvent(&next_event) && next_event.type == SDL_TEXTINPUT) + { + if (next_event.text.text[1] == '\0') // limit to ASCII + return next_event.text.text[0]; + } } return Impl_SDL_Scancode_To_Keycode(code); //fallback @@ -813,7 +817,7 @@ static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type) return; } - if (cv_keyboardlayout.value == 2 && (chat_on || CON_Ready() || (menu_text_input && menuactive))) //only use this this if on chat or console or the current menu wants inputs from us (except if its the control setup menu ig) + if (cv_keyboardlayout.value == 2) event.data1 = GetTypedChar(evt.keysym.scancode, &evt.keysym); else if (cv_keyboardlayout.value == 3) event.data1 = Impl_SDL_Keysym_To_Keycode(evt.keysym);