Skip to content

Commit

Permalink
chore: ensure proper string format to use with conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
pktiuk committed Apr 14, 2024
1 parent 7363860 commit ce07536
Show file tree
Hide file tree
Showing 11 changed files with 132 additions and 130 deletions.
16 changes: 8 additions & 8 deletions src/gamecontroller/gamecontrollerset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,28 +122,28 @@ template <typename T> void readConf(T *x, QXmlStreamReader *xml)

void GameControllerSet::readConfig(QXmlStreamReader *xml)
{
if (xml->isStartElement() && (xml->name() == "set"))
if (xml->isStartElement() && (xml->name().toString() == "set"))
{
xml->readNextStartElement();

while (!xml->atEnd() && (!xml->isEndElement() && xml->name() != "set"))
while (!xml->atEnd() && (!xml->isEndElement() && xml->name().toString() != "set"))
{
if ((xml->name() == "button") && xml->isStartElement())
if ((xml->name().toString() == "button") && xml->isStartElement())
{
getElemFromXml("button", xml);
} else if ((xml->name() == "trigger") && xml->isStartElement())
} else if ((xml->name().toString() == "trigger") && xml->isStartElement())
{
getElemFromXml("trigger", xml);
} else if ((xml->name() == "stick") && xml->isStartElement())
} else if ((xml->name().toString() == "stick") && xml->isStartElement())
{
getElemFromXml("stick", xml);
} else if ((xml->name() == "sensor") && xml->isStartElement())
} else if ((xml->name().toString() == "sensor") && xml->isStartElement())
{
getElemFromXml("sensor", xml);
} else if ((xml->name() == "dpad") && xml->isStartElement())
} else if ((xml->name().toString() == "dpad") && xml->isStartElement())
{
getElemFromXml("dpad", xml);
} else if ((xml->name() == "name") && xml->isStartElement())
} else if ((xml->name().toString() == "name") && xml->isStartElement())
{
QString temptext = xml->readElementText();

Expand Down
10 changes: 5 additions & 5 deletions src/inputdevicecalibration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,17 @@ void InputDeviceCalibration::applyCalibrations() const
*/
void InputDeviceCalibration::readConfig(QXmlStreamReader *xml)
{
while (xml->isStartElement() && (xml->name() == "calibration"))
while (xml->isStartElement() && (xml->name().toString() == "calibration"))
{
QString id = xml->attributes().value("device").toString();
if (id.isEmpty())
id = m_device->getUniqueIDString();
xml->readNextStartElement();

while (!xml->atEnd() && (!xml->isEndElement() && (xml->name() != "calibration")))
while (!xml->atEnd() && (!xml->isEndElement() && (xml->name().toString() != "calibration")))
{
CalibrationData calibration;
if ((xml->name() == "stick"))
if ((xml->name().toString() == "stick"))
{
calibration.type = CALIBRATION_DATA_STICK;
calibration.stick.index = xml->attributes().value("index").toString().toInt();
Expand All @@ -154,14 +154,14 @@ void InputDeviceCalibration::readConfig(QXmlStreamReader *xml)
calibration.stick.offsetY = xml->attributes().value("offsety").toString().toDouble();
calibration.stick.gainY = xml->attributes().value("gainy").toString().toDouble();
setCalibration(id, calibration);
} else if ((xml->name() == "accelerometer"))
} else if ((xml->name().toString() == "accelerometer"))
{
calibration.type = CALIBRATION_DATA_ACCELEROMETER;
calibration.accelerometer.orientationX = xml->attributes().value("orientationx").toString().toDouble();
calibration.accelerometer.orientationY = xml->attributes().value("orientationy").toString().toDouble();
calibration.accelerometer.orientationZ = xml->attributes().value("orientationz").toString().toDouble();
setCalibration(id, calibration);
} else if ((xml->name() == "gyroscope"))
} else if ((xml->name().toString() == "gyroscope"))
{
calibration.type = CALIBRATION_DATA_GYROSCOPE;
calibration.gyroscope.offsetX = xml->attributes().value("offsetx").toString().toDouble();
Expand Down
25 changes: 13 additions & 12 deletions src/joycontrolstick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -989,38 +989,38 @@ void JoyControlStick::setDiagonalRange(int value)
*/
void JoyControlStick::readConfig(QXmlStreamReader *xml)
{
if (xml->isStartElement() && (xml->name() == "stick"))
if (xml->isStartElement() && (xml->name().toString() == "stick"))
{
xml->readNextStartElement();

while (!xml->atEnd() && (!xml->isEndElement() && (xml->name() != "stick")))
while (!xml->atEnd() && (!xml->isEndElement() && (xml->name().toString() != "stick")))
{
if ((xml->name() == "deadZone") && xml->isStartElement())
if ((xml->name().toString() == "deadZone") && xml->isStartElement())
{
QString temptext = xml->readElementText();
int tempchoice = temptext.toInt();
this->setDeadZone(tempchoice);
} else if ((xml->name() == "maxZone") && xml->isStartElement())
} else if ((xml->name().toString() == "maxZone") && xml->isStartElement())
{
QString temptext = xml->readElementText();
int tempchoice = temptext.toInt();
this->setMaxZone(tempchoice);
} else if ((xml->name() == "modifierZone") && xml->isStartElement())
} else if ((xml->name().toString() == "modifierZone") && xml->isStartElement())
{
QString temptext = xml->readElementText();
int tempchoice = temptext.toInt();
setModifierZone(tempchoice);
} else if ((xml->name() == "modifierZoneInverted") && xml->isStartElement())
} else if ((xml->name().toString() == "modifierZoneInverted") && xml->isStartElement())
{
QString temptext = xml->readElementText();
int tempchoice = temptext.toInt();
setModifierZoneInverted(tempchoice);
} else if ((xml->name() == "diagonalRange") && xml->isStartElement())
} else if ((xml->name().toString() == "diagonalRange") && xml->isStartElement())
{
QString temptext = xml->readElementText();
int tempchoice = temptext.toInt();
this->setDiagonalRange(tempchoice);
} else if ((xml->name() == "mode") && xml->isStartElement())
} else if ((xml->name().toString() == "mode") && xml->isStartElement())
{
QString temptext = xml->readElementText();

Expand All @@ -1034,13 +1034,13 @@ void JoyControlStick::readConfig(QXmlStreamReader *xml)
{
this->setJoyMode(FourWayDiagonal);
}
} else if ((xml->name() == "squareStick") && xml->isStartElement())
} else if ((xml->name().toString() == "squareStick") && xml->isStartElement())
{
int tempchoice = xml->readElementText().toInt();

if ((tempchoice > 0) && (tempchoice <= 100))
this->setCircleAdjust(tempchoice / 100.0);
} else if ((xml->name() == GlobalVariables::JoyControlStickButton::xmlName) && xml->isStartElement())
} else if ((xml->name().toString() == GlobalVariables::JoyControlStickButton::xmlName) && xml->isStartElement())
{
int index = xml->attributes().value("index").toString().toInt();
JoyControlStickButton *button = buttons.value(static_cast<JoyStickDirections>(index));
Expand All @@ -1053,11 +1053,12 @@ void JoyControlStick::readConfig(QXmlStreamReader *xml)

if (!joyButtonXml.isNull())
delete joyButtonXml;
} else if ((xml->name() == GlobalVariables::JoyControlStickModifierButton::xmlName) && xml->isStartElement())
} else if ((xml->name().toString() == GlobalVariables::JoyControlStickModifierButton::xmlName) &&
xml->isStartElement())
{
JoyButtonXml *joyButtonXml = new JoyButtonXml(modifierButton);
joyButtonXml->readConfig(xml);
} else if ((xml->name() == "stickDelay") && xml->isStartElement())
} else if ((xml->name().toString() == "stickDelay") && xml->isStartElement())
{
QString temptext = xml->readElementText();
int tempchoice = temptext.toInt();
Expand Down
14 changes: 7 additions & 7 deletions src/joysensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,28 +681,28 @@ void JoySensor::establishPropertyUpdatedConnection()
*/
void JoySensor::readConfig(QXmlStreamReader *xml)
{
if (xml->isStartElement() && (xml->name() == "sensor"))
if (xml->isStartElement() && (xml->name().toString() == "sensor"))
{
xml->readNextStartElement();

while (!xml->atEnd() && (!xml->isEndElement() && (xml->name() != "sensor")))
while (!xml->atEnd() && (!xml->isEndElement() && (xml->name().toString() != "sensor")))
{
if ((xml->name() == "deadZone") && xml->isStartElement())
if ((xml->name().toString() == "deadZone") && xml->isStartElement())
{
QString temptext = xml->readElementText();
float tempchoice = temptext.toFloat();
setDeadZone(tempchoice);
} else if ((xml->name() == "maxZone") && xml->isStartElement())
} else if ((xml->name().toString() == "maxZone") && xml->isStartElement())
{
QString temptext = xml->readElementText();
float tempchoice = temptext.toFloat();
setMaxZone(tempchoice);
} else if ((xml->name() == "diagonalRange") && xml->isStartElement())
} else if ((xml->name().toString() == "diagonalRange") && xml->isStartElement())
{
QString temptext = xml->readElementText();
int tempchoice = temptext.toInt();
setDiagonalRange(tempchoice);
} else if ((xml->name() == GlobalVariables::JoySensorButton::xmlName) && xml->isStartElement())
} else if ((xml->name().toString() == GlobalVariables::JoySensorButton::xmlName) && xml->isStartElement())
{
int index = xml->attributes().value("index").toString().toInt();
JoySensorButton *button = m_buttons.value(static_cast<JoySensorDirection>(index));
Expand All @@ -715,7 +715,7 @@ void JoySensor::readConfig(QXmlStreamReader *xml)

if (!joyButtonXml.isNull())
delete joyButtonXml;
} else if ((xml->name() == "sensorDelay") && xml->isStartElement())
} else if ((xml->name().toString() == "sensorDelay") && xml->isStartElement())
{
QString temptext = xml->readElementText();
int tempchoice = temptext.toInt();
Expand Down
Loading

0 comments on commit ce07536

Please sign in to comment.