Browse Source

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

hondres 9 years ago
parent
commit
541c9039c5

+ 12 - 6
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"):

+ 1 - 1
platform/x11/joystick_linux.cpp

@@ -28,7 +28,7 @@
 /*************************************************************************/
 
 //author: Andreas Haas <hondres,  [email protected]>
-#ifdef __linux__
+#ifdef JOYDEV_ENABLED
 
 #include "joystick_linux.h"
 #include "print_string.h"

+ 1 - 1
platform/x11/joystick_linux.h

@@ -30,7 +30,7 @@
 //author: Andreas Haas <hondres,  [email protected]>
 #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"

+ 3 - 3
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)

+ 1 - 1
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