From: DeaDDooMER Date: Wed, 31 Jul 2019 18:30:48 +0000 (+0300) Subject: fix chat/console input on android X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=f4de88f1f4384cc3c798bccc695d92ad3781eb7b;p=d2df-sdl.git fix chat/console input on android --- diff --git a/src/game/g_console.pas b/src/game/g_console.pas index edf484f..2105faf 100644 --- a/src/game/g_console.pas +++ b/src/game/g_console.pas @@ -146,7 +146,6 @@ var down, up: SSArray; end; menu_toggled: BOOLEAN; (* hack for menu controls *) - gSkipFirstChar: Boolean; (* hack for console/chat input *) procedure g_Console_Switch; @@ -718,23 +717,14 @@ begin menu_toggled := True end; 'toggleconsole': - begin - g_Console_Switch; - gSkipFirstChar := g_Console_Interactive(); - end; + g_Console_Switch; 'togglechat': - begin - if not gConsoleShow and (g_ActiveWindow = nil) then - g_Console_Chat_Switch; - gSkipFirstChar := not g_Console_Interactive() - end; + if not gConsoleShow and (g_ActiveWindow = nil) then + g_Console_Chat_Switch; 'toggleteamchat': if gGameSettings.GameMode in [GM_TDM, GM_CTF] then - begin if not gConsoleShow and (g_ActiveWindow = nil) then g_Console_Chat_Switch(True); - gSkipFirstChar := not g_Console_Interactive() - end; end end; @@ -1170,12 +1160,8 @@ end; procedure g_Console_Char(C: AnsiChar); begin - if not gSkipFirstChar then - begin - Insert(C, Line, CPos); - CPos := CPos + 1; - end; - gSkipFirstChar := False + Insert(C, Line, CPos); + CPos := CPos + 1; end; @@ -1383,19 +1369,15 @@ begin IK_0, IK_1, IK_2, IK_3, IK_4, IK_5, IK_6, IK_7, IK_8, IK_9, IK_MINUS, IK_EQUALS: (* see TEXTINPUT event *) else - if not gSkipFirstChar then + if gConsoleShow and not Cons_Shown and g_Console_MatchBind(K, 'toggleconsole') then + g_Console_Switch; + if g_Console_MatchBind(K, 'togglemenu') then begin - if gConsoleShow and g_Console_MatchBind(K, 'toggleconsole') then - g_Console_Switch; - - if g_Console_MatchBind(K, 'togglemenu') then - begin - menu_toggled := True; - if gChatShow then - g_Console_Chat_Switch - else if gConsoleShow then - g_Console_Switch - end + menu_toggled := True; + if gChatShow then + g_Console_Chat_Switch + else if gConsoleShow and not Cons_Shown then + g_Console_Switch end end end; diff --git a/src/game/g_main.pas b/src/game/g_main.pas index 86c5f84..b559583 100644 --- a/src/game/g_main.pas +++ b/src/game/g_main.pas @@ -116,12 +116,6 @@ begin e_WriteLog(gLanguage, TMsgType.Notify); g_Language_Set(gLanguage); -{$IFNDEF HEADLESS} -{$IFNDEF ANDROID} - SDL_StartTextInput(); -{$ENDIF} -{$ENDIF} - {$IF not DEFINED(HEADLESS) and DEFINED(ENABLE_HOLMES)} flexloaded := true; if not fuiAddWad('flexui.wad') then @@ -173,10 +167,6 @@ begin SDLMain(); {$WARNINGS ON} -{$IFNDEF HEADLESS} - SDL_StopTextInput(); -{$ENDIF} - e_WriteLog('Releasing SDL', TMsgType.Notify); SDL_Quit(); end; diff --git a/src/game/g_touch.pas b/src/game/g_touch.pas index 7cdc328..9eed28e 100644 --- a/src/game/g_touch.pas +++ b/src/game/g_touch.pas @@ -184,6 +184,7 @@ implementation procedure g_Touch_Init; begin {$IFNDEF HEADLESS} + g_Touch_ShowKeyboard(FALSE); g_touch_enabled := SDL_GetNumTouchDevices() > 0 {$ENDIF} end; @@ -191,9 +192,6 @@ implementation procedure g_Touch_ShowKeyboard(yes: Boolean); begin {$IFNDEF HEADLESS} - if not g_touch_enabled then - Exit; - if yes then SDL_StartTextInput else