forked from Clones/Controlify
🐛 Fix hotplugging controllers when no controllers were connected on startup
This commit is contained in:
@ -99,6 +99,8 @@ public class Controlify implements ControlifyApi {
|
||||
}
|
||||
}
|
||||
|
||||
ClientTickEvents.START_CLIENT_TICK.register(this::tick);
|
||||
|
||||
// listen for new controllers
|
||||
GLFW.glfwSetJoystickCallback((jid, event) -> {
|
||||
try {
|
||||
@ -119,7 +121,11 @@ public class Controlify implements ControlifyApi {
|
||||
if (nativeOnboardingFuture != null) return nativeOnboardingFuture;
|
||||
|
||||
if (config().globalSettings().vibrationOnboarded) {
|
||||
return CompletableFuture.completedFuture(config().globalSettings().loadVibrationNatives);
|
||||
boolean loadNatives = config().globalSettings().loadVibrationNatives;
|
||||
if (loadNatives && !SDL2NativesManager.isInitialised()) {
|
||||
SDL2NativesManager.initialise();
|
||||
}
|
||||
return CompletableFuture.completedFuture(loadNatives);
|
||||
}
|
||||
|
||||
nativeOnboardingFuture = new CompletableFuture<>();
|
||||
@ -180,8 +186,6 @@ public class Controlify implements ControlifyApi {
|
||||
config().saveIfDirty();
|
||||
}
|
||||
|
||||
ClientTickEvents.START_CLIENT_TICK.register(this::tick);
|
||||
|
||||
FabricLoader.getInstance().getEntrypoints("controlify", ControlifyEntrypoint.class).forEach(entrypoint -> {
|
||||
try {
|
||||
entrypoint.onControllersDiscovered(this);
|
||||
|
@ -31,9 +31,11 @@ public class SDL2NativesManager {
|
||||
private static final String NATIVE_LIBRARY_URL = "https://maven.isxander.dev/releases/dev/isxander/sdl2-jni-natives/%s/".formatted(SDL2_VERSION);
|
||||
|
||||
private static boolean loaded = false;
|
||||
private static boolean initialised = false;
|
||||
|
||||
public static void initialise() {
|
||||
if (loaded) return;
|
||||
if (initialised) return;
|
||||
initialised = true;
|
||||
|
||||
DebugLog.log("Initialising SDL2 native library");
|
||||
|
||||
@ -124,6 +126,10 @@ public class SDL2NativesManager {
|
||||
return loaded;
|
||||
}
|
||||
|
||||
public static boolean isInitialised() {
|
||||
return initialised;
|
||||
}
|
||||
|
||||
private record Target(Util.OS os, boolean is64Bit, boolean isARM) {
|
||||
public static final Target CURRENT = Util.make(() -> {
|
||||
Util.OS os = Util.getPlatform();
|
||||
|
Reference in New Issue
Block a user