in src/modules/keyboardmanager/common/Shortcut.cpp [647:794]
bool Shortcut::IsKeyboardStateClearExceptShortcut(KeyboardManagerInput::InputInterface& ii) const
{
// Iterate through all the virtual key codes - 0xFF is set to key down because of the Num Lock
for (int keyVal = 1; keyVal < 0xFF; keyVal++)
{
// Ignore problematic key codes
if (IgnoreKeyCode(keyVal))
{
continue;
}
// Check state of the key. If the key is pressed down but it is not part of the shortcut then the keyboard state is not clear
if (ii.GetVirtualKeyState(keyVal))
{
// If one of the win keys is pressed check if it is part of the shortcut
if (keyVal == VK_LWIN)
{
if (winKey != ModifierKey::Left && winKey != ModifierKey::Both)
{
return false;
}
else
{
continue;
}
}
else if (keyVal == VK_RWIN)
{
if (winKey != ModifierKey::Right && winKey != ModifierKey::Both)
{
return false;
}
else
{
continue;
}
}
// If one of the ctrl keys is pressed check if it is part of the shortcut
else if (keyVal == VK_LCONTROL)
{
if (ctrlKey != ModifierKey::Left && ctrlKey != ModifierKey::Both)
{
return false;
}
else
{
continue;
}
}
else if (keyVal == VK_RCONTROL)
{
if (ctrlKey != ModifierKey::Right && ctrlKey != ModifierKey::Both)
{
return false;
}
else
{
continue;
}
}
else if (keyVal == VK_CONTROL)
{
if (ctrlKey == ModifierKey::Disabled)
{
return false;
}
else
{
continue;
}
}
// If one of the alt keys is pressed check if it is part of the shortcut
else if (keyVal == VK_LMENU)
{
if (altKey != ModifierKey::Left && altKey != ModifierKey::Both)
{
return false;
}
else
{
continue;
}
}
else if (keyVal == VK_RMENU)
{
if (altKey != ModifierKey::Right && altKey != ModifierKey::Both)
{
return false;
}
else
{
continue;
}
}
else if (keyVal == VK_MENU)
{
if (altKey == ModifierKey::Disabled)
{
return false;
}
else
{
continue;
}
}
// If one of the shift keys is pressed check if it is part of the shortcut
else if (keyVal == VK_LSHIFT)
{
if (shiftKey != ModifierKey::Left && shiftKey != ModifierKey::Both)
{
return false;
}
else
{
continue;
}
}
else if (keyVal == VK_RSHIFT)
{
if (shiftKey != ModifierKey::Right && shiftKey != ModifierKey::Both)
{
return false;
}
else
{
continue;
}
}
else if (keyVal == VK_SHIFT)
{
if (shiftKey == ModifierKey::Disabled)
{
return false;
}
else
{
continue;
}
}
// If any other key is pressed check if it is the action key
else if (keyVal != actionKey)
{
return false;
}
}
}
return true;
}