Fix text input rapidly activated/deactivated when closing console

Fixes virtual keyboard on Android flashing rapidly when the console is closed.
This commit is contained in:
Robert Müller 2024-07-23 12:49:46 +02:00
parent b7e1af4bbe
commit 8b3e686fdb
2 changed files with 13 additions and 4 deletions

View file

@ -857,13 +857,18 @@ CGameConsole::~CGameConsole()
m_pConsoleLogger->OnConsoleDeletion(); m_pConsoleLogger->OnConsoleDeletion();
} }
CGameConsole::CInstance *CGameConsole::CurrentConsole() CGameConsole::CInstance *CGameConsole::ConsoleForType(int ConsoleType)
{ {
if(m_ConsoleType == CONSOLETYPE_REMOTE) if(ConsoleType == CONSOLETYPE_REMOTE)
return &m_RemoteConsole; return &m_RemoteConsole;
return &m_LocalConsole; return &m_LocalConsole;
} }
CGameConsole::CInstance *CGameConsole::CurrentConsole()
{
return ConsoleForType(m_ConsoleType);
}
void CGameConsole::OnReset() void CGameConsole::OnReset()
{ {
m_RemoteConsole.Reset(); m_RemoteConsole.Reset();
@ -972,7 +977,6 @@ void CGameConsole::OnRender()
if(m_ConsoleState == CONSOLE_CLOSING) if(m_ConsoleState == CONSOLE_CLOSING)
{ {
m_ConsoleState = CONSOLE_CLOSED; m_ConsoleState = CONSOLE_CLOSED;
pConsole->m_Input.Deactivate();
pConsole->m_BacklogLastActiveLine = -1; pConsole->m_BacklogLastActiveLine = -1;
} }
else if(m_ConsoleState == CONSOLE_OPENING) else if(m_ConsoleState == CONSOLE_OPENING)
@ -1135,7 +1139,10 @@ void CGameConsole::OnRender()
// render console input (wrap line) // render console input (wrap line)
pConsole->m_Input.SetHidden(m_ConsoleType == CONSOLETYPE_REMOTE && Client()->State() == IClient::STATE_ONLINE && !Client()->RconAuthed() && (pConsole->m_UserGot || !pConsole->m_UsernameReq)); pConsole->m_Input.SetHidden(m_ConsoleType == CONSOLETYPE_REMOTE && Client()->State() == IClient::STATE_ONLINE && !Client()->RconAuthed() && (pConsole->m_UserGot || !pConsole->m_UsernameReq));
pConsole->m_Input.Activate(EInputPriority::CONSOLE); // Ensure that the input is active if(m_ConsoleState == CONSOLE_OPEN)
{
pConsole->m_Input.Activate(EInputPriority::CONSOLE); // Ensure that the input is active
}
const CUIRect InputCursorRect = {x, y + FONT_SIZE, 0.0f, 0.0f}; const CUIRect InputCursorRect = {x, y + FONT_SIZE, 0.0f, 0.0f};
const bool WasChanged = pConsole->m_Input.WasChanged(); const bool WasChanged = pConsole->m_Input.WasChanged();
const bool WasCursorChanged = pConsole->m_Input.WasCursorChanged(); const bool WasCursorChanged = pConsole->m_Input.WasCursorChanged();
@ -1463,6 +1470,7 @@ void CGameConsole::Toggle(int Type)
} }
else else
{ {
ConsoleForType(Type)->m_Input.Deactivate();
Input()->MouseModeRelative(); Input()->MouseModeRelative();
Ui()->SetEnabled(true); Ui()->SetEnabled(true);
m_pClient->OnRelease(); m_pClient->OnRelease();

View file

@ -146,6 +146,7 @@ class CGameConsole : public CComponent
CInstance m_LocalConsole; CInstance m_LocalConsole;
CInstance m_RemoteConsole; CInstance m_RemoteConsole;
CInstance *ConsoleForType(int ConsoleType);
CInstance *CurrentConsole(); CInstance *CurrentConsole();
int m_ConsoleType; int m_ConsoleType;