Skip to content

Commit

Permalink
Merge branch 'fix-138-xwiimote' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterBowman committed Nov 22, 2017
2 parents bcdb7d7 + d61345f commit 0eb18f3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
12 changes: 9 additions & 3 deletions cmake/FindXWiimote.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,27 @@
# Sets the following variables:
#
# XWIIMOTE_FOUND - System has xwiimote
# XWIIMOTE_VERSION - xwiimote version
# XWIIMOTE_INCLUDE_DIRS - xwiimote include directories
# XWIIMOTE_LIBRARIES - xwiimote libraries

if(UNIX)
find_package(PkgConfig)
pkg_check_modules(XWIIMOTE QUIET libxwiimote)

if(NOT XWIIMOTE_INCLUDE_DIR)
find_path(XWIIMOTE_INCLUDE_DIR xwiimote.h)
find_path(XWIIMOTE_INCLUDE_DIR xwiimote.h HINTS ${XWIIMOTE_INCLUDEDIR})
endif()

if(NOT XWIIMOTE_LIBRARY)
find_library(XWIIMOTE_LIBRARY NAMES xwiimote libxwiimote)
find_library(XWIIMOTE_LIBRARY NAMES xwiimote
HINTS ${XWIIMOTE_LIBDIR})
endif()
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(XWiimote DEFAULT_MSG XWIIMOTE_INCLUDE_DIR XWIIMOTE_LIBRARY)
find_package_handle_standard_args(XWiimote REQUIRED_VARS XWIIMOTE_INCLUDE_DIR XWIIMOTE_LIBRARY
VERSION_VAR XWIIMOTE_VERSION)

mark_as_advanced(XWIIMOTE_INCLUDE_DIR XWIIMOTE_LIBRARY)

Expand Down
7 changes: 6 additions & 1 deletion libraries/YarpPlugins/WiimoteSensor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ yarp_prepare_plugin(WiimoteSensor
WRAPPER analogServer)

if(NOT SKIP_WiimoteSensor)
find_package(XWiimote REQUIRED)
find_package(XWiimote 0.3 REQUIRED)

if(XWIIMOTE_VERSION VERSION_LESS "2")
add_definitions(-DXWIIMOTE_LEGACY_INTERFACE)
endif()

include_directories(${YARP_INCLUDE_DIRS} ${XWIIMOTE_INCLUDE_DIRS} ${COLOR_DEBUG_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR})

yarp_add_plugin(WiimoteSensor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,13 @@ void roboticslab::WiimoteDispatcherThread::run()
return;
}

#ifdef XWIIMOTE_LEGACY_INTERFACE
// xwii_iface_dispatch not available on Trusty
// https://github.com/roboticslab-uc3m/yarp-devices/issues/134
int ret = xwii_iface_poll(iface, &event);
#else
int ret = xwii_iface_dispatch(iface, &event, sizeof(event));
#endif

if (ret != 0)
{
Expand Down

0 comments on commit 0eb18f3

Please sign in to comment.