Skip to content
This repository has been archived by the owner on Aug 31, 2020. It is now read-only.

Commit

Permalink
Fixed #143 - old profiles can be used again
Browse files Browse the repository at this point in the history
  • Loading branch information
juliagoda committed Jul 7, 2020
1 parent d1f1a7b commit 8a0dc3d
Show file tree
Hide file tree
Showing 13 changed files with 272 additions and 381 deletions.
Binary file added 2020-07-07-030409_1366x768_scrot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 16 additions & 1 deletion src/gamecontroller/gamecontrollerset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,28 @@ void GameControllerSet::getElemFromXml(QString elemName, QXmlStreamReader *xml)
GameControllerTrigger *axis = nullptr;
GameControllerTriggerXml* triggerAxisXml = nullptr;

switch(index-1)
switch(index - 1)
{
// for older profiles
case 0:
axis = qobject_cast<GameControllerTrigger*>(getJoyAxis(SDL_CONTROLLER_AXIS_TRIGGERLEFT));
triggerAxisXml = new GameControllerTriggerXml(axis, this);
readConf(triggerAxisXml, xml);
break;

// for older profiles
case 1:
axis = qobject_cast<GameControllerTrigger*>(getJoyAxis(SDL_CONTROLLER_AXIS_TRIGGERRIGHT));
triggerAxisXml = new GameControllerTriggerXml(axis, this);
readConf(triggerAxisXml, xml);
break;

case 4:
axis = qobject_cast<GameControllerTrigger*>(getJoyAxis(SDL_CONTROLLER_AXIS_TRIGGERLEFT));
triggerAxisXml = new GameControllerTriggerXml(axis, this);
readConf(triggerAxisXml, xml);
break;

case 5:
axis = qobject_cast<GameControllerTrigger*>(getJoyAxis(SDL_CONTROLLER_AXIS_TRIGGERRIGHT));
triggerAxisXml = new GameControllerTriggerXml(axis, this);
Expand Down
37 changes: 37 additions & 0 deletions src/gamecontroller/gamecontrollertrigger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,43 @@ GameControllerTrigger::GameControllerTrigger(int index, int originset, SetJoysti
}


void GameControllerTrigger::reset(int index)
{
qInstallMessageHandler(MessageHandler::myMessageOutput);

reset();
m_index = index;
}


void GameControllerTrigger::reset()
{
qInstallMessageHandler(MessageHandler::myMessageOutput);

deadZone = GlobalVariables::GameControllerTrigger::AXISDEADZONE;
isActive = false;

eventActive = false;
maxZoneValue = GlobalVariables::GameControllerTrigger::AXISMAXZONE;
throttle = this->DEFAULTTHROTTLE;

paxisbutton->reset();
naxisbutton->reset();
activeButton = nullptr;
lastKnownThottledValue = 0;
lastKnownRawValue = 0;

adjustRange();
setCurrentRawValue(currentThrottledDeadValue);
currentThrottledValue = calculateThrottledValue(currentRawValue);
axisName.clear();

pendingEvent = false;
pendingValue = currentRawValue;
pendingIgnoreSets = false;
}


QString GameControllerTrigger::getXmlName()
{
qInstallMessageHandler(MessageHandler::myMessageOutput);
Expand Down
4 changes: 4 additions & 0 deletions src/gamecontroller/gamecontrollertrigger.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ class GameControllerTrigger : public JoyAxis

static const ThrottleTypes DEFAULTTHROTTLE;

public slots:
virtual void reset();
virtual void reset(int index);

protected:
void correctJoystickThrottle();

Expand Down
2 changes: 1 addition & 1 deletion src/globalvariables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ const double GlobalVariables::JoyControlStick::PI = acos(-1.0);
// Set default values used for stick properties.
const int GlobalVariables::JoyControlStick::DEFAULTDEADZONE = 8000;
const int GlobalVariables::JoyControlStick::DEFAULTMAXZONE = GlobalVariables::GameControllerTrigger::AXISMAXZONE;
const int GlobalVariables::JoyControlStick::DEFAULTDIAGONALRANGE = 90;
const int GlobalVariables::JoyControlStick::DEFAULTDIAGONALRANGE = 45;
const double GlobalVariables::JoyControlStick::DEFAULTCIRCLE = 0.0;
const int GlobalVariables::JoyControlStick::DEFAULTSTICKDELAY = 0;

Expand Down
18 changes: 10 additions & 8 deletions src/joyaxis.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,16 @@ class JoyAxis : public QObject
int axis_center_cal;
int axis_min_cal;
int axis_max_cal;
int lastKnownThottledValue;
int lastKnownRawValue;
int pendingValue;

bool isActive;
bool pendingEvent;
bool pendingIgnoreSets;
bool eventActive;

JoyAxisButton *activeButton;

// TODO: CHECK IF PROPERTY IS NEEDED.
//bool pendingUpdateLastValues;
Expand Down Expand Up @@ -205,21 +215,13 @@ public slots:
void disconnectPropertyUpdatedConnection();

private:
bool isActive;
bool eventActive;

JoyAxisButton *activeButton;
int m_originset;

JoyControlStick *m_stick;

SetJoystick *m_parentSet;
int lastKnownThottledValue;
int lastKnownRawValue;

int pendingValue;
bool pendingEvent;
bool pendingIgnoreSets;

void resetPrivateVars();
};
Expand Down
37 changes: 20 additions & 17 deletions src/joybutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ JoyButton::~JoyButton()

// threadPool->clear();

//reset();
resetPrivVars();
reset();
//resetPrivVars();
}

void JoyButton::queuePendingEvent(bool pressed, bool ignoresets)
Expand Down Expand Up @@ -4887,30 +4887,33 @@ void JoyButton::resetAllProperties()
{
resetSlotsProp(true);

m_toggle = false;
turboInterval = 0;
actionName.clear();
m_toggle = GlobalVariables::JoyButton::DEFAULTTOGGLE;
turboInterval = GlobalVariables::JoyButton::DEFAULTTURBOINTERVAL;
currentTurboMode = NormalTurbo;
m_useTurbo = GlobalVariables::JoyButton::DEFAULTUSETURBO;
isDown = false;
toggleActiveState = false;
m_useTurbo = false;
mouseSpeedX = 50;
mouseSpeedY = 50;
wheelSpeedX = 20;
wheelSpeedY = 20;
mouseMode = MouseCursor;
mouseSpeedX = GlobalVariables::JoyButton::DEFAULTMOUSESPEEDX;
mouseSpeedY = GlobalVariables::JoyButton::DEFAULTMOUSESPEEDY;
wheelSpeedX = GlobalVariables::JoyButton::DEFAULTWHEELX;
wheelSpeedY = GlobalVariables::JoyButton::DEFAULTWHEELY;
mouseMode = DEFAULTMOUSEMODE;
mouseCurve = DEFAULTMOUSECURVE;
springWidth = 0;
springHeight = 0;
sensitivity = 1.0;
setSelection = -1;
setSelectionCondition = SetChangeDisabled;
springWidth = GlobalVariables::JoyButton::DEFAULTSPRINGWIDTH;
springHeight = GlobalVariables::JoyButton::DEFAULTSPRINGHEIGHT;
sensitivity = GlobalVariables::JoyButton::DEFAULTSENSITIVITY;
setSelection = GlobalVariables::JoyButton::DEFAULTSETSELECTION;
setSelectionCondition = DEFAULTSETCONDITION;
m_ignoresets = false;
ignoreEvents = false;
whileHeldStatus = false;
buttonName.clear();
actionName.clear();
cycleResetActive = false;
cycleResetInterval = 0;
relativeSpring = false;
cycleResetActive = GlobalVariables::JoyButton::DEFAULTCYCLERESETACTIVE;
cycleResetInterval = GlobalVariables::JoyButton::DEFAULTCYCLERESET;
relativeSpring = GlobalVariables::JoyButton::DEFAULTRELATIVESPRING;
lastDistance = 0.0;
lastMouseDistance = 0.0;
currentMouseDistance = 0.0;
Expand Down
2 changes: 1 addition & 1 deletion src/joybutton.h
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ private slots:
maxMouseDistanceAccelThreshold = GlobalVariables::JoyButton::DEFAULTMAXACCELTHRESHOLD;
startAccelMultiplier = GlobalVariables::JoyButton::DEFAULTSTARTACCELMULTIPLIER;
accelDuration = GlobalVariables::JoyButton::DEFAULTACCELEASINGDURATION;
extraAccelCurve = LinearAccelCurve;
extraAccelCurve = DEFAULTEXTRAACCELCURVE;
}
}

Expand Down
14 changes: 11 additions & 3 deletions src/xml/inputdevicexml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,10 +664,18 @@ void InputDeviceXml::writeConfig(QXmlStreamWriter *xml)

xml->writeStartElement("sets");

QListIterator<SetJoystick*> setJoysList(m_inputDevice->getJoystick_sets().values());
QHash<int, SetJoystick*>::const_iterator i = m_inputDevice->getJoystick_sets().constBegin();

while (setJoysList.hasNext())
setJoysList.next()->writeConfig(xml);
while (i != m_inputDevice->getJoystick_sets().constEnd()) {
qDebug() << i.key() << Qt::endl;

if (!i.value()->isSetEmpty())
i.value()->writeConfig(xml);
else
qDebug() << "Set is empty";

++i;
}

xml->writeEndElement();
xml->writeEndElement();
Expand Down
24 changes: 18 additions & 6 deletions src/xml/joyaxisxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ bool JoyAxisXml::readMainConfig(QXmlStreamReader *xml)
QString temptext = xml->readElementText();
int tempchoice = temptext.toInt();

qDebug() << "From xml config dead zone is: " << tempchoice;
#ifndef QT_DEBUG_NO_OUTPUT
qDebug() << "From xml config dead zone is: " << tempchoice;
#endif

m_joyAxis->setDeadZone(tempchoice);
}
Expand All @@ -146,7 +148,9 @@ bool JoyAxisXml::readMainConfig(QXmlStreamReader *xml)
QString temptext = xml->readElementText();
int tempchoice = temptext.toInt();

qDebug() << "From xml config max zone is: " << tempchoice;
#ifndef QT_DEBUG_NO_OUTPUT
qDebug() << "From xml config max zone is: " << tempchoice;
#endif

m_joyAxis->setMaxZoneValue(tempchoice);
}
Expand All @@ -156,7 +160,9 @@ bool JoyAxisXml::readMainConfig(QXmlStreamReader *xml)
QString temptext = xml->readElementText();
int tempchoice = temptext.toInt();

qDebug() << "From xml config center value is: " << tempchoice;
#ifndef QT_DEBUG_NO_OUTPUT
qDebug() << "From xml config center value is: " << tempchoice;
#endif

m_joyAxis->setAxisCenterCal(tempchoice);
}
Expand All @@ -166,7 +172,9 @@ bool JoyAxisXml::readMainConfig(QXmlStreamReader *xml)
QString temptext = xml->readElementText();
int tempchoice = temptext.toInt();

qDebug() << "From xml config min value is: " << tempchoice;
#ifndef QT_DEBUG_NO_OUTPUT
qDebug() << "From xml config min value is: " << tempchoice;
#endif

m_joyAxis->setAxisMinCal(tempchoice);
}
Expand All @@ -177,7 +185,9 @@ bool JoyAxisXml::readMainConfig(QXmlStreamReader *xml)
QString temptext = xml->readElementText();
int tempchoice = temptext.toInt();

qDebug() << "From xml config max value is: " << tempchoice;
#ifndef QT_DEBUG_NO_OUTPUT
qDebug() << "From xml config max value is: " << tempchoice;
#endif

m_joyAxis->setAxisMaxCal(tempchoice);
}
Expand All @@ -186,7 +196,9 @@ bool JoyAxisXml::readMainConfig(QXmlStreamReader *xml)
found = true;
QString temptext = xml->readElementText();

qDebug() << "From xml config throttle name is: " << temptext;
#ifndef QT_DEBUG_NO_OUTPUT
qDebug() << "From xml config throttle name is: " << temptext;
#endif

if (temptext == "negativehalf")
{
Expand Down
Loading

0 comments on commit 8a0dc3d

Please sign in to comment.