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
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
}

View file

@ -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
}

View file

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

View file

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

View file

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

View file

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

View file

@ -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: */