1
0
forked from Clones/Controlify

🐛 Catch errors with controller detection, so they still load on failure

This commit is contained in:
isXander
2023-08-06 23:28:04 +01:00
parent 2069f1ab6d
commit 372cfa69c3
2 changed files with 11 additions and 3 deletions

View File

@ -48,13 +48,21 @@ public class ControllerHIDService {
}
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) {
info.hidDevice.ifPresent(hid -> {
var hex = HexFormat.of().withPrefix("0x");
Log.LOGGER.info("VID: {}, PID: {}", hex.toHexDigits(hid.vendorID()), hex.toHexDigits(hid.productID()));
});
}
return info;
}