Skip to content

Commit

Permalink
Qt: Call 'map_text_to_keycode()' only when Shift modifier is being used
Browse files Browse the repository at this point in the history
  • Loading branch information
bslenul authored and F0bes committed Oct 10, 2024
1 parent 7dd2ebd commit 5845109
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pcsx2-qt/QtKeyCodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 5845109

Please sign in to comment.