void AxisEditDialog::selectTriggerPreset() { JoyAxisButton *paxisbutton = axis->getPAxisButton(); QList<JoyButtonSlot*> *paxisslots = paxisbutton->getAssignedSlots(); if (paxisslots->length() == 1) { JoyButtonSlot *pslot = paxisslots->at(0); if (pslot->getSlotMode() == JoyButtonSlot::JoyMouseButton && pslot->getSlotCode() == JoyButtonSlot::MouseLB) { ui->presetsComboBox->setCurrentIndex(1); } else if (pslot->getSlotMode() == JoyButtonSlot::JoyMouseButton && pslot->getSlotCode() == JoyButtonSlot::MouseRB) { ui->presetsComboBox->setCurrentIndex(2); } else { ui->presetsComboBox->setCurrentIndex(0); } } else if (paxisslots->length() == 0) { ui->presetsComboBox->setCurrentIndex(3); } else { ui->presetsComboBox->setCurrentIndex(0); } }
int JoyAxisContextMenu::getTriggerPresetIndex() { int result = 0; PadderCommon::inputDaemonMutex.lock(); JoyAxisButton *paxisbutton = axis->getPAxisButton(); QList<JoyButtonSlot*> *paxisslots = paxisbutton->getAssignedSlots(); if (paxisslots->length() == 1) { JoyButtonSlot *pslot = paxisslots->at(0); if (pslot->getSlotMode() == JoyButtonSlot::JoyMouseButton && pslot->getSlotCode() == JoyButtonSlot::MouseLB) { result = 1; } else if (pslot->getSlotMode() == JoyButtonSlot::JoyMouseButton && pslot->getSlotCode() == JoyButtonSlot::MouseRB) { result = 2; } } else if (paxisslots->length() == 0) { result = 3; } PadderCommon::inputDaemonMutex.unlock(); return result; }
void AdvanceButtonDialog::updateSlotsScrollArea(int value) { int index = ui->slotListWidget->currentRow(); int itemcount = ui->slotListWidget->count(); if (index == (itemcount - 1) && value > 0) { appendBlankKeyGrabber(); } else if (index < (itemcount - 1) && value == 0) { QListWidgetItem *item = ui->slotListWidget->takeItem(index); delete item; item = 0; } this->button->clearSlotsEventReset(); for (int i = 0; i < ui->slotListWidget->count(); i++) { SimpleKeyGrabberButton *button = ui->slotListWidget->item(i)->data(Qt::UserRole).value<SimpleKeyGrabberButton*>(); JoyButtonSlot *tempbuttonslot = button->getValue(); if (tempbuttonslot->getSlotCode() > 0) { JoyButtonSlot *buttonslot = new JoyButtonSlot(tempbuttonslot->getSlotCode(), tempbuttonslot->getSlotMode()); this->button->setAssignedSlot(buttonslot->getSlotCode(), buttonslot->getSlotMode()); } } changeTurboForSequences(); emit slotsChanged(); }
void AdvanceButtonDialog::insertDistanceSlot() { int index = ui->slotListWidget->currentRow(); SimpleKeyGrabberButton *tempbutton = ui->slotListWidget->currentItem()->data(Qt::UserRole).value<SimpleKeyGrabberButton*>(); int tempDistance = 0; for (int i = 0; i < ui->slotListWidget->count(); i++) { SimpleKeyGrabberButton *button = ui->slotListWidget->item(i)->data(Qt::UserRole).value<SimpleKeyGrabberButton*>(); JoyButtonSlot *tempbuttonslot = button->getValue(); if (tempbuttonslot->getSlotMode() == JoyButtonSlot::JoyDistance) { tempDistance += tempbuttonslot->getSlotCode(); } else if (tempbuttonslot->getSlotMode() == JoyButtonSlot::JoyCycle) { tempDistance = 0; } } int testDistance = ui->distanceSpinBox->value(); if (testDistance + tempDistance <= 100) { tempbutton->setValue(testDistance, JoyButtonSlot::JoyDistance); // Stop all events on JoyButton this->button->eventReset(); this->button->setAssignedSlot(testDistance, 0, index, JoyButtonSlot::JoyDistance); updateSlotsScrollArea(testDistance); } }
void AdvanceButtonDialog::performStatsWidgetRefresh(QListWidgetItem *item) { SimpleKeyGrabberButton *tempbutton = item->data(Qt::UserRole).value<SimpleKeyGrabberButton*>(); JoyButtonSlot *slot = tempbutton->getValue(); if (slot->getSlotMode() == JoyButtonSlot::JoyPause) { refreshTimeComboBoxes(slot); } else if (slot->getSlotMode() == JoyButtonSlot::JoyRelease) { refreshTimeComboBoxes(slot); } else if (slot->getSlotMode() == JoyButtonSlot::JoyHold) { refreshTimeComboBoxes(slot); } else if (slot->getSlotMode() == JoyButtonSlot::JoyKeyPress) { refreshTimeComboBoxes(slot); } else if (slot->getSlotMode() == JoyButtonSlot::JoyDelay) { refreshTimeComboBoxes(slot); } else if (slot->getSlotMode() == JoyButtonSlot::JoyDistance) { disconnect(ui->distanceSpinBox, SIGNAL(valueChanged(int)), this, SLOT(checkSlotDistanceUpdate())); ui->distanceSpinBox->setValue(slot->getSlotCode()); connect(ui->distanceSpinBox, SIGNAL(valueChanged(int)), this, SLOT(checkSlotDistanceUpdate())); }
void JoyControlStickEditDialogHelper::setFromPendingSlots() { if (!pendingSlots.isEmpty()) { QHashIterator<JoyControlStick::JoyStickDirections, JoyButtonSlot*> iter(pendingSlots); while (iter.hasNext()) { iter.next(); JoyButtonSlot *slot = iter.value(); if (slot) { JoyControlStick::JoyStickDirections tempDir = iter.key(); JoyControlStickButton *button = stick->getDirectionButton(tempDir); if (button) { button->clearSlotsEventReset(false); button->setAssignedSlot(slot->getSlotCode(), slot->getSlotCodeAlias(), slot->getSlotMode()); } slot->deleteLater(); } } } }
void AxisEditDialog::implementTriggerPresets(int index) { JoyButtonSlot *pbuttonslot = 0; if (index == 1) { pbuttonslot = new JoyButtonSlot(JoyButtonSlot::MouseLB, JoyButtonSlot::JoyMouseButton, this); } else if (index == 2) { pbuttonslot = new JoyButtonSlot(JoyButtonSlot::MouseRB, JoyButtonSlot::JoyMouseButton, this); } else if (index == 3) { JoyAxisButton *nbutton = axis->getNAxisButton(); JoyAxisButton *pbutton = axis->getPAxisButton(); //nbutton->clearSlotsEventReset(); QMetaObject::invokeMethod(nbutton, "clearSlotsEventReset", Qt::BlockingQueuedConnection); refreshNButtonLabel(); QMetaObject::invokeMethod(pbutton, "clearSlotsEventReset", Qt::BlockingQueuedConnection); //pbutton->clearSlotsEventReset(); refreshPButtonLabel(); } if (pbuttonslot) { JoyAxisButton *nbutton = axis->getNAxisButton(); JoyAxisButton *pbutton = axis->getPAxisButton(); if (nbutton->getAssignedSlots()->length() > 0) { QMetaObject::invokeMethod(nbutton, "clearSlotsEventReset", Qt::BlockingQueuedConnection, Q_ARG(bool, false)); //nbutton->clearSlotsEventReset(); refreshNButtonLabel(); } 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(); }
void AdvanceButtonDialog::updateSelectedSlot(int value) { SimpleKeyGrabberButton *grabbutton = static_cast<SimpleKeyGrabberButton*>(sender()); JoyButtonSlot *tempbuttonslot = grabbutton->getValue(); int index = ui->slotListWidget->currentRow(); // Stop all events on JoyButton this->button->eventReset(); this->button->setAssignedSlot(tempbuttonslot->getSlotCode(), tempbuttonslot->getSlotCodeAlias(), index, tempbuttonslot->getSlotMode()); updateSlotsScrollArea(value); }
void AdvanceButtonDialog::changeTurboForSequences() { bool containsSequences = false; for (int i = 0; i < ui->slotListWidget->count() && !containsSequences; i++) { SimpleKeyGrabberButton *button = ui->slotListWidget->item(i)->data(Qt::UserRole).value<SimpleKeyGrabberButton*>(); JoyButtonSlot *tempbuttonslot = button->getValue(); if (tempbuttonslot->getSlotCode() > 0 && (tempbuttonslot->getSlotMode() == JoyButtonSlot::JoyPause || tempbuttonslot->getSlotMode() == JoyButtonSlot::JoyHold || tempbuttonslot->getSlotMode() == JoyButtonSlot::JoyDistance ) ) { containsSequences = true; } } if (containsSequences) { if (ui->turboCheckbox->isChecked()) { ui->turboCheckbox->setChecked(false); this->button->setUseTurbo(false); emit turboChanged(false); } if (ui->turboCheckbox->isEnabled()) { ui->turboCheckbox->setEnabled(false); emit turboButtonEnabledChange(false); } } else { if (!ui->turboCheckbox->isEnabled()) { ui->turboCheckbox->setEnabled(true); emit turboButtonEnabledChange(true); } } }
void JoyAxisContextMenu::setTriggerPreset() { QAction *action = static_cast<QAction*>(sender()); int item = action->data().toInt(); JoyButtonSlot *pbuttonslot = 0; if (item == 0) { pbuttonslot = new JoyButtonSlot(JoyButtonSlot::MouseLB, JoyButtonSlot::JoyMouseButton, this); } else if (item == 1) { pbuttonslot = new JoyButtonSlot(JoyButtonSlot::MouseRB, JoyButtonSlot::JoyMouseButton, this); } else if (item == 2) { JoyAxisButton *pbutton = axis->getPAxisButton(); QMetaObject::invokeMethod(pbutton, "clearSlotsEventReset", Qt::BlockingQueuedConnection); } if (pbuttonslot) { QMetaObject::invokeMethod(&helper, "setPAssignedSlot", Qt::BlockingQueuedConnection, Q_ARG(int, pbuttonslot->getSlotCode()), Q_ARG(unsigned int, pbuttonslot->getSlotCodeAlias()), Q_ARG(JoyButtonSlot::JoySlotInputAction, pbuttonslot->getSlotMode())); //JoyAxisButton *button = axis->getPAxisButton(); //QMetaObject::invokeMethod(button, "clearSlotsEventReset", // Q_ARG(bool, false)); //button->clearSlotsEventReset(false); /*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(); } }
void DPadEditDialog::selectCurrentPreset() { JoyDPadButton *upButton = dpad->getJoyButton(JoyDPadButton::DpadUp); QList<JoyButtonSlot*> *upslots = upButton->getAssignedSlots(); JoyDPadButton *downButton = dpad->getJoyButton(JoyDPadButton::DpadDown); QList<JoyButtonSlot*> *downslots = downButton->getAssignedSlots(); JoyDPadButton *leftButton = dpad->getJoyButton(JoyDPadButton::DpadLeft); QList<JoyButtonSlot*> *leftslots = leftButton->getAssignedSlots(); JoyDPadButton *rightButton = dpad->getJoyButton(JoyDPadButton::DpadRight); QList<JoyButtonSlot*> *rightslots = rightButton->getAssignedSlots(); if (upslots->length() == 1 && downslots->length() == 1 && leftslots->length() == 1 && rightslots->length() == 1) { JoyButtonSlot *upslot = upslots->at(0); JoyButtonSlot *downslot = downslots->at(0); JoyButtonSlot *leftslot = leftslots->at(0); JoyButtonSlot *rightslot = rightslots->at(0); if (upslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && upslot->getSlotCode() == JoyButtonSlot::MouseUp && downslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && downslot->getSlotCode() == JoyButtonSlot::MouseDown && leftslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && leftslot->getSlotCode() == JoyButtonSlot::MouseLeft && rightslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && rightslot->getSlotCode() == JoyButtonSlot::MouseRight) { ui->presetsComboBox->setCurrentIndex(1); } else if (upslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && upslot->getSlotCode() == JoyButtonSlot::MouseUp && downslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && downslot->getSlotCode() == JoyButtonSlot::MouseDown && leftslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && leftslot->getSlotCode() == JoyButtonSlot::MouseRight && rightslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && rightslot->getSlotCode() == JoyButtonSlot::MouseLeft) { ui->presetsComboBox->setCurrentIndex(2); } else if (upslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && upslot->getSlotCode() == JoyButtonSlot::MouseDown && downslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && downslot->getSlotCode() == JoyButtonSlot::MouseUp && leftslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && leftslot->getSlotCode() == JoyButtonSlot::MouseLeft && rightslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && rightslot->getSlotCode() == JoyButtonSlot::MouseRight) { ui->presetsComboBox->setCurrentIndex(3); } else if (upslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && upslot->getSlotCode() == JoyButtonSlot::MouseDown && downslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && downslot->getSlotCode() == JoyButtonSlot::MouseUp && leftslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && leftslot->getSlotCode() == JoyButtonSlot::MouseRight && rightslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && rightslot->getSlotCode() == JoyButtonSlot::MouseLeft) { ui->presetsComboBox->setCurrentIndex(4); } else if (upslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)upslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Up) && downslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)downslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Down) && leftslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)leftslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Left) && rightslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)rightslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Right)) { ui->presetsComboBox->setCurrentIndex(5); } else if (upslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)upslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_W) && downslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)downslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_S) && leftslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)leftslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_A) && rightslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)rightslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_D)) { ui->presetsComboBox->setCurrentIndex(6); } else if (upslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)upslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8) && downslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)downslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2) && leftslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)leftslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4) && rightslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)rightslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6)) { ui->presetsComboBox->setCurrentIndex(7); } } else if (upslots->length() == 0 && downslots->length() == 0 && leftslots->length() == 0 && rightslots->length() == 0) { ui->presetsComboBox->setCurrentIndex(8); } }
AdvanceButtonDialog::AdvanceButtonDialog(JoyButton *button, QWidget *parent) : QDialog(parent, Qt::Dialog), ui(new Ui::AdvanceButtonDialog) { ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); this->button = button; oldRow = 0; if (this->button->getToggleState()) { ui->toggleCheckbox->setChecked(true); } if (this->button->isUsingTurbo()) { ui->turboCheckbox->setChecked(true); ui->turboSlider->setEnabled(true); } int interval = this->button->getTurboInterval() / 10; if (interval < MINIMUMTURBO) { interval = JoyButton::ENABLEDTURBODEFAULT / 10; } ui->turboSlider->setValue(interval); this->changeTurboText(interval); QListIterator<JoyButtonSlot*> iter(*(this->button->getAssignedSlots())); while (iter.hasNext()) { JoyButtonSlot *buttonslot = iter.next(); SimpleKeyGrabberButton *existingCode = new SimpleKeyGrabberButton(this); existingCode->setText(buttonslot->getSlotString()); existingCode->setValue(buttonslot->getSlotCode(), buttonslot->getSlotCodeAlias(), buttonslot->getSlotMode()); QListWidgetItem *item = new QListWidgetItem(); item->setData(Qt::UserRole, QVariant::fromValue<SimpleKeyGrabberButton*>(existingCode)); QHBoxLayout *layout= new QHBoxLayout(); layout->setContentsMargins(10, 0, 10, 0); layout->addWidget(existingCode); QWidget *widget = new QWidget(); widget->setLayout(layout); item->setSizeHint(widget->sizeHint()); ui->slotListWidget->addItem(item); ui->slotListWidget->setItemWidget(item, widget); connectButtonEvents(existingCode); } appendBlankKeyGrabber(); populateSetSelectionComboBox(); if (this->button->getSetSelection() > -1 && this->button->getChangeSetCondition() != JoyButton::SetChangeDisabled) { int selectIndex = (int)this->button->getChangeSetCondition(); selectIndex += this->button->getSetSelection() * 3; if (this->button->getOriginSet() < this->button->getSetSelection()) { selectIndex -= 3; } ui->setSelectionComboBox->setCurrentIndex(selectIndex); } fillTimeComboBoxes(); ui->actionTenthsComboBox->setCurrentIndex(1); updateActionTimeLabel(); changeTurboForSequences(); if (button->isCycleResetActive()) { ui->autoResetCycleCheckBox->setEnabled(true); ui->autoResetCycleCheckBox->setChecked(true); checkCycleResetWidgetStatus(true); } if (button->getCycleResetTime() != 0) { populateAutoResetInterval(); } updateWindowTitleButtonName(); connect(ui->turboCheckbox, SIGNAL(clicked(bool)), ui->turboSlider, SLOT(setEnabled(bool))); connect(ui->turboSlider, SIGNAL(valueChanged(int)), this, SLOT(checkTurboIntervalValue(int))); connect(ui->insertSlotButton, SIGNAL(clicked()), this, SLOT(insertSlot())); connect(ui->deleteSlotButton, SIGNAL(clicked()), this, SLOT(deleteSlot())); connect(ui->clearAllPushButton, SIGNAL(clicked()), this, SLOT(clearAllSlots())); connect(ui->pausePushButton, SIGNAL(clicked()), this, SLOT(insertPauseSlot())); connect(ui->holdPushButton, SIGNAL(clicked()), this, SLOT(insertHoldSlot())); connect(ui->cyclePushButton, SIGNAL(clicked()), this, SLOT(insertCycleSlot())); connect(ui->distancePushButton, SIGNAL(clicked()), this, SLOT(insertDistanceSlot())); connect(ui->releasePushButton, SIGNAL(clicked()), this, SLOT(insertReleaseSlot())); connect(ui->actionHundredthsComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateActionTimeLabel())); connect(ui->actionSecondsComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateActionTimeLabel())); connect(ui->actionMinutesComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateActionTimeLabel())); connect(ui->actionTenthsComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateActionTimeLabel())); connect(ui->toggleCheckbox, SIGNAL(clicked(bool)), button, SLOT(setToggle(bool))); connect(ui->turboCheckbox, SIGNAL(clicked(bool)), this, SLOT(checkTurboSetting(bool))); connect(ui->setSelectionComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateSetSelection())); connect(ui->mouseModPushButton, SIGNAL(clicked()), this, SLOT(insertMouseSpeedModSlot())); connect(ui->slotListWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(performStatsWidgetRefresh(QListWidgetItem*))); connect(ui->actionHundredthsComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(checkSlotTimeUpdate())); connect(ui->actionTenthsComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(checkSlotTimeUpdate())); connect(ui->actionSecondsComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(checkSlotTimeUpdate())); connect(ui->actionMinutesComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(checkSlotTimeUpdate())); connect(ui->distanceSpinBox, SIGNAL(valueChanged(int)), this, SLOT(checkSlotDistanceUpdate())); connect(ui->mouseSpeedModSpinBox, SIGNAL(valueChanged(int)), this, SLOT(checkSlotMouseModUpdate())); connect(ui->pressTimePushButton, SIGNAL(clicked()), this, SLOT(insertKeyPressSlot())); connect(ui->delayPushButton, SIGNAL(clicked()), this, SLOT(insertDelaySlot())); connect(ui->autoResetCycleCheckBox, SIGNAL(clicked(bool)), this, SLOT(checkCycleResetWidgetStatus(bool))); connect(ui->autoResetCycleCheckBox, SIGNAL(clicked(bool)), this, SLOT(setButtonCycleReset(bool))); connect(ui->resetCycleDoubleSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setButtonCycleResetInterval(double))); connect(button, SIGNAL(toggleChanged(bool)), ui->toggleCheckbox, SLOT(setChecked(bool))); connect(button, SIGNAL(turboChanged(bool)), this, SLOT(checkTurboSetting(bool))); }
void AxisEditDialog::selectCurrentPreset() { JoyAxisButton *naxisbutton = axis->getNAxisButton(); QList<JoyButtonSlot*> *naxisslots = naxisbutton->getAssignedSlots(); JoyAxisButton *paxisbutton = axis->getPAxisButton(); QList<JoyButtonSlot*> *paxisslots = paxisbutton->getAssignedSlots(); if (naxisslots->length() == 1 && paxisslots->length() == 1) { JoyButtonSlot *nslot = naxisslots->at(0); JoyButtonSlot *pslot = paxisslots->at(0); if (nslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && nslot->getSlotCode() == JoyButtonSlot::MouseLeft && pslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && pslot->getSlotCode() == JoyButtonSlot::MouseRight) { ui->presetsComboBox->setCurrentIndex(1); } else if (nslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && nslot->getSlotCode() == JoyButtonSlot::MouseRight && pslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && pslot->getSlotCode() == JoyButtonSlot::MouseLeft) { ui->presetsComboBox->setCurrentIndex(2); } else if (nslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && nslot->getSlotCode() == JoyButtonSlot::MouseUp && pslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && pslot->getSlotCode() == JoyButtonSlot::MouseDown) { ui->presetsComboBox->setCurrentIndex(3); } else if (nslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && nslot->getSlotCode() == JoyButtonSlot::MouseDown && pslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && pslot->getSlotCode() == JoyButtonSlot::MouseUp) { ui->presetsComboBox->setCurrentIndex(4); } else if (nslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)nslot->getSlotCode() == AntKeyMapper::returnVirtualKey(Qt::Key_Up) && pslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)pslot->getSlotCode() == AntKeyMapper::returnVirtualKey(Qt::Key_Down)) { ui->presetsComboBox->setCurrentIndex(5); } else if (nslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)nslot->getSlotCode() == AntKeyMapper::returnVirtualKey(Qt::Key_Left) && pslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)pslot->getSlotCode() == AntKeyMapper::returnVirtualKey(Qt::Key_Right)) { ui->presetsComboBox->setCurrentIndex(6); } else if (nslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)nslot->getSlotCode() == AntKeyMapper::returnVirtualKey(Qt::Key_W) && pslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)pslot->getSlotCode() == AntKeyMapper::returnVirtualKey(Qt::Key_S)) { ui->presetsComboBox->setCurrentIndex(7); } else if (nslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)nslot->getSlotCode() == AntKeyMapper::returnVirtualKey(Qt::Key_A) && pslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)pslot->getSlotCode() == AntKeyMapper::returnVirtualKey(Qt::Key_D)) { ui->presetsComboBox->setCurrentIndex(8); } else if (nslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)nslot->getSlotCode() == AntKeyMapper::returnVirtualKey(QtKeyMapperBase::AntKey_KP_8) && pslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)pslot->getSlotCode() == AntKeyMapper::returnVirtualKey(QtKeyMapperBase::AntKey_KP_2)) { ui->presetsComboBox->setCurrentIndex(9); } else if (nslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)nslot->getSlotCode() == AntKeyMapper::returnVirtualKey(QtKeyMapperBase::AntKey_KP_4) && pslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)pslot->getSlotCode() == AntKeyMapper::returnVirtualKey(QtKeyMapperBase::AntKey_KP_6)) { ui->presetsComboBox->setCurrentIndex(10); } else { ui->presetsComboBox->setCurrentIndex(0); } } else if (naxisslots->length() == 0 && paxisslots->length() == 0) { ui->presetsComboBox->setCurrentIndex(11); } else { ui->presetsComboBox->setCurrentIndex(0); } }
void AxisEditDialog::implementPresets(int index) { JoyButtonSlot *nbuttonslot = 0; JoyButtonSlot *pbuttonslot = 0; if (index == 1) { nbuttonslot = new JoyButtonSlot(JoyButtonSlot::MouseLeft, JoyButtonSlot::JoyMouseMovement, this); pbuttonslot = new JoyButtonSlot(JoyButtonSlot::MouseRight, JoyButtonSlot::JoyMouseMovement, this); } else if (index == 2) { nbuttonslot = new JoyButtonSlot(JoyButtonSlot::MouseRight, JoyButtonSlot::JoyMouseMovement, this); pbuttonslot = new JoyButtonSlot(JoyButtonSlot::MouseLeft, JoyButtonSlot::JoyMouseMovement, this); } else if (index == 3) { nbuttonslot = new JoyButtonSlot(JoyButtonSlot::MouseUp, JoyButtonSlot::JoyMouseMovement, this); pbuttonslot = new JoyButtonSlot(JoyButtonSlot::MouseDown, JoyButtonSlot::JoyMouseMovement, this); } else if (index == 4) { nbuttonslot = new JoyButtonSlot(JoyButtonSlot::MouseDown, JoyButtonSlot::JoyMouseMovement, this); pbuttonslot = new JoyButtonSlot(JoyButtonSlot::MouseUp, JoyButtonSlot::JoyMouseMovement, this); } else if (index == 5) { nbuttonslot = new JoyButtonSlot(AntKeyMapper::returnVirtualKey(Qt::Key_Up), Qt::Key_Up, JoyButtonSlot::JoyKeyboard, this); pbuttonslot = new JoyButtonSlot(AntKeyMapper::returnVirtualKey(Qt::Key_Down), Qt::Key_Down, JoyButtonSlot::JoyKeyboard, this); } else if (index == 6) { nbuttonslot = new JoyButtonSlot(AntKeyMapper::returnVirtualKey(Qt::Key_Left), Qt::Key_Left, JoyButtonSlot::JoyKeyboard, this); pbuttonslot = new JoyButtonSlot(AntKeyMapper::returnVirtualKey(Qt::Key_Right), Qt::Key_Right, JoyButtonSlot::JoyKeyboard, this); } else if (index == 7) { nbuttonslot = new JoyButtonSlot(AntKeyMapper::returnVirtualKey(Qt::Key_W), Qt::Key_W, JoyButtonSlot::JoyKeyboard, this); pbuttonslot = new JoyButtonSlot(AntKeyMapper::returnVirtualKey(Qt::Key_S), Qt::Key_S, JoyButtonSlot::JoyKeyboard, this); } else if (index == 8) { nbuttonslot = new JoyButtonSlot(AntKeyMapper::returnVirtualKey(Qt::Key_A), Qt::Key_A, JoyButtonSlot::JoyKeyboard, this); pbuttonslot = new JoyButtonSlot(AntKeyMapper::returnVirtualKey(Qt::Key_D), Qt::Key_D, JoyButtonSlot::JoyKeyboard, this); } else if (index == 9) { nbuttonslot = new JoyButtonSlot(AntKeyMapper::returnVirtualKey(QtKeyMapperBase::AntKey_KP_8), QtKeyMapperBase::AntKey_KP_8, JoyButtonSlot::JoyKeyboard, this); pbuttonslot = new JoyButtonSlot(AntKeyMapper::returnVirtualKey(QtKeyMapperBase::AntKey_KP_2), QtKeyMapperBase::AntKey_KP_2, JoyButtonSlot::JoyKeyboard, this); } else if (index == 10) { nbuttonslot = new JoyButtonSlot(AntKeyMapper::returnVirtualKey(QtKeyMapperBase::AntKey_KP_4), QtKeyMapperBase::AntKey_KP_4, JoyButtonSlot::JoyKeyboard, this); pbuttonslot = new JoyButtonSlot(AntKeyMapper::returnVirtualKey(QtKeyMapperBase::AntKey_KP_6), QtKeyMapperBase::AntKey_KP_6, JoyButtonSlot::JoyKeyboard, this); } else if (index == 11) { JoyAxisButton *nbutton = axis->getNAxisButton(); JoyAxisButton *pbutton = axis->getPAxisButton(); nbutton->clearSlotsEventReset(); refreshNButtonLabel(); pbutton->clearSlotsEventReset(); refreshPButtonLabel(); } if (nbuttonslot) { JoyAxisButton *button = axis->getNAxisButton(); button->clearSlotsEventReset(false); button->setAssignedSlot(nbuttonslot->getSlotCode(), nbuttonslot->getSlotCodeAlias(), nbuttonslot->getSlotMode()); refreshNButtonLabel(); nbuttonslot->deleteLater(); } if (pbuttonslot) { JoyAxisButton *button = axis->getPAxisButton(); button->clearSlotsEventReset(false); button->setAssignedSlot(pbuttonslot->getSlotCode(), pbuttonslot->getSlotCodeAlias(), pbuttonslot->getSlotMode()); refreshPButtonLabel(); pbuttonslot->deleteLater(); } }
void JoyAxisContextMenu::setAxisPreset() { //PadderCommon::lockInputDevices(); //InputDevice *tempDevice = axis->getParentSet()->getInputDevice(); //QMetaObject::invokeMethod(tempDevice, "haltServices", Qt::BlockingQueuedConnection); QAction *action = static_cast<QAction*>(sender()); int item = action->data().toInt(); JoyButtonSlot *nbuttonslot = 0; JoyButtonSlot *pbuttonslot = 0; if (item == 0) { nbuttonslot = new JoyButtonSlot(JoyButtonSlot::MouseLeft, JoyButtonSlot::JoyMouseMovement, this); pbuttonslot = new JoyButtonSlot(JoyButtonSlot::MouseRight, JoyButtonSlot::JoyMouseMovement, this); } else if (item == 1) { nbuttonslot = new JoyButtonSlot(JoyButtonSlot::MouseRight, JoyButtonSlot::JoyMouseMovement, this); pbuttonslot = new JoyButtonSlot(JoyButtonSlot::MouseLeft, JoyButtonSlot::JoyMouseMovement, this); } else if (item == 2) { nbuttonslot = new JoyButtonSlot(JoyButtonSlot::MouseUp, JoyButtonSlot::JoyMouseMovement, this); pbuttonslot = new JoyButtonSlot(JoyButtonSlot::MouseDown, JoyButtonSlot::JoyMouseMovement, this); } else if (item == 3) { nbuttonslot = new JoyButtonSlot(JoyButtonSlot::MouseDown, JoyButtonSlot::JoyMouseMovement, this); pbuttonslot = new JoyButtonSlot(JoyButtonSlot::MouseUp, JoyButtonSlot::JoyMouseMovement, this); } else if (item == 4) { nbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Up), Qt::Key_Up, JoyButtonSlot::JoyKeyboard, this); pbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Down), Qt::Key_Down, JoyButtonSlot::JoyKeyboard, this); } else if (item == 5) { nbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Left), Qt::Key_Left, JoyButtonSlot::JoyKeyboard, this); pbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Right), Qt::Key_Right, JoyButtonSlot::JoyKeyboard, this); } else if (item == 6) { nbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_W), Qt::Key_W, JoyButtonSlot::JoyKeyboard, this); pbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_S), Qt::Key_S, JoyButtonSlot::JoyKeyboard, this); } else if (item == 7) { nbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_A), Qt::Key_A, JoyButtonSlot::JoyKeyboard, this); pbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_D), Qt::Key_D, JoyButtonSlot::JoyKeyboard, this); } else if (item == 8) { nbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8), QtKeyMapperBase::AntKey_KP_8, JoyButtonSlot::JoyKeyboard, this); pbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2), QtKeyMapperBase::AntKey_KP_2, JoyButtonSlot::JoyKeyboard, this); } else if (item == 9) { nbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4), QtKeyMapperBase::AntKey_KP_4, JoyButtonSlot::JoyKeyboard, this); pbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6), QtKeyMapperBase::AntKey_KP_6, JoyButtonSlot::JoyKeyboard, this); } else if (item == 10) { QMetaObject::invokeMethod(&helper, "clearAndResetAxisButtons", Qt::BlockingQueuedConnection); } if (nbuttonslot) { QMetaObject::invokeMethod(&helper, "setNAssignedSlot", Qt::BlockingQueuedConnection, Q_ARG(int, nbuttonslot->getSlotCode()), Q_ARG(unsigned int, nbuttonslot->getSlotCodeAlias()), Q_ARG(JoyButtonSlot::JoySlotInputAction, nbuttonslot->getSlotMode())); //JoyAxisButton *button = axis->getNAxisButton(); //QMetaObject::invokeMethod(button, "clearSlotsEventReset", // Q_ARG(bool, false)); //button->clearSlotsEventReset(false); /*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) { QMetaObject::invokeMethod(&helper, "setPAssignedSlot", Qt::BlockingQueuedConnection, Q_ARG(int, nbuttonslot->getSlotCode()), Q_ARG(unsigned int, nbuttonslot->getSlotCodeAlias()), Q_ARG(JoyButtonSlot::JoySlotInputAction, nbuttonslot->getSlotMode())); //JoyAxisButton *button = axis->getPAxisButton(); //QMetaObject::invokeMethod(button, "clearSlotsEventReset", // Q_ARG(bool, false)); //button->clearSlotsEventReset(false); /*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(); } //PadderCommon::unlockInputDevices(); }
void JoyControlStickContextMenu::setStickPreset() { PadderCommon::lockInputDevices(); InputDevice *tempDevice = stick->getParentSet()->getInputDevice(); QMetaObject::invokeMethod(tempDevice, "haltServices", Qt::BlockingQueuedConnection); QAction *action = static_cast<QAction*>(sender()); int item = action->data().toInt(); JoyButtonSlot *upButtonSlot = 0; JoyButtonSlot *downButtonSlot = 0; JoyButtonSlot *leftButtonSlot = 0; JoyButtonSlot *rightButtonSlot = 0; JoyButtonSlot *upLeftButtonSlot = 0; JoyButtonSlot *upRightButtonSlot = 0; JoyButtonSlot *downLeftButtonSlot = 0; JoyButtonSlot *downRightButtonSlot = 0; if (item == 0) { upButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseUp, JoyButtonSlot::JoyMouseMovement, this); downButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseDown, JoyButtonSlot::JoyMouseMovement, this); leftButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseLeft, JoyButtonSlot::JoyMouseMovement, this); rightButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseRight, JoyButtonSlot::JoyMouseMovement, this); stick->setJoyMode(JoyControlStick::StandardMode); stick->setDiagonalRange(65); } else if (item == 1) { upButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseUp, JoyButtonSlot::JoyMouseMovement, this); downButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseDown, JoyButtonSlot::JoyMouseMovement, this); leftButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseRight, JoyButtonSlot::JoyMouseMovement, this); rightButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseLeft, JoyButtonSlot::JoyMouseMovement, this); stick->setJoyMode(JoyControlStick::StandardMode); stick->setDiagonalRange(65); } else if (item == 2) { upButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseDown, JoyButtonSlot::JoyMouseMovement, this); downButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseUp, JoyButtonSlot::JoyMouseMovement, this); leftButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseLeft, JoyButtonSlot::JoyMouseMovement, this); rightButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseRight, JoyButtonSlot::JoyMouseMovement, this); stick->setJoyMode(JoyControlStick::StandardMode); stick->setDiagonalRange(65); } else if (item == 3) { upButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseDown, JoyButtonSlot::JoyMouseMovement, this); downButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseUp, JoyButtonSlot::JoyMouseMovement, this); leftButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseRight, JoyButtonSlot::JoyMouseMovement, this); rightButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseLeft, JoyButtonSlot::JoyMouseMovement, this); stick->setJoyMode(JoyControlStick::StandardMode); stick->setDiagonalRange(65); } else if (item == 4) { upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Up), Qt::Key_Up, JoyButtonSlot::JoyKeyboard, this); downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Down), Qt::Key_Down, JoyButtonSlot::JoyKeyboard, this); leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Left), Qt::Key_Left, JoyButtonSlot::JoyKeyboard, this); rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Right), Qt::Key_Right, JoyButtonSlot::JoyKeyboard, this); stick->setJoyMode(JoyControlStick::StandardMode); stick->setDiagonalRange(45); } else if (item == 5) { upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_W), Qt::Key_W, JoyButtonSlot::JoyKeyboard, this); downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_S), Qt::Key_S, JoyButtonSlot::JoyKeyboard, this); leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_A), Qt::Key_A, JoyButtonSlot::JoyKeyboard, this); rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_D), Qt::Key_D, JoyButtonSlot::JoyKeyboard, this); stick->setJoyMode(JoyControlStick::StandardMode); stick->setDiagonalRange(45); } else if (item == 6) { if (stick->getJoyMode() == JoyControlStick::StandardMode || stick->getJoyMode() == JoyControlStick::FourWayCardinal) { upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8), QtKeyMapperBase::AntKey_KP_8, JoyButtonSlot::JoyKeyboard, this); downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2), QtKeyMapperBase::AntKey_KP_2, JoyButtonSlot::JoyKeyboard, this); leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4), QtKeyMapperBase::AntKey_KP_4, JoyButtonSlot::JoyKeyboard, this); rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6), QtKeyMapperBase::AntKey_KP_6, JoyButtonSlot::JoyKeyboard, this); } else if (stick->getJoyMode() == JoyControlStick::EightWayMode) { upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8), QtKeyMapperBase::AntKey_KP_8, JoyButtonSlot::JoyKeyboard, this); downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2), QtKeyMapperBase::AntKey_KP_2, JoyButtonSlot::JoyKeyboard, this); leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4), QtKeyMapperBase::AntKey_KP_4, JoyButtonSlot::JoyKeyboard, this); rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6), QtKeyMapperBase::AntKey_KP_6, JoyButtonSlot::JoyKeyboard, this); upLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_7), QtKeyMapperBase::AntKey_KP_7, JoyButtonSlot::JoyKeyboard, this); upRightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_9), QtKeyMapperBase::AntKey_KP_9, JoyButtonSlot::JoyKeyboard, this); downLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_1), QtKeyMapperBase::AntKey_KP_1, JoyButtonSlot::JoyKeyboard, this); downRightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_3), QtKeyMapperBase::AntKey_KP_3, JoyButtonSlot::JoyKeyboard, this); } else if (stick->getJoyMode() == JoyControlStick::FourWayDiagonal) { upLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_7), QtKeyMapperBase::AntKey_KP_7, JoyButtonSlot::JoyKeyboard, this); upRightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_9), QtKeyMapperBase::AntKey_KP_9, JoyButtonSlot::JoyKeyboard, this); downLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_1), QtKeyMapperBase::AntKey_KP_1, JoyButtonSlot::JoyKeyboard, this); downRightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_3), QtKeyMapperBase::AntKey_KP_3, JoyButtonSlot::JoyKeyboard, this); } stick->setDiagonalRange(45); } else if (item == 7) { QHash<JoyControlStick::JoyStickDirections, JoyControlStickButton*> *buttons = stick->getButtons(); QHashIterator<JoyControlStick::JoyStickDirections, JoyControlStickButton*> iter(*buttons); while (iter.hasNext()) { JoyControlStickButton *button = iter.next().value(); QMetaObject::invokeMethod(button, "clearSlotsEventReset", Qt::BlockingQueuedConnection); //button->clearSlotsEventReset(); } stick->setDiagonalRange(45); } if (upButtonSlot) { JoyControlStickButton *button = stick->getDirectionButton(JoyControlStick::StickUp); QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); 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", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); 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", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); 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", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); 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", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); 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", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); 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", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); 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", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); 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(); } PadderCommon::unlockInputDevices(); }
AdvanceButtonDialog::AdvanceButtonDialog(JoyButton *button, QWidget *parent) : QDialog(parent, Qt::Window), ui(new Ui::AdvanceButtonDialog) { ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); this->button = button; oldRow = 0; if (this->button->getToggleState()) { ui->toggleCheckbox->setChecked(true); } if (this->button->isUsingTurbo()) { ui->turboCheckbox->setChecked(true); ui->turboSlider->setEnabled(true); } int interval = this->button->getTurboInterval() / 10; if (interval < MINIMUMTURBO) { interval = JoyButton::ENABLEDTURBODEFAULT / 10; } ui->turboSlider->setValue(interval); this->changeTurboText(interval); QListIterator<JoyButtonSlot*> iter(*(this->button->getAssignedSlots())); while (iter.hasNext()) { JoyButtonSlot *buttonslot = iter.next(); SimpleKeyGrabberButton *existingCode = new SimpleKeyGrabberButton(this); existingCode->setText(buttonslot->getSlotString()); existingCode->setValue(buttonslot->getSlotCode(), buttonslot->getSlotMode()); //existingCode->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); connectButtonEvents(existingCode); QListWidgetItem *item = new QListWidgetItem(); ui->slotListWidget->addItem(item); item->setData(Qt::UserRole, QVariant::fromValue<SimpleKeyGrabberButton*>(existingCode)); QHBoxLayout *layout= new QHBoxLayout(); layout->addWidget(existingCode); QWidget *widget = new QWidget(); widget->setLayout(layout); item->setSizeHint(widget->sizeHint()); ui->slotListWidget->setItemWidget(item, widget); } appendBlankKeyGrabber(); if (this->button->getSetSelection() > -1 && this->button->getChangeSetCondition() != JoyButton::SetChangeDisabled) { int offset = (int)this->button->getChangeSetCondition(); ui->setSelectionComboBox->setCurrentIndex((this->button->getSetSelection() * 3) + offset); } if (this->button->getOriginSet() == 0) { ui->setSelectionComboBox->model()->removeRows(1, 3); } else if (this->button->getOriginSet() == 1) { ui->setSelectionComboBox->model()->removeRows(4, 3); } else if (this->button->getOriginSet() == 2) { ui->setSelectionComboBox->model()->removeRows(7, 3); } else if (this->button->getOriginSet() == 3) { ui->setSelectionComboBox->model()->removeRows(10, 3); } else if (this->button->getOriginSet() == 4) { ui->setSelectionComboBox->model()->removeRows(13, 3); } else if (this->button->getOriginSet() == 5) { ui->setSelectionComboBox->model()->removeRows(16, 3); } else if (this->button->getOriginSet() == 6) { ui->setSelectionComboBox->model()->removeRows(19, 3); } else if (this->button->getOriginSet() == 7) { ui->setSelectionComboBox->model()->removeRows(22, 3); } updateActionTimeLabel(); changeTurboForSequences(); setWindowTitle(tr("Advanced").append(": ").append(button->getPartialName())); connect(ui->turboCheckbox, SIGNAL(clicked(bool)), ui->turboSlider, SLOT(setEnabled(bool))); connect(ui->turboSlider, SIGNAL(valueChanged(int)), this, SLOT(checkTurboIntervalValue(int))); connect(ui->insertSlotButton, SIGNAL(clicked()), this, SLOT(insertSlot())); connect(ui->deleteSlotButton, SIGNAL(clicked()), this, SLOT(deleteSlot())); connect(ui->clearAllPushButton, SIGNAL(clicked()), this, SLOT(clearAllSlots())); connect(ui->pausePushButton, SIGNAL(clicked()), this, SLOT(insertPauseSlot())); connect(ui->holdPushButton, SIGNAL(clicked()), this, SLOT(insertHoldSlot())); connect(ui->cyclePushButton, SIGNAL(clicked()), this, SLOT(insertCycleSlot())); connect(ui->distancePushButton, SIGNAL(clicked()), this, SLOT(insertDistanceSlot())); connect(ui->releasePushButton, SIGNAL(clicked()), this, SLOT(insertReleaseSlot())); connect(ui->actionSecondsComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateActionTimeLabel())); connect(ui->actionMillisecondsComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateActionTimeLabel())); connect(ui->toggleCheckbox, SIGNAL(clicked(bool)), button, SLOT(setToggle(bool))); connect(ui->turboCheckbox, SIGNAL(clicked(bool)), this, SLOT(checkTurboSetting(bool))); connect(ui->setSelectionComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateSetSelection())); connect(button, SIGNAL(toggleChanged(bool)), ui->toggleCheckbox, SLOT(setChecked(bool))); connect(button, SIGNAL(turboChanged(bool)), this, SLOT(checkTurboSetting(bool))); }
void AxisEditDialog::implementAxisPresets(int index) { JoyButtonSlot *nbuttonslot = 0; JoyButtonSlot *pbuttonslot = 0; PadderCommon::lockInputDevices(); InputDevice *tempDevice = axis->getParentSet()->getInputDevice(); QMetaObject::invokeMethod(tempDevice, "haltServices", Qt::BlockingQueuedConnection); if (index == 1) { nbuttonslot = new JoyButtonSlot(JoyButtonSlot::MouseLeft, JoyButtonSlot::JoyMouseMovement, this); pbuttonslot = new JoyButtonSlot(JoyButtonSlot::MouseRight, JoyButtonSlot::JoyMouseMovement, this); } else if (index == 2) { nbuttonslot = new JoyButtonSlot(JoyButtonSlot::MouseRight, JoyButtonSlot::JoyMouseMovement, this); pbuttonslot = new JoyButtonSlot(JoyButtonSlot::MouseLeft, JoyButtonSlot::JoyMouseMovement, this); } else if (index == 3) { nbuttonslot = new JoyButtonSlot(JoyButtonSlot::MouseUp, JoyButtonSlot::JoyMouseMovement, this); pbuttonslot = new JoyButtonSlot(JoyButtonSlot::MouseDown, JoyButtonSlot::JoyMouseMovement, this); } else if (index == 4) { nbuttonslot = new JoyButtonSlot(JoyButtonSlot::MouseDown, JoyButtonSlot::JoyMouseMovement, this); pbuttonslot = new JoyButtonSlot(JoyButtonSlot::MouseUp, JoyButtonSlot::JoyMouseMovement, this); } else if (index == 5) { nbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Up), Qt::Key_Up, JoyButtonSlot::JoyKeyboard, this); pbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Down), Qt::Key_Down, JoyButtonSlot::JoyKeyboard, this); } else if (index == 6) { nbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Left), Qt::Key_Left, JoyButtonSlot::JoyKeyboard, this); pbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Right), Qt::Key_Right, JoyButtonSlot::JoyKeyboard, this); } else if (index == 7) { nbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_W), Qt::Key_W, JoyButtonSlot::JoyKeyboard, this); pbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_S), Qt::Key_S, JoyButtonSlot::JoyKeyboard, this); } else if (index == 8) { nbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_A), Qt::Key_A, JoyButtonSlot::JoyKeyboard, this); pbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_D), Qt::Key_D, JoyButtonSlot::JoyKeyboard, this); } else if (index == 9) { nbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8), QtKeyMapperBase::AntKey_KP_8, JoyButtonSlot::JoyKeyboard, this); pbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2), QtKeyMapperBase::AntKey_KP_2, JoyButtonSlot::JoyKeyboard, this); } else if (index == 10) { nbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4), QtKeyMapperBase::AntKey_KP_4, JoyButtonSlot::JoyKeyboard, this); pbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6), QtKeyMapperBase::AntKey_KP_6, JoyButtonSlot::JoyKeyboard, this); } else if (index == 11) { JoyAxisButton *nbutton = axis->getNAxisButton(); JoyAxisButton *pbutton = axis->getPAxisButton(); QMetaObject::invokeMethod(nbutton, "clearSlotsEventReset", Qt::BlockingQueuedConnection); //nbutton->clearSlotsEventReset(); refreshNButtonLabel(); QMetaObject::invokeMethod(pbutton, "clearSlotsEventReset", Qt::BlockingQueuedConnection); //pbutton->clearSlotsEventReset(); refreshPButtonLabel(); } if (nbuttonslot) { JoyAxisButton *button = axis->getNAxisButton(); QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); 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(); } if (pbuttonslot) { JoyAxisButton *button = axis->getPAxisButton(); QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false)); //button->clearSlotsEventReset(false); 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(); } PadderCommon::unlockInputDevices(); }
/** * @brief Assign the appropriate slots to DPad buttons based on the preset item * that was chosen. */ void DPadContextMenu::setDPadPreset() { QAction *action = static_cast<QAction*>(sender()); int item = action->data().toInt(); JoyButtonSlot *upButtonSlot = 0; JoyButtonSlot *downButtonSlot = 0; JoyButtonSlot *leftButtonSlot = 0; JoyButtonSlot *rightButtonSlot = 0; JoyButtonSlot *upLeftButtonSlot = 0; JoyButtonSlot *upRightButtonSlot = 0; JoyButtonSlot *downLeftButtonSlot = 0; JoyButtonSlot *downRightButtonSlot = 0; if (item == 0) { upButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseUp, JoyButtonSlot::JoyMouseMovement, this); downButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseDown, JoyButtonSlot::JoyMouseMovement, this); leftButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseLeft, JoyButtonSlot::JoyMouseMovement, this); rightButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseRight, JoyButtonSlot::JoyMouseMovement, this); dpad->setJoyMode(JoyDPad::StandardMode); } else if (item == 1) { upButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseUp, JoyButtonSlot::JoyMouseMovement, this); downButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseDown, JoyButtonSlot::JoyMouseMovement, this); leftButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseRight, JoyButtonSlot::JoyMouseMovement, this); rightButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseLeft, JoyButtonSlot::JoyMouseMovement, this); dpad->setJoyMode(JoyDPad::StandardMode); } else if (item == 2) { upButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseDown, JoyButtonSlot::JoyMouseMovement, this); downButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseUp, JoyButtonSlot::JoyMouseMovement, this); leftButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseLeft, JoyButtonSlot::JoyMouseMovement, this); rightButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseRight, JoyButtonSlot::JoyMouseMovement, this); dpad->setJoyMode(JoyDPad::StandardMode); } else if (item == 3) { upButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseDown, JoyButtonSlot::JoyMouseMovement, this); downButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseUp, JoyButtonSlot::JoyMouseMovement, this); leftButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseRight, JoyButtonSlot::JoyMouseMovement, this); rightButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseLeft, JoyButtonSlot::JoyMouseMovement, this); dpad->setJoyMode(JoyDPad::StandardMode); } else if (item == 4) { upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Up), Qt::Key_Up, JoyButtonSlot::JoyKeyboard, this); downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Down), Qt::Key_Down, JoyButtonSlot::JoyKeyboard, this); leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Left), Qt::Key_Left, JoyButtonSlot::JoyKeyboard, this); rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Right), Qt::Key_Right, JoyButtonSlot::JoyKeyboard, this); dpad->setJoyMode(JoyDPad::StandardMode); } else if (item == 5) { upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_W), Qt::Key_W, JoyButtonSlot::JoyKeyboard, this); downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_S), Qt::Key_S, JoyButtonSlot::JoyKeyboard, this); leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_A), Qt::Key_A, JoyButtonSlot::JoyKeyboard, this); rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_D), Qt::Key_D, JoyButtonSlot::JoyKeyboard, this); dpad->setJoyMode(JoyDPad::StandardMode); } else if (item == 6) { if (dpad->getJoyMode() == JoyDPad::StandardMode || dpad->getJoyMode() == JoyDPad::FourWayCardinal) { upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8), QtKeyMapperBase::AntKey_KP_8, JoyButtonSlot::JoyKeyboard, this); downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2), QtKeyMapperBase::AntKey_KP_2, JoyButtonSlot::JoyKeyboard, this); leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4), QtKeyMapperBase::AntKey_KP_4, JoyButtonSlot::JoyKeyboard, this); rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6), QtKeyMapperBase::AntKey_KP_6, JoyButtonSlot::JoyKeyboard, this); } else if (dpad->getJoyMode() == JoyDPad::EightWayMode) { upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8), QtKeyMapperBase::AntKey_KP_8, JoyButtonSlot::JoyKeyboard, this); downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2), QtKeyMapperBase::AntKey_KP_2, JoyButtonSlot::JoyKeyboard, this); leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4), QtKeyMapperBase::AntKey_KP_4, JoyButtonSlot::JoyKeyboard, this); rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6), QtKeyMapperBase::AntKey_KP_6, JoyButtonSlot::JoyKeyboard, this); upLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_7), QtKeyMapperBase::AntKey_KP_7, JoyButtonSlot::JoyKeyboard, this); upRightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_9), QtKeyMapperBase::AntKey_KP_9, JoyButtonSlot::JoyKeyboard, this); downLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_1), QtKeyMapperBase::AntKey_KP_1, JoyButtonSlot::JoyKeyboard, this); downRightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_3), QtKeyMapperBase::AntKey_KP_3, JoyButtonSlot::JoyKeyboard, this); } else if (dpad->getJoyMode() == JoyDPad::FourWayDiagonal) { upLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_7), QtKeyMapperBase::AntKey_KP_7, JoyButtonSlot::JoyKeyboard, this); upRightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_9), QtKeyMapperBase::AntKey_KP_9, JoyButtonSlot::JoyKeyboard, this); downLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_1), QtKeyMapperBase::AntKey_KP_1, JoyButtonSlot::JoyKeyboard, this); downRightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_3), QtKeyMapperBase::AntKey_KP_3, JoyButtonSlot::JoyKeyboard, this); } } else if (item == 7) { QHash<int, JoyDPadButton*> *buttons = dpad->getButtons(); QHashIterator<int, JoyDPadButton*> iter(*buttons); while (iter.hasNext()) { JoyDPadButton *button = iter.next().value(); button->clearSlotsEventReset(); } } if (upButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadUp); button->clearSlotsEventReset(false); button->setAssignedSlot(upButtonSlot->getSlotCode(), upButtonSlot->getSlotCodeAlias(), upButtonSlot->getSlotMode()); upButtonSlot->deleteLater(); } if (downButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadDown); button->clearSlotsEventReset(false); button->setAssignedSlot(downButtonSlot->getSlotCode(), downButtonSlot->getSlotCodeAlias(), downButtonSlot->getSlotMode()); downButtonSlot->deleteLater(); } if (leftButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadLeft); button->clearSlotsEventReset(false); button->setAssignedSlot(leftButtonSlot->getSlotCode(), leftButtonSlot->getSlotCodeAlias(), leftButtonSlot->getSlotMode()); leftButtonSlot->deleteLater(); } if (rightButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadRight); button->clearSlotsEventReset(false); button->setAssignedSlot(rightButtonSlot->getSlotCode(), rightButtonSlot->getSlotCodeAlias(), rightButtonSlot->getSlotMode()); rightButtonSlot->deleteLater(); } if (upLeftButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadLeftUp); button->clearSlotsEventReset(false); button->setAssignedSlot(upLeftButtonSlot->getSlotCode(), upLeftButtonSlot->getSlotCodeAlias(), upLeftButtonSlot->getSlotMode()); upLeftButtonSlot->deleteLater(); } if (upRightButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadRightUp); button->clearSlotsEventReset(false); button->setAssignedSlot(upRightButtonSlot->getSlotCode(), upRightButtonSlot->getSlotCodeAlias(), upRightButtonSlot->getSlotMode()); upRightButtonSlot->deleteLater(); } if (downLeftButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadLeftDown); button->clearSlotsEventReset(false); button->setAssignedSlot(downLeftButtonSlot->getSlotCode(), downLeftButtonSlot->getSlotCodeAlias(), downLeftButtonSlot->getSlotMode()); downLeftButtonSlot->deleteLater(); } if (downRightButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadRightDown); button->clearSlotsEventReset(false); button->setAssignedSlot(downRightButtonSlot->getSlotCode(), downRightButtonSlot->getSlotCodeAlias(), downRightButtonSlot->getSlotMode()); downRightButtonSlot->deleteLater(); } }
void DPadEditDialog::implementPresets(int index) { JoyButtonSlot *upButtonSlot = 0; JoyButtonSlot *downButtonSlot = 0; JoyButtonSlot *leftButtonSlot = 0; JoyButtonSlot *rightButtonSlot = 0; JoyButtonSlot *upLeftButtonSlot = 0; JoyButtonSlot *upRightButtonSlot = 0; JoyButtonSlot *downLeftButtonSlot = 0; JoyButtonSlot *downRightButtonSlot = 0; if (index == 1) { upButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseUp, JoyButtonSlot::JoyMouseMovement, this); downButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseDown, JoyButtonSlot::JoyMouseMovement, this); leftButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseLeft, JoyButtonSlot::JoyMouseMovement, this); rightButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseRight, JoyButtonSlot::JoyMouseMovement, this); ui->joyModeComboBox->setCurrentIndex(0); } else if (index == 2) { upButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseUp, JoyButtonSlot::JoyMouseMovement, this); downButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseDown, JoyButtonSlot::JoyMouseMovement, this); leftButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseRight, JoyButtonSlot::JoyMouseMovement, this); rightButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseLeft, JoyButtonSlot::JoyMouseMovement, this); ui->joyModeComboBox->setCurrentIndex(0); } else if (index == 3) { upButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseDown, JoyButtonSlot::JoyMouseMovement, this); downButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseUp, JoyButtonSlot::JoyMouseMovement, this); leftButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseLeft, JoyButtonSlot::JoyMouseMovement, this); rightButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseRight, JoyButtonSlot::JoyMouseMovement, this); ui->joyModeComboBox->setCurrentIndex(0); } else if (index == 4) { upButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseDown, JoyButtonSlot::JoyMouseMovement, this); downButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseUp, JoyButtonSlot::JoyMouseMovement, this); leftButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseRight, JoyButtonSlot::JoyMouseMovement, this); rightButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseLeft, JoyButtonSlot::JoyMouseMovement, this); ui->joyModeComboBox->setCurrentIndex(0); } else if (index == 5) { upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Up), Qt::Key_Up, JoyButtonSlot::JoyKeyboard, this); downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Down), Qt::Key_Down, JoyButtonSlot::JoyKeyboard, this); leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Left), Qt::Key_Left, JoyButtonSlot::JoyKeyboard, this); rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Right), Qt::Key_Right, JoyButtonSlot::JoyKeyboard, this); ui->joyModeComboBox->setCurrentIndex(0); } else if (index == 6) { upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_W), Qt::Key_W, JoyButtonSlot::JoyKeyboard, this); downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_S), Qt::Key_S, JoyButtonSlot::JoyKeyboard, this); leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_A), Qt::Key_A, JoyButtonSlot::JoyKeyboard, this); rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_D), Qt::Key_D, JoyButtonSlot::JoyKeyboard, this); ui->joyModeComboBox->setCurrentIndex(0); } else if (index == 7) { if (ui->joyModeComboBox->currentIndex() == 0 || ui->joyModeComboBox->currentIndex() == 2) { upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8), QtKeyMapperBase::AntKey_KP_8, JoyButtonSlot::JoyKeyboard, this); downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2), QtKeyMapperBase::AntKey_KP_2, JoyButtonSlot::JoyKeyboard, this); leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4), QtKeyMapperBase::AntKey_KP_4, JoyButtonSlot::JoyKeyboard, this); rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6), QtKeyMapperBase::AntKey_KP_6, JoyButtonSlot::JoyKeyboard, this); } else if (ui->joyModeComboBox->currentIndex() == 1) { upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8), QtKeyMapperBase::AntKey_KP_8, JoyButtonSlot::JoyKeyboard, this); downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2), QtKeyMapperBase::AntKey_KP_2, JoyButtonSlot::JoyKeyboard, this); leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4), QtKeyMapperBase::AntKey_KP_4, JoyButtonSlot::JoyKeyboard, this); rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6), QtKeyMapperBase::AntKey_KP_6, JoyButtonSlot::JoyKeyboard, this); upLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_7), QtKeyMapperBase::AntKey_KP_7, JoyButtonSlot::JoyKeyboard, this); upRightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_9), QtKeyMapperBase::AntKey_KP_9, JoyButtonSlot::JoyKeyboard, this); downLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_1), QtKeyMapperBase::AntKey_KP_1, JoyButtonSlot::JoyKeyboard, this); downRightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_3), QtKeyMapperBase::AntKey_KP_3, JoyButtonSlot::JoyKeyboard, this); } else if (ui->joyModeComboBox->currentIndex() == 3) { upLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_7), QtKeyMapperBase::AntKey_KP_7, JoyButtonSlot::JoyKeyboard, this); upRightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_9), QtKeyMapperBase::AntKey_KP_9, JoyButtonSlot::JoyKeyboard, this); downLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_1), QtKeyMapperBase::AntKey_KP_1, JoyButtonSlot::JoyKeyboard, this); downRightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_3), QtKeyMapperBase::AntKey_KP_3, JoyButtonSlot::JoyKeyboard, this); } } else if (index == 8) { QHash<int, JoyDPadButton*> *buttons = dpad->getButtons(); QHashIterator<int, JoyDPadButton*> iter(*buttons); while (iter.hasNext()) { JoyDPadButton *button = iter.next().value(); button->clearSlotsEventReset(); } } if (upButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadUp); button->clearSlotsEventReset(false); button->setAssignedSlot(upButtonSlot->getSlotCode(), upButtonSlot->getSlotCodeAlias(), upButtonSlot->getSlotMode()); upButtonSlot->deleteLater(); } if (downButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadDown); button->clearSlotsEventReset(false); button->setAssignedSlot(downButtonSlot->getSlotCode(), downButtonSlot->getSlotCodeAlias(), downButtonSlot->getSlotMode()); downButtonSlot->deleteLater(); } if (leftButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadLeft); button->clearSlotsEventReset(false); button->setAssignedSlot(leftButtonSlot->getSlotCode(), leftButtonSlot->getSlotCodeAlias(), leftButtonSlot->getSlotMode()); leftButtonSlot->deleteLater(); } if (rightButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadRight); button->clearSlotsEventReset(false); button->setAssignedSlot(rightButtonSlot->getSlotCode(), rightButtonSlot->getSlotCodeAlias(), rightButtonSlot->getSlotMode()); rightButtonSlot->deleteLater(); } if (upLeftButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadLeftUp); button->clearSlotsEventReset(false); button->setAssignedSlot(upLeftButtonSlot->getSlotCode(), upLeftButtonSlot->getSlotCodeAlias(), upLeftButtonSlot->getSlotMode()); upLeftButtonSlot->deleteLater(); } if (upRightButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadRightUp); button->clearSlotsEventReset(false); button->setAssignedSlot(upRightButtonSlot->getSlotCode(), upRightButtonSlot->getSlotCodeAlias(), upRightButtonSlot->getSlotMode()); upRightButtonSlot->deleteLater(); } if (downLeftButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadLeftDown); button->clearSlotsEventReset(false); button->setAssignedSlot(downLeftButtonSlot->getSlotCode(), downLeftButtonSlot->getSlotCodeAlias(), downLeftButtonSlot->getSlotMode()); downLeftButtonSlot->deleteLater(); } if (downRightButtonSlot) { JoyDPadButton *button = dpad->getJoyButton(JoyDPadButton::DpadRightDown); button->clearSlotsEventReset(false); button->setAssignedSlot(downRightButtonSlot->getSlotCode(), downRightButtonSlot->getSlotCodeAlias(), downRightButtonSlot->getSlotMode()); downRightButtonSlot->deleteLater(); } }
int JoyControlStickContextMenu::getPresetIndex() { int result = 0; JoyControlStickButton *upButton = stick->getDirectionButton(JoyControlStick::StickUp); QList<JoyButtonSlot*> *upslots = upButton->getAssignedSlots(); JoyControlStickButton *downButton = stick->getDirectionButton(JoyControlStick::StickDown); QList<JoyButtonSlot*> *downslots = downButton->getAssignedSlots(); JoyControlStickButton *leftButton = stick->getDirectionButton(JoyControlStick::StickLeft); QList<JoyButtonSlot*> *leftslots = leftButton->getAssignedSlots(); JoyControlStickButton *rightButton = stick->getDirectionButton(JoyControlStick::StickRight); QList<JoyButtonSlot*> *rightslots = rightButton->getAssignedSlots(); if (upslots->length() == 1 && downslots->length() == 1 && leftslots->length() == 1 && rightslots->length() == 1) { JoyButtonSlot *upslot = upslots->at(0); JoyButtonSlot *downslot = downslots->at(0); JoyButtonSlot *leftslot = leftslots->at(0); JoyButtonSlot *rightslot = rightslots->at(0); if (upslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && upslot->getSlotCode() == JoyButtonSlot::MouseUp && downslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && downslot->getSlotCode() == JoyButtonSlot::MouseDown && leftslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && leftslot->getSlotCode() == JoyButtonSlot::MouseLeft && rightslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && rightslot->getSlotCode() == JoyButtonSlot::MouseRight) { result = 1; } else if (upslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && upslot->getSlotCode() == JoyButtonSlot::MouseUp && downslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && downslot->getSlotCode() == JoyButtonSlot::MouseDown && leftslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && leftslot->getSlotCode() == JoyButtonSlot::MouseRight && rightslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && rightslot->getSlotCode() == JoyButtonSlot::MouseLeft) { result = 2; } else if (upslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && upslot->getSlotCode() == JoyButtonSlot::MouseDown && downslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && downslot->getSlotCode() == JoyButtonSlot::MouseUp && leftslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && leftslot->getSlotCode() == JoyButtonSlot::MouseLeft && rightslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && rightslot->getSlotCode() == JoyButtonSlot::MouseRight) { result = 3; } else if (upslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && upslot->getSlotCode() == JoyButtonSlot::MouseDown && downslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && downslot->getSlotCode() == JoyButtonSlot::MouseUp && leftslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && leftslot->getSlotCode() == JoyButtonSlot::MouseRight && rightslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && rightslot->getSlotCode() == JoyButtonSlot::MouseLeft) { result = 4; } else if (upslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)upslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Up) && downslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)downslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Down) && leftslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)leftslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Left) && rightslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)rightslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Right)) { result = 5; } else if (upslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)upslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_W) && downslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)downslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_S) && leftslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)leftslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_A) && rightslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)rightslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_D)) { result = 6; } else if (upslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)upslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8) && downslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)downslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2) && leftslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)leftslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4) && rightslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)rightslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6)) { result = 7; } } else if (upslots->length() == 0 && downslots->length() == 0 && leftslots->length() == 0 && rightslots->length() == 0) { result = 8; } return result; }
int JoyAxisContextMenu::getPresetIndex() { int result = 0; PadderCommon::inputDaemonMutex.lock(); JoyAxisButton *naxisbutton = axis->getNAxisButton(); QList<JoyButtonSlot*> *naxisslots = naxisbutton->getAssignedSlots(); JoyAxisButton *paxisbutton = axis->getPAxisButton(); QList<JoyButtonSlot*> *paxisslots = paxisbutton->getAssignedSlots(); if (naxisslots->length() == 1 && paxisslots->length() == 1) { JoyButtonSlot *nslot = naxisslots->at(0); JoyButtonSlot *pslot = paxisslots->at(0); if (nslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && nslot->getSlotCode() == JoyButtonSlot::MouseLeft && pslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && pslot->getSlotCode() == JoyButtonSlot::MouseRight) { result = 1; } else if (nslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && nslot->getSlotCode() == JoyButtonSlot::MouseRight && pslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && pslot->getSlotCode() == JoyButtonSlot::MouseLeft) { result = 2; } else if (nslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && nslot->getSlotCode() == JoyButtonSlot::MouseUp && pslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && pslot->getSlotCode() == JoyButtonSlot::MouseDown) { result = 3; } else if (nslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && nslot->getSlotCode() == JoyButtonSlot::MouseDown && pslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && pslot->getSlotCode() == JoyButtonSlot::MouseUp) { result = 4; } else if (nslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)nslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Up) && pslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)pslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Down)) { result = 5; } else if (nslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)nslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Left) && pslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)pslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Right)) { result = 6; } else if (nslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)nslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_W) && pslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)pslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_S)) { result = 7; } else if (nslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)nslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_A) && pslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)pslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_D)) { result = 8; } else if (nslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)nslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8) && pslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)pslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2)) { result = 9; } else if (nslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)nslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4) && pslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && (unsigned int)pslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6)) { result = 10; } } else if (naxisslots->length() == 0 && paxisslots->length() == 0) { result = 11; } PadderCommon::inputDaemonMutex.unlock(); return result; }