Skip to content

Commit

Permalink
Avoid conflicts with multiple versions of udev by first trying the li…
Browse files Browse the repository at this point in the history
…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 1e8f074
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 3 deletions.
10 changes: 10 additions & 0 deletions configure
Expand Up @@ -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
}
Expand Down
6 changes: 6 additions & 0 deletions configure.in
Expand Up @@ -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
}
Expand Down
3 changes: 3 additions & 0 deletions include/SDL_config.h.in
Expand Up @@ -360,4 +360,7 @@
/* Enable ime support */
#undef SDL_USE_IME

/* Enable dynamic udev support */
#undef SDL_UDEV_DYNAMIC

#endif /* SDL_config_h_ */
2 changes: 2 additions & 0 deletions src/core/linux/SDL_dbus.c
Expand Up @@ -237,3 +237,5 @@ SDL_DBus_ScreensaverInhibit(SDL_bool inhibit)
}
}
#endif

/* vi: set ts=4 sw=4 expandtab: */
2 changes: 2 additions & 0 deletions src/core/linux/SDL_ibus.c
Expand Up @@ -680,3 +680,5 @@ SDL_IBus_PumpEvents(void)
}

#endif

/* vi: set ts=4 sw=4 expandtab: */
2 changes: 2 additions & 0 deletions src/core/linux/SDL_ime.c
Expand Up @@ -136,3 +136,5 @@ SDL_IME_PumpEvents()
if (SDL_IME_PumpEvents_Real)
SDL_IME_PumpEvents_Real();
}

/* vi: set ts=4 sw=4 expandtab: */
19 changes: 16 additions & 3 deletions src/core/linux/SDL_udev.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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]);
Expand Down Expand Up @@ -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.