Made XInput2 optional at compile-time.

This is required for RHEL 5, CentOS 5 and Cygwin-X.

Fixes #314.
This commit is contained in:
Camilla Berglund 2015-01-27 23:48:29 +01:00
parent 93855ae6ab
commit f4c127f75a
7 changed files with 40 additions and 22 deletions

View File

@ -273,19 +273,19 @@ if (_GLFW_X11)
list(APPEND glfw_PKG_DEPS "xinerama")
# Check for XInput (high-resolution cursor motion)
if (NOT X11_Xinput_FOUND)
message(FATAL_ERROR "The XInput library and headers were not found")
endif()
if (X11_Xinput_FOUND)
list(APPEND glfw_INCLUDE_DIRS "${X11_Xinput_INCLUDE_PATH}")
list(APPEND glfw_PKG_DEPS "xi")
list(APPEND glfw_INCLUDE_DIRS "${X11_Xinput_INCLUDE_PATH}")
if (X11_Xinput_LIB)
list(APPEND glfw_LIBRARIES "${X11_Xinput_LIB}")
else()
# Backwards compatibility (bug in CMake 2.8.7)
list(APPEND glfw_LIBRARIES Xi)
endif()
if (X11_Xinput_LIB)
list(APPEND glfw_LIBRARIES "${X11_Xinput_LIB}")
else()
# Backwards compatibility (bug in CMake 2.8.7)
list(APPEND glfw_LIBRARIES Xi)
set(_GLFW_HAS_XINPUT TRUE)
endif()
list(APPEND glfw_PKG_DEPS "xi")
# Check for Xf86VidMode (fallback gamma control)
if (NOT X11_xf86vmode_FOUND)

View File

@ -64,6 +64,7 @@ GLFW bundles a number of dependencies in the `deps/` directory.
- [Cocoa] Bugfix: `glfwSetWindowSize` did not change the video mode for full
screen windows
- [X11] Made XInput2 optional at compile-time
## Contact

View File

@ -302,6 +302,11 @@ point retrieval mechanism.
- `_GLFW_HAS_GLXGETPROCADDRESSEXT` to use `glXGetProcAddressEXT` (legacy)
- `_GLFW_HAS_DLOPEN` to do manual retrieval with `dlopen` (fallback)
In addition, support for the following X11 extensions can be enabled:
- `_GLFW_HAS_XINPUT` to use XInput2 for high-resolution cursor motion
(recommended)
If you are using the Cocoa window creation API, the following options are
available:

View File

@ -62,6 +62,8 @@
// Define this to 1 to force use of high-performance GPU on Optimus systems
#cmakedefine _GLFW_USE_OPTIMUS_HPG
// Define this to 1 if the XInput X11 extension is available
#cmakedefine _GLFW_HAS_XINPUT
// Define this to 1 if glXGetProcAddress is available
#cmakedefine _GLFW_HAS_GLXGETPROCADDRESS
// Define this to 1 if glXGetProcAddressARB is available

View File

@ -535,6 +535,7 @@ static GLboolean initExtensions(void)
_glfw.x11.xinerama.available = GL_TRUE;
}
#if defined(_GLFW_HAS_XINPUT)
if (XQueryExtension(_glfw.x11.display,
"XInputExtension",
&_glfw.x11.xi.majorOpcode,
@ -551,6 +552,7 @@ static GLboolean initExtensions(void)
_glfw.x11.xi.available = GL_TRUE;
}
}
#endif /*_GLFW_HAS_XINPUT*/
// Check if Xkb is supported on this display
_glfw.x11.xkb.versionMajor = 1;

View File

@ -43,15 +43,17 @@
// The XRandR extension provides mode setting and gamma control
#include <X11/extensions/Xrandr.h>
// The XInput2 extension provides improved input events
#include <X11/extensions/XInput2.h>
// The Xkb extension provides improved keyboard support
#include <X11/XKBlib.h>
// The Xinerama extension provides legacy monitor indices
#include <X11/extensions/Xinerama.h>
#if defined(_GLFW_HAS_XINPUT)
// The XInput2 extension provides improved input events
#include <X11/extensions/XInput2.h>
#endif
#include "posix_tls.h"
#if defined(_GLFW_GLX)
@ -188,15 +190,6 @@ typedef struct _GLFWlibraryX11
int versionMinor;
} xkb;
struct {
GLboolean available;
int majorOpcode;
int eventBase;
int errorBase;
int versionMajor;
int versionMinor;
} xi;
struct {
int count;
int timeout;
@ -215,6 +208,17 @@ typedef struct _GLFWlibraryX11
int versionMinor;
} xinerama;
#if defined(_GLFW_HAS_XINPUT)
struct {
GLboolean available;
int majorOpcode;
int eventBase;
int errorBase;
int versionMajor;
int versionMinor;
} xi;
#endif /*_GLFW_HAS_XINPUT*/
} _GLFWlibraryX11;

View File

@ -412,6 +412,7 @@ static GLboolean createWindow(_GLFWwindow* window,
XFree(hint);
}
#if defined(_GLFW_HAS_XINPUT)
if (_glfw.x11.xi.available)
{
// Select for XInput2 events
@ -426,6 +427,7 @@ static GLboolean createWindow(_GLFWwindow* window,
XISelectEvents(_glfw.x11.display, window->x11.handle, &eventmask, 1);
}
#endif /*_GLFW_HAS_XINPUT*/
if (_glfw.x11.XdndAware)
{
@ -1310,6 +1312,7 @@ static void processEvent(XEvent *event)
case DestroyNotify:
return;
#if defined(_GLFW_HAS_XINPUT)
case GenericEvent:
{
if (event->xcookie.extension == _glfw.x11.xi.majorOpcode &&
@ -1355,6 +1358,7 @@ static void processEvent(XEvent *event)
XFreeEventData(_glfw.x11.display, &event->xcookie);
break;
}
#endif /*_GLFW_HAS_XINPUT*/
default:
{