Fixed enabling udev hotplug detection on Linux

This commit is contained in:
Sam Lantinga 2021-12-15 10:39:42 -08:00
parent 60c3ca49b4
commit 67c4b99639
1 changed files with 20 additions and 0 deletions

View File

@ -1011,6 +1011,26 @@ int SDL_hid_init(void)
return 0;
}
#if defined(SDL_USE_LIBUDEV)
if (SDL_getenv("SDL_HIDAPI_JOYSTICK_DISABLE_UDEV") != NULL) {
SDL_LogDebug(SDL_LOG_CATEGORY_INPUT,
"udev disabled by SDL_HIDAPI_JOYSTICK_DISABLE_UDEV");
linux_enumeration_method = ENUMERATION_FALLBACK;
} else if (access("/.flatpak-info", F_OK) == 0
|| access("/run/host/container-manager", F_OK) == 0) {
/* Explicitly check `/.flatpak-info` because, for old versions of
* Flatpak, this was the only available way to tell if we were in
* a Flatpak container. */
SDL_LogDebug(SDL_LOG_CATEGORY_INPUT,
"Container detected, disabling HIDAPI udev integration");
linux_enumeration_method = ENUMERATION_FALLBACK;
} else {
SDL_LogDebug(SDL_LOG_CATEGORY_INPUT,
"Using udev for HIDAPI joystick device discovery");
linux_enumeration_method = ENUMERATION_LIBUDEV;
}
#endif
#ifdef SDL_LIBUSB_DYNAMIC
++attempts;
libusb_ctx.libhandle = SDL_LoadObject(SDL_LIBUSB_DYNAMIC);