Check pkg-config for libudev and enable gamepad code only if found. Linux only for now

This commit is contained in:
hondres 2015-12-21 22:39:03 +01:00
parent 1bc91848e3
commit 541c9039c5
5 changed files with 18 additions and 12 deletions

View File

@ -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"):

View File

@ -28,7 +28,7 @@
/*************************************************************************/
//author: Andreas Haas <hondres, liugam3@gmail.com>
#ifdef __linux__
#ifdef JOYDEV_ENABLED
#include "joystick_linux.h"
#include "print_string.h"

View File

@ -30,7 +30,7 @@
//author: Andreas Haas <hondres, liugam3@gmail.com>
#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"

View File

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

View File

@ -126,7 +126,7 @@ class OS_X11 : public OS_Unix {
InputDefault *input;
#ifdef __linux__
#ifdef JOYDEV_ENABLED
joystick_linux *joystick;
#endif