mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-07 11:58:12 +00:00
Don't fail joystick initialization if udev isn't available
(cherry picked from commit 5fff9bc1e3
)
This commit is contained in:
@@ -1036,21 +1036,24 @@ static int LINUX_JoystickInit(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (enumeration_method == ENUMERATION_LIBUDEV) {
|
if (enumeration_method == ENUMERATION_LIBUDEV) {
|
||||||
if (SDL_UDEV_Init() < 0) {
|
if (SDL_UDEV_Init() == 0) {
|
||||||
return SDL_SetError("Could not initialize UDEV");
|
/* Set up the udev callback */
|
||||||
}
|
if (SDL_UDEV_AddCallback(joystick_udev_callback) < 0) {
|
||||||
|
SDL_UDEV_Quit();
|
||||||
|
return SDL_SetError("Could not set up joystick <-> udev callback");
|
||||||
|
}
|
||||||
|
|
||||||
/* Set up the udev callback */
|
/* Force a scan to build the initial device list */
|
||||||
if (SDL_UDEV_AddCallback(joystick_udev_callback) < 0) {
|
SDL_UDEV_Scan();
|
||||||
SDL_UDEV_Quit();
|
} else {
|
||||||
return SDL_SetError("Could not set up joystick <-> udev callback");
|
SDL_LogDebug(SDL_LOG_CATEGORY_INPUT,
|
||||||
|
"udev init failed, disabling udev integration");
|
||||||
|
enumeration_method = ENUMERATION_FALLBACK;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/* Force a scan to build the initial device list */
|
|
||||||
SDL_UDEV_Scan();
|
|
||||||
} else
|
|
||||||
#endif
|
#endif
|
||||||
{
|
|
||||||
|
if (enumeration_method != ENUMERATION_LIBUDEV) {
|
||||||
#if defined(HAVE_INOTIFY)
|
#if defined(HAVE_INOTIFY)
|
||||||
inotify_fd = SDL_inotify_init1();
|
inotify_fd = SDL_inotify_init1();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user