keyboard: only map single buttons

key combos are not really supported at the moment
This commit is contained in:
Megamouse 2024-08-13 20:15:14 +02:00
parent 7bcaab4f3a
commit 4d5897d519
3 changed files with 11 additions and 5 deletions

View File

@ -418,7 +418,7 @@ void keyboard_pad_handler::processKeyEvent(QKeyEvent* event, bool pressed)
return;
const bool is_num_key = list.removeAll("Num") > 0;
const QString name = QString::fromStdString(GetKeyName(event));
const QString name = QString::fromStdString(GetKeyName(event, true));
// TODO: Edge case: switching numlock keeps numpad keys pressed due to now different modifier
@ -824,7 +824,7 @@ QStringList keyboard_pad_handler::GetKeyNames(const QKeyEvent* keyEvent)
return list;
}
std::string keyboard_pad_handler::GetKeyName(const QKeyEvent* keyEvent)
std::string keyboard_pad_handler::GetKeyName(const QKeyEvent* keyEvent, bool with_modifiers)
{
// Handle special cases first
if (std::string name = native_scan_code_to_string(keyEvent->nativeScanCode()); !name.empty())
@ -852,7 +852,13 @@ std::string keyboard_pad_handler::GetKeyName(const QKeyEvent* keyEvent)
default:
break;
}
return QKeySequence(keyEvent->key() | keyEvent->modifiers()).toString(QKeySequence::NativeText).toStdString();
if (with_modifiers)
{
return QKeySequence(keyEvent->key() | keyEvent->modifiers()).toString(QKeySequence::NativeText).toStdString();
}
return QKeySequence(keyEvent->key()).toString(QKeySequence::NativeText).toStdString();
}
std::string keyboard_pad_handler::GetKeyName(const u32& keyCode)

View File

@ -91,7 +91,7 @@ public:
static std::string GetMouseName(const QMouseEvent* event);
static std::string GetMouseName(u32 button);
static QStringList GetKeyNames(const QKeyEvent* keyEvent);
static std::string GetKeyName(const QKeyEvent* keyEvent);
static std::string GetKeyName(const QKeyEvent* keyEvent, bool with_modifiers);
static std::string GetKeyName(const u32& keyCode);
static std::set<u32> GetKeyCodes(const cfg::string& cfg_string);
static u32 GetKeyCode(const QString& keyName);

View File

@ -883,7 +883,7 @@ void pad_settings_dialog::keyPressEvent(QKeyEvent *keyEvent)
}
else
{
m_cfg_entries[m_button_id].insert_key(keyboard_pad_handler::GetKeyName(keyEvent), m_enable_multi_binding);
m_cfg_entries[m_button_id].insert_key(keyboard_pad_handler::GetKeyName(keyEvent, false), m_enable_multi_binding);
}
ReactivateButtons();