summaryrefslogtreecommitdiff
path: root/platform/x11
diff options
context:
space:
mode:
Diffstat (limited to 'platform/x11')
-rw-r--r--platform/x11/SCsub14
-rw-r--r--platform/x11/context_gl_x11.cpp64
-rw-r--r--platform/x11/context_gl_x11.h8
-rw-r--r--platform/x11/detect.py360
-rw-r--r--platform/x11/export/export.cpp28
-rw-r--r--platform/x11/export/export.h31
-rw-r--r--platform/x11/godot_x11.cpp2
-rw-r--r--platform/x11/joypad_linux.cpp (renamed from platform/x11/joystick_linux.cpp)174
-rw-r--r--platform/x11/joypad_linux.h (renamed from platform/x11/joystick_linux.h)50
-rw-r--r--platform/x11/key_mapping_x11.cpp7
-rw-r--r--platform/x11/key_mapping_x11.h2
-rw-r--r--platform/x11/logo.pngbin2055 -> 2061 bytes
-rw-r--r--platform/x11/os_x11.cpp372
-rw-r--r--platform/x11/os_x11.h38
-rw-r--r--platform/x11/platform_config.h6
15 files changed, 714 insertions, 442 deletions
diff --git a/platform/x11/SCsub b/platform/x11/SCsub
index 80fd347ded..4ae8ac07f7 100644
--- a/platform/x11/SCsub
+++ b/platform/x11/SCsub
@@ -1,11 +1,13 @@
+#!/usr/bin/env python
+
Import('env')
-common_x11=[\
- "context_gl_x11.cpp",\
- "os_x11.cpp",\
- "key_mapping_x11.cpp",\
- "joystick_linux.cpp",\
+common_x11 = [\
+ "context_gl_x11.cpp",\
+ "os_x11.cpp",\
+ "key_mapping_x11.cpp",\
+ "joypad_linux.cpp",\
]
-env.Program('#bin/godot',['godot_x11.cpp']+common_x11)
+env.Program('#bin/godot', ['godot_x11.cpp'] + common_x11)
diff --git a/platform/x11/context_gl_x11.cpp b/platform/x11/context_gl_x11.cpp
index 9f987e1376..39b704d2c4 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-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 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 */
@@ -34,7 +34,9 @@
#include <unistd.h>
#include <stdlib.h>
+#define GLX_GLXEXT_PROTOTYPES
#include <GL/glx.h>
+#include <GL/glxext.h>
#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091
#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092
@@ -74,12 +76,19 @@ static GLWrapperFuncPtr wrapper_get_proc_address(const char* p_function) {
}*/
+static bool ctxErrorOccurred = false;
+static int ctxErrorHandler( Display *dpy, XErrorEvent *ev )
+{
+ ctxErrorOccurred = true;
+ return 0;
+}
+
Error ContextGL_X11::initialize() {
GLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = NULL;
-// const char *extensions = glXQueryExtensionsString(x11_display, DefaultScreen(x11_display));
+ //const char *extensions = glXQueryExtensionsString(x11_display, DefaultScreen(x11_display));
glXCreateContextAttribsARB = (GLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddress((const GLubyte*)"glXCreateContextAttribsARB");
@@ -131,20 +140,31 @@ Error ContextGL_X11::initialize() {
//};
+ int (*oldHandler)(Display*, XErrorEvent*) =
+ XSetErrorHandler(&ctxErrorHandler);
+
+
if (!opengl_3_context) {
//oldstyle context:
p->glx_context = glXCreateContext(x11_display, vi, 0, GL_TRUE);
} else {
static int context_attribs[] = {
GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
- GLX_CONTEXT_MINOR_VERSION_ARB, 0,
+ GLX_CONTEXT_MINOR_VERSION_ARB, 3,
+ GLX_CONTEXT_FLAGS_ARB , GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB/*|GLX_CONTEXT_DEBUG_BIT_ARB*/,
None
};
p->glx_context = glXCreateContextAttribsARB(x11_display, fbc[0], NULL, true, context_attribs);
- ERR_FAIL_COND_V(!p->glx_context,ERR_UNCONFIGURED);
+ ERR_EXPLAIN("Could not obtain an OpenGL 3.3 context!");
+ ERR_FAIL_COND_V(ctxErrorOccurred || !p->glx_context,ERR_UNCONFIGURED);
}
+ XSync( x11_display, False );
+ XSetErrorHandler( oldHandler );
+
+ print_line("ALL IS GOOD");
+
glXMakeCurrent(x11_display, x11_window, p->glx_context);
/*
@@ -176,6 +196,41 @@ int ContextGL_X11::get_window_height() {
return xwa.height;
}
+void ContextGL_X11::set_use_vsync(bool p_use) {
+ static bool setup = false;
+ static PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT = NULL;
+ static PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalMESA = NULL;
+ static PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI = NULL;
+
+ if (!setup) {
+ setup = true;
+ String extensions = glXQueryExtensionsString(x11_display, DefaultScreen(x11_display));
+ if (extensions.find("GLX_EXT_swap_control") != -1)
+ glXSwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC) glXGetProcAddressARB((const GLubyte*)"glXSwapIntervalEXT");
+ if (extensions.find("GLX_MESA_swap_control") != -1)
+ glXSwapIntervalMESA = (PFNGLXSWAPINTERVALSGIPROC) glXGetProcAddressARB((const GLubyte*)"glXSwapIntervalMESA");
+ if (extensions.find("GLX_SGI_swap_control") != -1)
+ glXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC) glXGetProcAddressARB((const GLubyte*)"glXSwapIntervalSGI");
+ }
+ int val = p_use ? 1:0;
+ if (glXSwapIntervalMESA) {
+ glXSwapIntervalMESA(val);
+ }
+ else if (glXSwapIntervalSGI) {
+ glXSwapIntervalSGI(val);
+ }
+ else if (glXSwapIntervalEXT) {
+ GLXDrawable drawable = glXGetCurrentDrawable();
+ glXSwapIntervalEXT(x11_display, drawable, val);
+ }
+ else return;
+ use_vsync = p_use;
+}
+bool ContextGL_X11::is_using_vsync() const {
+
+ return use_vsync;
+}
+
ContextGL_X11::ContextGL_X11(::Display *p_x11_display,::Window &p_x11_window,const OS::VideoMode& p_default_video_mode,bool p_opengl_3_context) : x11_window(p_x11_window) {
@@ -189,6 +244,7 @@ ContextGL_X11::ContextGL_X11(::Display *p_x11_display,::Window &p_x11_window,con
glx_minor=glx_major=0;
p = memnew( ContextGL_X11_Private );
p->glx_context=0;
+ use_vsync=false;
}
diff --git a/platform/x11/context_gl_x11.h b/platform/x11/context_gl_x11.h
index c77fb3e333..efea700224 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-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 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 */
@@ -48,13 +48,14 @@ class ContextGL_X11 : public ContextGL {
ContextGL_X11_Private *p;
OS::VideoMode default_video_mode;
-// ::Colormap x11_colormap;
+ //::Colormap x11_colormap;
::Display *x11_display;
::Window& x11_window;
bool double_buffer;
bool direct_render;
int glx_minor,glx_major;
bool opengl_3_context;
+ bool use_vsync;
public:
virtual void release_current();
@@ -65,6 +66,9 @@ public:
virtual Error initialize();
+ virtual void set_use_vsync(bool p_use);
+ virtual bool is_using_vsync() const;
+
ContextGL_X11(::Display *p_x11_display,::Window &p_x11_window,const OS::VideoMode& p_default_video_mode,bool p_opengl_3_context);
~ContextGL_X11();
diff --git a/platform/x11/detect.py b/platform/x11/detect.py
index 5a43bf9323..b5f6359d21 100644
--- a/platform/x11/detect.py
+++ b/platform/x11/detect.py
@@ -5,205 +5,241 @@ import platform
def is_active():
- return True
+ return True
+
def get_name():
- return "X11"
+ return "X11"
def can_build():
- if (os.name!="posix"):
- return False
+ if (os.name != "posix"):
+ return False
+
+ if sys.platform == "darwin":
+ return False # no x11 on mac for now
- if sys.platform == "darwin":
- return False # no x11 on mac for now
+ errorval = os.system("pkg-config --version > /dev/null")
- errorval=os.system("pkg-config --version > /dev/null")
+ if (errorval):
+ print("pkg-config not found.. x11 disabled.")
+ return False
- if (errorval):
- print("pkg-config not found.. x11 disabled.")
- return False
+ x11_error = os.system("pkg-config x11 --modversion > /dev/null ")
+ if (x11_error):
+ print("X11 not found.. x11 disabled.")
+ return False
- x11_error=os.system("pkg-config x11 --modversion > /dev/null ")
- if (x11_error):
- print("X11 not found.. x11 disabled.")
- return False
+ ssl_error = os.system("pkg-config openssl --modversion > /dev/null ")
+ if (ssl_error):
+ print("OpenSSL not found.. x11 disabled.")
+ return False
- ssl_error=os.system("pkg-config openssl --modversion > /dev/null ")
- if (ssl_error):
- print("OpenSSL not found.. x11 disabled.")
- return False
+ x11_error = os.system("pkg-config xcursor --modversion > /dev/null ")
+ if (x11_error):
+ print("xcursor not found.. x11 disabled.")
+ return False
- x11_error=os.system("pkg-config xcursor --modversion > /dev/null ")
- if (x11_error):
- print("xcursor not found.. x11 disabled.")
- return False
+ x11_error = os.system("pkg-config xinerama --modversion > /dev/null ")
+ if (x11_error):
+ print("xinerama not found.. x11 disabled.")
+ return False
- x11_error=os.system("pkg-config xinerama --modversion > /dev/null ")
- if (x11_error):
- print("xinerama not found.. x11 disabled.")
- return False
+ x11_error = os.system("pkg-config xrandr --modversion > /dev/null ")
+ if (x11_error):
+ print("xrandr not found.. x11 disabled.")
+ return False
+ return True # X11 enabled
- return True # X11 enabled
def get_opts():
- return [
- ('use_llvm','Use llvm compiler','no'),
- ('use_static_cpp','link stdc++ statically','no'),
- ('use_sanitizer','Use llvm compiler sanitize address','no'),
- ('use_leak_sanitizer','Use llvm compiler sanitize memory leaks','no'),
- ('pulseaudio','Detect & Use pulseaudio','yes'),
- ('udev','Use udev for gamepad connection callbacks','no'),
- ('new_wm_api', 'Use experimental window management API','no'),
- ('debug_release', 'Add debug symbols to release version','no'),
- ]
+ return [
+ ('use_llvm', 'Use llvm compiler', 'no'),
+ ('use_static_cpp', 'link stdc++ statically', 'no'),
+ ('use_sanitizer', 'Use llvm compiler sanitize address', 'no'),
+ ('use_leak_sanitizer', 'Use llvm compiler sanitize memory leaks', 'no'),
+ ('pulseaudio', 'Detect & Use pulseaudio', 'yes'),
+ ('udev', 'Use udev for gamepad connection callbacks', 'no'),
+ ('debug_release', 'Add debug symbols to release version', 'no'),
+ ]
-def get_flags():
- return [
- ('builtin_zlib', 'no'),
- ("openssl", "yes"),
- #("theora","no"),
- ]
+def get_flags():
+ return [
+ ('builtin_freetype', 'no'),
+ ('builtin_libpng', 'no'),
+ ('builtin_openssl', 'no'),
+ ('builtin_zlib', 'no'),
+ ]
def configure(env):
- is64=sys.maxsize > 2**32
-
- if (env["bits"]=="default"):
- if (is64):
- env["bits"]="64"
- else:
- env["bits"]="32"
-
- env.Append(CPPPATH=['#platform/x11'])
- if (env["use_llvm"]=="yes"):
- if 'clang++' not in env['CXX']:
- env["CC"]="clang"
- env["CXX"]="clang++"
- env["LD"]="clang++"
- env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND'])
- env.extra_suffix=".llvm"
-
- if (env["colored"]=="yes"):
- if sys.stdout.isatty():
- env.Append(CXXFLAGS=["-fcolor-diagnostics"])
-
- if (env["use_sanitizer"]=="yes"):
- env.Append(CXXFLAGS=['-fsanitize=address','-fno-omit-frame-pointer'])
- env.Append(LINKFLAGS=['-fsanitize=address'])
- env.extra_suffix+="s"
-
- if (env["use_leak_sanitizer"]=="yes"):
- env.Append(CXXFLAGS=['-fsanitize=address','-fno-omit-frame-pointer'])
- env.Append(LINKFLAGS=['-fsanitize=address'])
- env.extra_suffix+="s"
-
-
- #if (env["tools"]=="no"):
- # #no tools suffix
- # env['OBJSUFFIX'] = ".nt"+env['OBJSUFFIX']
- # env['LIBSUFFIX'] = ".nt"+env['LIBSUFFIX']
-
-
- if (env["target"]=="release"):
-
- if (env["debug_release"]=="yes"):
- env.Append(CCFLAGS=['-g2'])
- else:
- env.Append(CCFLAGS=['-O3','-ffast-math'])
-
- elif (env["target"]=="release_debug"):
-
- env.Append(CCFLAGS=['-O2','-ffast-math','-DDEBUG_ENABLED'])
- if (env["debug_release"]=="yes"):
- env.Append(CCFLAGS=['-g2'])
-
- elif (env["target"]=="debug"):
-
- env.Append(CCFLAGS=['-g2', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED'])
-
- env.ParseConfig('pkg-config x11 --cflags --libs')
- env.ParseConfig('pkg-config xinerama --cflags --libs')
- env.ParseConfig('pkg-config xcursor --cflags --libs')
-
- if (env["openssl"]=="yes"):
- env.ParseConfig('pkg-config openssl --cflags --libs')
-
-
- if (env["freetype"]=="yes"):
- env.ParseConfig('pkg-config freetype2 --cflags --libs')
-
-
- if (env["freetype"]!="no"):
- env.Append(CCFLAGS=['-DFREETYPE_ENABLED'])
- if (env["freetype"]=="builtin"):
- env.Append(CPPPATH=['#drivers/freetype'])
- env.Append(CPPPATH=['#drivers/freetype/freetype/include'])
-
+ is64 = sys.maxsize > 2**32
- env.Append(CPPFLAGS=['-DOPENGL_ENABLED','-DGLEW_ENABLED'])
+ if (env["bits"] == "default"):
+ if (is64):
+ env["bits"] = "64"
+ else:
+ env["bits"] = "32"
- if os.system("pkg-config --exists alsa")==0:
- print("Enabling ALSA")
- env.Append(CPPFLAGS=["-DALSA_ENABLED"])
- env.Append(LIBS=['asound'])
- else:
- print("ALSA libraries not found, disabling driver")
+ env.Append(CPPPATH=['#platform/x11'])
+ if (env["use_llvm"] == "yes"):
+ if 'clang++' not in env['CXX']:
+ env["CC"] = "clang"
+ env["CXX"] = "clang++"
+ env["LD"] = "clang++"
+ env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND'])
+ env.extra_suffix = ".llvm"
- if (platform.system() == "Linux"):
- env.Append(CPPFLAGS=["-DJOYDEV_ENABLED"])
- if (env["udev"]=="yes"):
- # pkg-config returns 0 when the lib exists...
- found_udev = not os.system("pkg-config --exists libudev")
+ if (env["use_sanitizer"] == "yes"):
+ env.Append(CXXFLAGS=['-fsanitize=address', '-fno-omit-frame-pointer'])
+ env.Append(LINKFLAGS=['-fsanitize=address'])
+ env.extra_suffix += "s"
- if (found_udev):
- print("Enabling udev support")
- env.Append(CPPFLAGS=["-DUDEV_ENABLED"])
- env.ParseConfig('pkg-config libudev --cflags --libs')
- else:
- print("libudev development libraries not found, disabling udev support")
+ if (env["use_leak_sanitizer"] == "yes"):
+ env.Append(CXXFLAGS=['-fsanitize=address', '-fno-omit-frame-pointer'])
+ env.Append(LINKFLAGS=['-fsanitize=address'])
+ env.extra_suffix += "s"
+
+ # if (env["tools"]=="no"):
+ # #no tools suffix
+ # env['OBJSUFFIX'] = ".nt"+env['OBJSUFFIX']
+ # env['LIBSUFFIX'] = ".nt"+env['LIBSUFFIX']
+
+ if (env["target"] == "release"):
- if (env["pulseaudio"]=="yes"):
- if not os.system("pkg-config --exists libpulse-simple"):
- print("Enabling PulseAudio")
- env.Append(CPPFLAGS=["-DPULSEAUDIO_ENABLED"])
- env.ParseConfig('pkg-config --cflags --libs libpulse-simple')
- else:
- print("PulseAudio development libraries not found, disabling driver")
+ if (env["debug_release"] == "yes"):
+ env.Append(CCFLAGS=['-g2'])
+ else:
+ env.Append(CCFLAGS=['-O3', '-ffast-math'])
+
+ elif (env["target"] == "release_debug"):
- env.Append(CPPFLAGS=['-DX11_ENABLED','-DUNIX_ENABLED','-DGLES2_ENABLED','-DGLES_OVER_GL'])
- env.Append(LIBS=['GL', 'GLU', 'pthread', 'z'])
- #env.Append(CPPFLAGS=['-DMPC_FIXED_POINT'])
+ env.Append(CCFLAGS=['-O2', '-ffast-math', '-DDEBUG_ENABLED'])
+ if (env["debug_release"] == "yes"):
+ env.Append(CCFLAGS=['-g2'])
-#host compiler is default..
+ elif (env["target"] == "debug"):
+
+ env.Append(CCFLAGS=['-g2', '-Wall', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
+
+ 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 xrandr --cflags --libs')
- if (is64 and env["bits"]=="32"):
- env.Append(CPPFLAGS=['-m32'])
- env.Append(LINKFLAGS=['-m32','-L/usr/lib/i386-linux-gnu'])
- elif (not is64 and env["bits"]=="64"):
- env.Append(CPPFLAGS=['-m64'])
- env.Append(LINKFLAGS=['-m64','-L/usr/lib/i686-linux-gnu'])
+ if (env['builtin_openssl'] == 'no'):
+ env.ParseConfig('pkg-config openssl --cflags --libs')
+
+ if (env['builtin_libwebp'] == 'no'):
+ env.ParseConfig('pkg-config libwebp --cflags --libs')
+
+ # freetype depends on libpng and zlib, so bundling one of them while keeping others
+ # as shared libraries leads to weird issues
+ if (env['builtin_freetype'] == 'yes' or env['builtin_libpng'] == 'yes' or env['builtin_zlib'] == 'yes'):
+ env['builtin_freetype'] = 'yes'
+ env['builtin_libpng'] = 'yes'
+ env['builtin_zlib'] = 'yes'
+
+ if (env['builtin_freetype'] == 'no'):
+ env.ParseConfig('pkg-config freetype2 --cflags --libs')
+
+ if (env['builtin_libpng'] == 'no'):
+ env.ParseConfig('pkg-config libpng --cflags --libs')
+
+ if (env['builtin_enet'] == 'no'):
+ env.ParseConfig('pkg-config libenet --cflags --libs')
+
+ if (env['builtin_squish'] == 'no' and env["tools"] == "yes"):
+ env.ParseConfig('pkg-config libsquish --cflags --libs')
+
+ # Sound and video libraries
+ # Keep the order as it triggers chained dependencies (ogg needed by others, etc.)
+
+ if (env['builtin_libtheora'] == 'no'):
+ env['builtin_libogg'] = 'no' # Needed to link against system libtheora
+ env['builtin_libvorbis'] = 'no' # Needed to link against system libtheora
+ env.ParseConfig('pkg-config theora theoradec --cflags --libs')
+
+ if (env['builtin_libvpx'] == 'no'):
+ env.ParseConfig('pkg-config vpx --cflags --libs')
+
+ if (env['builtin_libvorbis'] == 'no'):
+ env['builtin_libogg'] = 'no' # Needed to link against system libvorbis
+ env.ParseConfig('pkg-config vorbis vorbisfile --cflags --libs')
+
+ if (env['builtin_opus'] == 'no'):
+ env['builtin_libogg'] = 'no' # Needed to link against system opus
+ env.ParseConfig('pkg-config opus opusfile --cflags --libs')
+
+ if (env['builtin_libogg'] == 'no'):
+ env.ParseConfig('pkg-config ogg --cflags --libs')
+
+ env.Append(CPPFLAGS=['-DOPENGL_ENABLED'])
+
+ if os.system("pkg-config --exists alsa") == 0:
+ print("Enabling ALSA")
+ env.Append(CPPFLAGS=["-DALSA_ENABLED"])
+ env.ParseConfig('pkg-config alsa --cflags --libs')
+ else:
+ print("ALSA libraries not found, disabling driver")
+
+ if (platform.system() == "Linux"):
+ env.Append(CPPFLAGS=["-DJOYDEV_ENABLED"])
+ if (env["udev"] == "yes"):
+ # pkg-config returns 0 when the lib exists...
+ found_udev = not os.system("pkg-config --exists libudev")
+ if (found_udev):
+ print("Enabling udev support")
+ env.Append(CPPFLAGS=["-DUDEV_ENABLED"])
+ env.ParseConfig('pkg-config libudev --cflags --libs')
+ else:
+ print("libudev development libraries not found, disabling udev support")
- import methods
+ if (env["pulseaudio"] == "yes"):
+ if not os.system("pkg-config --exists libpulse-simple"):
+ print("Enabling PulseAudio")
+ env.Append(CPPFLAGS=["-DPULSEAUDIO_ENABLED"])
+ env.ParseConfig('pkg-config --cflags --libs libpulse-simple')
+ else:
+ print("PulseAudio development libraries not found, disabling driver")
- env.Append( BUILDERS = { 'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )
- env.Append( BUILDERS = { 'GLSL' : env.Builder(action = methods.build_glsl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )
- env.Append( BUILDERS = { 'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )
- #env.Append( BUILDERS = { 'HLSL9' : env.Builder(action = methods.build_hlsl_dx9_headers, suffix = 'hlsl.h',src_suffix = '.hlsl') } )
+ if (env['builtin_zlib'] == 'no'):
+ env.ParseConfig('pkg-config zlib --cflags --libs')
- if(env["new_wm_api"]=="yes"):
- env.Append(CPPFLAGS=['-DNEW_WM_API'])
- env.ParseConfig('pkg-config xinerama --cflags --libs')
+ env.Append(CPPFLAGS=['-DX11_ENABLED', '-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DGLES_OVER_GL'])
+ env.Append(LIBS=['GL', 'pthread'])
- if (env["use_static_cpp"]=="yes"):
- env.Append(LINKFLAGS=['-static-libstdc++'])
+ if (platform.system() == "Linux"):
+ env.Append(LIBS=['dl'])
+ # env.Append(CPPFLAGS=['-DMPC_FIXED_POINT'])
- env["x86_opt_gcc"]=True
+# host compiler is default..
+ if (is64 and env["bits"] == "32"):
+ env.Append(CPPFLAGS=['-m32'])
+ env.Append(LINKFLAGS=['-m32', '-L/usr/lib/i386-linux-gnu'])
+ elif (not is64 and env["bits"] == "64"):
+ env.Append(CPPFLAGS=['-m64'])
+ env.Append(LINKFLAGS=['-m64', '-L/usr/lib/i686-linux-gnu'])
+
+ import methods
+
+ # FIXME: Commented out when moving to gles3
+ #env.Append(BUILDERS={'GLSL120': env.Builder(action=methods.build_legacygl_headers, suffix='glsl.h', src_suffix='.glsl')})
+ #env.Append(BUILDERS={'GLSL': env.Builder(action=methods.build_glsl_headers, suffix='glsl.h', src_suffix='.glsl')})
+ #env.Append(BUILDERS={'GLSL120GLES': env.Builder(action=methods.build_gles2_headers, suffix='glsl.h', src_suffix='.glsl')})
+ #env.Append( BUILDERS = { 'HLSL9' : env.Builder(action = methods.build_hlsl_dx9_headers, suffix = 'hlsl.h',src_suffix = '.hlsl') } )
+
+ if (env["use_static_cpp"] == "yes"):
+ env.Append(LINKFLAGS=['-static-libstdc++'])
+
+ list_of_x86 = ['x86_64', 'x86', 'i386', 'i586']
+ if any(platform.machine() in s for s in list_of_x86):
+ env["x86_libtheora_opt_gcc"] = True
diff --git a/platform/x11/export/export.cpp b/platform/x11/export/export.cpp
index bed57fbe9f..c1af323453 100644
--- a/platform/x11/export/export.cpp
+++ b/platform/x11/export/export.cpp
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* export.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 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 */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
#include "export.h"
#include "platform/x11/logo.h"
#include "tools/editor/editor_import_export.h"
diff --git a/platform/x11/export/export.h b/platform/x11/export/export.h
index 1077709ea1..5beaba2cfb 100644
--- a/platform/x11/export/export.h
+++ b/platform/x11/export/export.h
@@ -1,4 +1,29 @@
-
-
+/*************************************************************************/
+/* export.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 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 */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
void register_x11_exporter();
-
diff --git a/platform/x11/godot_x11.cpp b/platform/x11/godot_x11.cpp
index c500f939c4..f85ba17020 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-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 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/joypad_linux.cpp
index 2793cc5734..362999661e 100644
--- a/platform/x11/joystick_linux.cpp
+++ b/platform/x11/joypad_linux.cpp
@@ -1,11 +1,11 @@
/*************************************************************************/
-/* joystick_linux.cpp */
+/* joypad_linux.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 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 */
@@ -27,10 +27,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-//author: Andreas Haas <hondres, liugam3@gmail.com>
#ifdef JOYDEV_ENABLED
-#include "joystick_linux.h"
+#include "joypad_linux.h"
#include <linux/input.h>
#include <unistd.h>
@@ -45,9 +44,11 @@
#define test_bit(nr, addr) (((1UL << ((nr) % LONG_BITS)) & ((addr)[(nr) / LONG_BITS])) != 0)
#define NBITS(x) ((((x)-1)/LONG_BITS)+1)
+#ifdef UDEV_ENABLED
static const char* ignore_str = "/dev/input/js";
+#endif
-joystick_linux::Joystick::Joystick() {
+JoypadLinux::Joypad::Joypad() {
fd = -1;
dpad = 0;
devpath = "";
@@ -56,7 +57,7 @@ joystick_linux::Joystick::Joystick() {
}
}
-joystick_linux::Joystick::~Joystick() {
+JoypadLinux::Joypad::~Joypad() {
for (int i = 0; i < MAX_ABS; i++) {
if (abs_info[i]) {
@@ -65,7 +66,7 @@ joystick_linux::Joystick::~Joystick() {
}
}
-void joystick_linux::Joystick::reset() {
+void JoypadLinux::Joypad::reset() {
dpad = 0;
fd = -1;
@@ -78,7 +79,7 @@ void joystick_linux::Joystick::reset() {
}
}
-joystick_linux::joystick_linux(InputDefault *in)
+JoypadLinux::JoypadLinux(InputDefault *in)
{
exit_udev = false;
input = in;
@@ -86,37 +87,37 @@ joystick_linux::joystick_linux(InputDefault *in)
joy_thread = Thread::create(joy_thread_func, this);
}
-joystick_linux::~joystick_linux() {
+JoypadLinux::~JoypadLinux() {
exit_udev = true;
Thread::wait_to_finish(joy_thread);
memdelete(joy_thread);
memdelete(joy_mutex);
- close_joystick();
+ close_joypad();
}
-void joystick_linux::joy_thread_func(void *p_user) {
+void JoypadLinux::joy_thread_func(void *p_user) {
if (p_user) {
- joystick_linux* joy = (joystick_linux*) p_user;
- joy->run_joystick_thread();
+ JoypadLinux* joy = (JoypadLinux*) p_user;
+ joy->run_joypad_thread();
}
return;
}
-void joystick_linux::run_joystick_thread() {
+void JoypadLinux::run_joypad_thread() {
#ifdef UDEV_ENABLED
udev *_udev = udev_new();
ERR_FAIL_COND(!_udev);
- enumerate_joysticks(_udev);
- monitor_joysticks(_udev);
+ enumerate_joypads(_udev);
+ monitor_joypads(_udev);
udev_unref(_udev);
#else
- monitor_joysticks();
+ monitor_joypads();
#endif
}
#ifdef UDEV_ENABLED
-void joystick_linux::enumerate_joysticks(udev *p_udev) {
+void JoypadLinux::enumerate_joypads(udev *p_udev) {
udev_enumerate *enumerate;
udev_list_entry *devices, *dev_list_entry;
@@ -124,7 +125,7 @@ void joystick_linux::enumerate_joysticks(udev *p_udev) {
enumerate = udev_enumerate_new(p_udev);
udev_enumerate_add_match_subsystem(enumerate,"input");
- udev_enumerate_add_match_property(enumerate, "ID_INPUT_JOYSTICK", "1");
+ udev_enumerate_add_match_property(enumerate, "ID_INPUT_JOYPAD", "1");
udev_enumerate_scan_devices(enumerate);
devices = udev_enumerate_get_list_entry(enumerate);
@@ -139,7 +140,7 @@ void joystick_linux::enumerate_joysticks(udev *p_udev) {
String devnode_str = devnode;
if (devnode_str.find(ignore_str) == -1) {
joy_mutex->lock();
- open_joystick(devnode);
+ open_joypad(devnode);
joy_mutex->unlock();
}
}
@@ -148,7 +149,7 @@ void joystick_linux::enumerate_joysticks(udev *p_udev) {
udev_enumerate_unref(enumerate);
}
-void joystick_linux::monitor_joysticks(udev *p_udev) {
+void JoypadLinux::monitor_joypads(udev *p_udev) {
udev_device *dev = NULL;
udev_monitor *mon = udev_monitor_new_from_netlink(p_udev, "udev");
@@ -186,9 +187,9 @@ void joystick_linux::monitor_joysticks(udev *p_udev) {
if (devnode_str.find(ignore_str) == -1) {
if (action == "add")
- open_joystick(devnode);
+ open_joypad(devnode);
else if (String(action) == "remove")
- close_joystick(get_joy_from_path(devnode));
+ close_joypad(get_joy_from_path(devnode));
}
}
@@ -198,12 +199,11 @@ void joystick_linux::monitor_joysticks(udev *p_udev) {
}
usleep(50000);
}
- //printf("exit udev\n");
udev_monitor_unref(mon);
}
#endif
-void joystick_linux::monitor_joysticks() {
+void JoypadLinux::monitor_joypads() {
while (!exit_udev) {
joy_mutex->lock();
@@ -211,7 +211,7 @@ void joystick_linux::monitor_joysticks() {
char fname[64];
sprintf(fname, "/dev/input/event%d", i);
if (attached_devices.find(fname) == -1) {
- open_joystick(fname);
+ open_joypad(fname);
}
}
joy_mutex->unlock();
@@ -219,37 +219,37 @@ void joystick_linux::monitor_joysticks() {
}
}
-int joystick_linux::get_free_joy_slot() const {
+int JoypadLinux::get_free_joy_slot() const {
- for (int i = 0; i < JOYSTICKS_MAX; i++) {
+ for (int i = 0; i < JOYPADS_MAX; i++) {
- if (joysticks[i].fd == -1) return i;
+ if (joypads[i].fd == -1) return i;
}
return -1;
}
-int joystick_linux::get_joy_from_path(String p_path) const {
+int JoypadLinux::get_joy_from_path(String p_path) const {
- for (int i = 0; i < JOYSTICKS_MAX; i++) {
+ for (int i = 0; i < JOYPADS_MAX; i++) {
- if (joysticks[i].devpath == p_path) {
+ if (joypads[i].devpath == p_path) {
return i;
}
}
return -2;
}
-void joystick_linux::close_joystick(int p_id) {
+void JoypadLinux::close_joypad(int p_id) {
if (p_id == -1) {
- for (int i=0; i<JOYSTICKS_MAX; i++) {
+ for (int i=0; i<JOYPADS_MAX; i++) {
- close_joystick(i);
+ close_joypad(i);
};
return;
}
else if (p_id < 0) return;
- Joystick &joy = joysticks[p_id];
+ Joypad &joy = joypads[p_id];
if (joy.fd != -1) {
@@ -258,7 +258,7 @@ void joystick_linux::close_joystick(int p_id) {
attached_devices.remove(attached_devices.find(joy.devpath));
input->joy_connection_changed(p_id, false, "");
};
-};
+}
static String _hex_str(uint8_t p_byte) {
@@ -270,11 +270,11 @@ static String _hex_str(uint8_t p_byte) {
ret[1] = dict[p_byte & 0xF];
return ret;
-};
+}
-void joystick_linux::setup_joystick_properties(int p_id) {
+void JoypadLinux::setup_joypad_properties(int p_id) {
- Joystick* joy = &joysticks[p_id];
+ Joypad* joy = &joypads[p_id];
unsigned long keybit[NBITS(KEY_MAX)] = { 0 };
unsigned long absbit[NBITS(ABS_MAX)] = { 0 };
@@ -316,13 +316,21 @@ void joystick_linux::setup_joystick_properties(int p_id) {
}
}
}
-}
+ joy->force_feedback = false;
+ joy->ff_effect_timestamp = 0;
+ unsigned long ffbit[NBITS(FF_CNT)];
+ if (ioctl(joy->fd, EVIOCGBIT(EV_FF, sizeof(ffbit)), ffbit) != -1) {
+ if (test_bit(FF_RUMBLE, ffbit)) {
+ joy->force_feedback = true;
+ }
+ }
+}
-void joystick_linux::open_joystick(const char *p_path) {
+void JoypadLinux::open_joypad(const char *p_path) {
int joy_num = get_free_joy_slot();
- int fd = open(p_path, O_RDONLY | O_NONBLOCK);
+ int fd = open(p_path, O_RDWR | O_NONBLOCK);
if (fd != -1 && joy_num != -1) {
unsigned long evbit[NBITS(EV_MAX)] = { 0 };
@@ -340,7 +348,7 @@ void joystick_linux::open_joystick(const char *p_path) {
}
//check if the device supports basic gamepad events, prevents certain keyboards from
- //being detected as joysticks
+ //being detected as joypads
if (!(test_bit(EV_KEY, evbit) && test_bit(EV_ABS, evbit) &&
(test_bit(ABS_X, absbit) || test_bit(ABS_Y, absbit) || test_bit(ABS_HAT0X, absbit) ||
test_bit(ABS_GAS, absbit) || test_bit(ABS_RUDDER, absbit)) &&
@@ -363,12 +371,12 @@ void joystick_linux::open_joystick(const char *p_path) {
return;
}
- joysticks[joy_num].reset();
+ joypads[joy_num].reset();
- Joystick &joy = joysticks[joy_num];
+ Joypad &joy = joypads[joy_num];
joy.fd = fd;
joy.devpath = String(p_path);
- setup_joystick_properties(joy_num);
+ setup_joypad_properties(joy_num);
sprintf(uid, "%04x%04x", __bswap_16(inpid.bustype), 0);
if (inpid.vendor && inpid.product && inpid.version) {
@@ -392,7 +400,54 @@ void joystick_linux::open_joystick(const char *p_path) {
}
}
-InputDefault::JoyAxis joystick_linux::axis_correct(const input_absinfo *p_abs, int p_value) const {
+void JoypadLinux::joypad_vibration_start(int p_id, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp)
+{
+ Joypad& joy = joypads[p_id];
+ if (!joy.force_feedback || joy.fd == -1 || p_weak_magnitude < 0.f || p_weak_magnitude > 1.f || p_strong_magnitude < 0.f || p_strong_magnitude > 1.f) {
+ return;
+ }
+ if (joy.ff_effect_id != -1) {
+ joypad_vibration_stop(p_id, p_timestamp);
+ }
+
+ struct ff_effect effect;
+ effect.type = FF_RUMBLE;
+ effect.id = -1;
+ effect.u.rumble.weak_magnitude = floor(p_weak_magnitude * (float)0xffff);
+ effect.u.rumble.strong_magnitude = floor(p_strong_magnitude * (float)0xffff);
+ effect.replay.length = floor(p_duration * 1000);
+ effect.replay.delay = 0;
+
+ if (ioctl(joy.fd, EVIOCSFF, &effect) < 0) {
+ return;
+ }
+
+ struct input_event play;
+ play.type = EV_FF;
+ play.code = effect.id;
+ play.value = 1;
+ write(joy.fd, (const void*)&play, sizeof(play));
+
+ joy.ff_effect_id = effect.id;
+ joy.ff_effect_timestamp = p_timestamp;
+}
+
+void JoypadLinux::joypad_vibration_stop(int p_id, uint64_t p_timestamp)
+{
+ Joypad& joy = joypads[p_id];
+ if (!joy.force_feedback || joy.fd == -1 || joy.ff_effect_id == -1) {
+ return;
+ }
+
+ if (ioctl(joy.fd, EVIOCRMFF, joy.ff_effect_id) < 0) {
+ return;
+ }
+
+ joy.ff_effect_id = -1;
+ joy.ff_effect_timestamp = p_timestamp;
+}
+
+InputDefault::JoyAxis JoypadLinux::axis_correct(const input_absinfo *p_abs, int p_value) const {
int min = p_abs->minimum;
int max = p_abs->maximum;
@@ -412,17 +467,17 @@ InputDefault::JoyAxis joystick_linux::axis_correct(const input_absinfo *p_abs, i
return jx;
}
-uint32_t joystick_linux::process_joysticks(uint32_t p_event_id) {
+uint32_t JoypadLinux::process_joypads(uint32_t p_event_id) {
if (joy_mutex->try_lock() != OK) {
return p_event_id;
}
- for (int i=0; i<JOYSTICKS_MAX; i++) {
+ for (int i=0; i<JOYPADS_MAX; i++) {
- if (joysticks[i].fd == -1) continue;
+ if (joypads[i].fd == -1) continue;
input_event events[32];
- Joystick* joy = &joysticks[i];
+ Joypad* joy = &joypads[i];
int len;
@@ -483,8 +538,21 @@ uint32_t joystick_linux::process_joysticks(uint32_t p_event_id) {
}
}
if (len == 0 || (len < 0 && errno != EAGAIN)) {
- close_joystick(i);
+ close_joypad(i);
};
+
+ if (joy->force_feedback) {
+ uint64_t timestamp = input->get_joy_vibration_timestamp(i);
+ if (timestamp > joy->ff_effect_timestamp) {
+ Vector2 strength = input->get_joy_vibration_strength(i);
+ float duration = input->get_joy_vibration_duration(i);
+ if (strength.x == 0 && strength.y == 0) {
+ joypad_vibration_stop(i, timestamp);
+ } else {
+ joypad_vibration_start(i, strength.x, strength.y, duration, timestamp);
+ }
+ }
+ }
}
joy_mutex->unlock();
return p_event_id;
diff --git a/platform/x11/joystick_linux.h b/platform/x11/joypad_linux.h
index 4f0533721b..18ad199f6b 100644
--- a/platform/x11/joystick_linux.h
+++ b/platform/x11/joypad_linux.h
@@ -1,11 +1,11 @@
/*************************************************************************/
-/* joystick_linux.h */
+/* joypad_linux.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 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 */
@@ -28,8 +28,9 @@
/*************************************************************************/
//author: Andreas Haas <hondres, liugam3@gmail.com>
-#ifndef JOYSTICK_LINUX_H
-#define JOYSTICK_LINUX_H
+#ifndef JOYPAD_LINUX_H
+#define JOYPAD_LINUX_H
+
#ifdef JOYDEV_ENABLED
#include "main/input_default.h"
#include "os/thread.h"
@@ -37,21 +38,21 @@
struct input_absinfo;
-class joystick_linux
+class JoypadLinux
{
public:
- joystick_linux(InputDefault *in);
- ~joystick_linux();
- uint32_t process_joysticks(uint32_t p_event_id);
+ JoypadLinux(InputDefault *in);
+ ~JoypadLinux();
+ uint32_t process_joypads(uint32_t p_event_id);
private:
enum {
- JOYSTICKS_MAX = 16,
+ JOYPADS_MAX = 16,
MAX_ABS = 63,
MAX_KEY = 767, // Hack because <linux/input.h> can't be included here
};
- struct Joystick {
+ struct Joypad {
InputDefault::JoyAxis curr_axis[MAX_ABS];
int key_map[MAX_KEY];
int abs_map[MAX_ABS];
@@ -61,8 +62,12 @@ private:
String devpath;
input_absinfo *abs_info[MAX_ABS];
- Joystick();
- ~Joystick();
+ bool force_feedback;
+ int ff_effect_id;
+ uint64_t ff_effect_timestamp;
+
+ Joypad();
+ ~Joypad();
void reset();
};
@@ -70,7 +75,7 @@ private:
Mutex *joy_mutex;
Thread *joy_thread;
InputDefault *input;
- Joystick joysticks[JOYSTICKS_MAX];
+ Joypad joypads[JOYPADS_MAX];
Vector<String> attached_devices;
static void joy_thread_func(void *p_user);
@@ -78,18 +83,21 @@ private:
int get_joy_from_path(String path) const;
int get_free_joy_slot() const;
- void setup_joystick_properties(int p_id);
- void close_joystick(int p_id = -1);
+ void setup_joypad_properties(int p_id);
+ void close_joypad(int p_id = -1);
#ifdef UDEV_ENABLED
- void enumerate_joysticks(struct udev *_udev);
- void monitor_joysticks(struct udev *_udev);
+ void enumerate_joypads(struct udev *_udev);
+ void monitor_joypads(struct udev *_udev);
#endif
- void monitor_joysticks();
- void run_joystick_thread();
- void open_joystick(const char* path);
+ void monitor_joypads();
+ void run_joypad_thread();
+ void open_joypad(const char* path);
+
+ void joypad_vibration_start(int p_id, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp);
+ void joypad_vibration_stop(int p_id, uint64_t p_timestamp);
InputDefault::JoyAxis axis_correct(const input_absinfo *abs, int value) const;
};
#endif
-#endif // JOYSTICK_LINUX_H
+#endif // JOYPAD_LINUX_H
diff --git a/platform/x11/key_mapping_x11.cpp b/platform/x11/key_mapping_x11.cpp
index 190d6925dd..d25fe40c4d 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-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 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 */
@@ -90,8 +90,8 @@ static _XTranslatePair _xkeysym_to_keycode[]={
{ XK_Begin, KEY_CLEAR },
{ XK_Insert, KEY_INSERT },
{ XK_Delete, KEY_DELETE },
-// { XK_KP_Equal, KEY_EQUAL },
-// { XK_KP_Separator, KEY_COMMA },
+ //{ XK_KP_Equal, KEY_EQUAL },
+ //{ XK_KP_Separator, KEY_COMMA },
{ XK_KP_Decimal, KEY_KP_PERIOD },
{ XK_KP_Delete, KEY_KP_PERIOD },
{ XK_KP_Enter, KEY_KP_ENTER },
@@ -197,6 +197,7 @@ unsigned int KeyMappingX11::get_keycode(KeySym p_keysym) {
return 0;
}
+
KeySym KeyMappingX11::get_keysym(unsigned int p_code) {
// kinda bruteforce.. could optimize.
diff --git a/platform/x11/key_mapping_x11.h b/platform/x11/key_mapping_x11.h
index e3aede8388..9749b2ec2a 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-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 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/logo.png b/platform/x11/logo.png
index c40214d6de..1cc93b46ac 100644
--- a/platform/x11/logo.png
+++ b/platform/x11/logo.png
Binary files differ
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index 66723c0295..13e01ab6ac 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-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 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 */
@@ -27,7 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "servers/visual/visual_server_raster.h"
-#include "drivers/gles2/rasterizer_gles2.h"
+#include "drivers/gles3/rasterizer_gles3.h"
#include "os_x11.h"
#include "key_mapping_x11.h"
#include <stdio.h>
@@ -57,6 +57,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
+#include <dlfcn.h>
//stupid linux.h
#ifdef KEY_TAB
@@ -73,7 +74,7 @@ int OS_X11::get_video_driver_count() const {
}
const char * OS_X11::get_video_driver_name(int p_driver) const {
- return "GLES2";
+ return "GLES3";
}
OS::VideoMode OS_X11::get_default_video_mode() const {
@@ -115,7 +116,40 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
x11_display = XOpenDisplay(NULL);
char * modifiers = XSetLocaleModifiers ("@im=none");
- ERR_FAIL_COND( modifiers == NULL );
+ if (modifiers==NULL) {
+ WARN_PRINT("Error setting locale modifiers");
+ }
+
+ const char* err;
+ xrr_get_monitors = NULL;
+ xrr_free_monitors = NULL;
+ int xrandr_major = 0;
+ int xrandr_minor = 0;
+ int event_base, error_base;
+ xrandr_ext_ok = XRRQueryExtension(x11_display,&event_base, &error_base);
+ xrandr_handle = dlopen("libXrandr.so.2", RTLD_LAZY);
+ if (!xrandr_handle) {
+ err = dlerror();
+ fprintf(stderr, "could not load libXrandr.so.2, Error: %s\n", err);
+ }
+ else {
+ XRRQueryVersion(x11_display, &xrandr_major, &xrandr_minor);
+ if (((xrandr_major << 8) | xrandr_minor) >= 0x0105) {
+ xrr_get_monitors = (xrr_get_monitors_t) dlsym(xrandr_handle, "XRRGetMonitors");
+ if (!xrr_get_monitors) {
+ err = dlerror();
+ fprintf(stderr, "could not find symbol XRRGetMonitors\nError: %s\n", err);
+ }
+ else {
+ xrr_free_monitors = (xrr_free_monitors_t) dlsym(xrandr_handle, "XRRFreeMonitors");
+ if (!xrr_free_monitors) {
+ err = dlerror();
+ fprintf(stderr, "could not find XRRFreeMonitors\nError: %s\n", err);
+ xrr_get_monitors = NULL;
+ }
+ }
+ }
+ }
xim = XOpenIM (x11_display, NULL, NULL, NULL);
@@ -169,21 +203,22 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
//print_line("def videomode "+itos(current_videomode.width)+","+itos(current_videomode.height));
#if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED)
- context_gl = memnew( ContextGL_X11( x11_display, x11_window,current_videomode, false ) );
+
+ context_gl = memnew( ContextGL_X11( x11_display, x11_window,current_videomode, true ) );
context_gl->initialize();
- rasterizer = memnew( RasterizerGLES2 );
+ RasterizerGLES3::register_config();
-#endif
- visual_server = memnew( VisualServerRaster(rasterizer) );
+ RasterizerGLES3::make_current();
+#endif
+ visual_server = memnew( VisualServerRaster );
+#if 0
if (get_render_thread_mode()!=RENDER_THREAD_UNSAFE) {
visual_server =memnew(VisualServerWrapMT(visual_server,get_render_thread_mode()==RENDER_SEPARATE_THREAD));
}
-
-#if 1
- // NEW_WM_API
+#endif
// borderless fullscreen window mode
if (current_videomode.fullscreen) {
// needed for lxde/openbox, possibly others
@@ -233,22 +268,6 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
XSetWMNormalHints(x11_display, x11_window, xsh);
XFree(xsh);
}
-#else
- capture_idle = 0;
- minimized = false;
- maximized = false;
-
- if (current_videomode.fullscreen) {
- //set_wm_border(false);
- set_wm_fullscreen(true);
- }
- if (!current_videomode.resizable) {
- int screen = get_current_screen();
- Size2i screen_size = get_screen_size(screen);
- set_window_size(screen_size);
- set_window_resizable(false);
- }
-#endif
AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton();
@@ -312,7 +331,7 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
/* set the name and class hints for the window manager to use */
classHint = XAllocClassHint();
if (classHint) {
- classHint->res_name = (char *)"Godot";
+ classHint->res_name = (char *)"Godot_Engine";
classHint->res_class = (char *)"Godot";
}
XSetClassHint(x11_display, x11_window, classHint);
@@ -406,7 +425,6 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
XFreeGC(x11_display, gc);
-
if (cursor == None)
{
ERR_PRINT("FAILED CREATING CURSOR");
@@ -440,7 +458,7 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
input = memnew( InputDefault );
#ifdef JOYDEV_ENABLED
- joystick = memnew( joystick_linux(input));
+ joypad = memnew( JoypadLinux(input));
#endif
_ensure_data_dir();
}
@@ -456,12 +474,14 @@ void OS_X11::finalize() {
spatial_sound_2d_server->finish();
memdelete(spatial_sound_2d_server);
- //if (debugger_connection_console) {
-// memdelete(debugger_connection_console);
-//}
+ /*
+ if (debugger_connection_console) {
+ memdelete(debugger_connection_console);
+ }
+ */
#ifdef JOYDEV_ENABLED
- memdelete(joystick);
+ memdelete(joypad);
#endif
memdelete(input);
@@ -472,7 +492,7 @@ void OS_X11::finalize() {
visual_server->finish();
memdelete(visual_server);
- memdelete(rasterizer);
+ //memdelete(rasterizer);
physics_server->finish();
memdelete(physics_server);
@@ -480,6 +500,9 @@ void OS_X11::finalize() {
physics_2d_server->finish();
memdelete(physics_2d_server);
+ if (xrandr_handle)
+ dlclose(xrandr_handle);
+
XUnmapWindow( x11_display, x11_window );
XDestroyWindow( x11_display, x11_window );
@@ -542,7 +565,7 @@ void OS_X11::set_mouse_mode(MouseMode p_mode) {
ButtonPressMask | ButtonReleaseMask |
PointerMotionMask, GrabModeAsync, GrabModeAsync,
x11_window, None, CurrentTime) !=
- GrabSuccess) {
+ GrabSuccess) {
ERR_PRINT("NO GRAB");
}
@@ -606,22 +629,6 @@ OS::VideoMode OS_X11::get_video_mode(int p_screen) const {
void OS_X11::get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen) const {
}
-//#ifdef NEW_WM_API
-#if 0
-// Just now not needed. Can be used for a possible OS.set_border(bool) method
-void OS_X11::set_wm_border(bool p_enabled) {
- // needed for lxde/openbox, possibly others
- Hints hints;
- Atom property;
- hints.flags = 2;
- hints.decorations = p_enabled ? 1L : 0L;
- property = XInternAtom(x11_display, "_MOTIF_WM_HINTS", True);
- XChangeProperty(x11_display, x11_window, property, property, 32, PropModeReplace, (unsigned char *)&hints, 5);
- XMapRaised(x11_display, x11_window);
- //XMoveResizeWindow(x11_display, x11_window, 0, 0, 800, 800);
-}
-#endif
-
void OS_X11::set_wm_fullscreen(bool p_enabled) {
// Using EWMH -- Extened Window Manager Hints
XEvent xev;
@@ -722,6 +729,46 @@ Size2 OS_X11::get_screen_size(int p_screen) const {
return size;
}
+int OS_X11::get_screen_dpi(int p_screen) const {
+
+ //invalid screen?
+ ERR_FAIL_INDEX_V(p_screen, get_screen_count(), 0);
+
+ //Get physical monitor Dimensions through XRandR and calculate dpi
+ Size2 sc = get_screen_size(p_screen);
+ if (xrandr_ext_ok) {
+ int count = 0;
+ if (xrr_get_monitors) {
+ xrr_monitor_info *monitors = xrr_get_monitors(x11_display, x11_window, true, &count);
+ if (p_screen < count) {
+ double xdpi = sc.width / (double) monitors[p_screen].mwidth * 25.4;
+ double ydpi = sc.height / (double) monitors[p_screen].mheight * 25.4;
+ xrr_free_monitors(monitors);
+ return (xdpi + ydpi) / 2;
+ }
+ xrr_free_monitors(monitors);
+ }
+ else if (p_screen == 0) {
+ XRRScreenSize *sizes = XRRSizes(x11_display, 0, &count);
+ if (sizes) {
+ double xdpi = sc.width / (double) sizes[0].mwidth * 25.4;
+ double ydpi = sc.height / (double) sizes[0].mheight * 25.4;
+ return (xdpi + ydpi) / 2;
+ }
+ }
+ }
+
+ int width_mm = DisplayWidthMM(x11_display, p_screen);
+ int height_mm = DisplayHeightMM(x11_display, p_screen);
+ double xdpi = (width_mm ? sc.width / (double) width_mm * 25.4 : 0);
+ double ydpi = (height_mm ? sc.height / (double) height_mm * 25.4 : 0);
+ if (xdpi || xdpi)
+ return (xdpi + ydpi)/(xdpi && ydpi ? 2 : 1);
+
+ //could not get dpi
+ return 96;
+}
+
Point2 OS_X11::get_window_position() const {
int x,y;
Window child;
@@ -734,54 +781,7 @@ Point2 OS_X11::get_window_position() const {
}
void OS_X11::set_window_position(const Point2& p_position) {
- // Using EWMH -- Extended Window Manager Hints
- // to get the size of the decoration
-#if 0
- Atom property = XInternAtom(x11_display,"_NET_FRAME_EXTENTS", True);
- Atom type;
- int format;
- unsigned long len;
- unsigned long remaining;
- unsigned char *data = NULL;
- int result;
-
- result = XGetWindowProperty(
- x11_display,
- x11_window,
- property,
- 0,
- 32,
- False,
- AnyPropertyType,
- &type,
- &format,
- &len,
- &remaining,
- &data
- );
-
- long left = 0L;
- long top = 0L;
-
- if( result == Success ) {
- long *extends = (long *) data;
-
- left = extends[0];
- top = extends[2];
-
- XFree(data);
- }
-
- int screen = get_current_screen();
- Point2i screen_position = get_screen_position(screen);
-
- left -= screen_position.x;
- top -= screen_position.y;
-
- XMoveWindow(x11_display,x11_window,p_position.x - left,p_position.y - top);
-#else
XMoveWindow(x11_display,x11_window,p_position.x,p_position.y);
-#endif
}
Size2 OS_X11::get_window_size() const {
@@ -825,20 +825,19 @@ bool OS_X11::is_window_resizable() const {
}
void OS_X11::set_window_minimized(bool p_enabled) {
- // Using ICCCM -- Inter-Client Communication Conventions Manual
- XEvent xev;
- Atom wm_change = XInternAtom(x11_display, "WM_CHANGE_STATE", False);
+ // Using ICCCM -- Inter-Client Communication Conventions Manual
+ XEvent xev;
+ Atom wm_change = XInternAtom(x11_display, "WM_CHANGE_STATE", False);
- memset(&xev, 0, sizeof(xev));
- xev.type = ClientMessage;
- xev.xclient.window = x11_window;
- xev.xclient.message_type = wm_change;
- xev.xclient.format = 32;
- xev.xclient.data.l[0] = p_enabled ? WM_IconicState : WM_NormalState;
+ memset(&xev, 0, sizeof(xev));
+ xev.type = ClientMessage;
+ xev.xclient.window = x11_window;
+ xev.xclient.message_type = wm_change;
+ xev.xclient.format = 32;
+ xev.xclient.data.l[0] = p_enabled ? WM_IconicState : WM_NormalState;
- XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
+ XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
- //XEvent xev;
Atom wm_state = XInternAtom(x11_display, "_NET_WM_STATE", False);
Atom wm_hidden = XInternAtom(x11_display, "_NET_WM_STATE_HIDDEN", False);
@@ -902,47 +901,33 @@ void OS_X11::set_window_maximized(bool p_enabled) {
xev.xclient.data.l[2] = wm_max_vert;
XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
-/* sorry this does not fix it, fails on multi monitor
- XWindowAttributes xwa;
- 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;
}
bool OS_X11::is_window_maximized() const {
// Using EWMH -- Extended Window Manager Hints
- Atom property = XInternAtom(x11_display,"_NET_WM_STATE",False );
- Atom type;
- int format;
- unsigned long len;
- unsigned long remaining;
- unsigned char *data = NULL;
+ Atom property = XInternAtom(x11_display,"_NET_WM_STATE",False );
+ Atom type;
+ int format;
+ unsigned long len;
+ unsigned long remaining;
+ unsigned char *data = NULL;
- int result = XGetWindowProperty(
- x11_display,
- x11_window,
- property,
- 0,
- 1024,
- False,
- XA_ATOM,
- &type,
- &format,
- &len,
- &remaining,
- &data
- );
+ int result = XGetWindowProperty(
+ x11_display,
+ x11_window,
+ property,
+ 0,
+ 1024,
+ False,
+ XA_ATOM,
+ &type,
+ &format,
+ &len,
+ &remaining,
+ &data
+ );
if(result == Success) {
Atom *atoms = (Atom*) data;
@@ -966,6 +951,26 @@ bool OS_X11::is_window_maximized() const {
return false;
}
+void OS_X11::request_attention() {
+ // Using EWMH -- Extended Window Manager Hints
+ //
+ // Sets the _NET_WM_STATE_DEMANDS_ATTENTION atom for WM_STATE
+ // Will be unset by the window manager after user react on the request for attention
+ //
+ XEvent xev;
+ Atom wm_state = XInternAtom(x11_display, "_NET_WM_STATE", False);
+ Atom wm_attention = XInternAtom(x11_display, "_NET_WM_STATE_DEMANDS_ATTENTION", False);
+
+ memset(&xev, 0, sizeof(xev));
+ xev.type = ClientMessage;
+ xev.xclient.window = x11_window;
+ xev.xclient.message_type = wm_state;
+ xev.xclient.format = 32;
+ xev.xclient.data.l[0] = _NET_WM_STATE_ADD;
+ xev.xclient.data.l[1] = wm_attention;
+
+ XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
+}
InputModifierState OS_X11::get_key_modifier_state(unsigned int p_x11_state) {
@@ -1176,6 +1181,19 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) {
event.key.mod.shift=true;
}
+ //don't set mod state if modifier keys are released by themselves
+ //else event.is_action() will not work correctly here
+ if (!event.key.pressed) {
+ if (event.key.scancode == KEY_SHIFT)
+ event.key.mod.shift = false;
+ else if (event.key.scancode == KEY_CONTROL)
+ event.key.mod.control = false;
+ else if (event.key.scancode == KEY_ALT)
+ event.key.mod.alt = false;
+ else if (event.key.scancode == KEY_META)
+ event.key.mod.meta = false;
+ }
+
//printf("key: %x\n",event.key.scancode);
input->parse_input_event( event);
}
@@ -1286,11 +1304,6 @@ void OS_X11::process_xevents() {
} break;
case FocusIn:
minimized = false;
-#ifdef NEW_WM_API
- if(current_videomode.fullscreen) {
- set_wm_fullscreen(true);
- }
-#endif
main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
if (mouse_mode==MOUSE_MODE_CAPTURED) {
XGrabPointer(x11_display, x11_window, True,
@@ -1301,12 +1314,6 @@ void OS_X11::process_xevents() {
break;
case FocusOut:
-#ifdef NEW_WM_API
- if(current_videomode.fullscreen) {
- set_wm_fullscreen(false);
- set_window_minimized(true);
- }
-#endif
main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
if (mouse_mode==MOUSE_MODE_CAPTURED) {
//dear X11, I try, I really try, but you never work, you do whathever you want.
@@ -1450,13 +1457,6 @@ void OS_X11::process_xevents() {
Point2i rel = pos - last_mouse_pos;
-#ifdef NEW_WM_API
- if (mouse_mode==MOUSE_MODE_CAPTURED) {
- pos.x = current_videomode.width / 2;
- pos.y = current_videomode.height / 2;
- }
-#endif
-
InputEvent motion_event;
motion_event.ID=++event_id;
motion_event.type=InputEvent::MOUSE_MOTION;
@@ -1469,8 +1469,8 @@ void OS_X11::process_xevents() {
input->set_mouse_pos(pos);
motion_event.mouse_motion.global_x=pos.x;
motion_event.mouse_motion.global_y=pos.y;
- motion_event.mouse_motion.speed_x=input->get_mouse_speed().x;
- motion_event.mouse_motion.speed_y=input->get_mouse_speed().y;
+ motion_event.mouse_motion.speed_x=input->get_last_mouse_speed().x;
+ motion_event.mouse_motion.speed_y=input->get_last_mouse_speed().y;
motion_event.mouse_motion.relative_x=rel.x;
motion_event.mouse_motion.relative_y=rel.y;
@@ -1550,7 +1550,7 @@ void OS_X11::process_xevents() {
//Reply that all is well.
XClientMessageEvent m;
- memset(&m, sizeof(m), 0);
+ memset(&m, 0, sizeof(m));
m.type = ClientMessage;
m.display = x11_display;
m.window = xdnd_source_window;
@@ -1587,7 +1587,7 @@ void OS_X11::process_xevents() {
//xdnd position event, reply with an XDND status message
//just depending on type of data for now
XClientMessageEvent m;
- memset(&m, sizeof(m), 0);
+ memset(&m, 0, sizeof(m));
m.type = ClientMessage;
m.display = event.xclient.display;
m.window = event.xclient.data.l[0];
@@ -1614,7 +1614,7 @@ void OS_X11::process_xevents() {
else {
//Reply that we're not interested.
XClientMessageEvent m;
- memset(&m, sizeof(m), 0);
+ memset(&m, 0, sizeof(m));
m.type = ClientMessage;
m.display = event.xclient.display;
m.window = event.xclient.data.l[0];
@@ -1696,7 +1696,6 @@ static String _get_clipboard(Atom p_source, Window x11_window, ::Display* x11_di
if (Sown == x11_window) {
- printf("returning internal clipboard\n");
return p_internal_clipboard;
};
@@ -1740,7 +1739,7 @@ static String _get_clipboard(Atom p_source, Window x11_window, ::Display* x11_di
return ret;
-};
+}
String OS_X11::get_clipboard() const {
@@ -1752,7 +1751,7 @@ String OS_X11::get_clipboard() const {
};
return ret;
-};
+}
String OS_X11::get_name() {
@@ -1884,7 +1883,7 @@ void OS_X11::set_icon(const Image& p_icon) {
if (!p_icon.empty()) {
Image img=p_icon;
- img.convert(Image::FORMAT_RGBA);
+ img.convert(Image::FORMAT_RGBA8);
int w = img.get_width();
int h = img.get_height();
@@ -1897,7 +1896,7 @@ void OS_X11::set_icon(const Image& p_icon) {
pd[0]=w;
pd[1]=h;
- DVector<uint8_t>::Read r = img.get_data().read();
+ PoolVector<uint8_t>::Read r = img.get_data().read();
long * wr = &pd[2];
uint8_t const * pr = r.ptr();
@@ -1926,16 +1925,16 @@ void OS_X11::run() {
main_loop->init();
-// uint64_t last_ticks=get_ticks_usec();
+ //uint64_t last_ticks=get_ticks_usec();
-// int frames=0;
-// uint64_t frame=0;
+ //int frames=0;
+ //uint64_t frame=0;
while (!force_quit) {
process_xevents(); // get rid of pending events
#ifdef JOYDEV_ENABLED
- event_id = joystick->process_joysticks(event_id);
+ event_id = joypad->process_joypads(event_id);
#endif
if (Main::iteration()==true)
break;
@@ -1952,6 +1951,20 @@ String OS_X11::get_joy_guid(int p_device) const {
return input->get_joy_guid_remapped(p_device);
}
+void OS_X11::set_use_vsync(bool p_enable) {
+ if (context_gl)
+ return context_gl->set_use_vsync(p_enable);
+}
+
+bool OS_X11::is_vsync_enabled() const {
+
+ if (context_gl)
+ return context_gl->is_using_vsync();
+
+ return true;
+}
+
+
void OS_X11::set_context(int p_context) {
XClassHint* classHint = NULL;
@@ -1982,7 +1995,12 @@ OS_X11::OS_X11() {
AudioDriverManagerSW::add_driver(&driver_alsa);
#endif
+ if(AudioDriverManagerSW::get_driver_count() == 0){
+ WARN_PRINT("No sound driver found... Defaulting to dummy driver");
+ AudioDriverManagerSW::add_driver(&driver_dummy);
+ }
+
minimized = false;
xim_style=0L;
mouse_mode=MOUSE_MODE_VISIBLE;
-};
+}
diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h
index 1369340b04..bf676b5edf 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-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 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 */
@@ -34,7 +34,7 @@
#include "drivers/unix/os_unix.h"
#include "context_gl_x11.h"
#include "servers/visual_server.h"
-#include "servers/visual/visual_server_wrap_mt.h"
+//#include "servers/visual/visual_server_wrap_mt.h"
#include "servers/visual/rasterizer.h"
#include "servers/physics_server.h"
#include "servers/audio/audio_server_sw.h"
@@ -44,14 +44,16 @@
#include "drivers/rtaudio/audio_driver_rtaudio.h"
#include "drivers/alsa/audio_driver_alsa.h"
#include "drivers/pulseaudio/audio_driver_pulseaudio.h"
+#include "servers/audio/audio_driver_dummy.h"
#include "servers/physics_2d/physics_2d_server_sw.h"
#include "servers/physics_2d/physics_2d_server_wrap_mt.h"
#include "main/input_default.h"
-#include "joystick_linux.h"
+#include "joypad_linux.h"
#include <X11/keysym.h>
#include <X11/Xlib.h>
#include <X11/Xcursor/Xcursor.h>
+#include <X11/extensions/Xrandr.h>
// Hints for X11 fullscreen
typedef struct {
@@ -62,6 +64,20 @@ typedef struct {
unsigned long status;
} Hints;
+typedef struct _xrr_monitor_info {
+ Atom name;
+ Bool primary;
+ Bool automatic;
+ int noutput;
+ int x;
+ int y;
+ int width;
+ int height;
+ int mwidth;
+ int mheight;
+ RROutput *outputs;
+} xrr_monitor_info;
+
#undef CursorShape
/**
@author Juan Linietsky <reduzio@gmail.com>
@@ -84,7 +100,7 @@ class OS_X11 : public OS_Unix {
#if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED)
ContextGL_X11 *context_gl;
#endif
- Rasterizer *rasterizer;
+ //Rasterizer *rasterizer;
VisualServer *visual_server;
VideoMode current_videomode;
List<String> args;
@@ -139,7 +155,7 @@ class OS_X11 : public OS_Unix {
InputDefault *input;
#ifdef JOYDEV_ENABLED
- joystick_linux *joystick;
+ JoypadLinux *joypad;
#endif
#ifdef RTAUDIO_ENABLED
@@ -153,6 +169,7 @@ class OS_X11 : public OS_Unix {
#ifdef PULSEAUDIO_ENABLED
AudioDriverPulseAudio driver_pulseaudio;
#endif
+ AudioDriverDummy driver_dummy;
Atom net_wm_icon;
@@ -162,6 +179,12 @@ class OS_X11 : public OS_Unix {
//void set_wm_border(bool p_enabled);
void set_wm_fullscreen(bool p_enabled);
+ typedef xrr_monitor_info* (*xrr_get_monitors_t)(Display *dpy, Window window, Bool get_active, int *nmonitors);
+ typedef void (*xrr_free_monitors_t)(xrr_monitor_info* monitors);
+ xrr_get_monitors_t xrr_get_monitors;
+ xrr_free_monitors_t xrr_free_monitors;
+ void *xrandr_handle;
+ Bool xrandr_ext_ok;
protected:
@@ -219,6 +242,7 @@ public:
virtual void set_current_screen(int p_screen);
virtual Point2 get_screen_position(int p_screen=0) const;
virtual Size2 get_screen_size(int p_screen=0) const;
+ virtual int get_screen_dpi(int p_screen=0) const;
virtual Point2 get_window_position() const;
virtual void set_window_position(const Point2& p_position);
virtual Size2 get_window_size() const;
@@ -231,6 +255,7 @@ public:
virtual bool is_window_minimized() const;
virtual void set_window_maximized(bool p_enabled);
virtual bool is_window_maximized() const;
+ virtual void request_attention();
virtual void move_window_to_foreground();
virtual void alert(const String& p_alert,const String& p_title="ALERT!");
@@ -240,6 +265,9 @@ public:
virtual void set_context(int p_context);
+ virtual void set_use_vsync(bool p_enable);
+ virtual bool is_vsync_enabled() const;
+
void run();
OS_X11();
diff --git a/platform/x11/platform_config.h b/platform/x11/platform_config.h
index aac50c27c2..342270b74a 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-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 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 */
@@ -34,6 +34,4 @@
#define PTHREAD_BSD_SET_NAME
#endif
-#define GLES2_INCLUDE_H "gl_context/glew.h"
-
-
+#define GLES3_INCLUDE_H "glad/glad.h"