diff --git a/src/qt_gui/kbm_gui.cpp b/src/qt_gui/kbm_gui.cpp index 8a09c3d79..d2eaa4b43 100644 --- a/src/qt_gui/kbm_gui.cpp +++ b/src/qt_gui/kbm_gui.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include "common/path_util.h" #include "kbm_config_dialog.h" @@ -991,6 +992,46 @@ bool KBMSettings::eventFilter(QObject* obj, QEvent* event) { } return true; } + + QList AxisList = { + ui->LStickUpButton, ui->LStickDownButton, ui->LStickLeftButton, ui->LStickRightButton, + ui->RStickUpButton, ui->LStickDownButton, ui->LStickLeftButton, ui->RStickRightButton}; + + if (event->type() == QEvent::Wheel) { + QWheelEvent* wheelEvent = static_cast(event); + if (wheelEvent->angleDelta().y() > 5) { + if (std::find(AxisList.begin(), AxisList.end(), MappingButton) == AxisList.end()) { + SetMapping("mousewheelup"); + } else { + QMessageBox::information(this, "Cannot set mapping", + "Mousewheel cannot be mapped to stick outputs"); + } + } else if (wheelEvent->angleDelta().y() < -5) { + if (std::find(AxisList.begin(), AxisList.end(), MappingButton) == AxisList.end()) { + SetMapping("mousewheeldown"); + } else { + QMessageBox::information(this, "Cannot set mapping", + "Mousewheel cannot be mapped to stick outputs"); + } + } + if (wheelEvent->angleDelta().x() > 5) { + if (std::find(AxisList.begin(), AxisList.end(), MappingButton) == AxisList.end()) { + SetMapping("mousewheelright"); + } else { + QMessageBox::information(this, "Cannot set mapping", + "Mousewheel cannot be mapped to stick outputs"); + } + } else if (wheelEvent->angleDelta().x() < -5) { + if (std::find(AxisList.begin(), AxisList.end(), MappingButton) == AxisList.end()) { + SetMapping("mousewheelleft"); + } else { + QMessageBox::information(this, "Cannot set mapping", + "Mousewheel cannot be mapped to stick outputs"); + } + } + + return true; + } } return QDialog::eventFilter(obj, event); }