From 928e395e097f6267707e48d46e70278bbadf43d7 Mon Sep 17 00:00:00 2001 From: tlarok <116431383+tlarok@users.noreply.github.com> Date: Wed, 2 Apr 2025 19:27:05 +0200 Subject: [PATCH] Update kbm_gui.cpp --- src/qt_gui/kbm_gui.cpp | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/src/qt_gui/kbm_gui.cpp b/src/qt_gui/kbm_gui.cpp index e46dbf37e..110b575bd 100644 --- a/src/qt_gui/kbm_gui.cpp +++ b/src/qt_gui/kbm_gui.cpp @@ -699,7 +699,10 @@ bool KBMSettings::eventFilter(QObject* obj, QEvent* event) { if (event->type() == QEvent::KeyPress) { QKeyEvent* keyEvent = static_cast(event); QString keyText; - + if (timer && timer->isActive()) { + timer->stop(); + } + switch (keyEvent->key()) { case Qt::Key_Space: keyText = "space"; @@ -992,11 +995,7 @@ bool KBMSettings::eventFilter(QObject* obj, QEvent* event) { EnableMappingButtons(); timer->stop(); - if (modifier != "") { - MappingButton->setText(modifier + "," + mapping); - } else { - MappingButton->setText(mapping); - } + MappingButton->setText(mapping); mappinglist.clear(); // Clear the list for the next mapping return true; @@ -1005,6 +1004,11 @@ bool KBMSettings::eventFilter(QObject* obj, QEvent* event) { if (event->type() == QEvent::MouseButtonPress) { QMouseEvent* mouseEvent = static_cast(event); QString buttonText; + + if (timer && timer->isActive()) { + timer->stop(); + } + switch (mouseEvent->button()) { case Qt::LeftButton: buttonText = "leftbutton"; @@ -1018,6 +1022,9 @@ bool KBMSettings::eventFilter(QObject* obj, QEvent* event) { default: break; } + if (!buttonText.isEmpty() && !mappinglist.contains(buttonText)) { + SetMapping(buttonText); // Add the key to the mapping list + } return true; } @@ -1026,11 +1033,7 @@ bool KBMSettings::eventFilter(QObject* obj, QEvent* event) { EnableMappingButtons(); timer->stop(); - if (modifier != "") { - MappingButton->setText(modifier + "," + mapping); - } else { - MappingButton->setText(mapping); - } + MappingButton->setText(mapping); mappinglist.clear(); // Clear the list for the next mapping return true; @@ -1082,6 +1085,15 @@ bool KBMSettings::eventFilter(QObject* obj, QEvent* event) { tr("Mousewheel cannot be mapped to stick outputs")); } } + if (!WheelText.isEmpty() && !mappinglist.contains(WheelText)) { + SetMapping(WheelText); + } + EnableMapping = false; + EnableMappingButtons(); + timer->stop(); + MappingButton->setText(mapping); + mappinglist.clear(); + return true; } }