mirror of https://github.com/mgba-emu/mgba.git
Qt: Fix some controllers with multiple players (e.g. Mayflash GC adapter) getting duplicated
This commit is contained in:
parent
0a57aca1a5
commit
f394c51a75
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue