joystick: Don't use udev in Flatpak or pressure-vessel container Flatpak[1] and pressure-vessel[2] are known to use user namespaces, therefore udev event notification via netlink won't work reliably. Both frameworks provide a filesystem API that libraries can use to detect them. Do that, and automatically fall back from udev-based device discovery to the inotify-based fallback introduced in Bug #5337. [1] <https://flatpak.org/> [2] <https://gitlab.steamos.cloud/steamrt/steam-runtime-tools/-/tree/master/pressure-vessel> Signed-off-by: Simon McVittie <smcv@collabora.com>
diff --git a/src/joystick/linux/SDL_sysjoystick.c b/src/joystick/linux/SDL_sysjoystick.c
index 12832be..9350958 100644
--- a/src/joystick/linux/SDL_sysjoystick.c
+++ b/src/joystick/linux/SDL_sysjoystick.c
@@ -635,9 +635,19 @@ LINUX_JoystickInit(void)
#if SDL_USE_LIBUDEV
if (enumeration_method == ENUMERATION_UNSET) {
if (SDL_getenv("SDL_JOYSTICK_DISABLE_UDEV") != NULL) {
+ SDL_LogDebug(SDL_LOG_CATEGORY_INPUT,
+ "udev disabled by SDL_JOYSTICK_DISABLE_UDEV");
+ enumeration_method = ENUMERATION_FALLBACK;
+ }
+ else if (access("/.flatpak-info", F_OK) == 0
+ || access("/run/pressure-vessel", F_OK) == 0) {
+ SDL_LogDebug(SDL_LOG_CATEGORY_INPUT,
+ "Container detected, disabling udev integration");
enumeration_method = ENUMERATION_FALLBACK;
}
else {
+ SDL_LogDebug(SDL_LOG_CATEGORY_INPUT,
+ "Using udev for joystick device discovery");
enumeration_method = ENUMERATION_LIBUDEV;
}
}