Better check for SDL gamepad detection
This commit is contained in:
@@ -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 = true;
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user