KBM Gui fixes

This commit is contained in:
rainmakerv3 2025-06-22 17:18:22 +08:00
parent 4bfd8b967b
commit b238e62add
2 changed files with 87 additions and 65 deletions

View File

@ -144,6 +144,8 @@ tr("Do you want to overwrite existing mappings with the mappings from the Common
QString SOSString = tr("Speed Offset (def 0.125):") + " " + SOSValue;
ui->SpeedOffsetLabel->setText(SOSString);
});
connect(this, &KBMSettings::PushKBMEvent, this, [this]() { CheckMapping(MappingButton); });
}
void KBMSettings::ButtonConnects() {
@ -518,7 +520,6 @@ void KBMSettings::StartTimer(QPushButton*& button) {
MappingTimer = 3;
EnableMapping = true;
MappingCompleted = false;
modifier = "";
mapping = button->text();
DisableMappingButtons();
@ -909,7 +910,6 @@ bool KBMSettings::eventFilter(QObject* obj, QEvent* event) {
}
return true;
}
}
if (event->type() == QEvent::MouseButtonPress) {
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
@ -948,41 +948,61 @@ bool KBMSettings::eventFilter(QObject* obj, QEvent* event) {
QWheelEvent* wheelEvent = static_cast<QWheelEvent*>(event);
if (pressedKeys.size() < 3) {
if (wheelEvent->angleDelta().y() > 5) {
if (std::find(AxisList.begin(), AxisList.end(), MappingButton) == AxisList.end()) {
if (std::find(AxisList.begin(), AxisList.end(), MappingButton) ==
AxisList.end()) {
pressedKeys.insert("mousewheelup");
if (QApplication::keyboardModifiers() == Qt::NoModifier)
emit PushKBMEvent();
} else {
QMessageBox::information(this, tr("Cannot set mapping"),
QMessageBox::information(
this, tr("Cannot set mapping"),
tr("Mousewheel cannot be mapped to stick outputs"));
}
} else if (wheelEvent->angleDelta().y() < -5) {
if (std::find(AxisList.begin(), AxisList.end(), MappingButton) == AxisList.end()) {
if (std::find(AxisList.begin(), AxisList.end(), MappingButton) ==
AxisList.end()) {
pressedKeys.insert("mousewheeldown");
if (QApplication::keyboardModifiers() == Qt::NoModifier)
emit PushKBMEvent();
} else {
QMessageBox::information(this, tr("Cannot set mapping"),
QMessageBox::information(
this, tr("Cannot set mapping"),
tr("Mousewheel cannot be mapped to stick outputs"));
}
}
if (wheelEvent->angleDelta().x() > 5) {
if (std::find(AxisList.begin(), AxisList.end(), MappingButton) == AxisList.end()) {
if (std::find(AxisList.begin(), AxisList.end(), MappingButton) ==
AxisList.end()) {
// QT changes scrolling to horizontal for all widgets with the alt modifier
pressedKeys.insert(
GetModifiedButton(Qt::AltModifier, "mousewheelup", "mousewheelright"));
if (QApplication::keyboardModifiers() == Qt::NoModifier)
emit PushKBMEvent();
} else {
QMessageBox::information(this, tr("Cannot set mapping"),
QMessageBox::information(
this, tr("Cannot set mapping"),
tr("Mousewheel cannot be mapped to stick outputs"));
}
} else if (wheelEvent->angleDelta().x() < -5) {
if (std::find(AxisList.begin(), AxisList.end(), MappingButton) == AxisList.end()) {
if (std::find(AxisList.begin(), AxisList.end(), MappingButton) ==
AxisList.end()) {
pressedKeys.insert(
GetModifiedButton(Qt::AltModifier, "mousewheeldown", "mousewheelleft"));
if (QApplication::keyboardModifiers() == Qt::NoModifier)
emit PushKBMEvent();
} else {
QMessageBox::information(this, tr("Cannot set mapping"),
QMessageBox::information(
this, tr("Cannot set mapping"),
tr("Mousewheel cannot be mapped to stick outputs"));
}
}
}
}
if (event->type() == QEvent::KeyRelease || event->type() == QEvent::MouseButtonRelease)
emit PushKBMEvent();
}
return QDialog::eventFilter(obj, event);
}

View File

@ -26,6 +26,9 @@ public:
explicit KBMSettings(std::shared_ptr<GameInfoClass> game_info_get, QWidget* parent = nullptr);
~KBMSettings();
signals:
void PushKBMEvent();
private Q_SLOTS:
void SaveKBMConfig(bool CloseOnSave);
void SetDefault();
@ -50,7 +53,6 @@ private:
bool MappingCompleted = false;
bool HelpWindowOpen = false;
QString mapping;
QString modifier;
int MappingTimer;
QTimer* timer;
QPushButton* MappingButton;