From 5845109b757fa82bcd38385b2aa68c640d734018 Mon Sep 17 00:00:00 2001 From: Bobby Smith <33353403+bslenul@users.noreply.github.com> Date: Tue, 8 Oct 2024 12:45:54 +0200 Subject: [PATCH] Qt: Call 'map_text_to_keycode()' only when Shift modifier is being used --- pcsx2-qt/QtKeyCodes.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pcsx2-qt/QtKeyCodes.cpp b/pcsx2-qt/QtKeyCodes.cpp index 9adf958234..c0fb37e20f 100644 --- a/pcsx2-qt/QtKeyCodes.cpp +++ b/pcsx2-qt/QtKeyCodes.cpp @@ -566,16 +566,17 @@ const char* InputManager::ConvertHostKeyboardCodeToIcon(u32 code) u32 QtUtils::KeyEventToCode(const QKeyEvent* ev) { + Qt::KeyboardModifiers modifiers = ev->modifiers(); const QString text = ev->text(); - const u8 keycode = map_text_to_keycode(text); // Map special text symbols to keycodes + // Map special text symbols to keycodes if we're using Shift modifier. + // Also check that we're not using Keypad modifier otherwise "NumpadAsterisk" would return "8" keycode + // and "NumpadPlus" would return "Equal" keycode. + const bool set_keycode = (modifiers & Qt::ShiftModifier) && !(modifiers & Qt::KeypadModifier); + const u8 keycode = set_keycode ? map_text_to_keycode(text) : 0; int key = ev->key(); if (keycode != 0) - { key = keycode; // Override key if mapped - } - - Qt::KeyboardModifiers modifiers = ev->modifiers(); #ifdef __APPLE__ // On macOS, Qt applies the Keypad modifier regardless of whether the arrow keys, or numpad was pressed.