Skip to content

Commit

Permalink
[Ref] Reuse GetModifierMask() result.
Browse files Browse the repository at this point in the history
git-svn-id: https://source.openmpt.org/svn/openmpt/trunk/OpenMPT@21652 56274372-70c3-4bfc-bfc3-4c3a0b034d27
  • Loading branch information
sagamusix committed Sep 20, 2024
1 parent 3ea8d94 commit fc37b94
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions mptrack/InputHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,28 +559,29 @@ bool CInputHandler::IsKeyPressHandledByTextBox(DWORD key, HWND hWnd) const
return false;

// Alpha-numerics (only shift or no modifier):
if(!GetModifierMask().test_any_except(ModShift))
const auto modifierMask = GetModifierMask();
if(!modifierMask.test_any_except(ModShift))
{
if((key >= 'A' && key <= 'Z') || (key >= '0' && key <= '9')
|| (key >= VK_MULTIPLY && key <= VK_DIVIDE) || key == VK_SPACE || key == VK_CAPITAL
|| (key >= VK_OEM_1 && key <= VK_OEM_3) || (key >= VK_OEM_4 && key <= VK_OEM_8))
return true;
if((key >= VK_NUMPAD0 && key <= VK_NUMPAD9) && GetModifierMask() == ModNone)
if((key >= VK_NUMPAD0 && key <= VK_NUMPAD9) && modifierMask == ModNone)
return true;
if(key == VK_RETURN && (GetWindowLong(hWnd, GWL_STYLE) & ES_MULTILINE))
return true;
}

// Navigation (any modifier except Alt without any other modifiers):
if(GetModifierMask() != ModAlt)
if(modifierMask != ModAlt)
{
if(key == VK_LEFT || key == VK_RIGHT || key == VK_UP || key == VK_DOWN
|| key == VK_HOME || key == VK_END || key == VK_DELETE || key == VK_INSERT || key == VK_BACK)
return true;
}

// Copy paste etc..
if(GetModifierMask() == ModCtrl)
if(modifierMask == ModCtrl)
{
if(key == 'Y' || key == 'Z' || key == 'X' || key == 'C' || key == 'V' || key == 'A')
return true;
Expand Down

0 comments on commit fc37b94

Please sign in to comment.