v2.1.1: added some safety checks for controllers failing to initialize
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user