1
0
forked from Clones/Controlify

🐛 Fix crash when discovering controllers without SDL

This commit is contained in:
isXander
2023-09-26 23:05:00 +01:00
parent 291975505d
commit 33dd5729ff

View File

@ -434,6 +434,7 @@ public class Controlify implements ControlifyApi {
Log.LOGGER.error("GLFW failed to load gamepad mappings!"); Log.LOGGER.error("GLFW failed to load gamepad mappings!");
} }
if (SDL2NativesManager.isLoaded()) {
try (Memory memory = new Memory(bytes.length)) { try (Memory memory = new Memory(bytes.length)) {
memory.write(0, bytes, 0, bytes.length); memory.write(0, bytes, 0, bytes.length);
SDL_RWops rw = SDL_RWFromConstMem(memory, (int) memory.size()); SDL_RWops rw = SDL_RWFromConstMem(memory, (int) memory.size());
@ -442,7 +443,8 @@ public class Controlify implements ControlifyApi {
Log.LOGGER.error("SDL2 failed to load gamepad mappings!"); Log.LOGGER.error("SDL2 failed to load gamepad mappings!");
} }
} }
} catch (Exception e) { }
} catch (Throwable e) {
Log.LOGGER.error("Failed to load gamecontrollerdb.txt", e); Log.LOGGER.error("Failed to load gamecontrollerdb.txt", e);
} }
} }