PCSX2 / pcsx2

PCSX2 - The Playstation 2 Emulator
https://pcsx2.net
GNU General Public License v3.0
11.79k stars 1.63k forks source link

[BUG]: 2 keys on the numeric keypad do not work properly #11838

Open crashGG opened 1 month ago

crashGG commented 1 month ago

Describe the Bug

after this commit https://github.com/PCSX2/pcsx2/commit/fc715d58f049862a733bc4e23fe4e436b18dfbb6 2 keys on the numeric keypad do not work properly,+ becomes = , * becomes 8

Reproduction Steps

use v2.1.163 build https://github.com/PCSX2/pcsx2/releases/tag/v2.1.163, Press these two keys in the pcsx2 key setting

Expected Behavior

No response

PCSX2 Revision

v2.1.163

Operating System

Windows 10 (64bit)

If Linux - Specify Distro

No response

Logs & Dumps

No response

refractionpcsx2 commented 1 month ago

The original commit doesn't check for shift modifier, so yes, that will assume the independent keys are actually numbers too.

If you then press shift and one of those keys you're SOL :)

bslenul commented 1 month ago

So just change https://github.com/PCSX2/pcsx2/blob/95201409e38b6cfbba45eff0f7cd276751017321/pcsx2-qt/QtKeyCodes.cpp#L569-L578 to

    const QString text = ev->text();
    const u8 keycode = map_text_to_keycode(text); // Map special text symbols to keycodes
    int key = ev->key();
    Qt::KeyboardModifiers modifiers = ev->modifiers();

    if ((modifiers & Qt::ShiftModifier) && keycode != 0)
        key = keycode; // Override key if mapped

?

edit: Or even

    Qt::KeyboardModifiers modifiers = ev->modifiers();
    const QString text = ev->text();
    // Map special text symbols to keycodes if using Shift modifier
    const u8 keycode = (modifiers & Qt::ShiftModifier) ? map_text_to_keycode(text) : 0;
    int key = ev->key();

    if (keycode != 0)
        key = keycode; // Override key if mapped

to avoid unnecessary map_text_to_keycode() calls?

bslenul commented 1 month ago

Oh boy, I didn't notice but this messes up more than I originally imagined... I'm on a AZERTY keyboard and it breaks existing mapping completely :/ So I tried to remap my keys, and this is pretty messy, let's take L2/R2/L3/R3 as an example, normally bound to 1234, buuuuuuuut here's how it looks on a French AZERTY keyboard:

image

So binding L2 to & shows up as "7", R2 to " shows up as "Apostrophe", L3 to é shows up properly as "Eacute" and R3 to ' shows up properly as "Apostrophe". So not only it's confusing but as you can see R2 and R3 are set to the same keycode! Meaning if I press either " or ' I'll press R2 and R3 😓

Might be confusing in text so here's a screenshot: image