Skip to content

Commit

Permalink
Merge branch 'stable'
Browse files Browse the repository at this point in the history
  • Loading branch information
phire committed Jul 4, 2015
2 parents 3bbb2ed + 8a50dc8 commit d257800
Show file tree
Hide file tree
Showing 9 changed files with 482 additions and 9 deletions.
44 changes: 36 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ option(ENABLE_QT "Enable Qt (use the experimental Qt interface)" OFF)
option(ENABLE_PCH "Use PCH to speed up compilation" ON)
option(ENABLE_LTO "Enables Link Time Optimization" OFF)
option(ENABLE_GENERIC "Enables generic build that should run on any little-endian host" OFF)

# Enable SDL for default on operating systems that aren't OSX, Android, Linux or Windows.
if(NOT APPLE AND NOT ANDROID AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND NOT MSVC)
option(ENABLE_SDL "Enables SDL as a generic controller backend" ON)
else()
option(ENABLE_SDL "Enables SDL as a generic controller backend" OFF)
endif()

if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND NOT ANDROID)
option(ENABLE_EVDEV "Enables the evdev controller backend" ON)
endif()

if(APPLE)
option(OSX_USE_DEFAULT_SEARCH_PATH "Don't prioritize system library paths" OFF)
endif()
Expand Down Expand Up @@ -300,6 +312,14 @@ if(WIN32)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
endif(WIN32)

# Dolphin requires threads.
# The Apple build may not need an explicit flag because one of the
# frameworks may already provide it.
# But for non-OSX systems, we will use the CMake Threads package.
IF(NOT APPLE)
FIND_PACKAGE(Threads)
ENDIF(NOT APPLE)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Build type (Release/Debug/RelWithDebInfo/MinSizeRe)" FORCE)
Expand Down Expand Up @@ -508,6 +528,19 @@ if(USE_EGL)
add_definitions(-DUSE_EGL=1)
endif()

if(ENABLE_EVDEV)
include(FindLibudev REQUIRED)
include(FindLibevdev REQUIRED)
if(LIBUDEV_FOUND AND LIBEVDEV_FOUND)
message("libevdev/libudev found, enabling evdev controller backend")
add_definitions(-DHAVE_LIBUDEV=1)
add_definitions(-DHAVE_LIBEVDEV=1)
include_directories(${LIBUDEV_INCLUDE_DIR} ${LIBEVDEV_INCLUDE_DIR})
else()
message(FATAL_ERROR "Couldn't find libevdev and/or libudev. Can't build evdev controller backend.\nDisable ENABLE_EVDEV if you wish to build without controller support")
endif()
endif()

########################################
# Setup include directories (and make sure they are preferred over the Externals)
#
Expand Down Expand Up @@ -614,26 +647,21 @@ if(OPENAL_FOUND)
endif()
endif()

if(NOT ANDROID)
if(NOT APPLE)
include(FindSDL2 OPTIONAL)
endif()
if(ENABLE_SDL)
include(FindSDL2 OPTIONAL)
if(SDL2_FOUND)
message("Using shared SDL2")
add_definitions(-DHAVE_SDL=1)
include_directories(${SDL2_INCLUDE_DIR})
else(SDL2_FOUND)
# SDL2 not found, try SDL
if(NOT APPLE)
include(FindSDL OPTIONAL)
endif()
include(FindSDL OPTIONAL)
if(SDL_FOUND)
message("Using shared SDL")
add_definitions(-DHAVE_SDL=1)
include_directories(${SDL_INCLUDE_DIR})
else(SDL_FOUND)
message("SDL NOT found, disabling SDL input")
add_definitions(-DHAVE_SDL=0)
endif(SDL_FOUND)
endif(SDL2_FOUND)
endif()
Expand Down
33 changes: 33 additions & 0 deletions CMakeTests/FindLibevdev.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# - Try to find libevdev
# Once done this will define
# LIBEVDEV_FOUND - System has libevdev
# LIBEVDEV_INCLUDE_DIRS - The libevdev include directories
# LIBEVDEV_LIBRARIES - The libraries needed to use libevdev

find_package(PkgConfig)
pkg_check_modules(PC_LIBEVDEV QUIET libevdev)

FIND_PATH(
LIBEVDEV_INCLUDE_DIR libevdev/libevdev.h
HINTS ${PC_LIBEVDEV_INCLUDEDIR} ${PC_LIBEVDEV_INCLUDE_DIRS}
/usr/include
/usr/local/include
${LIBEVDEV_PATH_INCLUDES}
)

FIND_LIBRARY(
LIBEVDEV_LIBRARY
NAMES evdev libevdev
HINTS ${PC_LIBEVDEV_LIBDIR} ${PC_LIBEVDEV_LIBRARY_DIRS}
PATHS ${ADDITIONAL_LIBRARY_PATHS}
${LIBEVDEV_PATH_LIB}
)

set(LIBEVDEV_LIBRARIES ${LIBEVDEV_LIBRARY} )
set(LIBEVDEV_INCLUDE_DIRS ${LIBEVDEV_INCLUDE_DIR} )

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(libevdev DEFAULT_MSG
LIBEVDEV_LIBRARY LIBEVDEV_INCLUDE_DIR)

mark_as_advanced(LIBEVDEV_INCLUDE_DIR LIBEVDEV_LIBRARY )
28 changes: 28 additions & 0 deletions CMakeTests/FindLibudev.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# - Try to find LIBUDEV
# Once done this will define
# LIBUDEV_FOUND - System has LIBUDEV
# LIBUDEV_INCLUDE_DIRS - The LIBUDEV include directories
# LIBUDEV_LIBRARIES - The libraries needed to use LIBUDEV

FIND_PATH(
LIBUDEV_INCLUDE_DIR libudev.h
/usr/include
/usr/local/include
${LIBUDEV_PATH_INCLUDES}
)

FIND_LIBRARY(
LIBUDEV_LIBRARY
NAMES udev libudev
PATHS ${ADDITIONAL_LIBRARY_PATHS}
${LIBUDEV_PATH_LIB}
)

set(LIBUDEV_LIBRARIES ${LIBUDEV_LIBRARY} )
set(LIBUDEV_INCLUDE_DIRS ${LIBUDEV_INCLUDE_DIR} )

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LIBUDEV DEFAULT_MSG
LIBUDEV_LIBRARY LIBUDEV_INCLUDE_DIR)

mark_as_advanced(LIBUDEV_INCLUDE_DIR LIBUDEV_LIBRARY )
15 changes: 14 additions & 1 deletion CMakeTests/FindSDL2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,22 @@ IF(SDL2_LIBRARY_TEMP)
SET(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "")

SET(SDL2_FOUND "YES")

# extract the major and minor version numbers from SDL2/SDL_version.h
# we have to handle framework a little bit differently :
if("${SDL2_INCLUDE_DIR}" MATCHES ".framework")
set(SDL2_VERSION_H_INPUT "${SDL2_INCLUDE_DIR}/Headers/SDL_version.h")
else()
set(SDL2_VERSION_H_INPUT "${SDL2_INCLUDE_DIR}/SDL_version.h")
endif()
FILE(READ "${SDL2_VERSION_H_INPUT}" SDL2_VERSION_H_CONTENTS)
STRING(REGEX REPLACE ".*#define[ \t]+SDL_MAJOR_VERSION[ \t]+([0-9]+).*#define[ \t]+SDL_MINOR_VERSION[ \t]+([0-9]+).*#define[ \t]+SDL_PATCHLEVEL[ \t]+([0-9]+).*"
"\\1.\\2.\\3" SDL2_VERSION "${SDL2_VERSION_H_CONTENTS}")
#MESSAGE("SDL2 Version is ${SDL2_VERSION}")

ENDIF(SDL2_LIBRARY_TEMP)

INCLUDE(FindPackageHandleStandardArgs)

FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2
REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR)
REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR VERSION_VAR SDL2_VERSION)
5 changes: 5 additions & 0 deletions Source/Core/InputCommon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ elseif(ANDROID)
ControllerInterface/Android/Android.cpp)
endif()

if(LIBEVDEV_FOUND AND LIBUDEV_FOUND)
set(SRCS ${SRCS} ControllerInterface/evdev/evdev.cpp)
set(LIBS ${LIBS} ${LIBEVDEV_LIBRARY} ${LIBUDEV_LIBRARY})
endif()

if(SDL_FOUND OR SDL2_FOUND)
set(SRCS ${SRCS} ControllerInterface/SDL/SDL.cpp)
if (SDL2_FOUND)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#ifdef CIFACE_USE_ANDROID
#include "InputCommon/ControllerInterface/Android/Android.h"
#endif
#ifdef CIFACE_USE_EVDEV
#include "InputCommon/ControllerInterface/evdev/evdev.h"
#endif

using namespace ciface::ExpressionParser;

Expand Down Expand Up @@ -69,6 +72,9 @@ void ControllerInterface::Initialize(void* const hwnd)
#ifdef CIFACE_USE_ANDROID
ciface::Android::Init(m_devices);
#endif
#ifdef CIFACE_USE_EVDEV
ciface::evdev::Init(m_devices);
#endif

m_is_init = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
#if defined(HAVE_SDL) && HAVE_SDL
#define CIFACE_USE_SDL
#endif
#if defined(HAVE_LIBEVDEV) && defined(HAVE_LIBUDEV)
#define CIFACE_USE_EVDEV
#endif

//
// ControllerInterface
Expand Down
Loading

0 comments on commit d257800

Please sign in to comment.