From ab9b6c2b80dea25eeca0412946b5a539d9763e81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Mon, 14 Nov 2022 22:58:26 +0100 Subject: [PATCH] Allow both shift keys to be used for all hotkeys Handle both shift keys in some cases where only the left shift key was previously supported. The `CChat::m_ReverseTAB` variable is removed because it's unnecessary. --- src/game/client/components/chat.cpp | 31 ++++++++++------------------- src/game/client/components/chat.h | 1 - src/game/editor/editor.cpp | 4 ++-- 3 files changed, 13 insertions(+), 23 deletions(-) diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index 01bd9dfd9..5bdaa2d3d 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -81,7 +81,6 @@ void CChat::Reset() m_PrevScoreBoardShowed = false; m_PrevShowChat = false; - m_ReverseTAB = false; m_Show = false; m_InputUpdate = false; m_ChatStringOffset = 0; @@ -307,6 +306,8 @@ bool CChat::OnInput(IInput::CEvent Event) } if(Event.m_Flags & IInput::FLAG_PRESS && Event.m_Key == KEY_TAB) { + const bool ShiftPressed = Input()->ShiftIsPressed(); + // fill the completion buffer if(!m_CompletionUsed) { @@ -353,9 +354,9 @@ bool CChat::OnInput(IInput::CEvent Event) const size_t NumCommands = m_vCommands.size(); - if(m_ReverseTAB && m_CompletionUsed) + if(ShiftPressed && m_CompletionUsed) m_CompletionChosen--; - else if(!m_ReverseTAB) + else if(!ShiftPressed) m_CompletionChosen++; m_CompletionChosen = (m_CompletionChosen + 2 * NumCommands) % (2 * NumCommands); @@ -367,7 +368,7 @@ bool CChat::OnInput(IInput::CEvent Event) int SearchType; int Index; - if(m_ReverseTAB) + if(ShiftPressed) { SearchType = ((m_CompletionChosen - i + 2 * NumCommands) % (2 * NumCommands)) / NumCommands; Index = (m_CompletionChosen - i + NumCommands) % NumCommands; @@ -425,11 +426,11 @@ bool CChat::OnInput(IInput::CEvent Event) CGameClient::CClientData *pCompletionClientData; for(int i = 0; i < m_PlayerCompletionListLength; ++i) { - if(m_ReverseTAB && m_CompletionUsed) + if(ShiftPressed && m_CompletionUsed) { m_CompletionChosen--; } - else if(!m_ReverseTAB) + else if(!ShiftPressed) { m_CompletionChosen++; } @@ -484,27 +485,17 @@ bool CChat::OnInput(IInput::CEvent Event) else { // reset name completion process - if(Event.m_Flags & IInput::FLAG_PRESS && Event.m_Key != KEY_TAB) + if(Event.m_Flags & IInput::FLAG_PRESS && Event.m_Key != KEY_TAB && Event.m_Key != KEY_LSHIFT && Event.m_Key != KEY_RSHIFT) { - if(Event.m_Key != KEY_LSHIFT) - { - m_CompletionChosen = -1; - m_CompletionUsed = false; - } + m_CompletionChosen = -1; + m_CompletionUsed = false; } m_OldChatStringLength = m_Input.GetLength(); m_Input.ProcessInput(Event); m_InputUpdate = true; } - if(Event.m_Flags & IInput::FLAG_PRESS && Event.m_Key == KEY_LSHIFT) - { - m_ReverseTAB = true; - } - else if(Event.m_Flags & IInput::FLAG_RELEASE && Event.m_Key == KEY_LSHIFT) - { - m_ReverseTAB = false; - } + if(Event.m_Flags & IInput::FLAG_PRESS && Event.m_Key == KEY_UP) { if(m_pHistoryEntry) diff --git a/src/game/client/components/chat.h b/src/game/client/components/chat.h index 16b72cd0f..66fde6e04 100644 --- a/src/game/client/components/chat.h +++ b/src/game/client/components/chat.h @@ -110,7 +110,6 @@ class CChat : public CComponent }; std::vector m_vCommands; - bool m_ReverseTAB; struct CHistoryEntry { diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index da3ed2cda..cf541a648 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -2553,7 +2553,7 @@ void CEditor::DoMapEditor(CUIRect View) if(Input()->ModifierIsPressed() || UI()->MouseButton(2)) { - if(Input()->KeyIsPressed(KEY_LSHIFT)) + if(Input()->ShiftIsPressed()) s_Operation = OP_PAN_EDITOR; else s_Operation = OP_PAN_WORLD; @@ -2646,7 +2646,7 @@ void CEditor::DoMapEditor(CUIRect View) { if(!UI()->MouseButton(0)) { - if(Input()->KeyIsPressed(KEY_LSHIFT)) + if(Input()->ShiftIsPressed()) { CLayerQuads *pQuadLayer = (CLayerQuads *)GetSelectedLayerType(0, LAYERTYPE_QUADS); if(pQuadLayer)