forked from Clones/Controlify
🐛 Catch errors with controller detection, so they still load on failure
This commit is contained in:
@ -116,7 +116,7 @@ public class Controlify implements ControlifyApi {
|
|||||||
this.onControllerDisconnect(jid);
|
this.onControllerDisconnect(jid);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (Exception e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -203,7 +203,7 @@ public class Controlify implements ControlifyApi {
|
|||||||
FabricLoader.getInstance().getEntrypoints("controlify", ControlifyEntrypoint.class).forEach(entrypoint -> {
|
FabricLoader.getInstance().getEntrypoints("controlify", ControlifyEntrypoint.class).forEach(entrypoint -> {
|
||||||
try {
|
try {
|
||||||
entrypoint.onControllersDiscovered(this);
|
entrypoint.onControllersDiscovered(this);
|
||||||
} catch (Exception e) {
|
} catch (Throwable e) {
|
||||||
Log.LOGGER.error("Failed to run `onControllersDiscovered` on Controlify entrypoint: " + entrypoint.getClass().getName(), e);
|
Log.LOGGER.error("Failed to run `onControllersDiscovered` on Controlify entrypoint: " + entrypoint.getClass().getName(), e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -48,13 +48,21 @@ public class ControllerHIDService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ControllerHIDInfo fetchType(int jid) {
|
public ControllerHIDInfo fetchType(int jid) {
|
||||||
ControllerHIDInfo info = fetchType0(jid);
|
ControllerHIDInfo info;
|
||||||
|
try {
|
||||||
|
info = fetchType0(jid);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
Log.LOGGER.error("Failed to fetch controller type!", e);
|
||||||
|
info = new ControllerHIDInfo(ControllerType.UNKNOWN, Optional.empty());
|
||||||
|
}
|
||||||
|
|
||||||
if (DebugProperties.PRINT_VID_PID) {
|
if (DebugProperties.PRINT_VID_PID) {
|
||||||
info.hidDevice.ifPresent(hid -> {
|
info.hidDevice.ifPresent(hid -> {
|
||||||
var hex = HexFormat.of().withPrefix("0x");
|
var hex = HexFormat.of().withPrefix("0x");
|
||||||
Log.LOGGER.info("VID: {}, PID: {}", hex.toHexDigits(hid.vendorID()), hex.toHexDigits(hid.productID()));
|
Log.LOGGER.info("VID: {}, PID: {}", hex.toHexDigits(hid.vendorID()), hex.toHexDigits(hid.productID()));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user