diff --git a/src/advancebuttondialog.cpp b/src/advancebuttondialog.cpp index 978f3a34..5d1b9c1d 100644 --- a/src/advancebuttondialog.cpp +++ b/src/advancebuttondialog.cpp @@ -271,11 +271,18 @@ void AdvanceButtonDialog::updateSelectedSlot(int value) // Stop all events on JoyButton //this->button->eventReset(); QMetaObject::invokeMethod(this->button, "eventReset"); + QMetaObject::invokeMethod(this->button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, tempbuttonslot->getSlotCode()), + Q_ARG(unsigned int, tempbuttonslot->getSlotCodeAlias()), + Q_ARG(int, index), + Q_ARG(JoyButtonSlot::JoySlotInputAction, tempbuttonslot->getSlotMode())); - this->button->setAssignedSlot(tempbuttonslot->getSlotCode(), + /*this->button->setAssignedSlot(tempbuttonslot->getSlotCode(), tempbuttonslot->getSlotCodeAlias(), index, tempbuttonslot->getSlotMode()); + */ + updateSlotsScrollArea(value); PadderCommon::unlockInputDevices(); @@ -451,10 +458,16 @@ void AdvanceButtonDialog::insertPauseSlot() { tempbutton->setValue(actionTime, JoyButtonSlot::JoyPause); // Stop all events on JoyButton - QMetaObject::invokeMethod(this->button, "eventReset", Qt::BlockingQueuedConnection); + QMetaObject::invokeMethod(this->button, "eventReset"); //this->button->eventReset(); - this->button->setAssignedSlot(actionTime, 0, index, JoyButtonSlot::JoyPause); + QMetaObject::invokeMethod(this->button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, actionTime), + Q_ARG(int, 0), + Q_ARG(int, index), + Q_ARG(int, static_cast(JoyButtonSlot::JoyPause))); + //this->button->setAssignedSlot(actionTime, 0, index, JoyButtonSlot::JoyPause); + updateSlotsScrollArea(actionTime); } @@ -473,10 +486,15 @@ void AdvanceButtonDialog::insertReleaseSlot() { tempbutton->setValue(actionTime, JoyButtonSlot::JoyRelease); // Stop all events on JoyButton - QMetaObject::invokeMethod(this->button, "eventReset", Qt::BlockingQueuedConnection); + QMetaObject::invokeMethod(this->button, "eventReset"); //this->button->eventReset(); - this->button->setAssignedSlot(actionTime, 0, index, JoyButtonSlot::JoyRelease); + QMetaObject::invokeMethod(this->button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, actionTime), + Q_ARG(unsigned int, 0), + Q_ARG(int, index), + Q_ARG(JoyButtonSlot::JoySlotInputAction, JoyButtonSlot::JoyRelease)); + //this->button->setAssignedSlot(actionTime, 0, index, JoyButtonSlot::JoyRelease); updateSlotsScrollArea(actionTime); } @@ -495,10 +513,15 @@ void AdvanceButtonDialog::insertHoldSlot() { tempbutton->setValue(actionTime, JoyButtonSlot::JoyHold); // Stop all events on JoyButton - QMetaObject::invokeMethod(this->button, "eventReset", Qt::BlockingQueuedConnection); + QMetaObject::invokeMethod(this->button, "eventReset"); //this->button->eventReset(); - this->button->setAssignedSlot(actionTime, 0, index, JoyButtonSlot::JoyHold); + QMetaObject::invokeMethod(this->button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, actionTime), + Q_ARG(unsigned int, 0), + Q_ARG(int, index), + Q_ARG(JoyButtonSlot::JoySlotInputAction, JoyButtonSlot::JoyHold)); + //this->button->setAssignedSlot(actionTime, 0, index, JoyButtonSlot::JoyHold); updateSlotsScrollArea(actionTime); } @@ -519,10 +542,15 @@ void AdvanceButtonDialog::insertSetChangeSlot() { tempbutton->setValue(setIndex, JoyButtonSlot::JoySetChange); // Stop all events on JoyButton - QMetaObject::invokeMethod(this->button, "eventReset", Qt::BlockingQueuedConnection); + QMetaObject::invokeMethod(this->button, "eventReset"); //this->button->eventReset(); - this->button->setAssignedSlot(setIndex, 0, index, JoyButtonSlot::JoySetChange); + QMetaObject::invokeMethod(this->button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, setIndex), + Q_ARG(unsigned int, 0), + Q_ARG(int, index), + Q_ARG(JoyButtonSlot::JoySlotInputAction, JoyButtonSlot::JoySetChange)); + //this->button->setAssignedSlot(setIndex, 0, index, JoyButtonSlot::JoySetChange); updateSlotsScrollArea(setIndex); } @@ -644,14 +672,16 @@ void AdvanceButtonDialog::insertCycleSlot() tempbutton->setValue(1, JoyButtonSlot::JoyCycle); // Stop all events on JoyButton - QMetaObject::invokeMethod(this->button, "eventReset", Qt::BlockingQueuedConnection); + QMetaObject::invokeMethod(this->button, "eventReset"); //this->button->eventReset(); - /*QMetaObject::invokeMethod(this->button, "setAssignedSlot", Q_ARG(int, 1), - Q_ARG(uint, 0), Q_ARG(int, index), + QMetaObject::invokeMethod(this->button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, 1), + Q_ARG(unsigned int, 0), + Q_ARG(int, index), Q_ARG(JoyButtonSlot::JoySlotInputAction, JoyButtonSlot::JoyCycle)); - */ - this->button->setAssignedSlot(1, 0, index, JoyButtonSlot::JoyCycle); + + //this->button->setAssignedSlot(1, 0, index, JoyButtonSlot::JoyCycle); updateSlotsScrollArea(1); PadderCommon::unlockInputDevices(); @@ -687,10 +717,15 @@ void AdvanceButtonDialog::insertDistanceSlot() tempbutton->setValue(testDistance, JoyButtonSlot::JoyDistance); // Stop all events on JoyButton - QMetaObject::invokeMethod(this->button, "eventReset", Qt::BlockingQueuedConnection); + QMetaObject::invokeMethod(this->button, "eventReset"); //this->button->eventReset(); - this->button->setAssignedSlot(testDistance, 0, index, JoyButtonSlot::JoyDistance); + QMetaObject::invokeMethod(this->button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, testDistance), + Q_ARG(unsigned int, 0), + Q_ARG(int, index), + Q_ARG(JoyButtonSlot::JoySlotInputAction, JoyButtonSlot::JoyDistance)); + //this->button->setAssignedSlot(testDistance, 0, index, JoyButtonSlot::JoyDistance); updateSlotsScrollArea(testDistance); } @@ -705,12 +740,18 @@ void AdvanceButtonDialog::placeNewSlot(JoyButtonSlot *slot) tempbutton->setValue(slot->getSlotCode(), slot->getSlotCodeAlias(), slot->getSlotMode()); // Stop all events on JoyButton - QMetaObject::invokeMethod(this->button, "eventReset", Qt::BlockingQueuedConnection); + QMetaObject::invokeMethod(this->button, "eventReset"); //this->button->eventReset(); - this->button->setAssignedSlot(slot->getSlotCode(), + QMetaObject::invokeMethod(this->button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, slot->getSlotCode()), + Q_ARG(unsigned int, slot->getSlotCodeAlias()), + Q_ARG(int, index), + Q_ARG(JoyButtonSlot::JoySlotInputAction, slot->getSlotMode())); + /*this->button->setAssignedSlot(slot->getSlotCode(), slot->getSlotCodeAlias(), index, slot->getSlotMode()); + */ updateSlotsScrollArea(slot->getSlotCode()); slot->deleteLater(); } @@ -857,10 +898,15 @@ void AdvanceButtonDialog::insertMouseSpeedModSlot() tempbutton->setValue(tempMouseMod, JoyButtonSlot::JoyMouseSpeedMod); // Stop all events on JoyButton - QMetaObject::invokeMethod(this->button, "eventReset", Qt::BlockingQueuedConnection); + QMetaObject::invokeMethod(this->button, "eventReset"); //this->button->eventReset(); - this->button->setAssignedSlot(tempMouseMod, 0, index, JoyButtonSlot::JoyMouseSpeedMod); + QMetaObject::invokeMethod(this->button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, tempMouseMod), + Q_ARG(unsigned int, 0), + Q_ARG(int, index), + Q_ARG(JoyButtonSlot::JoySlotInputAction, JoyButtonSlot::JoyMouseSpeedMod)); + //this->button->setAssignedSlot(tempMouseMod, 0, index, JoyButtonSlot::JoyMouseSpeedMod); updateSlotsScrollArea(tempMouseMod); } @@ -880,10 +926,15 @@ void AdvanceButtonDialog::insertKeyPressSlot() tempbutton->setValue(actionTime, JoyButtonSlot::JoyKeyPress); // Stop all events on JoyButton - QMetaObject::invokeMethod(this->button, "eventReset", Qt::BlockingQueuedConnection); + QMetaObject::invokeMethod(this->button, "eventReset"); //this->button->eventReset(); - this->button->setAssignedSlot(actionTime, 0, index, JoyButtonSlot::JoyKeyPress); + QMetaObject::invokeMethod(this->button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, actionTime), + Q_ARG(unsigned int, 0), + Q_ARG(int, index), + Q_ARG(JoyButtonSlot::JoySlotInputAction, JoyButtonSlot::JoyKeyPress)); + //this->button->setAssignedSlot(actionTime, 0, index, JoyButtonSlot::JoyKeyPress); updateSlotsScrollArea(actionTime); } @@ -902,10 +953,15 @@ void AdvanceButtonDialog::insertDelaySlot() { tempbutton->setValue(actionTime, JoyButtonSlot::JoyDelay); // Stop all events on JoyButton - QMetaObject::invokeMethod(this->button, "eventReset", Qt::BlockingQueuedConnection); + QMetaObject::invokeMethod(this->button, "eventReset"); //this->button->eventReset(); - this->button->setAssignedSlot(actionTime, 0, index, JoyButtonSlot::JoyDelay); + QMetaObject::invokeMethod(this->button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, actionTime), + Q_ARG(unsigned int, 0), + Q_ARG(int, index), + Q_ARG(JoyButtonSlot::JoySlotInputAction, JoyButtonSlot::JoyDelay)); + //this->button->setAssignedSlot(actionTime, 0, index, JoyButtonSlot::JoyDelay); updateSlotsScrollArea(actionTime); } @@ -924,10 +980,13 @@ void AdvanceButtonDialog::insertTextEntrySlot() { tempbutton->setValue(temp, JoyButtonSlot::JoyTextEntry); // Stop all events on JoyButton - QMetaObject::invokeMethod(this->button, "eventReset", Qt::BlockingQueuedConnection); + QMetaObject::invokeMethod(this->button, "eventReset"); //this->button->eventReset(); - this->button->setAssignedSlot(tempbutton->getValue(), index); + QMetaObject::invokeMethod(this->button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(JoyButtonSlot*, tempbutton->getValue()), + Q_ARG(int, index)); + //this->button->setAssignedSlot(tempbutton->getValue(), index); tempbutton->setToolTip(temp); updateSlotsScrollArea(0); } @@ -950,10 +1009,13 @@ void AdvanceButtonDialog::insertExecuteSlot() { tempbutton->setValue(temp, JoyButtonSlot::JoyExecute); // Stop all events on JoyButton - QMetaObject::invokeMethod(this->button, "eventReset", Qt::BlockingQueuedConnection); + QMetaObject::invokeMethod(this->button, "eventReset"); //this->button->eventReset(); - this->button->setAssignedSlot(tempbutton->getValue(), index); + QMetaObject::invokeMethod(this->button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(JoyButtonSlot*, tempbutton->getValue()), + Q_ARG(int, index)); + //this->button->setAssignedSlot(tempbutton->getValue(), index); tempbutton->setToolTip(temp); updateSlotsScrollArea(0); } @@ -1083,10 +1145,15 @@ void AdvanceButtonDialog::checkSlotTimeUpdate() tempbutton->setValue(actionTime, tempbuttonslot->getSlotMode()); // Stop all events on JoyButton - QMetaObject::invokeMethod(this->button, "eventReset", Qt::BlockingQueuedConnection); + QMetaObject::invokeMethod(this->button, "eventReset"); //this->button->eventReset(); - this->button->setAssignedSlot(actionTime, 0, index, tempbuttonslot->getSlotMode()); + QMetaObject::invokeMethod(this->button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, actionTime), + Q_ARG(unsigned int, 0), + Q_ARG(int, index), + Q_ARG(JoyButtonSlot::JoySlotInputAction, tempbuttonslot->getSlotMode())); + //this->button->setAssignedSlot(actionTime, 0, index, tempbuttonslot->getSlotMode()); updateSlotsScrollArea(actionTime); } } @@ -1111,10 +1178,15 @@ void AdvanceButtonDialog::checkSlotMouseModUpdate() tempbutton->setValue(tempMouseMod, tempbuttonslot->getSlotMode()); // Stop all events on JoyButton - QMetaObject::invokeMethod(this->button, "eventReset", Qt::BlockingQueuedConnection); + QMetaObject::invokeMethod(this->button, "eventReset"); //this->button->eventReset(); - this->button->setAssignedSlot(tempMouseMod, 0, index, tempbuttonslot->getSlotMode()); + QMetaObject::invokeMethod(this->button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, tempMouseMod), + Q_ARG(unsigned int, 0), + Q_ARG(int, index), + Q_ARG(JoyButtonSlot::JoySlotInputAction, tempbuttonslot->getSlotMode())); + //this->button->setAssignedSlot(tempMouseMod, 0, index, tempbuttonslot->getSlotMode()); updateSlotsScrollArea(tempMouseMod); } @@ -1138,10 +1210,15 @@ void AdvanceButtonDialog::checkSlotSetChangeUpdate() { tempbutton->setValue(setIndex, buttonslot->getSlotMode()); // Stop all events on JoyButton - QMetaObject::invokeMethod(this->button, "eventReset", Qt::BlockingQueuedConnection); + QMetaObject::invokeMethod(this->button, "eventReset"); //this->button->eventReset(); - this->button->setAssignedSlot(setIndex, 0, index, buttonslot->getSlotMode()); + QMetaObject::invokeMethod(this->button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, setIndex), + Q_ARG(unsigned int, 0), + Q_ARG(int, index), + Q_ARG(JoyButtonSlot::JoySlotInputAction, buttonslot->getSlotMode())); + //this->button->setAssignedSlot(setIndex, 0, index, buttonslot->getSlotMode()); updateSlotsScrollArea(setIndex); } } @@ -1184,10 +1261,15 @@ void AdvanceButtonDialog::checkSlotDistanceUpdate() tempbutton->setValue(testDistance, buttonslot->getSlotMode()); // Stop all events on JoyButton - QMetaObject::invokeMethod(this->button, "eventReset", Qt::BlockingQueuedConnection); + QMetaObject::invokeMethod(this->button, "eventReset"); //this->button->eventReset(); - this->button->setAssignedSlot(testDistance, 0, index, buttonslot->getSlotMode()); + QMetaObject::invokeMethod(this->button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, testDistance), + Q_ARG(unsigned int, 0), + Q_ARG(int, index), + Q_ARG(JoyButtonSlot::JoySlotInputAction, buttonslot->getSlotMode())); + //this->button->setAssignedSlot(testDistance, 0, index, buttonslot->getSlotMode()); updateSlotsScrollArea(testDistance); } } @@ -1437,10 +1519,13 @@ void AdvanceButtonDialog::showSelectProfileWindow() ->data(Qt::UserRole).value(); tempbutton->setValue(filename, JoyButtonSlot::JoyLoadProfile); // Stop all events on JoyButton - QMetaObject::invokeMethod(this->button, "eventReset", Qt::BlockingQueuedConnection); + QMetaObject::invokeMethod(this->button, "eventReset"); //this->button->eventReset(); - this->button->setAssignedSlot(tempbutton->getValue(), index); + QMetaObject::invokeMethod(this->button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(JoyButtonSlot*, tempbutton->getValue()), + Q_ARG(int, index)); + //this->button->setAssignedSlot(tempbutton->getValue(), index); tempbutton->setToolTip(filename); updateSlotsScrollArea(0); } diff --git a/src/axiseditdialog.cpp b/src/axiseditdialog.cpp index c107bc4b..44cd195f 100644 --- a/src/axiseditdialog.cpp +++ b/src/axiseditdialog.cpp @@ -244,10 +244,15 @@ void AxisEditDialog::implementAxisPresets(int index) if (nbuttonslot) { JoyAxisButton *button = axis->getNAxisButton(); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(nbuttonslot->getSlotCode(), nbuttonslot->getSlotCodeAlias(), nbuttonslot->getSlotMode()); + + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, nbuttonslot->getSlotCode()), + Q_ARG(unsigned int, nbuttonslot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, nbuttonslot->getSlotMode())); + //button->setAssignedSlot(nbuttonslot->getSlotCode(), nbuttonslot->getSlotCodeAlias(), nbuttonslot->getSlotMode()); refreshNButtonLabel(); nbuttonslot->deleteLater(); } @@ -255,10 +260,14 @@ void AxisEditDialog::implementAxisPresets(int index) if (pbuttonslot) { JoyAxisButton *button = axis->getPAxisButton(); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, - Q_ARG(bool, false)); + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(pbuttonslot->getSlotCode(), pbuttonslot->getSlotCodeAlias(), pbuttonslot->getSlotMode()); + + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, pbuttonslot->getSlotCode()), + Q_ARG(unsigned int, pbuttonslot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, pbuttonslot->getSlotMode())); + //button->setAssignedSlot(pbuttonslot->getSlotCode(), pbuttonslot->getSlotCodeAlias(), pbuttonslot->getSlotMode()); refreshPButtonLabel(); pbuttonslot->deleteLater(); } @@ -501,10 +510,12 @@ void AxisEditDialog::implementTriggerPresets(int index) { JoyAxisButton *nbutton = axis->getNAxisButton(); JoyAxisButton *pbutton = axis->getPAxisButton(); - nbutton->clearSlotsEventReset(); + //nbutton->clearSlotsEventReset(); + QMetaObject::invokeMethod(nbutton, "clearSlotsEventReset", Qt::BlockingQueuedConnection); refreshNButtonLabel(); - pbutton->clearSlotsEventReset(); + QMetaObject::invokeMethod(pbutton, "clearSlotsEventReset", Qt::BlockingQueuedConnection); + //pbutton->clearSlotsEventReset(); refreshPButtonLabel(); } @@ -515,12 +526,20 @@ void AxisEditDialog::implementTriggerPresets(int index) JoyAxisButton *pbutton = axis->getPAxisButton(); if (nbutton->getAssignedSlots()->length() > 0) { - nbutton->clearSlotsEventReset(); + QMetaObject::invokeMethod(nbutton, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + Q_ARG(bool, false)); + //nbutton->clearSlotsEventReset(); refreshNButtonLabel(); } - pbutton->clearSlotsEventReset(false); - pbutton->setAssignedSlot(pbuttonslot->getSlotCode(), pbuttonslot->getSlotCodeAlias(), pbuttonslot->getSlotMode()); + QMetaObject::invokeMethod(pbutton, "clearSlotsEventReset", + Q_ARG(bool, false)); + //pbutton->clearSlotsEventReset(false); + QMetaObject::invokeMethod(pbutton, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, pbuttonslot->getSlotCode()), + Q_ARG(unsigned int, pbuttonslot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, pbuttonslot->getSlotMode())); + //pbutton->setAssignedSlot(pbuttonslot->getSlotCode(), pbuttonslot->getSlotCodeAlias(), pbuttonslot->getSlotMode()); refreshPButtonLabel(); pbuttonslot->deleteLater(); } diff --git a/src/buttoneditdialog.cpp b/src/buttoneditdialog.cpp index 123082d0..1cfb9983 100644 --- a/src/buttoneditdialog.cpp +++ b/src/buttoneditdialog.cpp @@ -402,10 +402,14 @@ void ButtonEditDialog::processSlotAssignment(JoyButtonSlot *tempslot) { PadderCommon::lockInputDevices(); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(tempslot->getSlotCode(), tempslot->getSlotCodeAlias(), tempslot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, tempslot->getSlotCode()), + Q_ARG(unsigned int, tempslot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, tempslot->getSlotMode())); + //button->setAssignedSlot(tempslot->getSlotCode(), tempslot->getSlotCodeAlias(), tempslot->getSlotMode()); this->close(); tempslot->deleteLater(); diff --git a/src/dpadcontextmenu.cpp b/src/dpadcontextmenu.cpp index 22ac5510..ab9c4745 100644 --- a/src/dpadcontextmenu.cpp +++ b/src/dpadcontextmenu.cpp @@ -269,80 +269,112 @@ void DPadContextMenu::setDPadPreset() if (upButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadUp); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(upButtonSlot->getSlotCode(), upButtonSlot->getSlotCodeAlias(), upButtonSlot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, upButtonSlot->getSlotCode()), + Q_ARG(unsigned int, upButtonSlot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, upButtonSlot->getSlotMode())); + //button->setAssignedSlot(upButtonSlot->getSlotCode(), upButtonSlot->getSlotCodeAlias(), upButtonSlot->getSlotMode()); upButtonSlot->deleteLater(); } if (downButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadDown); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(downButtonSlot->getSlotCode(), downButtonSlot->getSlotCodeAlias(), downButtonSlot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, downButtonSlot->getSlotCode()), + Q_ARG(unsigned int, downButtonSlot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, downButtonSlot->getSlotMode())); + //button->setAssignedSlot(downButtonSlot->getSlotCode(), downButtonSlot->getSlotCodeAlias(), downButtonSlot->getSlotMode()); downButtonSlot->deleteLater(); } if (leftButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadLeft); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(leftButtonSlot->getSlotCode(), leftButtonSlot->getSlotCodeAlias(), leftButtonSlot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, leftButtonSlot->getSlotCode()), + Q_ARG(unsigned int, leftButtonSlot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, leftButtonSlot->getSlotMode())); + //button->setAssignedSlot(leftButtonSlot->getSlotCode(), leftButtonSlot->getSlotCodeAlias(), leftButtonSlot->getSlotMode()); leftButtonSlot->deleteLater(); } if (rightButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadRight); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(rightButtonSlot->getSlotCode(), rightButtonSlot->getSlotCodeAlias(), rightButtonSlot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, rightButtonSlot->getSlotCode()), + Q_ARG(unsigned int, rightButtonSlot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, rightButtonSlot->getSlotMode())); + //button->setAssignedSlot(rightButtonSlot->getSlotCode(), rightButtonSlot->getSlotCodeAlias(), rightButtonSlot->getSlotMode()); rightButtonSlot->deleteLater(); } if (upLeftButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadLeftUp); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(upLeftButtonSlot->getSlotCode(), upLeftButtonSlot->getSlotCodeAlias(), upLeftButtonSlot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, upLeftButtonSlot->getSlotCode()), + Q_ARG(unsigned int, upLeftButtonSlot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, upLeftButtonSlot->getSlotMode())); + //button->setAssignedSlot(upLeftButtonSlot->getSlotCode(), upLeftButtonSlot->getSlotCodeAlias(), upLeftButtonSlot->getSlotMode()); upLeftButtonSlot->deleteLater(); } if (upRightButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadRightUp); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(upRightButtonSlot->getSlotCode(), upRightButtonSlot->getSlotCodeAlias(), upRightButtonSlot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, upRightButtonSlot->getSlotCode()), + Q_ARG(unsigned int, upRightButtonSlot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, upRightButtonSlot->getSlotMode())); + //button->setAssignedSlot(upRightButtonSlot->getSlotCode(), upRightButtonSlot->getSlotCodeAlias(), upRightButtonSlot->getSlotMode()); upRightButtonSlot->deleteLater(); } if (downLeftButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadLeftDown); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(downLeftButtonSlot->getSlotCode(), downLeftButtonSlot->getSlotCodeAlias(), downLeftButtonSlot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, downLeftButtonSlot->getSlotCode()), + Q_ARG(unsigned int, downLeftButtonSlot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, downLeftButtonSlot->getSlotMode())); + //button->setAssignedSlot(downLeftButtonSlot->getSlotCode(), downLeftButtonSlot->getSlotCodeAlias(), downLeftButtonSlot->getSlotMode()); downLeftButtonSlot->deleteLater(); } if (downRightButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadRightDown); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(downRightButtonSlot->getSlotCode(), downRightButtonSlot->getSlotCodeAlias(), downRightButtonSlot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, downRightButtonSlot->getSlotCode()), + Q_ARG(unsigned int, downRightButtonSlot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, downRightButtonSlot->getSlotMode())); + //button->setAssignedSlot(downRightButtonSlot->getSlotCode(), downRightButtonSlot->getSlotCodeAlias(), downRightButtonSlot->getSlotMode()); downRightButtonSlot->deleteLater(); } diff --git a/src/dpadeditdialog.cpp b/src/dpadeditdialog.cpp index 77fccb3f..7cde2f5b 100644 --- a/src/dpadeditdialog.cpp +++ b/src/dpadeditdialog.cpp @@ -186,80 +186,112 @@ void DPadEditDialog::implementPresets(int index) if (upButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadUp); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(upButtonSlot->getSlotCode(), upButtonSlot->getSlotCodeAlias(), upButtonSlot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, upButtonSlot->getSlotCode()), + Q_ARG(unsigned int, upButtonSlot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, upButtonSlot->getSlotMode())); + //button->setAssignedSlot(upButtonSlot->getSlotCode(), upButtonSlot->getSlotCodeAlias(), upButtonSlot->getSlotMode()); upButtonSlot->deleteLater(); } if (downButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadDown); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(downButtonSlot->getSlotCode(), downButtonSlot->getSlotCodeAlias(), downButtonSlot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, downButtonSlot->getSlotCode()), + Q_ARG(unsigned int, downButtonSlot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, downButtonSlot->getSlotMode())); + //button->setAssignedSlot(downButtonSlot->getSlotCode(), downButtonSlot->getSlotCodeAlias(), downButtonSlot->getSlotMode()); downButtonSlot->deleteLater(); } if (leftButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadLeft); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(leftButtonSlot->getSlotCode(), leftButtonSlot->getSlotCodeAlias(), leftButtonSlot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, leftButtonSlot->getSlotCode()), + Q_ARG(unsigned int, leftButtonSlot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, leftButtonSlot->getSlotMode())); + //button->setAssignedSlot(leftButtonSlot->getSlotCode(), leftButtonSlot->getSlotCodeAlias(), leftButtonSlot->getSlotMode()); leftButtonSlot->deleteLater(); } if (rightButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadRight); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(rightButtonSlot->getSlotCode(), rightButtonSlot->getSlotCodeAlias(), rightButtonSlot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, rightButtonSlot->getSlotCode()), + Q_ARG(unsigned int, rightButtonSlot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, rightButtonSlot->getSlotMode())); + //button->setAssignedSlot(rightButtonSlot->getSlotCode(), rightButtonSlot->getSlotCodeAlias(), rightButtonSlot->getSlotMode()); rightButtonSlot->deleteLater(); } if (upLeftButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadLeftUp); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(upLeftButtonSlot->getSlotCode(), upLeftButtonSlot->getSlotCodeAlias(), upLeftButtonSlot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, upLeftButtonSlot->getSlotCode()), + Q_ARG(unsigned int, upLeftButtonSlot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, upLeftButtonSlot->getSlotMode())); + //button->setAssignedSlot(upLeftButtonSlot->getSlotCode(), upLeftButtonSlot->getSlotCodeAlias(), upLeftButtonSlot->getSlotMode()); upLeftButtonSlot->deleteLater(); } if (upRightButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadRightUp); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(upRightButtonSlot->getSlotCode(), upRightButtonSlot->getSlotCodeAlias(), upRightButtonSlot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, upRightButtonSlot->getSlotCode()), + Q_ARG(unsigned int, upRightButtonSlot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, upRightButtonSlot->getSlotMode())); + //button->setAssignedSlot(upRightButtonSlot->getSlotCode(), upRightButtonSlot->getSlotCodeAlias(), upRightButtonSlot->getSlotMode()); upRightButtonSlot->deleteLater(); } if (downLeftButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadLeftDown); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(downLeftButtonSlot->getSlotCode(), downLeftButtonSlot->getSlotCodeAlias(), downLeftButtonSlot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, downLeftButtonSlot->getSlotCode()), + Q_ARG(unsigned int, downLeftButtonSlot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, downLeftButtonSlot->getSlotMode())); + //button->setAssignedSlot(downLeftButtonSlot->getSlotCode(), downLeftButtonSlot->getSlotCodeAlias(), downLeftButtonSlot->getSlotMode()); downLeftButtonSlot->deleteLater(); } if (downRightButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadRightDown); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(downRightButtonSlot->getSlotCode(), downRightButtonSlot->getSlotCodeAlias(), downRightButtonSlot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, downRightButtonSlot->getSlotCode()), + Q_ARG(unsigned int, downRightButtonSlot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, downRightButtonSlot->getSlotMode())); + //button->setAssignedSlot(downRightButtonSlot->getSlotCode(), downRightButtonSlot->getSlotCodeAlias(), downRightButtonSlot->getSlotMode()); downRightButtonSlot->deleteLater(); } diff --git a/src/inputdaemon.cpp b/src/inputdaemon.cpp index 6e014dff..cd7fe96e 100644 --- a/src/inputdaemon.cpp +++ b/src/inputdaemon.cpp @@ -376,7 +376,7 @@ void InputDaemon::removeDevice(InputDevice *device) { if (device) { - PadderCommon::editingLock.lockForRead(); + /*PadderCommon::editingLock.lockForRead(); bool isEditing = PadderCommon::editingBindings; PadderCommon::editingLock.unlock(); @@ -387,6 +387,7 @@ void InputDaemon::removeDevice(InputDevice *device) PadderCommon::waitThisOut.wakeAll(); dismutex->unlock(); } + */ SDL_JoystickID deviceID = device->getSDLJoystickID(); diff --git a/src/joyaxiscontextmenu.cpp b/src/joyaxiscontextmenu.cpp index 3bb4a5ae..153b3c7d 100644 --- a/src/joyaxiscontextmenu.cpp +++ b/src/joyaxiscontextmenu.cpp @@ -294,20 +294,28 @@ void JoyAxisContextMenu::setAxisPreset() if (nbuttonslot) { JoyAxisButton *button = axis->getNAxisButton(); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(nbuttonslot->getSlotCode(), nbuttonslot->getSlotCodeAlias(), nbuttonslot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, nbuttonslot->getSlotCode()), + Q_ARG(unsigned int, nbuttonslot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, nbuttonslot->getSlotMode())); + //button->setAssignedSlot(nbuttonslot->getSlotCode(), nbuttonslot->getSlotCodeAlias(), nbuttonslot->getSlotMode()); nbuttonslot->deleteLater(); } if (pbuttonslot) { JoyAxisButton *button = axis->getPAxisButton(); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(pbuttonslot->getSlotCode(), pbuttonslot->getSlotCodeAlias(), pbuttonslot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, pbuttonslot->getSlotCode()), + Q_ARG(unsigned int, pbuttonslot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, pbuttonslot->getSlotMode())); + //button->setAssignedSlot(pbuttonslot->getSlotCode(), pbuttonslot->getSlotCodeAlias(), pbuttonslot->getSlotMode()); pbuttonslot->deleteLater(); } @@ -410,10 +418,14 @@ void JoyAxisContextMenu::setTriggerPreset() if (pbuttonslot) { JoyAxisButton *button = axis->getPAxisButton(); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(pbuttonslot->getSlotCode(), pbuttonslot->getSlotCodeAlias(), pbuttonslot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, pbuttonslot->getSlotCode()), + Q_ARG(unsigned int, pbuttonslot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, pbuttonslot->getSlotMode())); + //button->setAssignedSlot(pbuttonslot->getSlotCode(), pbuttonslot->getSlotCodeAlias(), pbuttonslot->getSlotMode()); pbuttonslot->deleteLater(); } } diff --git a/src/joybutton.cpp b/src/joybutton.cpp index 9d34c7c1..853d23e8 100644 --- a/src/joybutton.cpp +++ b/src/joybutton.cpp @@ -2856,6 +2856,25 @@ bool JoyButton::setAssignedSlot(JoyButtonSlot *otherSlot, int index) return permitSlot; } +/*bool JoyButton::setAssignedSlot(int code, int mode) +{ + return setAssignedSlot(code, + static_cast(mode)); +} + +bool JoyButton::setAssignedSlot(int code, unsigned int alias, int mode) +{ + return setAssignedSlot(code, alias, + static_cast(mode)); +} + +bool JoyButton::setAssignedSlot(int code, unsigned int alias, int index, int mode) +{ + return setAssignedSlot(code, alias, index, + static_cast(mode)); +} +*/ + QList* JoyButton::getAssignedSlots() { QList *newassign = &assignments; @@ -4962,11 +4981,12 @@ void JoyButton::establishMouseTimerConnections() connect(&staticMouseEventTimer, SIGNAL(timeout()), &mouseHelper, SLOT(mouseEvent()), Qt::UniqueConnection); - if (!staticMouseEventTimer.isActive()) + /*if (!staticMouseEventTimer.isActive()) { lastMouseTime.start(); staticMouseEventTimer.start(IDLEMOUSEREFRESHRATE); } + */ } void JoyButton::setSpringRelativeStatus(bool value) @@ -5537,18 +5557,14 @@ void JoyButton::restartLastMouseTime() void JoyButton::setStaticMouseThread(QThread *thread) { - //disconnect(&staticMouseEventTimer, 0, 0, 0); - int oldInterval = staticMouseEventTimer.interval(); staticMouseEventTimer.stop(); staticMouseEventTimer.moveToThread(thread); mouseHelper.moveToThread(thread); - // Only one connection will be made for each. - //connect(&staticMouseEventTimer, SIGNAL(timeout()), &mouseHelper, - // SLOT(mouseEvent()), Qt::UniqueConnection); - - staticMouseEventTimer.start(oldInterval); + QMetaObject::invokeMethod(&staticMouseEventTimer, "start", Qt::BlockingQueuedConnection, + Q_ARG(int, oldInterval)); + //staticMouseEventTimer.start(oldInterval); lastMouseTime.start(); } diff --git a/src/joybutton.h b/src/joybutton.h index aa5c23af..4e6bb757 100644 --- a/src/joybutton.h +++ b/src/joybutton.h @@ -72,17 +72,6 @@ public: bool isUsingTurbo(); void setCustomName(QString name); QString getCustomName(); - bool setAssignedSlot(int code, - JoyButtonSlot::JoySlotInputAction mode=JoyButtonSlot::JoyKeyboard); - - bool setAssignedSlot(int code, unsigned int alias, - JoyButtonSlot::JoySlotInputAction mode=JoyButtonSlot::JoyKeyboard); - - bool setAssignedSlot(int code, unsigned int alias, int index, - JoyButtonSlot::JoySlotInputAction mode=JoyButtonSlot::JoyKeyboard); - - - bool setAssignedSlot(JoyButtonSlot *otherSlot, int index); void removeAssignedSlot(int index); @@ -304,6 +293,8 @@ protected: static bool hasFutureSpringEvents(); virtual double getCurrentSpringDeadCircle(); void vdpadPassEvent(bool pressed, bool ignoresets=false); + bool insertAssignedSlot(int code, unsigned int alias, int index, + JoyButtonSlot::JoySlotInputAction mode=JoyButtonSlot::JoyKeyboard); QString buildActiveZoneSummary(QList &tempList); @@ -541,8 +532,22 @@ public slots: virtual void clearSlotsEventReset(bool clearSignalEmit=true); virtual void eventReset(); - bool insertAssignedSlot(int code, unsigned int alias, int index, - JoyButtonSlot::JoySlotInputAction mode=JoyButtonSlot::JoyKeyboard); + //bool setAssignedSlot(int code, int mode); + + //bool setAssignedSlot(int code, unsigned int alias, int mode); + + //bool setAssignedSlot(int code, unsigned int alias, int index, int mode); + + bool setAssignedSlot(int code, unsigned int alias, int index, + JoyButtonSlot::JoySlotInputAction mode=JoyButtonSlot::JoyKeyboard); + + bool setAssignedSlot(int code, + JoyButtonSlot::JoySlotInputAction mode=JoyButtonSlot::JoyKeyboard); + + bool setAssignedSlot(int code, unsigned int alias, + JoyButtonSlot::JoySlotInputAction mode=JoyButtonSlot::JoyKeyboard); + + bool setAssignedSlot(JoyButtonSlot *otherSlot, int index); void establishMouseTimerConnections(); void establishPropertyUpdatedConnections(); diff --git a/src/joybuttonslot.h b/src/joybuttonslot.h index 9460a1b9..8e7bd969 100644 --- a/src/joybuttonslot.h +++ b/src/joybuttonslot.h @@ -33,6 +33,7 @@ public: JoyPause, JoyHold, JoyCycle, JoyDistance, JoyRelease, JoyMouseSpeedMod, JoyKeyPress, JoyDelay, JoyLoadProfile, JoySetChange, JoyTextEntry, JoyExecute}; + enum JoySlotMouseDirection {MouseUp=1, MouseDown, MouseLeft, MouseRight}; enum JoySlotMouseWheelButton {MouseWheelUp=4, MouseWheelDown=5, MouseWheelLeft=6, MouseWheelRight=7}; @@ -97,6 +98,7 @@ public slots: }; Q_DECLARE_METATYPE(JoyButtonSlot*) +Q_DECLARE_METATYPE(JoyButtonSlot::JoySlotInputAction) #endif // JOYBUTTONSLOT_H diff --git a/src/joycontrolstickcontextmenu.cpp b/src/joycontrolstickcontextmenu.cpp index 998721bc..6fe12e26 100644 --- a/src/joycontrolstickcontextmenu.cpp +++ b/src/joycontrolstickcontextmenu.cpp @@ -271,80 +271,112 @@ void JoyControlStickContextMenu::setStickPreset() if (upButtonSlot) { JoyControlStickButton *button = stick->getDirectionButton(JoyControlStick::StickUp); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(upButtonSlot->getSlotCode(), upButtonSlot->getSlotCodeAlias(), upButtonSlot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, upButtonSlot->getSlotCode()), + Q_ARG(unsigned int, upButtonSlot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, upButtonSlot->getSlotMode())); + //button->setAssignedSlot(upButtonSlot->getSlotCode(), upButtonSlot->getSlotCodeAlias(), upButtonSlot->getSlotMode()); upButtonSlot->deleteLater(); } if (downButtonSlot) { JoyControlStickButton *button = stick->getDirectionButton(JoyControlStick::StickDown); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(downButtonSlot->getSlotCode(), downButtonSlot->getSlotCodeAlias(), downButtonSlot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, downButtonSlot->getSlotCode()), + Q_ARG(unsigned int, downButtonSlot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, downButtonSlot->getSlotMode())); + //button->setAssignedSlot(downButtonSlot->getSlotCode(), downButtonSlot->getSlotCodeAlias(), downButtonSlot->getSlotMode()); downButtonSlot->deleteLater(); } if (leftButtonSlot) { JoyControlStickButton *button = stick->getDirectionButton(JoyControlStick::StickLeft); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(leftButtonSlot->getSlotCode(), leftButtonSlot->getSlotCodeAlias(), leftButtonSlot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, leftButtonSlot->getSlotCode()), + Q_ARG(unsigned int, leftButtonSlot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, leftButtonSlot->getSlotMode())); + //button->setAssignedSlot(leftButtonSlot->getSlotCode(), leftButtonSlot->getSlotCodeAlias(), leftButtonSlot->getSlotMode()); leftButtonSlot->deleteLater(); } if (rightButtonSlot) { JoyControlStickButton *button = stick->getDirectionButton(JoyControlStick::StickRight); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(rightButtonSlot->getSlotCode(), rightButtonSlot->getSlotCodeAlias(), rightButtonSlot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, rightButtonSlot->getSlotCode()), + Q_ARG(unsigned int, rightButtonSlot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, rightButtonSlot->getSlotMode())); + //button->setAssignedSlot(rightButtonSlot->getSlotCode(), rightButtonSlot->getSlotCodeAlias(), rightButtonSlot->getSlotMode()); rightButtonSlot->deleteLater(); } if (upLeftButtonSlot) { JoyControlStickButton *button = stick->getDirectionButton(JoyControlStick::StickLeftUp); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(upLeftButtonSlot->getSlotCode(), upLeftButtonSlot->getSlotCodeAlias(), upLeftButtonSlot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, upLeftButtonSlot->getSlotCode()), + Q_ARG(unsigned int, upLeftButtonSlot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, upLeftButtonSlot->getSlotMode())); + //button->setAssignedSlot(upLeftButtonSlot->getSlotCode(), upLeftButtonSlot->getSlotCodeAlias(), upLeftButtonSlot->getSlotMode()); upLeftButtonSlot->deleteLater(); } if (upRightButtonSlot) { JoyControlStickButton *button = stick->getDirectionButton(JoyControlStick::StickRightUp); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(upRightButtonSlot->getSlotCode(), upRightButtonSlot->getSlotCodeAlias(), upRightButtonSlot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, upRightButtonSlot->getSlotCode()), + Q_ARG(unsigned int, upRightButtonSlot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, upRightButtonSlot->getSlotMode())); + //button->setAssignedSlot(upRightButtonSlot->getSlotCode(), upRightButtonSlot->getSlotCodeAlias(), upRightButtonSlot->getSlotMode()); upRightButtonSlot->deleteLater(); } if (downLeftButtonSlot) { JoyControlStickButton *button = stick->getDirectionButton(JoyControlStick::StickLeftDown); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(downLeftButtonSlot->getSlotCode(), downLeftButtonSlot->getSlotCodeAlias(), downLeftButtonSlot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, downLeftButtonSlot->getSlotCode()), + Q_ARG(unsigned int, downLeftButtonSlot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, downLeftButtonSlot->getSlotMode())); + //button->setAssignedSlot(downLeftButtonSlot->getSlotCode(), downLeftButtonSlot->getSlotCodeAlias(), downLeftButtonSlot->getSlotMode()); downLeftButtonSlot->deleteLater(); } if (downRightButtonSlot) { JoyControlStickButton *button = stick->getDirectionButton(JoyControlStick::StickRightDown); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(downRightButtonSlot->getSlotCode(), downRightButtonSlot->getSlotCodeAlias(), downRightButtonSlot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, downRightButtonSlot->getSlotCode()), + Q_ARG(unsigned int, downRightButtonSlot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, downRightButtonSlot->getSlotMode())); + //button->setAssignedSlot(downRightButtonSlot->getSlotCode(), downRightButtonSlot->getSlotCodeAlias(), downRightButtonSlot->getSlotMode()); downRightButtonSlot->deleteLater(); } diff --git a/src/joycontrolstickeditdialog.cpp b/src/joycontrolstickeditdialog.cpp index 7a837e5c..cd63ebcd 100644 --- a/src/joycontrolstickeditdialog.cpp +++ b/src/joycontrolstickeditdialog.cpp @@ -256,80 +256,112 @@ void JoyControlStickEditDialog::implementPresets(int index) if (upButtonSlot) { JoyControlStickButton *button = stick->getDirectionButton(JoyControlStick::StickUp); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(upButtonSlot->getSlotCode(), upButtonSlot->getSlotCodeAlias(), upButtonSlot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, upButtonSlot->getSlotCode()), + Q_ARG(unsigned int, upButtonSlot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, upButtonSlot->getSlotMode())); + //button->setAssignedSlot(upButtonSlot->getSlotCode(), upButtonSlot->getSlotCodeAlias(), upButtonSlot->getSlotMode()); upButtonSlot->deleteLater(); } if (downButtonSlot) { JoyControlStickButton *button = stick->getDirectionButton(JoyControlStick::StickDown); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(downButtonSlot->getSlotCode(), downButtonSlot->getSlotCodeAlias(), downButtonSlot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, downButtonSlot->getSlotCode()), + Q_ARG(unsigned int, downButtonSlot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, downButtonSlot->getSlotMode())); + //button->setAssignedSlot(downButtonSlot->getSlotCode(), downButtonSlot->getSlotCodeAlias(), downButtonSlot->getSlotMode()); downButtonSlot->deleteLater(); } if (leftButtonSlot) { JoyControlStickButton *button = stick->getDirectionButton(JoyControlStick::StickLeft); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(leftButtonSlot->getSlotCode(), leftButtonSlot->getSlotCodeAlias(), leftButtonSlot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, leftButtonSlot->getSlotCode()), + Q_ARG(unsigned int, leftButtonSlot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, leftButtonSlot->getSlotMode())); + //button->setAssignedSlot(leftButtonSlot->getSlotCode(), leftButtonSlot->getSlotCodeAlias(), leftButtonSlot->getSlotMode()); leftButtonSlot->deleteLater(); } if (rightButtonSlot) { JoyControlStickButton *button = stick->getDirectionButton(JoyControlStick::StickRight); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(rightButtonSlot->getSlotCode(), rightButtonSlot->getSlotCodeAlias(), rightButtonSlot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, rightButtonSlot->getSlotCode()), + Q_ARG(unsigned int, rightButtonSlot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, rightButtonSlot->getSlotMode())); + //button->setAssignedSlot(rightButtonSlot->getSlotCode(), rightButtonSlot->getSlotCodeAlias(), rightButtonSlot->getSlotMode()); rightButtonSlot->deleteLater(); } if (upLeftButtonSlot) { JoyControlStickButton *button = stick->getDirectionButton(JoyControlStick::StickLeftUp); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(upLeftButtonSlot->getSlotCode(), upLeftButtonSlot->getSlotCodeAlias(), upLeftButtonSlot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, upLeftButtonSlot->getSlotCode()), + Q_ARG(unsigned int, upLeftButtonSlot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, upLeftButtonSlot->getSlotMode())); + //button->setAssignedSlot(upLeftButtonSlot->getSlotCode(), upLeftButtonSlot->getSlotCodeAlias(), upLeftButtonSlot->getSlotMode()); upLeftButtonSlot->deleteLater(); } if (upRightButtonSlot) { JoyControlStickButton *button = stick->getDirectionButton(JoyControlStick::StickRightUp); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(upRightButtonSlot->getSlotCode(), upRightButtonSlot->getSlotCodeAlias(), upRightButtonSlot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, upRightButtonSlot->getSlotCode()), + Q_ARG(unsigned int, upRightButtonSlot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, upRightButtonSlot->getSlotMode())); + //button->setAssignedSlot(upRightButtonSlot->getSlotCode(), upRightButtonSlot->getSlotCodeAlias(), upRightButtonSlot->getSlotMode()); upRightButtonSlot->deleteLater(); } if (downLeftButtonSlot) { JoyControlStickButton *button = stick->getDirectionButton(JoyControlStick::StickLeftDown); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(downLeftButtonSlot->getSlotCode(), downLeftButtonSlot->getSlotCodeAlias(), downLeftButtonSlot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, downLeftButtonSlot->getSlotCode()), + Q_ARG(unsigned int, downLeftButtonSlot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, downLeftButtonSlot->getSlotMode())); + //button->setAssignedSlot(downLeftButtonSlot->getSlotCode(), downLeftButtonSlot->getSlotCodeAlias(), downLeftButtonSlot->getSlotMode()); downLeftButtonSlot->deleteLater(); } if (downRightButtonSlot) { JoyControlStickButton *button = stick->getDirectionButton(JoyControlStick::StickRightDown); - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); - button->setAssignedSlot(downRightButtonSlot->getSlotCode(), downRightButtonSlot->getSlotCodeAlias(), downRightButtonSlot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, downRightButtonSlot->getSlotCode()), + Q_ARG(unsigned int, downRightButtonSlot->getSlotCodeAlias()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, downRightButtonSlot->getSlotMode())); + //button->setAssignedSlot(downRightButtonSlot->getSlotCode(), downRightButtonSlot->getSlotCodeAlias(), downRightButtonSlot->getSlotMode()); downRightButtonSlot->deleteLater(); } diff --git a/src/keyboard/virtualkeyboardmousewidget.cpp b/src/keyboard/virtualkeyboardmousewidget.cpp index d8d6bbe5..fb95e9d9 100644 --- a/src/keyboard/virtualkeyboardmousewidget.cpp +++ b/src/keyboard/virtualkeyboardmousewidget.cpp @@ -524,9 +524,14 @@ QPushButton* VirtualKeyboardMouseWidget::createNoneKey() void VirtualKeyboardMouseWidget::processSingleKeyboardSelection(int keycode, unsigned int alias) { - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection); + QMetaObject::invokeMethod(button, "clearSlotsEventReset"); //button->clearSlotsEventReset(); - button->setAssignedSlot(keycode, alias); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, keycode), + Q_ARG(unsigned int, alias), + Q_ARG(int, 0), + Q_ARG(JoyButtonSlot::JoySlotInputAction, JoyButtonSlot::JoyKeyboard)); + //button->setAssignedSlot(keycode, alias); emit selectionFinished(); } @@ -538,9 +543,12 @@ void VirtualKeyboardMouseWidget::processAdvancedKeyboardSelection(int keycode, u void VirtualKeyboardMouseWidget::processSingleMouseSelection(JoyButtonSlot *tempslot) { - QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection); + QMetaObject::invokeMethod(button, "clearSlotsEventReset"); //button->clearSlotsEventReset(); - button->setAssignedSlot(tempslot->getSlotCode(), tempslot->getSlotMode()); + QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection, + Q_ARG(int, tempslot->getSlotCode()), + Q_ARG(JoyButtonSlot::JoySlotInputAction, tempslot->getSlotMode())); + //button->setAssignedSlot(tempslot->getSlotCode(), tempslot->getSlotMode()); emit selectionFinished(); } diff --git a/src/main.cpp b/src/main.cpp index 7c921214..78c60f78 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -115,6 +115,7 @@ int main(int argc, char *argv[]) qRegisterMetaType(); qRegisterMetaType(); qRegisterMetaType(); + qRegisterMetaType("JoyButtonSlot::JoySlotInputAction"); QTextStream outstream(stdout); QTextStream errorstream(stderr); @@ -172,7 +173,7 @@ int main(int argc, char *argv[]) } QMap *joysticks = new QMap(); - QThread inputEventThread; + QThread *inputEventThread = 0; // Cross-platform way of performing IPC. Currently, // only establish a connection and then disconnect. @@ -423,13 +424,13 @@ int main(int argc, char *argv[]) QIcon::setThemeName("/"); #endif - AntiMicroSettings settings(PadderCommon::configFilePath, QSettings::IniFormat); - settings.importFromCommandLine(cmdutility); + AntiMicroSettings *settings = new AntiMicroSettings(PadderCommon::configFilePath, QSettings::IniFormat); + settings->importFromCommandLine(cmdutility); QString targetLang = QLocale::system().name(); - if (settings.contains("Language")) + if (settings->contains("Language")) { - targetLang = settings.value("Language").toString(); + targetLang = settings->value("Language").toString(); } QTranslator qtTranslator; @@ -474,8 +475,8 @@ int main(int argc, char *argv[]) if (cmdutility.shouldListControllers()) { - InputDaemon *joypad_worker = new InputDaemon(joysticks, &settings, false); - AppLaunchHelper mainAppHelper(&settings, false); + InputDaemon *joypad_worker = new InputDaemon(joysticks, settings, false); + AppLaunchHelper mainAppHelper(settings, false); mainAppHelper.printControllerList(joysticks); joypad_worker->quit(); @@ -511,20 +512,21 @@ int main(int argc, char *argv[]) #ifdef USE_SDL_2 else if (cmdutility.shouldMapController()) { - InputDaemon *joypad_worker = new InputDaemon(joysticks, &settings); - joypad_worker->moveToThread(&inputEventThread); - //QObject::connect(&inputEventThread, SIGNAL(started()), joypad_worker, SLOT(refreshJoysticks())); - inputEventThread.start(QThread::HighPriority); + InputDaemon *joypad_worker = new InputDaemon(joysticks, settings); + inputEventThread = new QThread(); + joypad_worker->moveToThread(inputEventThread); + //QObject::connect(inputEventThread, SIGNAL(started()), joypad_worker, SLOT(refreshJoysticks())); + inputEventThread->start(QThread::HighPriority); - MainWindow *w = new MainWindow(joysticks, &cmdutility, &settings); + MainWindow *w = new MainWindow(joysticks, &cmdutility, settings); QObject::connect(a, SIGNAL(aboutToQuit()), w, SLOT(removeJoyTabs())); QObject::connect(a, SIGNAL(aboutToQuit()), joypad_worker, SLOT(quit())); - QObject::connect(a, SIGNAL(aboutToQuit()), joypad_worker, SLOT(deleteJoysticks())); - QObject::connect(a, SIGNAL(aboutToQuit()), &inputEventThread, SLOT(quit())); + QObject::connect(a, SIGNAL(aboutToQuit()), joypad_worker, SLOT(deleteJoysticks()), Qt::BlockingQueuedConnection); + QObject::connect(a, SIGNAL(aboutToQuit()), inputEventThread, SLOT(quit())); int app_result = a->exec(); - inputEventThread.wait(); + inputEventThread->wait(); //deleteInputDevices(joysticks); delete joysticks; @@ -536,6 +538,9 @@ int main(int argc, char *argv[]) delete localServer; localServer = 0; + delete inputEventThread; + inputEventThread = 0; + #ifdef WITH_X11 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) if (QApplication::platformName() == QStringLiteral("xcb")) @@ -645,17 +650,18 @@ int main(int argc, char *argv[]) .arg(factory->handler()->getName()), true, true); } - InputDaemon *joypad_worker = new InputDaemon(joysticks, &settings); - joypad_worker->moveToThread(&inputEventThread); - //QObject::connect(&inputEventThread, SIGNAL(started()), joypad_worker, SLOT(refreshJoysticks())); - inputEventThread.start(QThread::HighPriority); + InputDaemon *joypad_worker = new InputDaemon(joysticks, settings); + inputEventThread = new QThread(); + joypad_worker->moveToThread(inputEventThread); + //QObject::connect(inputEventThread, SIGNAL(started()), joypad_worker, SLOT(refreshJoysticks())); + inputEventThread->start(QThread::HighPriority); - MainWindow *w = new MainWindow(joysticks, &cmdutility, &settings); + MainWindow *w = new MainWindow(joysticks, &cmdutility, settings); FirstRunWizard *runWillard = 0; - if (w->getGraphicalStatus() && FirstRunWizard::shouldDisplay(&settings)) + if (w->getGraphicalStatus() && FirstRunWizard::shouldDisplay(settings)) { - runWillard = new FirstRunWizard(&settings, &qtTranslator, &myappTranslator); + runWillard = new FirstRunWizard(settings, &qtTranslator, &myappTranslator); QObject::connect(runWillard, SIGNAL(finished(int)), w, SLOT(changeWindowStatus())); runWillard->show(); } @@ -663,7 +669,7 @@ int main(int argc, char *argv[]) w->setAppTranslator(&qtTranslator); w->setTranslator(&myappTranslator); - AppLaunchHelper mainAppHelper(&settings, w->getGraphicalStatus()); + AppLaunchHelper mainAppHelper(settings, w->getGraphicalStatus()); mainAppHelper.initRunMethods(); QObject::connect(w, SIGNAL(joystickRefreshRequested()), joypad_worker, SLOT(refresh())); @@ -678,7 +684,8 @@ int main(int argc, char *argv[]) QObject::connect(a, SIGNAL(aboutToQuit()), w, SLOT(removeJoyTabs())); QObject::connect(a, SIGNAL(aboutToQuit()), joypad_worker, SLOT(quit())); QObject::connect(a, SIGNAL(aboutToQuit()), joypad_worker, SLOT(deleteJoysticks())); - QObject::connect(a, SIGNAL(aboutToQuit()), &inputEventThread, SLOT(quit())); + QObject::connect(a, SIGNAL(aboutToQuit()), joypad_worker, SLOT(deleteLater()), Qt::BlockingQueuedConnection); + QObject::connect(a, SIGNAL(aboutToQuit()), inputEventThread, SLOT(quit())); #ifdef Q_OS_WIN QObject::connect(a, SIGNAL(aboutToQuit()), &mainAppHelper, SLOT(appQuitPointerPrecision())); @@ -709,12 +716,12 @@ int main(int argc, char *argv[]) QThread::currentThread()->setPriority(QThread::HighPriority); #endif - JoyButton::setStaticMouseThread(&inputEventThread); + JoyButton::setStaticMouseThread(inputEventThread); QTimer::singleShot(20, w, SLOT(changeWindowStatus())); int app_result = a->exec(); - inputEventThread.wait(); + inputEventThread->wait(); // Log any remaining messages if they exist. appLogger.Log(); @@ -726,12 +733,15 @@ int main(int argc, char *argv[]) delete joysticks; joysticks = 0; - delete joypad_worker; + //delete joypad_worker; joypad_worker = 0; delete localServer; localServer = 0; + delete inputEventThread; + inputEventThread = 0; + AntKeyMapper::getInstance()->deleteInstance(); #ifdef Q_OS_UNIX @@ -754,6 +764,9 @@ int main(int argc, char *argv[]) delete w; w = 0; + delete settings; + settings = 0; + delete a; a = 0;