mirror of https://github.com/PCSX2/pcsx2.git
Qt: Fix arrow key handling on macOS
This commit is contained in:
parent
7763948fe4
commit
2e6bd23f22
|
@ -513,5 +513,22 @@ std::optional<std::string> InputManager::ConvertHostKeyboardCodeToString(u32 cod
|
||||||
|
|
||||||
u32 QtUtils::KeyEventToCode(const QKeyEvent* ev)
|
u32 QtUtils::KeyEventToCode(const QKeyEvent* ev)
|
||||||
{
|
{
|
||||||
return static_cast<u32>(ev->key()) | (static_cast<u32>(ev->modifiers()) & static_cast<u32>(Qt::KeypadModifier));
|
int key = ev->key();
|
||||||
|
Qt::KeyboardModifiers modifiers = ev->modifiers();
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
// On macOS, Qt applies the Keypad modifier regardless of whether the arrow keys, or numpad was pressed.
|
||||||
|
// The only way to differentiate between the keypad and the arrow keys is by the text.
|
||||||
|
// Hopefully some keyboard layouts don't change the numpad positioning...
|
||||||
|
if (modifiers & Qt::KeypadModifier && key >= Qt::Key_Insert && key <= Qt::Key_PageDown)
|
||||||
|
{
|
||||||
|
if (ev->text().isEmpty())
|
||||||
|
{
|
||||||
|
// Drop the modifier, because it's probably not actually a numpad push.
|
||||||
|
modifiers &= ~Qt::KeypadModifier;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return static_cast<u32>(key) | (static_cast<u32>(modifiers) & static_cast<u32>(Qt::KeypadModifier));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue