Skip to content
Permalink
Browse files

Avoid conflicts with multiple versions of udev by first trying the li…

…brary 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
  • Loading branch information
slouken committed Nov 29, 2016
1 parent 5220759 commit 1e8f074c4339ca8fbdec4f77042dc04420e29775
Showing with 41 additions and 3 deletions.
  1. +10 −0 configure
  2. +6 −0 configure.in
  3. +3 −0 include/SDL_config.h.in
  4. +2 −0 src/core/linux/SDL_dbus.c
  5. +2 −0 src/core/linux/SDL_ibus.c
  6. +2 −0 src/core/linux/SDL_ime.c
  7. +16 −3 src/core/linux/SDL_udev.c

$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
}
@@ -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
}
@@ -360,4 +360,7 @@
/* Enable ime support */
#undef SDL_USE_IME

/* Enable dynamic udev support */
#undef SDL_UDEV_DYNAMIC

#endif /* SDL_config_h_ */
@@ -237,3 +237,5 @@ SDL_DBus_ScreensaverInhibit(SDL_bool inhibit)
}
}
#endif

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

#endif

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

/* vi: set ts=4 sw=4 expandtab: */
@@ -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: */

0 comments on commit 1e8f074

Please sign in to comment.