Better check for SDL gamepad detection

This commit is contained in:
SimoneN64
2023-03-19 15:18:09 +01:00
parent 8b29b442ca
commit f2e0bda841

View File

@@ -27,7 +27,12 @@ void App::Run() {
case SDL_CONTROLLERDEVICEADDED: {
const int index = event.cdevice.which;
si.pif.gamepad = SDL_GameControllerOpen(index);
si.pif.gamepadConnected = false;
if (!si.pif.gamepad) {
Util::warn("[WARN]: Could not initialize gamepad: {}\n", SDL_GetError());
} else {
si.pif.gamepadConnected = true;
}
} break;
case SDL_CONTROLLERDEVICEREMOVED:
SDL_GameControllerClose(si.pif.gamepad);