diff options
Diffstat (limited to 'platform/x11')
-rw-r--r-- | platform/x11/context_gl_x11.cpp | 2 | ||||
-rw-r--r-- | platform/x11/context_gl_x11.h | 2 | ||||
-rw-r--r-- | platform/x11/detect.py | 37 | ||||
-rw-r--r-- | platform/x11/godot_x11.cpp | 2 | ||||
-rw-r--r-- | platform/x11/joystick_linux.cpp | 30 | ||||
-rw-r--r-- | platform/x11/joystick_linux.h | 5 | ||||
-rw-r--r-- | platform/x11/key_mapping_x11.cpp | 2 | ||||
-rw-r--r-- | platform/x11/key_mapping_x11.h | 2 | ||||
-rw-r--r-- | platform/x11/os_x11.cpp | 31 | ||||
-rw-r--r-- | platform/x11/os_x11.h | 6 | ||||
-rw-r--r-- | platform/x11/platform_config.h | 3 |
11 files changed, 85 insertions, 37 deletions
diff --git a/platform/x11/context_gl_x11.cpp b/platform/x11/context_gl_x11.cpp index 3db1f6da25..89bd5f58ff 100644 --- a/platform/x11/context_gl_x11.cpp +++ b/platform/x11/context_gl_x11.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/x11/context_gl_x11.h b/platform/x11/context_gl_x11.h index 8b81db9160..56404d0fae 100644 --- a/platform/x11/context_gl_x11.h +++ b/platform/x11/context_gl_x11.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/x11/detect.py b/platform/x11/detect.py index 0226c8b8c0..e035c72993 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -55,6 +55,7 @@ def get_opts(): ('use_sanitizer','Use llvm compiler sanitize address','no'), ('use_leak_sanitizer','Use llvm compiler sanitize memory leaks','no'), ('pulseaudio','Detect & Use pulseaudio','yes'), + ('gamepad','Gamepad support, requires libudev and libevdev','yes'), ('new_wm_api', 'Use experimental window management API','no'), ('debug_release', 'Add debug symbols to release version','no'), ] @@ -145,23 +146,33 @@ def configure(env): env.Append(CPPPATH=['#tools/freetype/freetype/include']) - - env.Append(CPPFLAGS=['-DOPENGL_ENABLED','-DGLEW_ENABLED']) - if platform.system() == 'Linux': + + if os.system("pkg-config --exists alsa")==0: + print("Enabling ALSA") env.Append(CPPFLAGS=["-DALSA_ENABLED"]) 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("ALSA libraries not found, disabling driver") + + if (env["gamepad"]=="yes" and platform.system() == "Linux"): + # pkg-config returns 0 when the lib exists... + found_udev = not os.system("pkg-config --exists libudev") + found_evdev = not os.system("pkg-config --exists libevdev") + + if (found_udev and found_evdev): + print("Enabling gamepad support with udev/evdev") + env.Append(CPPFLAGS=["-DJOYDEV_ENABLED"]) + env.ParseConfig('pkg-config libudev --cflags --libs') + env.ParseConfig('pkg-config libevdev --cflags --libs') else: - print("libudev development libraries not found, disabling gamepad support") + if (not found_udev): + print("libudev development libraries not found") + if (not found_evdev): + print("libevdev development libraries not found") + print("Some libraries are missing for the required gamepad support, aborting!") + print("Install the mentioned libraries or build with 'gamepad=no' to disable gamepad support.") + sys.exit(255) if (env["pulseaudio"]=="yes"): if not os.system("pkg-config --exists libpulse-simple"): diff --git a/platform/x11/godot_x11.cpp b/platform/x11/godot_x11.cpp index f90d40fa5c..ee83da25c1 100644 --- a/platform/x11/godot_x11.cpp +++ b/platform/x11/godot_x11.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/x11/joystick_linux.cpp b/platform/x11/joystick_linux.cpp index cc806f6f78..6eb3671bc0 100644 --- a/platform/x11/joystick_linux.cpp +++ b/platform/x11/joystick_linux.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -45,15 +45,20 @@ static const char* ignore_str = "/dev/input/js"; joystick_linux::Joystick::Joystick() { fd = -1; dpad = 0; + dev = NULL; + devpath = ""; } void joystick_linux::Joystick::reset() { - num_buttons = 0; - num_axes = 0; dpad = 0; fd = -1; + + InputDefault::JoyAxis jx; + jx.min = -1; + jx.value = 0.0f; for (int i=0; i < MAX_ABS; i++) { abs_map[i] = -1; + curr_axis[i] = jx; } } @@ -225,20 +230,23 @@ static String _hex_str(uint8_t p_byte) { void joystick_linux::setup_joystick_properties(int p_id) { Joystick* joy = &joysticks[p_id]; - libevdev* dev = joy->dev; + + int num_buttons = 0; + int num_axes = 0; + for (int i = BTN_JOYSTICK; i < KEY_MAX; ++i) { if (libevdev_has_event_code(dev, EV_KEY, i)) { - joy->key_map[i] = joy->num_buttons++; + joy->key_map[i] = num_buttons++; } } for (int i = BTN_MISC; i < BTN_JOYSTICK; ++i) { if (libevdev_has_event_code(dev, EV_KEY, i)) { - joy->key_map[i] = joy->num_buttons++; + joy->key_map[i] = num_buttons++; } } for (int i = 0; i < ABS_MISC; ++i) { @@ -249,7 +257,7 @@ void joystick_linux::setup_joystick_properties(int p_id) { } if (libevdev_has_event_code(dev, EV_ABS, i)) { - joy->abs_map[i] = joy->num_axes++; + joy->abs_map[i] = num_axes++; } } } @@ -387,7 +395,7 @@ uint32_t joystick_linux::process_joysticks(uint32_t p_event_id) { default: if (joy->abs_map[ev.code] != -1) { InputDefault::JoyAxis value = axis_correct(libevdev_get_abs_info(dev, ev.code), ev.value); - p_event_id = input->joy_axis(p_event_id, i, joy->abs_map[ev.code], value); + joy->curr_axis[joy->abs_map[ev.code]] = value; } break; } @@ -395,6 +403,12 @@ uint32_t joystick_linux::process_joysticks(uint32_t p_event_id) { } rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, &ev); } + for (int j = 0; j < MAX_ABS; j++) { + int index = joy->abs_map[j]; + if (index != -1) { + p_event_id = input->joy_axis(p_event_id, i, index, joy->curr_axis[index]); + } + } } joy_mutex->unlock(); return p_event_id; diff --git a/platform/x11/joystick_linux.h b/platform/x11/joystick_linux.h index 1064a6f841..ee9bd0352a 100644 --- a/platform/x11/joystick_linux.h +++ b/platform/x11/joystick_linux.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -54,10 +54,9 @@ private: }; struct Joystick { + InputDefault::JoyAxis curr_axis[MAX_ABS]; int key_map[MAX_KEY - BT_MISC]; int abs_map[MAX_ABS]; - int num_buttons; - int num_axes; int dpad; int fd; diff --git a/platform/x11/key_mapping_x11.cpp b/platform/x11/key_mapping_x11.cpp index 9c68ac1a2c..48f415a730 100644 --- a/platform/x11/key_mapping_x11.cpp +++ b/platform/x11/key_mapping_x11.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/x11/key_mapping_x11.h b/platform/x11/key_mapping_x11.h index 7ab883878f..979d8a112f 100644 --- a/platform/x11/key_mapping_x11.h +++ b/platform/x11/key_mapping_x11.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 0afab6442b..82df8dff60 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -447,6 +447,11 @@ void OS_X11::finalize() { // memdelete(debugger_connection_console); //} +#ifdef JOYDEV_ENABLED + memdelete(joystick); +#endif + memdelete(input); + memdelete(sample_manager); audio_server->finish(); @@ -461,10 +466,6 @@ void OS_X11::finalize() { physics_2d_server->finish(); memdelete(physics_2d_server); -#ifdef JOYDEV_ENABLED - memdelete(joystick); -#endif - memdelete(input); XUnmapWindow( x11_display, x11_window ); XDestroyWindow( x11_display, x11_window ); @@ -618,6 +619,7 @@ void OS_X11::set_wm_fullscreen(bool p_enabled) { xev.xclient.data.l[2] = 0; XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev); + } int OS_X11::get_screen_count() const { @@ -886,7 +888,16 @@ void OS_X11::set_window_maximized(bool p_enabled) { XGetWindowAttributes(x11_display,DefaultRootWindow(x11_display),&xwa); current_videomode.width = xwa.width; current_videomode.height = xwa.height; -*/ +//*/ + +// current_videomode.width = wm_max_horz; +// current_videomode.height = wm_max_vert; + + //Size2 ss = get_screen_size(get_current_screen()); + //current_videomode.width=ss.width; + //current_videomode.height=ss.height; + + maximized = p_enabled; } @@ -1763,6 +1774,14 @@ void OS_X11::run() { main_loop->finish(); } +bool OS_X11::is_joy_known(int p_device) { + return input->is_joy_mapped(p_device); +} + +String OS_X11::get_joy_guid(int p_device) const { + return input->get_joy_guid_remapped(p_device); +} + OS_X11::OS_X11() { #ifdef RTAUDIO_ENABLED diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index eee3e40136..91dbeac284 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -222,6 +222,10 @@ public: virtual void move_window_to_foreground(); virtual void alert(const String& p_alert,const String& p_title="ALERT!"); + + virtual bool is_joy_known(int p_device); + virtual String get_joy_guid(int p_device) const; + void run(); OS_X11(); diff --git a/platform/x11/platform_config.h b/platform/x11/platform_config.h index 1556b56058..aac50c27c2 100644 --- a/platform/x11/platform_config.h +++ b/platform/x11/platform_config.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -31,6 +31,7 @@ #endif #if defined(__FreeBSD__) || defined(__OpenBSD__) #include <stdlib.h> +#define PTHREAD_BSD_SET_NAME #endif #define GLES2_INCLUDE_H "gl_context/glew.h" |