Skip to content

Commit

Permalink
Merge pull request #47 from kodi-game/retroplayer
Browse files Browse the repository at this point in the history
Controller translation and udev support from RetroPlayer branch
  • Loading branch information
garbear authored Aug 21, 2016
2 parents 75966fa + 0fa9bfc commit 21ac0a7
Show file tree
Hide file tree
Showing 59 changed files with 3,006 additions and 299 deletions.
18 changes: 5 additions & 13 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,8 @@ compile
*.opensdf
*.vcxproj.user

project/VS2010Express/objs
project/VS2010Express/ipch
project/VS2010Express/libs
project/VS2010Express/platform/Debug
project/VS2010Express/platform/Release
project/BuildDependencies/downloads
project/BuildDependencies/lib
project/BuildDependencies/include
addons/*/project/VS2010Express/Debug
addons/*/project/VS2010Express/Release
addons/*/*.so
addons/*/addon/*.dll
addons/*/addon/addon.xml
peripheral.joystick/project/VS2010Express/Debug
peripheral.joystick/project/VS2010Express/Release
peripheral.joystick/*.so
peripheral.joystick/*.dll
peripheral.joystick/addon.xml
24 changes: 22 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,19 @@ include_directories(${INCLUDES}
${PCRE_INCLUDE_DIRS})

set(JOYSTICK_SOURCES src/addon.cpp
src/api/AnomalousTriggerFilter.cpp
src/api/AnomalousTrigger.cpp
src/api/Joystick.cpp
src/api/JoystickAsync.cpp
src/api/JoystickInterfaceCallback.cpp
src/api/JoystickManager.cpp
src/api/JoystickTranslator.cpp
src/api/PeripheralScanner.cpp
src/buttonmapper/ButtonMapper.cpp
src/buttonmapper/ButtonMapTranslator.cpp
src/buttonmapper/ControllerModel.cpp
src/buttonmapper/ControllerTransformer.cpp
src/buttonmapper/DriverGeometry.cpp
src/buttonmapper/JoystickFamily.cpp
src/filesystem/DirectoryCache.cpp
src/filesystem/DirectoryUtils.cpp
src/filesystem/Filesystem.cpp
Expand All @@ -42,7 +48,6 @@ set(JOYSTICK_SOURCES src/addon.cpp
src/log/LogConsole.cpp
src/settings/Settings.cpp
src/storage/ButtonMap.cpp
src/storage/ButtonMapTranslator.cpp
src/storage/Device.cpp
src/storage/JustABunchOfFiles.cpp
src/storage/StorageManager.cpp
Expand All @@ -51,6 +56,7 @@ set(JOYSTICK_SOURCES src/addon.cpp
src/storage/xml/ButtonMapXml.cpp
src/storage/xml/DatabaseXml.cpp
src/storage/xml/DeviceXml.cpp
src/storage/xml/JoystickFamiliesXml.cpp
src/utils/StringUtils.cpp)

check_include_files("syslog.h" HAVE_SYSLOG)
Expand Down Expand Up @@ -124,6 +130,20 @@ if("${CORE_SYSTEM_NAME}" STREQUAL "windows")
src/api/xinput/XInputDLL.cpp)
endif()

# --- udev ---------------------------------------------------------------------

find_package(udev REQUIRED)
if(UDEV_FOUND)
include_directories(${UDEV_INCLUDE_DIRS})

add_definitions(-DHAVE_UDEV)

list(APPEND JOYSTICK_SOURCES src/api/udev/JoystickInterfaceUdev.cpp
src/api/udev/JoystickUdev.cpp)

list(APPEND DEPLIBS ${UDEV_LIBRARIES})
endif()

# ------------------------------------------------------------------------------

build_addon(peripheral.joystick JOYSTICK DEPLIBS)
Expand Down
77 changes: 77 additions & 0 deletions cmake/Findudev.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# - try to find the udev library
#
# Cache Variables: (probably not for direct use in your scripts)
# UDEV_INCLUDE_DIR
# UDEV_SOURCE_DIR
# UDEV_LIBRARY
#
# Non-cache variables you might use in your CMakeLists.txt:
# UDEV_FOUND
# UDEV_INCLUDE_DIRS
# UDEV_LIBRARIES
#
# Requires these CMake modules:
# FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
#
# Original Author:
# 2014 Kevin M. Godby <[email protected]>
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)

set(UDEV_ROOT_DIR
"${UDEV_ROOT_DIR}"
CACHE
PATH
"Directory to search for udev")

find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_LIBUDEV libudev)
endif()

find_library(UDEV_LIBRARY
NAMES
udev
PATHS
${PC_LIBUDEV_LIBRARY_DIRS}
${PC_LIBUDEV_LIBDIR}
HINTS
"${UDEV_ROOT_DIR}"
PATH_SUFFIXES
lib
)

get_filename_component(_libdir "${UDEV_LIBRARY}" PATH)

find_path(UDEV_INCLUDE_DIR
NAMES
libudev.h
PATHS
${PC_LIBUDEV_INCLUDE_DIRS}
${PC_LIBUDEV_INCLUDEDIR}
HINTS
"${_libdir}"
"${_libdir}/.."
"${UDEV_ROOT_DIR}"
PATH_SUFFIXES
include
)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(UDEV
DEFAULT_MSG
UDEV_LIBRARY
UDEV_INCLUDE_DIR
)

if(UDEV_FOUND)
list(APPEND UDEV_LIBRARIES ${UDEV_LIBRARY})
list(APPEND UDEV_INCLUDE_DIRS ${UDEV_INCLUDE_DIR})
mark_as_advanced(UDEV_ROOT_DIR)
endif()

mark_as_advanced(UDEV_INCLUDE_DIR
UDEV_LIBRARY)

2 changes: 1 addition & 1 deletion peripheral.joystick/addon.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
provider-name="Team-Kodi">
<requires>
<c-pluff version="0.1"/>
<import addon="kodi.peripheral" version="1.0.19"/>
<import addon="kodi.peripheral" version="1.0.21"/>
</requires>
<extension
point="kodi.peripheral"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?xml version="1.0" ?>
<buttonmap>
<device name="Wireless 360 Controller" provider="cocoa" vid="045E" pid="028E" buttoncount="15" axiscount="6">
<configuration>
<axis index="4" center="-1" range="2" />
<axis index="5" center="-1" range="2" />
</configuration>
<controller id="game.controller.default">
<feature name="a" button="0" />
<feature name="b" button="1" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
<?xml version="1.0" ?>
<buttonmap>
<device name="Xbox 360 Wireless Receiver (XBOX)" provider="udev" vid="045E" pid="0291" buttoncount="15" axiscount="6">
<controller id="game.controller.default">
<feature name="a" button="0" />
<feature name="b" button="1" />
<feature name="back" button="6" />
<feature name="down" button="14" />
<feature name="guide" button="8" />
<feature name="left" button="11" />
<feature name="leftbumper" button="4" />
<feature name="leftmotor" motor="0" />
<feature name="leftstick">
<up axis="-1" />
<down axis="+1" />
<right axis="+0" />
<left axis="-0" />
</feature>
<feature name="leftthumb" button="9" />
<feature name="lefttrigger" axis="+2" />
<feature name="right" button="12" />
<feature name="rightbumper" button="5" />
<feature name="rightmotor" motor="1" />
<feature name="rightstick">
<up axis="-4" />
<down axis="+4" />
<right axis="+3" />
<left axis="-3" />
</feature>
<feature name="rightthumb" button="10" />
<feature name="righttrigger" axis="+5" />
<feature name="start" button="7" />
<feature name="up" button="13" />
<feature name="x" button="2" />
<feature name="y" button="3" />
</controller>
<controller id="game.controller.dreamcast">
<feature name="a" button="0" />
<feature name="analogstick">
<up axis="-1" />
<down axis="+1" />
<right axis="+0" />
<left axis="-0" />
</feature>
<feature name="b" button="1" />
<feature name="down" button="14" />
<feature name="left" button="11" />
<feature name="lefttrigger" axis="+2" />
<feature name="right" button="12" />
<feature name="righttrigger" axis="+5" />
<feature name="start" button="7" />
<feature name="up" button="13" />
<feature name="x" button="2" />
<feature name="y" button="3" />
</controller>
<controller id="game.controller.gba">
<feature name="a" button="0" />
<feature name="b" button="1" />
<feature name="down" button="14" />
<feature name="left" button="11" />
<feature name="leftbumper" button="4" />
<feature name="right" button="12" />
<feature name="rightbumper" button="5" />
<feature name="select" button="6" />
<feature name="start" button="7" />
<feature name="up" button="13" />
</controller>
<controller id="game.controller.genesis">
<feature name="a" button="0" />
<feature name="b" button="1" />
<feature name="c" button="5" />
<feature name="down" button="14" />
<feature name="left" button="11" />
<feature name="mode" button="6" />
<feature name="right" button="12" />
<feature name="start" button="7" />
<feature name="up" button="13" />
<feature name="x" button="2" />
<feature name="y" button="3" />
<feature name="z" button="4" />
</controller>
<controller id="game.controller.n64">
<feature name="a" button="0" />
<feature name="analogstick">
<up axis="-1" />
<down axis="+1" />
<right axis="+0" />
<left axis="-0" />
</feature>
<feature name="b" button="1" />
<feature name="cdown" axis="+4" />
<feature name="cleft" axis="-3" />
<feature name="cright" axis="+3" />
<feature name="cup" axis="-4" />
<feature name="down" button="14" />
<feature name="left" button="11" />
<feature name="leftbumper" button="4" />
<feature name="right" button="12" />
<feature name="rightbumper" button="5" />
<feature name="start" button="7" />
<feature name="up" button="13" />
<feature name="z" axis="+5" />
</controller>
<controller id="game.controller.nes">
<feature name="a" button="0" />
<feature name="b" button="1" />
<feature name="down" button="14" />
<feature name="left" button="11" />
<feature name="right" button="12" />
<feature name="select" button="6" />
<feature name="start" button="7" />
<feature name="up" button="13" />
</controller>
<controller id="game.controller.ps">
<feature name="circle" button="1" />
<feature name="cross" button="0" />
<feature name="down" button="14" />
<feature name="l3" button="9" />
<feature name="left" button="11" />
<feature name="leftbumper" button="4" />
<feature name="leftstick">
<up axis="-1" />
<down axis="+1" />
<right axis="+0" />
<left axis="-0" />
</feature>
<feature name="lefttrigger" axis="+2" />
<feature name="r3" button="10" />
<feature name="right" button="12" />
<feature name="rightbumper" button="5" />
<feature name="rightstick">
<up axis="-4" />
<down axis="+4" />
<right axis="+3" />
<left axis="-3" />
</feature>
<feature name="righttrigger" axis="+5" />
<feature name="select" button="6" />
<feature name="square" button="2" />
<feature name="start" button="7" />
<feature name="strongmotor" motor="0" />
<feature name="triangle" button="3" />
<feature name="up" button="13" />
<feature name="weakmotor" motor="1" />
</controller>
<controller id="game.controller.snes">
<feature name="a" button="0" />
<feature name="b" button="1" />
<feature name="down" button="14" />
<feature name="left" button="11" />
<feature name="leftbumper" button="4" />
<feature name="right" button="12" />
<feature name="rightbumper" button="5" />
<feature name="select" button="6" />
<feature name="start" button="7" />
<feature name="up" button="13" />
<feature name="x" button="2" />
<feature name="y" button="3" />
</controller>
</device>
</buttonmap>
Loading

0 comments on commit 21ac0a7

Please sign in to comment.