From 39bb28e353461ee9e462ffc15f09f0bd0834b084 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Mon, 8 Jan 2024 21:25:33 +0100 Subject: [PATCH] Fixed an issue where controllers were sometimes not added correctly when there was a mix of supported and unsupported devices present --- es-core/src/InputManager.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/es-core/src/InputManager.cpp b/es-core/src/InputManager.cpp index a830a1bf5..127ea996d 100644 --- a/es-core/src/InputManager.cpp +++ b/es-core/src/InputManager.cpp @@ -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;