v2.1.1: added some safety checks for controllers failing to initialize

This commit is contained in:
Evan Debenham
2023-06-07 13:01:34 -04:00
parent 744fa70ee1
commit e9ccd7929b

View File

@@ -59,10 +59,25 @@ public class ControllerHandler implements ControllerListener {
}
}
private static boolean initialized = false;
private static boolean failedInit = false;
public static boolean controllersSupported() {
if (DeviceCompat.isAndroid() && Gdx.app.getVersion() < 16) {
return false;
} else if (failedInit) {
return false;
} else if (initialized){
return true;
} else {
try {
//we do this to call Controllers.initialize(), which can fail in certain cases
// e.g. missing natives on very old 32-bit desktop platforms
Controllers.getCurrent();
initialized = true;
} catch (Exception e){
failedInit = true;
}
return true;
}
}