* @brief Serializes an InputDevice object into the the given XML stream * @param[in,out] xml The XML stream to write to */
| 379 | * @param[in,out] xml The XML stream to write to |
| 380 | */ |
| 381 | void InputDeviceXml::writeConfig(QXmlStreamWriter *xml) |
| 382 | { |
| 383 | xml->writeStartElement(m_inputDevice->getXmlName()); |
| 384 | xml->writeAttribute("configversion", QString::number(PadderCommon::LATESTCONFIGFILEVERSION)); |
| 385 | xml->writeAttribute("appversion", PadderCommon::programVersion); |
| 386 | |
| 387 | xml->writeComment("The SDL name for a joystick is included for informational purposes only."); |
| 388 | xml->writeTextElement("sdlname", m_inputDevice->getSDLName()); |
| 389 | xml->writeComment("The Unique ID for a joystick is included for informational purposes only."); |
| 390 | xml->writeTextElement("uniqueID", m_inputDevice->getUniqueIDString()); |
| 391 | // xml->writeTextElement("guid", m_inputDevice->getGUIDString()); |
| 392 | |
| 393 | if (!m_inputDevice->getProfileName().isEmpty()) |
| 394 | xml->writeTextElement("profilename", m_inputDevice->getProfileName()); |
| 395 | |
| 396 | QListIterator<JoyControlStick *> currJoyStick(m_inputDevice->getActiveSetJoystick()->getSticks().values()); |
| 397 | while (currJoyStick.hasNext()) |
| 398 | { |
| 399 | JoyControlStick *stick = currJoyStick.next(); |
| 400 | |
| 401 | xml->writeStartElement("stickAxisAssociation"); |
| 402 | xml->writeAttribute("index", QString::number(stick->getRealJoyIndex())); |
| 403 | xml->writeAttribute("xAxis", QString::number(stick->getAxisX()->getRealJoyIndex())); |
| 404 | xml->writeAttribute("yAxis", QString::number(stick->getAxisY()->getRealJoyIndex())); |
| 405 | xml->writeEndElement(); |
| 406 | } |
| 407 | |
| 408 | // write vdpadButtonAssociations |
| 409 | QListIterator<VDPad *> currVDPad(m_inputDevice->getActiveSetJoystick()->getVdpads().values()); |
| 410 | while (currVDPad.hasNext()) |
| 411 | { |
| 412 | VDPad *vdpad = currVDPad.next(); |
| 413 | xml->writeStartElement("vdpadButtonAssociations"); |
| 414 | xml->writeAttribute("index", QString::number(vdpad->getRealJoyNumber())); |
| 415 | JoyButton *button = vdpad->getVButton(JoyDPadButton::DpadUp); |
| 416 | |
| 417 | if (button != nullptr) |
| 418 | { |
| 419 | xml->writeStartElement("vdpadButtonAssociation"); |
| 420 | |
| 421 | if (typeid(*button) == typeid(JoyAxisButton)) |
| 422 | { |
| 423 | JoyAxisButton *axisbutton = qobject_cast<JoyAxisButton *>(button); |
| 424 | xml->writeAttribute("axis", QString::number(axisbutton->getAxis()->getRealJoyIndex())); |
| 425 | xml->writeAttribute("button", QString::number(button->getJoyNumber())); |
| 426 | } else |
| 427 | { |
| 428 | xml->writeAttribute("axis", QString::number(0)); |
| 429 | xml->writeAttribute("button", QString::number(button->getRealJoyNumber())); |
| 430 | } |
| 431 | |
| 432 | xml->writeAttribute("direction", QString::number(JoyDPadButton::DpadUp)); |
| 433 | xml->writeEndElement(); |
| 434 | } |
| 435 | |
| 436 | button = vdpad->getVButton(JoyDPadButton::DpadDown); |
| 437 | |
| 438 | if (button != nullptr) |
nothing calls this directly
no test coverage detected