From 541c9039c593e44afb86369c052ed846c42698bd Mon Sep 17 00:00:00 2001 From: hondres Date: Mon, 21 Dec 2015 22:39:03 +0100 Subject: [PATCH] Check pkg-config for libudev and enable gamepad code only if found. Linux only for now --- platform/x11/detect.py | 18 ++++++++++++------ platform/x11/joystick_linux.cpp | 2 +- platform/x11/joystick_linux.h | 2 +- platform/x11/os_x11.cpp | 6 +++--- platform/x11/os_x11.h | 2 +- 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/platform/x11/detect.py b/platform/x11/detect.py index c93905ed3c6..0226c8b8c06 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -45,10 +45,6 @@ def can_build(): print("xinerama not found.. x11 disabled.") return False - x11_error=os.system("pkg-config libevdev --modversion > /dev/null ") - if (x11_error): - print("evdev not found.. x11 disabled.") - return False return True # X11 enabled @@ -133,7 +129,6 @@ def configure(env): env.ParseConfig('pkg-config x11 --cflags --libs') env.ParseConfig('pkg-config xinerama --cflags --libs') env.ParseConfig('pkg-config xcursor --cflags --libs') - env.ParseConfig('pkg-config libevdev --cflags --libs') if (env["openssl"]=="yes"): env.ParseConfig('pkg-config openssl --cflags --libs') @@ -155,7 +150,18 @@ def configure(env): env.Append(CPPFLAGS=['-DOPENGL_ENABLED','-DGLEW_ENABLED']) if platform.system() == 'Linux': env.Append(CPPFLAGS=["-DALSA_ENABLED"]) - env.Append(LIBS=['asound', 'udev']) + env.Append(LIBS=['asound']) + + if not os.system("pkg-config --exists libudev"): + if not os.system("pkg-config --exists libevdev"): + print("Enabling udev/evdev") + env.Append(CPPFLAGS=["-DJOYDEV_ENABLED"]) + env.ParseConfig('pkg-config libudev --cflags --libs') + env.ParseConfig('pkg-config libevdev --cflags --libs') + else: + print("libevdev development libraries not found, disabling gamepad support") + else: + print("libudev development libraries not found, disabling gamepad support") if (env["pulseaudio"]=="yes"): if not os.system("pkg-config --exists libpulse-simple"): diff --git a/platform/x11/joystick_linux.cpp b/platform/x11/joystick_linux.cpp index e50916d2c2b..cc806f6f78b 100644 --- a/platform/x11/joystick_linux.cpp +++ b/platform/x11/joystick_linux.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ //author: Andreas Haas -#ifdef __linux__ +#ifdef JOYDEV_ENABLED #include "joystick_linux.h" #include "print_string.h" diff --git a/platform/x11/joystick_linux.h b/platform/x11/joystick_linux.h index 339a5f239d0..1064a6f8418 100644 --- a/platform/x11/joystick_linux.h +++ b/platform/x11/joystick_linux.h @@ -30,7 +30,7 @@ //author: Andreas Haas #ifndef JOYSTICK_LINUX_H #define JOYSTICK_LINUX_H -#ifdef __linux__ +#ifdef JOYDEV_ENABLED #include "main/input_default.h" #include "os/thread.h" #include "os/mutex.h" diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index d23994edd74..0afab6442b7 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -426,7 +426,7 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi physics_2d_server->init(); input = memnew( InputDefault ); -#ifdef __linux__ +#ifdef JOYDEV_ENABLED joystick = memnew( joystick_linux(input)); #endif _ensure_data_dir(); @@ -461,7 +461,7 @@ void OS_X11::finalize() { physics_2d_server->finish(); memdelete(physics_2d_server); -#ifdef __linux__ +#ifdef JOYDEV_ENABLED memdelete(joystick); #endif memdelete(input); @@ -1753,7 +1753,7 @@ void OS_X11::run() { while (!force_quit) { process_xevents(); // get rid of pending events -#ifdef __linux__ +#ifdef JOYDEV_ENABLED event_id = joystick->process_joysticks(event_id); #endif if (Main::iteration()==true) diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index 02518189e0e..eee3e401363 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -126,7 +126,7 @@ class OS_X11 : public OS_Unix { InputDefault *input; -#ifdef __linux__ +#ifdef JOYDEV_ENABLED joystick_linux *joystick; #endif