mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-04 14:08:37 +00:00
input: differentiate between left and right modifier keys
This commit is contained in:
parent
1cef7df006
commit
945bfaf0ea
4 changed files with 134 additions and 42 deletions
|
|
@ -110,7 +110,7 @@ void basic_keyboard_handler::keyPressEvent(QKeyEvent* keyEvent)
|
|||
|
||||
const int key = getUnmodifiedKey(keyEvent);
|
||||
|
||||
if (key < 0 || !HandleKey(static_cast<u32>(key), true, keyEvent->isAutoRepeat(), keyEvent->text().toStdU32String()))
|
||||
if (key < 0 || !HandleKey(static_cast<u32>(key), keyEvent->nativeScanCode(), true, keyEvent->isAutoRepeat(), keyEvent->text().toStdU32String()))
|
||||
{
|
||||
keyEvent->ignore();
|
||||
}
|
||||
|
|
@ -131,7 +131,7 @@ void basic_keyboard_handler::keyReleaseEvent(QKeyEvent* keyEvent)
|
|||
|
||||
const int key = getUnmodifiedKey(keyEvent);
|
||||
|
||||
if (key < 0 || !HandleKey(static_cast<u32>(key), false, keyEvent->isAutoRepeat(), keyEvent->text().toStdU32String()))
|
||||
if (key < 0 || !HandleKey(static_cast<u32>(key), keyEvent->nativeScanCode(), false, keyEvent->isAutoRepeat(), keyEvent->text().toStdU32String()))
|
||||
{
|
||||
keyEvent->ignore();
|
||||
}
|
||||
|
|
@ -182,11 +182,14 @@ void basic_keyboard_handler::LoadSettings(Keyboard& keyboard)
|
|||
buttons.emplace_back(Qt::Key_Control, CELL_KB_MKEY_L_CTRL);
|
||||
buttons.emplace_back(Qt::Key_Shift, CELL_KB_MKEY_L_SHIFT);
|
||||
buttons.emplace_back(Qt::Key_Alt, CELL_KB_MKEY_L_ALT);
|
||||
buttons.emplace_back(Qt::Key_Super_L, CELL_KB_MKEY_L_WIN);
|
||||
buttons.emplace_back(Qt::Key_Meta, CELL_KB_MKEY_L_WIN);
|
||||
//buttons.emplace_back(, CELL_KB_MKEY_R_CTRL); // There is no way to know if it's left or right in Qt at the moment
|
||||
//buttons.emplace_back(, CELL_KB_MKEY_R_SHIFT); // There is no way to know if it's left or right in Qt at the moment
|
||||
//buttons.emplace_back(, CELL_KB_MKEY_R_ALT); // There is no way to know if it's left or right in Qt at the moment
|
||||
buttons.emplace_back(Qt::Key_Super_R, CELL_KB_MKEY_R_WIN);
|
||||
//buttons.emplace_back(, CELL_KB_MKEY_R_WIN); // There is no way to know if it's left or right in Qt at the moment
|
||||
|
||||
buttons.emplace_back(Qt::Key_Super_L, CELL_KB_MKEY_L_WIN); // The super keys are supposed to be the windows keys, but they trigger the meta key instead. Let's assign the windows keys to both.
|
||||
buttons.emplace_back(Qt::Key_Super_R, CELL_KB_MKEY_R_WIN); // The super keys are supposed to be the windows keys, but they trigger the meta key instead. Let's assign the windows keys to both.
|
||||
|
||||
// CELL_KB_RAWDAT
|
||||
//buttons.emplace_back(, CELL_KEYC_NO_EVENT); // Redundant, listed for completeness
|
||||
|
|
@ -222,7 +225,7 @@ void basic_keyboard_handler::LoadSettings(Keyboard& keyboard)
|
|||
buttons.emplace_back(Qt::Key_Down, CELL_KEYC_DOWN_ARROW);
|
||||
buttons.emplace_back(Qt::Key_Up, CELL_KEYC_UP_ARROW);
|
||||
//buttons.emplace_back(, CELL_KEYC_NUM_LOCK);
|
||||
buttons.emplace_back(Qt::Key_Meta, CELL_KEYC_APPLICATION);
|
||||
//buttons.emplace_back(, CELL_KEYC_APPLICATION); // This is probably the PS key on the PS3 keyboard
|
||||
buttons.emplace_back(Qt::Key_Kana_Shift, CELL_KEYC_KANA); // maybe Key_Kana_Lock
|
||||
buttons.emplace_back(Qt::Key_Henkan, CELL_KEYC_HENKAN);
|
||||
buttons.emplace_back(Qt::Key_Muhenkan, CELL_KEYC_MUHENKAN);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "keyboard_pad_handler.h"
|
||||
#include "pad_thread.h"
|
||||
#include "Emu/Io/pad_config.h"
|
||||
#include "Emu/Io/KeyboardHandler.h"
|
||||
#include "Input/product_info.h"
|
||||
#include "rpcs3qt/gs_frame.h"
|
||||
|
||||
|
|
@ -821,12 +822,16 @@ u32 keyboard_pad_handler::GetKeyCode(const QString& keyName)
|
|||
|
||||
int keyboard_pad_handler::native_scan_code_from_string([[maybe_unused]] const std::string& key)
|
||||
{
|
||||
// NOTE: Qt throws a Ctrl key at us when using Alt Gr, so there is no point in distinguishing left and right Alt at the moment
|
||||
// NOTE: Qt throws a Ctrl key at us when using Alt Gr first, so right Alt does not work at the moment
|
||||
if (key == "Shift Left") return native_key::shift_l;
|
||||
if (key == "Shift Right") return native_key::shift_r;
|
||||
if (key == "Ctrl Left") return native_key::ctrl_l;
|
||||
if (key == "Ctrl Right") return native_key::ctrl_r;
|
||||
if (key == "Alt Left") return native_key::alt_l;
|
||||
if (key == "Alt Right") return native_key::alt_r;
|
||||
if (key == "Meta Left") return native_key::meta_l;
|
||||
if (key == "Meta Right") return native_key::meta_r;
|
||||
#ifdef _WIN32
|
||||
if (key == "Shift Left") return 42;
|
||||
if (key == "Shift Right") return 54;
|
||||
if (key == "Ctrl Left") return 29;
|
||||
if (key == "Ctrl Right") return 285;
|
||||
if (key == "Num+0" || key == "Num+Ins") return 82;
|
||||
if (key == "Num+1" || key == "Num+End") return 79;
|
||||
if (key == "Num+2" || key == "Num+Down") return 80;
|
||||
|
|
@ -851,15 +856,20 @@ int keyboard_pad_handler::native_scan_code_from_string([[maybe_unused]] const st
|
|||
|
||||
std::string keyboard_pad_handler::native_scan_code_to_string(int native_scan_code)
|
||||
{
|
||||
// NOTE: the other Qt function "nativeVirtualKey" does not distinguish between VK_SHIFT and VK_RSHIFT key in Qt at the moment
|
||||
// NOTE: Qt throws a Ctrl key at us when using Alt Gr first, so right Alt does not work at the moment
|
||||
// NOTE: for MacOs: nativeScanCode may not work
|
||||
switch (native_scan_code)
|
||||
{
|
||||
case native_key::shift_l: return "Shift Left";
|
||||
case native_key::shift_r: return "Shift Right";
|
||||
case native_key::ctrl_l: return "Ctrl Left";
|
||||
case native_key::ctrl_r: return "Ctrl Right";
|
||||
case native_key::alt_l: return "Alt Left";
|
||||
case native_key::alt_r: return "Alt Right";
|
||||
case native_key::meta_l: return "Meta Left";
|
||||
case native_key::meta_r: return "Meta Right";
|
||||
#ifdef _WIN32
|
||||
// NOTE: the other Qt function "nativeVirtualKey" does not distinguish between VK_SHIFT and VK_RSHIFT key in Qt at the moment
|
||||
// NOTE: Qt throws a Ctrl key at us when using Alt Gr, so there is no point in distinguishing left and right Alt at the moment
|
||||
case 42: return "Shift Left";
|
||||
case 54: return "Shift Right";
|
||||
case 29: return "Ctrl Left";
|
||||
case 285: return "Ctrl Right";
|
||||
case 82: return "Num+0"; // Also "Num+Ins" depending on numlock
|
||||
case 79: return "Num+1"; // Also "Num+End" depending on numlock
|
||||
case 80: return "Num+2"; // Also "Num+Down" depending on numlock
|
||||
|
|
@ -878,7 +888,6 @@ std::string keyboard_pad_handler::native_scan_code_to_string(int native_scan_cod
|
|||
case 284: return "Num+Enter";
|
||||
#else
|
||||
// TODO
|
||||
// NOTE for MacOs: nativeScanCode may not work
|
||||
#endif
|
||||
default: return "";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue