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

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