Avoid conflicts with multiple versions of udev by first trying the library that is linked with the executable, if any, and then picking the one that is in the build environment. This fixes joystick detection for applications using the Steam Linux Runtime
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
diff --git a/configure b/configure
index 08e73c5..173b9e7 100755
--- a/configure
+++ b/configure
@@ -21578,6 +21578,16 @@ fi
$as_echo "#define HAVE_LIBUDEV_H 1" >>confdefs.h
+
+ udev_lib=`find_lib "libudev.so.*" "" | sed 's/.*\/\(.*\)/\1/; q'`
+ if test x$udev_lib != x; then
+ echo "-- dynamic udev -> $udev_lib"
+
+cat >>confdefs.h <<_ACEOF
+#define SDL_UDEV_DYNAMIC "$udev_lib"
+_ACEOF
+
+ fi
fi
fi
}
diff --git a/configure.in b/configure.in
index 801d2f1..bf67b0a 100644
--- a/configure.in
+++ b/configure.in
@@ -2231,6 +2231,12 @@ AC_HELP_STRING([--enable-libudev], [enable libudev support [[default=yes]]]),
have_libudev_h_hdr=no)
if test x$have_libudev_h_hdr = xyes; then
AC_DEFINE(HAVE_LIBUDEV_H, 1, [ ])
+
+ udev_lib=[`find_lib "libudev.so.*" "" | sed 's/.*\/\(.*\)/\1/; q'`]
+ if test x$udev_lib != x; then
+ echo "-- dynamic udev -> $udev_lib"
+ AC_DEFINE_UNQUOTED(SDL_UDEV_DYNAMIC, "$udev_lib", [ ])
+ fi
fi
fi
}
diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in
index 850866a..f953cb0 100644
--- a/include/SDL_config.h.in
+++ b/include/SDL_config.h.in
@@ -360,4 +360,7 @@
/* Enable ime support */
#undef SDL_USE_IME
+/* Enable dynamic udev support */
+#undef SDL_UDEV_DYNAMIC
+
#endif /* SDL_config_h_ */
diff --git a/src/core/linux/SDL_dbus.c b/src/core/linux/SDL_dbus.c
index ab73ca1..332113d 100644
--- a/src/core/linux/SDL_dbus.c
+++ b/src/core/linux/SDL_dbus.c
@@ -237,3 +237,5 @@ SDL_DBus_ScreensaverInhibit(SDL_bool inhibit)
}
}
#endif
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/core/linux/SDL_ibus.c b/src/core/linux/SDL_ibus.c
index 3d63b8b..33ef6ac 100644
--- a/src/core/linux/SDL_ibus.c
+++ b/src/core/linux/SDL_ibus.c
@@ -680,3 +680,5 @@ SDL_IBus_PumpEvents(void)
}
#endif
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/core/linux/SDL_ime.c b/src/core/linux/SDL_ime.c
index 049bd6e..4809b24 100644
--- a/src/core/linux/SDL_ime.c
+++ b/src/core/linux/SDL_ime.c
@@ -136,3 +136,5 @@ SDL_IME_PumpEvents()
if (SDL_IME_PumpEvents_Real)
SDL_IME_PumpEvents_Real();
}
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/core/linux/SDL_udev.c b/src/core/linux/SDL_udev.c
index 351ecf3..a0b168d 100644
--- a/src/core/linux/SDL_udev.c
+++ b/src/core/linux/SDL_udev.c
@@ -33,7 +33,14 @@
#include "SDL.h"
-static const char* SDL_UDEV_LIBS[] = { "libudev.so.1", "libudev.so.0" };
+static const char *SDL_UDEV_LIBS[] = {
+#ifdef SDL_UDEV_DYNAMIC
+ SDL_UDEV_DYNAMIC
+#else
+ "libudev.so.1",
+ "libudev.so.0"
+#endif
+};
#define _THIS SDL_UDEV_PrivateData *_this
static _THIS = NULL;
@@ -252,8 +259,12 @@ SDL_UDEV_LoadLibrary(void)
if (_this == NULL) {
return SDL_SetError("UDEV not initialized");
}
-
-
+
+ /* See if there is a udev library already loaded */
+ if (SDL_UDEV_load_syms() == 0) {
+ return 0;
+ }
+
if (_this->udev_handle == NULL) {
for( i = 0 ; i < SDL_arraysize(SDL_UDEV_LIBS); i++) {
_this->udev_handle = SDL_LoadObject(SDL_UDEV_LIBS[i]);
@@ -536,3 +547,5 @@ SDL_UDEV_DelCallback(SDL_UDEV_Callback cb)
#endif /* SDL_USE_LIBUDEV */
+
+/* vi: set ts=4 sw=4 expandtab: */