diff --git a/interface/src/devices/JoystickManager.cpp b/interface/src/devices/JoystickManager.cpp index da3c1834af..6b8fd9563f 100644 --- a/interface/src/devices/JoystickManager.cpp +++ b/interface/src/devices/JoystickManager.cpp @@ -44,10 +44,16 @@ JoystickManager::~JoystickManager() { #endif } +QVector JoystickManager::getJoystickStates() { + QMutexLocker locker(&_joystickMutex); + return _joystickStates; +} + void JoystickManager::update() { #ifdef HAVE_SDL SDL_JoystickUpdate(); + QMutexLocker locker(&_joystickMutex); for (int i = 0; i < _joystickStates.size(); i++) { SDL_Joystick* joystick = _joysticks.at(i); JoystickState& state = _joystickStates[i]; diff --git a/interface/src/devices/JoystickManager.h b/interface/src/devices/JoystickManager.h index 53a255e129..1979cf0205 100644 --- a/interface/src/devices/JoystickManager.h +++ b/interface/src/devices/JoystickManager.h @@ -12,6 +12,7 @@ #ifndef hifi_JoystickManager_h #define hifi_JoystickManager_h +#include #include #include @@ -31,12 +32,13 @@ public: JoystickManager(); virtual ~JoystickManager(); - const QVector& getJoystickStates() const { return _joystickStates; } + QVector getJoystickStates(); void update(); private: QVector _joystickStates; + QMutex _joystickMutex; #ifdef HAVE_SDL QVector _joysticks;