Fixed an issue where controllers were sometimes not added correctly when there was a mix of supported and unsupported devices present

This commit is contained in:
Leon Styhre 2024-01-08 21:25:33 +01:00
parent 2356bd248f
commit 39bb28e353

View file

@ -110,12 +110,10 @@ void InputManager::init()
int numJoysticks {SDL_NumJoysticks()};
// Make sure that every joystick is actually supported by the GameController API.
for (int i {0}; i < numJoysticks; ++i)
if (!SDL_IsGameController(i))
--numJoysticks;
for (int i {0}; i < numJoysticks; ++i)
addControllerByDeviceIndex(nullptr, i);
for (int i {0}; i < numJoysticks; ++i) {
if (SDL_IsGameController(i))
addControllerByDeviceIndex(nullptr, i);
}
SDL_USER_CECBUTTONDOWN = SDL_RegisterEvents(2);
SDL_USER_CECBUTTONUP = SDL_USER_CECBUTTONDOWN + 1;