1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-06-08 09:31:58 +00:00

Attempt to fix joystick enabled/disabled state

This commit is contained in:
fgenesis 2016-07-19 02:45:56 +02:00
parent bff072039a
commit 3de004262b
4 changed files with 10 additions and 5 deletions

View file

@ -554,11 +554,11 @@ protected:
void modifyDt(float &dt); void modifyDt(float &dt);
void fixupJoysticks();
virtual void onJoystickAdded(int deviceID); virtual void onJoystickAdded(int deviceID);
virtual void onJoystickRemoved(int instanceID); virtual void onJoystickRemoved(int instanceID);
public: public:
void fixupJoysticks();
void initActionButtons(); void initActionButtons();
void importActionButtons(); void importActionButtons();
}; };

View file

@ -595,10 +595,9 @@ void UserSettings::apply()
j->deadZone1 = as.joycfg.s1dead; j->deadZone1 = as.joycfg.s1dead;
j->deadZone2 = as.joycfg.s2dead; j->deadZone2 = as.joycfg.s2dead;
} }
as.updateJoystick();
} }
dsq->initActionButtons(); dsq->initActionButtons();
dsq->fixupJoysticks();
core->debugLogActive = system.debugLogOn; core->debugLogActive = system.debugLogOn;

View file

@ -122,9 +122,13 @@ void ActionSet::updateJoystick()
if(reassign) if(reassign)
assignJoystickByName(true); assignJoystickByName(true);
// Enable joystick if used by this ActionSet.
// There might be other ActionSets that are also set to this
// joystick but disabled, so we can't just do
// j->setEnabled(enabled) here.
Joystick *j = core->getJoystick(joystickID); Joystick *j = core->getJoystick(joystickID);
if(j) if(j && enabled)
j->setEnabled(enabled); j->setEnabled(true);
} }
ActionInput *ActionSet::getActionInputByName(const std::string &name) ActionInput *ActionSet::getActionInputByName(const std::string &name)

View file

@ -52,6 +52,8 @@ public:
void clearActions(); void clearActions();
int assignJoystickByName(bool force); // -1 if no such joystick found int assignJoystickByName(bool force); // -1 if no such joystick found
void assignJoystickIdx(int idx, bool updateValues); void assignJoystickIdx(int idx, bool updateValues);
// note: this only ENABLES joysticks if they are needed, but never disables any
void updateJoystick(); void updateJoystick();
ActionInput *addActionInput(const std::string &name); ActionInput *addActionInput(const std::string &name);