Added Mousewheel mapping

This commit is contained in:
rainmakerv2 2025-02-27 14:02:15 +08:00
parent 16b907b130
commit ff4e3b11d6

View File

@ -6,6 +6,7 @@
#include <QMessageBox>
#include <QMouseEvent>
#include <QPushButton>
#include <QWheelEvent>
#include "common/path_util.h"
#include "kbm_config_dialog.h"
@ -991,6 +992,46 @@ bool KBMSettings::eventFilter(QObject* obj, QEvent* event) {
}
return true;
}
QList<QPushButton*> 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<QWheelEvent*>(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);
}