void InputDevice::updateSetDPadNames(int dpadIndex) { JoyDPad *dpad = getActiveSetJoystick()->getJoyDPad(dpadIndex); if (dpad) { setDPadName(dpadIndex, dpad->getDpadName()); } }
DPadEditDialog::DPadEditDialog(JoyDPad *dpad, QWidget *parent) : QDialog(parent, Qt::Window), ui(new Ui::DPadEditDialog) { ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); this->dpad = dpad; updateWindowTitleDPadName(); if (dpad->getJoyMode() == JoyDPad::StandardMode) { ui->joyModeComboBox->setCurrentIndex(0); } else if (dpad->getJoyMode() == JoyDPad::EightWayMode) { ui->joyModeComboBox->setCurrentIndex(1); } else if (dpad->getJoyMode() == JoyDPad::FourWayCardinal) { ui->joyModeComboBox->setCurrentIndex(2); } else if (dpad->getJoyMode() == JoyDPad::FourWayDiagonal) { ui->joyModeComboBox->setCurrentIndex(3); } selectCurrentPreset(); ui->dpadNameLineEdit->setText(dpad->getDpadName()); unsigned int dpadDelay = dpad->getDPadDelay(); ui->dpadDelaySlider->setValue(dpadDelay * .1); ui->dpadDelayDoubleSpinBox->setValue(dpadDelay * .001); connect(ui->presetsComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(implementPresets(int))); connect(ui->joyModeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(implementModes(int))); connect(ui->mouseSettingsPushButton, SIGNAL(clicked()), this, SLOT(openMouseSettingsDialog())); connect(ui->dpadNameLineEdit, SIGNAL(textEdited(QString)), dpad, SLOT(setDPadName(QString))); connect(ui->dpadDelaySlider, SIGNAL(valueChanged(int)), this, SLOT(updateJoyDPadDelay(int))); connect(dpad, SIGNAL(dpadDelayChanged(int)), this, SLOT(updateDPadDelaySpinBox(int))); connect(ui->dpadDelayDoubleSpinBox, SIGNAL(valueChanged(double)), this, SLOT(updateDPadDelaySlider(double))); connect(dpad, SIGNAL(dpadNameChanged()), this, SLOT(updateWindowTitleDPadName())); }
void InputDevice::readConfig(QXmlStreamReader *xml) { if (xml->isStartElement() && xml->name() == getXmlName()) { reset(); xml->readNextStartElement(); while (!xml->atEnd() && (!xml->isEndElement() && xml->name() != getXmlName())) { if (xml->name() == "sets" && xml->isStartElement()) { xml->readNextStartElement(); while (!xml->atEnd() && (!xml->isEndElement() && xml->name() != "sets")) { if (xml->name() == "set" && xml->isStartElement()) { int index = xml->attributes().value("index").toString().toInt(); index = index - 1; if (index >= 0 && index < joystick_sets.size()) { joystick_sets.value(index)->readConfig(xml); } } else { // If none of the above, skip the element xml->skipCurrentElement(); } xml->readNextStartElement(); } } else if (xml->name() == "stickAxisAssociation" && xml->isStartElement()) { int stickIndex = xml->attributes().value("index").toString().toInt(); int xAxis = xml->attributes().value("xAxis").toString().toInt(); int yAxis = xml->attributes().value("yAxis").toString().toInt(); if (stickIndex > 0 && xAxis > 0 && yAxis > 0) { xAxis -= 1; yAxis -= 1; stickIndex -= 1; for (int i=0; i <joystick_sets.size(); i++) { SetJoystick *currentset = joystick_sets.value(i); JoyAxis *axis1 = currentset->getJoyAxis(xAxis); JoyAxis *axis2 = currentset->getJoyAxis(yAxis); if (axis1 && axis2) { JoyControlStick *stick = new JoyControlStick(axis1, axis2, stickIndex, i, this); currentset->addControlStick(stickIndex, stick); } } xml->readNext(); } else { xml->skipCurrentElement(); } } else if (xml->name() == "vdpadButtonAssociations" && xml->isStartElement()) { int vdpadIndex = xml->attributes().value("index").toString().toInt(); if (vdpadIndex > 0) { for (int i=0; i <joystick_sets.size(); i++) { SetJoystick *currentset = joystick_sets.value(i); VDPad *vdpad = currentset->getVDPad(vdpadIndex-1); if (!vdpad) { vdpad = new VDPad(vdpadIndex-1, i, currentset); currentset->addVDPad(vdpadIndex-1, vdpad); } } xml->readNextStartElement(); while (!xml->atEnd() && (!xml->isEndElement() && xml->name() != "vdpadButtonAssociations")) { if (xml->name() == "vdpadButtonAssociation" && xml->isStartElement()) { int vdpadAxisIndex = xml->attributes().value("axis").toString().toInt(); int vdpadButtonIndex = xml->attributes().value("button").toString().toInt(); int vdpadDirection = xml->attributes().value("direction").toString().toInt(); if (vdpadAxisIndex > 0 && vdpadDirection > 0) { vdpadAxisIndex -= 1; for (int i=0; i < joystick_sets.size(); i++) { SetJoystick *currentset = joystick_sets.value(i); VDPad *vdpad = currentset->getVDPad(vdpadIndex-1); if (vdpad) { JoyAxis *axis = currentset->getJoyAxis(vdpadAxisIndex); if (axis) { JoyButton *button = 0; if (vdpadButtonIndex == 0) { button = axis->getNAxisButton(); } else if (vdpadButtonIndex == 1) { button = axis->getPAxisButton(); } if (button) { vdpad->addVButton((JoyDPadButton::JoyDPadDirections)vdpadDirection, button); } } } } } else if (vdpadButtonIndex > 0 && vdpadDirection > 0) { vdpadButtonIndex -= 1; for (int i=0; i < joystick_sets.size(); i++) { SetJoystick *currentset = joystick_sets.value(i); VDPad *vdpad = currentset->getVDPad(vdpadIndex-1); if (vdpad) { JoyButton *button = currentset->getJoyButton(vdpadButtonIndex); if (button) { vdpad->addVButton((JoyDPadButton::JoyDPadDirections)vdpadDirection, button); } } } } xml->readNext(); } else { xml->skipCurrentElement(); } xml->readNextStartElement(); } } for (int i=0; i < joystick_sets.size(); i++) { SetJoystick *currentset = joystick_sets.value(i); for (int j=0; j < currentset->getNumberVDPads(); j++) { VDPad *vdpad = currentset->getVDPad(j); if (vdpad && vdpad->isEmpty()) { currentset->removeVDPad(j); } } } } else if (xml->name() == "names" && xml->isStartElement()) { xml->readNextStartElement(); while (!xml->atEnd() && (!xml->isEndElement() && xml->name() != "names")) { if (xml->name() == "buttonname" && xml->isStartElement()) { int index = xml->attributes().value("index").toString().toInt(); QString temp = xml->readElementText(); index = index - 1; if (index >= 0 && !temp.isEmpty()) { setButtonName(index, temp); } } else if (xml->name() == "axisbuttonname" && xml->isStartElement()) { int index = xml->attributes().value("index").toString().toInt(); int buttonIndex = xml->attributes().value("button").toString().toInt(); QString temp = xml->readElementText(); index = index - 1; buttonIndex = buttonIndex - 1; if (index >= 0 && !temp.isEmpty()) { setAxisButtonName(index, buttonIndex, temp); } } else if (xml->name() == "controlstickbuttonname" && xml->isStartElement()) { int index = xml->attributes().value("index").toString().toInt(); int buttonIndex = xml->attributes().value("button").toString().toInt(); QString temp = xml->readElementText(); index = index - 1; if (index >= 0 && !temp.isEmpty()) { setStickButtonName(index, buttonIndex, temp); } } else if (xml->name() == "dpadbuttonname" && xml->isStartElement()) { int index = xml->attributes().value("index").toString().toInt(); int buttonIndex = xml->attributes().value("button").toString().toInt(); QString temp = xml->readElementText(); index = index - 1; if (index >= 0 && !temp.isEmpty()) { setDPadButtonName(index, buttonIndex, temp); } } else if (xml->name() == "vdpadbuttonname" && xml->isStartElement()) { int index = xml->attributes().value("index").toString().toInt(); int buttonIndex = xml->attributes().value("button").toString().toInt(); QString temp = xml->readElementText(); index = index - 1; if (index >= 0 && !temp.isEmpty()) { setVDPadButtonName(index, buttonIndex, temp); } } else if (xml->name() == "axisname" && xml->isStartElement()) { int index = xml->attributes().value("index").toString().toInt(); QString temp = xml->readElementText(); index = index - 1; if (index >= 0 && !temp.isEmpty()) { setAxisName(index, temp); } } else if (xml->name() == "controlstickname" && xml->isStartElement()) { int index = xml->attributes().value("index").toString().toInt(); QString temp = xml->readElementText(); index = index - 1; if (index >= 0 && !temp.isEmpty()) { setStickName(index, temp); } } else if (xml->name() == "dpadname" && xml->isStartElement()) { int index = xml->attributes().value("index").toString().toInt(); QString temp = xml->readElementText(); index = index - 1; if (index >= 0 && !temp.isEmpty()) { setDPadName(index, temp); } } else if (xml->name() == "vdpadname" && xml->isStartElement()) { int index = xml->attributes().value("index").toString().toInt(); QString temp = xml->readElementText(); index = index - 1; if (index >= 0 && !temp.isEmpty()) { setVDPadName(index, temp); } } else { // If none of the above, skip the element xml->skipCurrentElement(); } xml->readNextStartElement(); } } else if (xml->name() == "keyPressTime" && xml->isStartElement()) { QString temptext = xml->readElementText(); int tempchoice = temptext.toInt(); if (tempchoice >= 10) { this->setDeviceKeyDelay(tempchoice); } } else { // If none of the above, skip the element xml->skipCurrentElement(); } xml->readNextStartElement(); } } }