Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add X11 XInput2 input plugin, including MPX and with support for axis…
… controls.

Based on the original XLib plugin, and thus shares some of its warts.
  • Loading branch information
Max-E committed Jul 20, 2013
1 parent 2e92e38 commit 9fbc5ff
Show file tree
Hide file tree
Showing 7 changed files with 560 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Expand Up @@ -430,6 +430,12 @@ if(NOT ANDROID)
else()
add_definitions(-DHAVE_XRANDR=0)
endif(XRANDR_FOUND)
include(FindX11XInput2)
if(X11_Xinput2_FOUND)
add_definitions(-DHAVE_X11_XINPUT2=1)
else()
add_definitions(-DHAVE_X11_XINPUT2=0)
endif(X11_Xinput2_FOUND)
endif()
if(ENCODE_FRAMEDUMPS)
check_libav()
Expand Down
30 changes: 30 additions & 0 deletions CMakeTests/FindX11XInput2.cmake
@@ -0,0 +1,30 @@
# For finding the X11 XInput extension, version 2. Because the standard CMake
# FindX11.cmake may only know to look for version 1. Newer versions of CMake
# than 2.8.7 might not have this problem, I wouldn't know. Better to be safe.


if(USE_X11)

IF(NOT X11_FOUND)
INCLUDE(FindX11)
ENDIF(NOT X11_FOUND)

IF(X11_FOUND)
FIND_PATH(X11_Xinput2_INCLUDE_PATH X11/extensions/XInput2.h ${X11_INC_SEARCH_PATH})

FIND_LIBRARY(X11_Xinput2_LIB Xi ${X11_LIB_SEARCH_PATH})

IF (X11_Xinput2_INCLUDE_PATH AND X11_Xinput2_LIB)
SET(X11_Xinput2_FOUND TRUE)
SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xinput2_INCLUDE_PATH})
message("X11 Xinput2 found")
ENDIF (X11_Xinput2_INCLUDE_PATH AND X11_Xinput2_LIB)

MARK_AS_ADVANCED(
X11_Xinput2_INCLUDE_PATH
X11_Xinput2_LIB
)

ENDIF(X11_FOUND)

endif()
4 changes: 4 additions & 0 deletions Source/Core/InputCommon/CMakeLists.txt
Expand Up @@ -23,6 +23,10 @@ elseif(X11_FOUND)
set(SRCS ${SRCS}
Src/ControllerInterface/SDL/SDL.cpp
Src/ControllerInterface/Xlib/Xlib.cpp)
if(X11_Xinput2_FOUND)
set(SRCS ${SRCS}
Src/ControllerInterface/Xlib/XInput2.cpp)
endif()
elseif(ANDROID)
set(SRCS ${SRCS}
Src/ControllerInterface/Android/Android.cpp)
Expand Down
Expand Up @@ -8,6 +8,9 @@
#endif
#ifdef CIFACE_USE_XLIB
#include "Xlib/Xlib.h"
#ifdef CIFACE_USE_X11_XINPUT2
#include "Xlib/XInput2.h"
#endif
#endif
#ifdef CIFACE_USE_OSX
#include "OSX/OSX.h"
Expand Down Expand Up @@ -48,6 +51,9 @@ void ControllerInterface::Initialize()
#endif
#ifdef CIFACE_USE_XLIB
ciface::Xlib::Init(m_devices, m_hwnd);
#ifdef CIFACE_USE_X11_XINPUT2
ciface::XInput2::Init(m_devices, m_hwnd);
#endif
#endif
#ifdef CIFACE_USE_OSX
ciface::OSX::Init(m_devices, m_hwnd);
Expand Down
Expand Up @@ -21,6 +21,9 @@
#if defined(HAVE_X11) && HAVE_X11
#define CIFACE_USE_XLIB
#define CIFACE_USE_SDL
#if defined(HAVE_X11_XINPUT2) && HAVE_X11_XINPUT2
#define CIFACE_USE_X11_XINPUT2
#endif
#endif
#if defined(__APPLE__)
#define CIFACE_USE_OSX
Expand Down

0 comments on commit 9fbc5ff

Please sign in to comment.