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
This commit is contained in:
Sam Lantinga 2016-11-29 05:34:20 -08:00
parent 5220759f03
commit 1e8f074c43
7 changed files with 41 additions and 3 deletions

10
configure vendored
View File

@ -21578,6 +21578,16 @@ fi
$as_echo "#define HAVE_LIBUDEV_H 1" >>confdefs.h $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
fi fi
} }

View File

@ -2231,6 +2231,12 @@ AC_HELP_STRING([--enable-libudev], [enable libudev support [[default=yes]]]),
have_libudev_h_hdr=no) have_libudev_h_hdr=no)
if test x$have_libudev_h_hdr = xyes; then if test x$have_libudev_h_hdr = xyes; then
AC_DEFINE(HAVE_LIBUDEV_H, 1, [ ]) 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
fi fi
} }

View File

@ -360,4 +360,7 @@
/* Enable ime support */ /* Enable ime support */
#undef SDL_USE_IME #undef SDL_USE_IME
/* Enable dynamic udev support */
#undef SDL_UDEV_DYNAMIC
#endif /* SDL_config_h_ */ #endif /* SDL_config_h_ */

View File

@ -237,3 +237,5 @@ SDL_DBus_ScreensaverInhibit(SDL_bool inhibit)
} }
} }
#endif #endif
/* vi: set ts=4 sw=4 expandtab: */

View File

@ -680,3 +680,5 @@ SDL_IBus_PumpEvents(void)
} }
#endif #endif
/* vi: set ts=4 sw=4 expandtab: */

View File

@ -136,3 +136,5 @@ SDL_IME_PumpEvents()
if (SDL_IME_PumpEvents_Real) if (SDL_IME_PumpEvents_Real)
SDL_IME_PumpEvents_Real(); SDL_IME_PumpEvents_Real();
} }
/* vi: set ts=4 sw=4 expandtab: */

View File

@ -33,7 +33,14 @@
#include "SDL.h" #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 #define _THIS SDL_UDEV_PrivateData *_this
static _THIS = NULL; static _THIS = NULL;
@ -253,6 +260,10 @@ SDL_UDEV_LoadLibrary(void)
return SDL_SetError("UDEV not initialized"); 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) { if (_this->udev_handle == NULL) {
for( i = 0 ; i < SDL_arraysize(SDL_UDEV_LIBS); i++) { for( i = 0 ; i < SDL_arraysize(SDL_UDEV_LIBS); i++) {
@ -536,3 +547,5 @@ SDL_UDEV_DelCallback(SDL_UDEV_Callback cb)
#endif /* SDL_USE_LIBUDEV */ #endif /* SDL_USE_LIBUDEV */
/* vi: set ts=4 sw=4 expandtab: */