diff --git a/src/platform/qt/input/SDLInputDriver.cpp b/src/platform/qt/input/SDLInputDriver.cpp index 620602f03..792c84834 100644 --- a/src/platform/qt/input/SDLInputDriver.cpp +++ b/src/platform/qt/input/SDLInputDriver.cpp @@ -249,6 +249,7 @@ SDLGamepad::SDLGamepad(SDLInputDriver* driver, int index, QObject* parent) #if SDL_VERSION_ATLEAST(2, 0, 0) SDL_Joystick* joystick = SDL_JoystickListGetPointer(&s_sdlEvents.joysticks, m_index)->joystick; SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(joystick), m_guid, sizeof(m_guid)); + m_id = SDL_JoystickInstanceID(joystick); #endif } @@ -395,11 +396,10 @@ QString SDLGamepad::visibleName() const { #if SDL_VERSION_ATLEAST(2, 0, 0) bool SDLGamepad::updateIndex() { - char guid[34]; for (size_t i = 0; i < SDL_JoystickListSize(&s_sdlEvents.joysticks); ++i) { SDL_Joystick* joystick = SDL_JoystickListGetPointer(&s_sdlEvents.joysticks, i)->joystick; - SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(joystick), guid, sizeof(guid)); - if (memcmp(guid, m_guid, 33) == 0) { + SDL_JoystickID id = SDL_JoystickInstanceID(joystick); + if (id == m_id) { m_index = i; return true; } diff --git a/src/platform/qt/input/SDLInputDriver.h b/src/platform/qt/input/SDLInputDriver.h index 217dc40a7..70c7eed17 100644 --- a/src/platform/qt/input/SDLInputDriver.h +++ b/src/platform/qt/input/SDLInputDriver.h @@ -109,6 +109,7 @@ private: size_t m_index; #if SDL_VERSION_ATLEAST(2, 0, 0) char m_guid[34]{}; + SDL_JoystickID m_id; #endif bool verify() const;