mirror of https://github.com/encounter/SDL.git
Don't use udev for joystick enumeration if running in a container
If we are running in a container, like Flatpak[1] or pressure-vessel[2], it's likely that we are using user namespaces, therefore udev event notification via netlink won't work reliably. Use their filesystem API to detect them and automatically fallback to the inotify-based enumeration. [1] <https://flatpak.org/> [2] <https://gitlab.steamos.cloud/steamrt/steam-runtime-tools/-/tree/master/pressure-vessel> Signed-off-by: Ludovico de Nittis <ludovico.denittis@collabora.com>
This commit is contained in:
parent
2c3269152a
commit
8d43f45a7b
|
@ -740,6 +740,14 @@ HIDAPI_JoystickInit(void)
|
||||||
SDL_LogDebug(SDL_LOG_CATEGORY_INPUT,
|
SDL_LogDebug(SDL_LOG_CATEGORY_INPUT,
|
||||||
"udev disabled by SDL_HIDAPI_JOYSTICK_DISABLE_UDEV");
|
"udev disabled by SDL_HIDAPI_JOYSTICK_DISABLE_UDEV");
|
||||||
linux_enumeration_method = ENUMERATION_FALLBACK;
|
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 {
|
} else {
|
||||||
SDL_LogDebug(SDL_LOG_CATEGORY_INPUT,
|
SDL_LogDebug(SDL_LOG_CATEGORY_INPUT,
|
||||||
"Using udev for HIDAPI joystick device discovery");
|
"Using udev for HIDAPI joystick device discovery");
|
||||||
|
|
|
@ -658,7 +658,10 @@ LINUX_JoystickInit(void)
|
||||||
enumeration_method = ENUMERATION_FALLBACK;
|
enumeration_method = ENUMERATION_FALLBACK;
|
||||||
}
|
}
|
||||||
else if (access("/.flatpak-info", F_OK) == 0
|
else if (access("/.flatpak-info", F_OK) == 0
|
||||||
|| access("/run/pressure-vessel", 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,
|
SDL_LogDebug(SDL_LOG_CATEGORY_INPUT,
|
||||||
"Container detected, disabling udev integration");
|
"Container detected, disabling udev integration");
|
||||||
enumeration_method = ENUMERATION_FALLBACK;
|
enumeration_method = ENUMERATION_FALLBACK;
|
||||||
|
|
Loading…
Reference in New Issue