Merge pull request #30 from lysannkessler/osx-refactor_sync-mplus
Synchronous motion plus init & OSX Refactoring. Incorporates work by lysannkessler, janoc, and jscasallas.
This commit is contained in:
@@ -57,6 +57,7 @@ Additional Contributors:
|
|||||||
- Jan Ciger - Reviatech SAS <jan.ciger@reviatech.com>
|
- Jan Ciger - Reviatech SAS <jan.ciger@reviatech.com>
|
||||||
- Gabriele Randelli and the WiiC project <http://wiic.sourceforge.net/>
|
- Gabriele Randelli and the WiiC project <http://wiic.sourceforge.net/>
|
||||||
- Juan Sebastian Casallas <https://github.com/jscasallas/wiiuse>
|
- Juan Sebastian Casallas <https://github.com/jscasallas/wiiuse>
|
||||||
|
- Lysann Schlegel <https://github.com/lysannkessler/wiiuse>
|
||||||
|
|
||||||
|
|
||||||
License
|
License
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ function(_osgbundle_split_debug_versions releasevar debugvar)
|
|||||||
set(debug)
|
set(debug)
|
||||||
foreach(fn ${ARGN})
|
foreach(fn ${ARGN})
|
||||||
get_filename_component(name "${fn}" NAME_WE)
|
get_filename_component(name "${fn}" NAME_WE)
|
||||||
if(${name} MATCHES "d$")
|
if("${name}" MATCHES "d$")
|
||||||
list(APPEND debug "${fn}")
|
list(APPEND debug "${fn}")
|
||||||
else()
|
else()
|
||||||
list(APPEND release "${fn}")
|
list(APPEND release "${fn}")
|
||||||
@@ -75,9 +75,21 @@ endif()
|
|||||||
function(install_osg_plugins var)
|
function(install_osg_plugins var)
|
||||||
set(INSTALLEDPLUGINS)
|
set(INSTALLEDPLUGINS)
|
||||||
foreach(plugin ${OSGDB_PLUGINS_RELEASE} ${OSGWRAPPER_PLUGINS_RELEASE})
|
foreach(plugin ${OSGDB_PLUGINS_RELEASE} ${OSGWRAPPER_PLUGINS_RELEASE})
|
||||||
install(FILES "${plugin}" DESTINATION "${OSG_PATH_TO_PLUGINS}")
|
install(FILES "${plugin}"
|
||||||
|
DESTINATION "${OSG_PATH_TO_PLUGINS}"
|
||||||
|
CONFIGURATIONS Release RelWithDebInfo MinSizeRel)
|
||||||
get_filename_component(name "${plugin}" NAME)
|
get_filename_component(name "${plugin}" NAME)
|
||||||
list(APPEND INSTALLEDPLUGINS "${OSG_PATH_TO_PLUGINS}/${name}")
|
list(APPEND INSTALLEDPLUGINS "${OSG_PATH_TO_PLUGINS}/${name}")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
foreach(plugin ${OSGDB_PLUGINS_DEBUG} ${OSGWRAPPER_PLUGINS_DEBUG})
|
||||||
|
install(FILES
|
||||||
|
"${plugin}"
|
||||||
|
DESTINATION
|
||||||
|
"${OSG_PATH_TO_PLUGINS}"
|
||||||
|
CONFIGURATIONS
|
||||||
|
Debug)
|
||||||
|
#get_filename_component(name "${plugin}" NAME)
|
||||||
|
#list(APPEND INSTALLEDPLUGINS "${OSG_PATH_TO_PLUGINS}/${name}")
|
||||||
|
endforeach()
|
||||||
set(${var} ${INSTALLEDPLUGINS} PARENT_SCOPE)
|
set(${var} ${INSTALLEDPLUGINS} PARENT_SCOPE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|||||||
@@ -35,8 +35,6 @@ int main(int argc, char* argv[]) {
|
|||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
io_object_t _ioObject;
|
io_object_t _ioObject;
|
||||||
IOHIDDeviceInterface122 **_interface;
|
IOHIDDeviceInterface122 **_interface;
|
||||||
bool _gotdata;
|
|
||||||
int _gotsize;
|
|
||||||
unsigned char _buffer[512];
|
unsigned char _buffer[512];
|
||||||
IOReturn result = (*_interface)->setInterruptReportHandlerCallback(_interface,
|
IOReturn result = (*_interface)->setInterruptReportHandlerCallback(_interface,
|
||||||
_buffer, 512,
|
_buffer, 512,
|
||||||
|
|||||||
@@ -213,6 +213,7 @@ function(add_doxygen _doxyfile)
|
|||||||
else()
|
else()
|
||||||
add_custom_target(${DOC_TARGET} ALL)
|
add_custom_target(${DOC_TARGET} ALL)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT IS_ABSOLUTE "${OUTPUT_DIRECTORY}")
|
if(NOT IS_ABSOLUTE "${OUTPUT_DIRECTORY}")
|
||||||
@@ -228,6 +229,28 @@ function(add_doxygen _doxyfile)
|
|||||||
"${OUTPUT_DIRECTORY}/html"
|
"${OUTPUT_DIRECTORY}/html"
|
||||||
"${OUTPUT_DIRECTORY}/latex")
|
"${OUTPUT_DIRECTORY}/latex")
|
||||||
|
|
||||||
|
if(NOT TARGET ${DOC_TARGET}_open)
|
||||||
|
# Create a target to open the generated HTML file.
|
||||||
|
if(WIN32)
|
||||||
|
set(DOXYGEN_LAUNCHER_COMMAND start "Documentation")
|
||||||
|
elseif(NOT APPLE)
|
||||||
|
set(DOXYGEN_LAUNCHER_COMMAND xdg-open)
|
||||||
|
endif()
|
||||||
|
if(DOXYGEN_LAUNCHER_COMMAND)
|
||||||
|
add_custom_target(${DOC_TARGET}_open
|
||||||
|
COMMAND ${DOXYGEN_LAUNCHER_COMMAND} "${OUTPUT_DIRECTORY}/html/index.html")
|
||||||
|
set_target_properties(${DOC_TARGET}_open
|
||||||
|
PROPERTIES
|
||||||
|
EXCLUDE_FROM_ALL
|
||||||
|
TRUE)
|
||||||
|
set_target_properties(${DOC_TARGET}_open
|
||||||
|
PROPERTIES
|
||||||
|
EXCLUDE_FROM_DEFAULT_BUILD
|
||||||
|
TRUE)
|
||||||
|
add_dependencies(${DOC_TARGET}_open ${DOC_TARGET})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
get_filename_component(_doxyfileabs "${_doxyfile}" ABSOLUTE)
|
get_filename_component(_doxyfileabs "${_doxyfile}" ABSOLUTE)
|
||||||
get_filename_component(INCLUDE_FILE "${_doxyfileabs}" NAME)
|
get_filename_component(INCLUDE_FILE "${_doxyfileabs}" NAME)
|
||||||
get_filename_component(INCLUDE_PATH "${_doxyfileabs}" PATH)
|
get_filename_component(INCLUDE_PATH "${_doxyfileabs}" PATH)
|
||||||
|
|||||||
@@ -31,8 +31,29 @@ macro(_enable_extra_compiler_warnings_flags)
|
|||||||
if(COMPILER_WARNINGS_EXTREME)
|
if(COMPILER_WARNINGS_EXTREME)
|
||||||
set(_flags "${_flags} /Wall /wd4619 /wd4668 /wd4820 /wd4571 /wd4710")
|
set(_flags "${_flags} /Wall /wd4619 /wd4668 /wd4820 /wd4571 /wd4710")
|
||||||
endif()
|
endif()
|
||||||
elseif(CMAKE_COMPILER_IS_GNUCXX)
|
else()
|
||||||
set(_flags "-W -Wall")
|
include(CheckCXXCompilerFlag)
|
||||||
|
set(_flags)
|
||||||
|
|
||||||
|
check_cxx_compiler_flag(-W SUPPORTS_W_FLAG)
|
||||||
|
if(SUPPORTS_W_FLAG)
|
||||||
|
set(_flags "${_flags} -W")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
check_cxx_compiler_flag(-Wall SUPPORTS_WALL_FLAG)
|
||||||
|
if(SUPPORTS_WALL_FLAG)
|
||||||
|
set(_flags "${_flags} -Wall")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
check_cxx_compiler_flag(-Wextra SUPPORTS_WEXTRA_FLAG)
|
||||||
|
if(SUPPORTS_WEXTRA_FLAG)
|
||||||
|
set(_flags "${_flags} -Wextra")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
check_cxx_compiler_flag(-Weffc++ SUPPORTS_WEFFCXX_FLAG)
|
||||||
|
if(SUPPORTS_WEFFCXX_FLAG)
|
||||||
|
set(_flags "${_flags} -Weffc++")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,9 @@ function(add_file_copy_target _target _dest)
|
|||||||
get_filename_component(fullpath "${fn}" ABSOLUTE)
|
get_filename_component(fullpath "${fn}" ABSOLUTE)
|
||||||
get_filename_component(fn "${fn}" NAME)
|
get_filename_component(fn "${fn}" NAME)
|
||||||
else()
|
else()
|
||||||
get_filename_component(fullpath "${CMAKE_CURRENT_SOURCE_DIR}/${fn}" ABSOLUTE)
|
get_filename_component(fullpath
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/${fn}"
|
||||||
|
ABSOLUTE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Clean up output file name
|
# Clean up output file name
|
||||||
|
|||||||
202
cmake/FindAdrienne.cmake
Normal file
202
cmake/FindAdrienne.cmake
Normal file
@@ -0,0 +1,202 @@
|
|||||||
|
# - try to find Adrienne Electronics Corporation timecode card library
|
||||||
|
#
|
||||||
|
# SDK available from the manufacturer: http://www.adrielec.com/
|
||||||
|
#
|
||||||
|
# Cache Variables: (probably not for direct use in your scripts)
|
||||||
|
# ADRIENNE_INCLUDE_DIR
|
||||||
|
# ADRIENNE_LIBRARY
|
||||||
|
# ADRIENNE_RUNTIME_LIBRARY
|
||||||
|
# ADRIENNE_INCLUDE_FILE
|
||||||
|
#
|
||||||
|
# Variables you might use in your CMakeLists.txt:
|
||||||
|
# ADRIENNE_FOUND
|
||||||
|
# ADRIENNE_INCLUDE_DIRS
|
||||||
|
# ADRIENNE_LIBRARIES
|
||||||
|
# ADRIENNE_RUNTIME_LIBRARIES - the AEC_NTTC.dll file
|
||||||
|
# ADRIENNE_RUNTIME_LIBRARY_DIRS
|
||||||
|
#
|
||||||
|
# ADRIENNE_INCLUDE_FILENAME - this is probably AEC_NTTC.h, but it might also
|
||||||
|
# be AECINTTC.H.
|
||||||
|
#
|
||||||
|
# ADRIENNE_INCLUDE_HAS_EXTERN_C - Some (most) versions of the header already
|
||||||
|
# wrap their definitions in extern "C" { }, but some do not.
|
||||||
|
#
|
||||||
|
# ADRIENNE_DEFINITIONS - defines a quoted ADRIENNE_INCLUDE_FILENAME as above,
|
||||||
|
# so you can write a line like #include ADRIENNE_INCLUDE_FILENAME
|
||||||
|
# Also defines ADRIENNE_BEFORE_INCLUDE and ADRIENNE_AFTER_INCLUDE to handle
|
||||||
|
# adding extern "C" { and } if the header file doesn't do so itself.
|
||||||
|
#
|
||||||
|
# Variables that might be set by the user in the gui/command line to help
|
||||||
|
# find the library:
|
||||||
|
# ADRIENNE_ROOT_DIR - root of an Adrienne CD, disk, or extracted/copied contents
|
||||||
|
# thereof.
|
||||||
|
#
|
||||||
|
# Requires these CMake modules:
|
||||||
|
# FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
|
||||||
|
#
|
||||||
|
# Original Author:
|
||||||
|
# 2012 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||||
|
# http://academic.cleardefinition.com
|
||||||
|
# Iowa State University HCI Graduate Program/VRAC
|
||||||
|
#
|
||||||
|
# Copyright Iowa State University 2012.
|
||||||
|
# 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)
|
||||||
|
|
||||||
|
# Apparently Windows only.
|
||||||
|
if(WIN32 OR CYGWIN)
|
||||||
|
set(ADRIENNE_ROOT_DIR
|
||||||
|
"${ADRIENNE_ROOT_DIR}"
|
||||||
|
CACHE
|
||||||
|
PATH
|
||||||
|
"Directory to search for Adrienne Electronics Timecode data - root of a software distribution or extracted download from http://www.adrielec.com/")
|
||||||
|
|
||||||
|
set(ADRIENNE_DEFINITIONS)
|
||||||
|
|
||||||
|
set(ADRIENNE_INCLUDE_SEARCH
|
||||||
|
# from AecPCIeTC_8-12a: contains AEC_NTTC.h with extern "C" and three extra functions:
|
||||||
|
# AEC_PCTC_OPEN_ALL, AEC_PCTC_CLOSE_ALL, AEC_PCTC_INITIALIZE_EVENT
|
||||||
|
"SDK_SourceCode"
|
||||||
|
|
||||||
|
# from AecPci6_02_CD - called AECINTTC.H but otherwise essentially identical to earlier versions
|
||||||
|
"TestPrograms_WithDLL/DLL_API_INFO"
|
||||||
|
# A zipped development project contains essentially the same, named AEC_NTTC.h so we'll add this in case it's unzipped.
|
||||||
|
"TestPrograms_WithDLL/ZippedDevelopmentProjects/AecMfc32_Rel504"
|
||||||
|
|
||||||
|
# from pc-ltc - called AECINTTC.H and lacks extern "C"
|
||||||
|
"NT-CODE/C40-APP1"
|
||||||
|
)
|
||||||
|
set(ADRIENNE_HEADER_NAMES
|
||||||
|
AEC_NTTC.H
|
||||||
|
AEC_NTTC.h
|
||||||
|
Aec_nttc.h
|
||||||
|
AECINTTC.H)
|
||||||
|
|
||||||
|
set(ADRIENNE_LIB_SEARCH)
|
||||||
|
set(ADRIENNE_DLL_SEARCH)
|
||||||
|
|
||||||
|
if(CMAKE_SIZEOF_VOID_P MATCHES "8")
|
||||||
|
# 64 bit code - apparently initially packaged only in the
|
||||||
|
# PCIe version of their software
|
||||||
|
list(APPEND ADRIENNE_LIB_SEARCH
|
||||||
|
# from AecPCIeTC_8-12a
|
||||||
|
"64BitOS_files/DLL Versions")
|
||||||
|
|
||||||
|
list(APPEND ADRIENNE_DLL_SEARCH
|
||||||
|
# from AecPCIeTC_8-12a
|
||||||
|
"64BitOS_files/DLL Versions")
|
||||||
|
else()
|
||||||
|
# 32-bit code, much more prevalent.
|
||||||
|
list(APPEND ADRIENNE_LIB_SEARCH
|
||||||
|
# from AecPCIeTC_8-12a
|
||||||
|
"32BitOS_files/DLLversions"
|
||||||
|
|
||||||
|
# from AecPci6_02_CD
|
||||||
|
"TestPrograms_WithDLL/DLL_API_INFO"
|
||||||
|
|
||||||
|
# from pc-ltc
|
||||||
|
"NT-CODE/DLL"
|
||||||
|
)
|
||||||
|
|
||||||
|
list(APPEND ADRIENNE_DLL_SEARCH
|
||||||
|
# from AecPCIeTC_8-12a
|
||||||
|
"32BitOS_files/DLLversions"
|
||||||
|
|
||||||
|
# from AecPci6_02_CD
|
||||||
|
"TestPrograms_WithDLL"
|
||||||
|
|
||||||
|
# from pc-ltc
|
||||||
|
"NT-CODE/DLL")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_library(ADRIENNE_LIBRARY
|
||||||
|
NAMES
|
||||||
|
AEC_NTTC
|
||||||
|
PATHS
|
||||||
|
"${ADRIENNE_ROOT_DIR}"
|
||||||
|
PATH_SUFFIXES
|
||||||
|
${ADRIENNE_LIB_SEARCH})
|
||||||
|
|
||||||
|
find_path(ADRIENNE_INCLUDE_DIR
|
||||||
|
NAMES
|
||||||
|
${ADRIENNE_HEADER_NAMES}
|
||||||
|
PATHS
|
||||||
|
"${ADRIENNE_ROOT_DIR}"
|
||||||
|
PATH_SUFFIXES
|
||||||
|
${ADRIENNE_INCLUDE_SEARCH})
|
||||||
|
|
||||||
|
if(ADRIENNE_INCLUDE_DIR)
|
||||||
|
find_file(ADRIENNE_INCLUDE_FILE
|
||||||
|
NAMES
|
||||||
|
${ADRIENNE_HEADER_NAMES}
|
||||||
|
HINTS
|
||||||
|
${ADRIENNE_INCLUDE_DIR})
|
||||||
|
|
||||||
|
# Get include filename
|
||||||
|
get_filename_component(ADRIENNE_INCLUDE_FILENAME
|
||||||
|
"${ADRIENNE_INCLUDE_FILE}"
|
||||||
|
NAME)
|
||||||
|
list(APPEND ADRIENNE_DEFINITIONS -DADRIENNE_INCLUDE_FILENAME="ADRIENNE_INCLUDE_FILENAME")
|
||||||
|
|
||||||
|
# Find out if it has extern "C" in it.
|
||||||
|
file(STRINGS "${ADRIENNE_INCLUDE_FILE}" strings)
|
||||||
|
set(ADRIENNE_INCLUDE_HAS_EXTERN_C OFF)
|
||||||
|
foreach(_line ${strings})
|
||||||
|
if("${_line}" STREQUAL "extern \"C\"")
|
||||||
|
set(ADRIENNE_INCLUDE_HAS_EXTERN_C ON)
|
||||||
|
break()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
if(ADRIENNE_INCLUDE_HAS_EXTERN_C)
|
||||||
|
list(APPEND ADRIENNE_DEFINITIONS -DADRIENNE_BEFORE_INCLUDE -DADRIENNE_AFTER_INCLUDE)
|
||||||
|
else()
|
||||||
|
list(APPEND ADRIENNE_DEFINITIONS "-DADRIENNE_BEFORE_INCLUDE=extern \"C\" {" "-DADRIENNE_AFTER_INCLUDE=}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
get_filename_component(_adrienne_libdir "${ADRIENNE_LIBRARY}" PATH)
|
||||||
|
find_file(ADRIENNE_RUNTIME_LIBRARY
|
||||||
|
NAMES
|
||||||
|
AEC_NTTC.dll
|
||||||
|
HINTS
|
||||||
|
"${_adrienne_libdir}"
|
||||||
|
"${_adrienne_libdir}/.."
|
||||||
|
PATHS
|
||||||
|
"${ADRIENNE_ROOT_DIR}"
|
||||||
|
PATH_SUFFIXES
|
||||||
|
${ADRIENNE_DLL_SEARCH})
|
||||||
|
|
||||||
|
|
||||||
|
set(ADRIENNE_RUNTIME_LIBRARIES "${ADRIENNE_RUNTIME_LIBRARY}")
|
||||||
|
get_filename_component(ADRIENNE_RUNTIME_LIBRARY_DIRS
|
||||||
|
"${ADRIENNE_RUNTIME_LIBRARY}"
|
||||||
|
PATH)
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(Adrienne
|
||||||
|
DEFAULT_MSG
|
||||||
|
ADRIENNE_LIBRARY
|
||||||
|
ADRIENNE_RUNTIME_LIBRARY
|
||||||
|
ADRIENNE_INCLUDE_DIR
|
||||||
|
ADRIENNE_INCLUDE_FILENAME)
|
||||||
|
|
||||||
|
if(ADRIENNE_FOUND)
|
||||||
|
set(ADRIENNE_LIBRARIES "${ADRIENNE_LIBRARY}")
|
||||||
|
set(ADRIENNE_INCLUDE_DIRS "${ADRIENNE_INCLUDE_DIR}")
|
||||||
|
mark_as_advanced(ADRIENNE_ROOT_DIR)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
mark_as_advanced(
|
||||||
|
ADRIENNE_LIBRARY
|
||||||
|
ADRIENNE_RUNTIME_LIBRARY
|
||||||
|
ADRIENNE_INCLUDE_DIR
|
||||||
|
ADRIENNE_INCLUDE_FILE)
|
||||||
|
else()
|
||||||
|
set(ADRIENNE_FOUND OFF)
|
||||||
|
set(ADRIENNE_SDK_IS_WINDOWS_ONLY NOTFOUND)
|
||||||
|
find_package_handle_standard_args(Adrienne
|
||||||
|
DEFAULT_MSG
|
||||||
|
ADRIENNE_SDK_IS_WINDOWS_ONLY)
|
||||||
|
endif()
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
# Useful configuration variables you might want to add to your cache:
|
# Useful configuration variables you might want to add to your cache:
|
||||||
# CPPDOM_ROOT_DIR - A directory prefix to search
|
# CPPDOM_ROOT_DIR - A directory prefix to search
|
||||||
# (a path that contains include/ as a subdirectory)
|
# (a path that contains include/ as a subdirectory)
|
||||||
# CPPDOM_ADDITIONAL_VERSIONS - Additional versions (outside of 0.7.8 to 1.0.0)
|
# CPPDOM_ADDITIONAL_VERSIONS - Additional versions (outside of 0.7.8 to 1.2.0)
|
||||||
# to use when constructing search names and paths
|
# to use when constructing search names and paths
|
||||||
#
|
#
|
||||||
# This script will use Flagpoll, if found, to provide hints to the location
|
# This script will use Flagpoll, if found, to provide hints to the location
|
||||||
@@ -26,11 +26,11 @@
|
|||||||
# and trigger an automatic re-run.
|
# and trigger an automatic re-run.
|
||||||
#
|
#
|
||||||
# Original Author:
|
# Original Author:
|
||||||
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
# 2009-2012 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||||
# http://academic.cleardefinition.com
|
# http://academic.cleardefinition.com
|
||||||
# Iowa State University HCI Graduate Program/VRAC
|
# Iowa State University HCI Graduate Program/VRAC
|
||||||
#
|
#
|
||||||
# Copyright Iowa State University 2009-2010.
|
# Copyright Iowa State University 2009-2012.
|
||||||
# Distributed under the Boost Software License, Version 1.0.
|
# Distributed under the Boost Software License, Version 1.0.
|
||||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
# http://www.boost.org/LICENSE_1_0.txt)
|
# http://www.boost.org/LICENSE_1_0.txt)
|
||||||
@@ -41,6 +41,8 @@ set(_FP_PKG_NAME cppdom)
|
|||||||
|
|
||||||
set(CPPDOM_VERSIONS
|
set(CPPDOM_VERSIONS
|
||||||
${CPPDOM_ADDITIONAL_VERSIONS}
|
${CPPDOM_ADDITIONAL_VERSIONS}
|
||||||
|
1.3.0
|
||||||
|
1.2.0
|
||||||
1.1.2
|
1.1.2
|
||||||
1.1.1
|
1.1.1
|
||||||
1.1.0
|
1.1.0
|
||||||
@@ -99,6 +101,28 @@ endif()
|
|||||||
|
|
||||||
set(_ROOT_DIR "${CPPDOM_ROOT_DIR}")
|
set(_ROOT_DIR "${CPPDOM_ROOT_DIR}")
|
||||||
|
|
||||||
|
if(CMAKE_SIZEOF_VOID_P MATCHES "8")
|
||||||
|
set(_VRJ_LIBSUFFIXES lib64 lib)
|
||||||
|
set(_VRJ_LIBDSUFFIXES
|
||||||
|
debug
|
||||||
|
lib64/x86_64/debug
|
||||||
|
lib64/debug
|
||||||
|
lib64
|
||||||
|
lib/x86_64/debug
|
||||||
|
lib/debug
|
||||||
|
lib)
|
||||||
|
set(_VRJ_LIBDSUFFIXES_ONLY
|
||||||
|
debug
|
||||||
|
lib64/x86_64/debug
|
||||||
|
lib64/debug
|
||||||
|
lib/x86_64/debug
|
||||||
|
lib/debug)
|
||||||
|
else()
|
||||||
|
set(_VRJ_LIBSUFFIXES lib)
|
||||||
|
set(_VRJ_LIBDSUFFIXES debug lib/i686/debug lib/debug lib)
|
||||||
|
set(_VRJ_LIBDSUFFIXES_ONLY debug lib/i686/debug lib/debug)
|
||||||
|
endif()
|
||||||
|
|
||||||
find_path(CPPDOM_INCLUDE_DIR
|
find_path(CPPDOM_INCLUDE_DIR
|
||||||
${_HEADER}
|
${_HEADER}
|
||||||
HINTS
|
HINTS
|
||||||
|
|||||||
@@ -184,6 +184,7 @@ if(DCUBED_FOUND)
|
|||||||
set(DCUBED_INCLUDE_DIRS
|
set(DCUBED_INCLUDE_DIRS
|
||||||
"${DCUBED_CORE_INCLUDE_DIR}"
|
"${DCUBED_CORE_INCLUDE_DIR}"
|
||||||
"${DCUBED_CORE_INCLUDE_DIR}/if3"
|
"${DCUBED_CORE_INCLUDE_DIR}/if3"
|
||||||
|
"${DCUBED_CORE_INCLUDE_DIR}/.."
|
||||||
"${DCUBED_WRAPPER_INCLUDE_DIR}")
|
"${DCUBED_WRAPPER_INCLUDE_DIR}")
|
||||||
mark_as_advanced(DCUBED_ROOT_DIR)
|
mark_as_advanced(DCUBED_ROOT_DIR)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
180
cmake/FindDirectInput.cmake
Normal file
180
cmake/FindDirectInput.cmake
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
# - try to find DirectInput library (part of DirectX SDK)
|
||||||
|
#
|
||||||
|
# Cache Variables: (probably not for direct use in your scripts)
|
||||||
|
# DIRECTINPUT_DXGUID_LIBRARY
|
||||||
|
# DIRECTINPUT_DXERR_LIBRARY
|
||||||
|
# DIRECTINPUT_DINPUT_LIBRARY
|
||||||
|
# DIRECTINPUT_INCLUDE_DIR
|
||||||
|
#
|
||||||
|
# Non-cache variables you should use in your CMakeLists.txt:
|
||||||
|
# DIRECTINPUT_LIBRARIES
|
||||||
|
# DIRECTINPUT_INCLUDE_DIRS
|
||||||
|
# DIRECTINPUT_FOUND - if this is not true, do not attempt to use this library
|
||||||
|
#
|
||||||
|
# Requires these CMake modules:
|
||||||
|
# FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
|
||||||
|
#
|
||||||
|
# Original Author:
|
||||||
|
# 2011 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||||
|
# http://academic.cleardefinition.com
|
||||||
|
# Iowa State University HCI Graduate Program/VRAC
|
||||||
|
#
|
||||||
|
# Copyright Iowa State University 2011.
|
||||||
|
# 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(DIRECTINPUT_ROOT_DIR
|
||||||
|
"${DIRECTINPUT_ROOT_DIR}"
|
||||||
|
CACHE
|
||||||
|
PATH
|
||||||
|
"Root directory to search for DirectX/DirectInput")
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
file(TO_CMAKE_PATH "$ENV{ProgramFiles}" _PROG_FILES)
|
||||||
|
file(TO_CMAKE_PATH "$ENV{ProgramFiles(x86)}" _PROG_FILES_X86)
|
||||||
|
if(_PROG_FILES_X86)
|
||||||
|
set(_PROG_FILES "${_PROG_FILES_X86}")
|
||||||
|
endif()
|
||||||
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||||
|
set(_lib_suffixes lib/x64 lib)
|
||||||
|
else()
|
||||||
|
set(_lib_suffixes lib/x86 lib)
|
||||||
|
endif()
|
||||||
|
macro(_append_dxsdk_in_inclusive_range _low _high)
|
||||||
|
if((NOT MSVC_VERSION LESS ${_low}) AND (NOT MSVC_VERSION GREATER ${_high}))
|
||||||
|
list(APPEND DXSDK_DIRS ${ARGN})
|
||||||
|
endif()
|
||||||
|
endmacro()
|
||||||
|
_append_dxsdk_in_inclusive_range(1500 1600 "${_PROG_FILES}/Microsoft DirectX SDK (June 2010)")
|
||||||
|
_append_dxsdk_in_inclusive_range(1400 1600
|
||||||
|
"${_PROG_FILES}/Microsoft DirectX SDK (February 2010)"
|
||||||
|
"${_PROG_FILES}/Microsoft DirectX SDK (August 2009)"
|
||||||
|
"${_PROG_FILES}/Microsoft DirectX SDK (March 2009)"
|
||||||
|
"${_PROG_FILES}/Microsoft DirectX SDK (November 2008)"
|
||||||
|
"${_PROG_FILES}/Microsoft DirectX SDK (August 2008)"
|
||||||
|
"${_PROG_FILES}/Microsoft DirectX SDK (June 2008)"
|
||||||
|
"${_PROG_FILES}/Microsoft DirectX SDK (March 2008)")
|
||||||
|
_append_dxsdk_in_inclusive_range(1310 1500
|
||||||
|
"${_PROG_FILES}/Microsoft DirectX SDK (November 2007)"
|
||||||
|
"${_PROG_FILES}/Microsoft DirectX SDK (August 2007)"
|
||||||
|
"${_PROG_FILES}/Microsoft DirectX SDK (June 2007)"
|
||||||
|
"${_PROG_FILES}/Microsoft DirectX SDK (April 2007)"
|
||||||
|
"${_PROG_FILES}/Microsoft DirectX SDK (February 2007)"
|
||||||
|
"${_PROG_FILES}/Microsoft DirectX SDK (December 2006)"
|
||||||
|
"${_PROG_FILES}/Microsoft DirectX SDK (October 2006)"
|
||||||
|
"${_PROG_FILES}/Microsoft DirectX SDK (August 2006)"
|
||||||
|
"${_PROG_FILES}/Microsoft DirectX SDK (June 2006)"
|
||||||
|
"${_PROG_FILES}/Microsoft DirectX SDK (April 2006)"
|
||||||
|
"${_PROG_FILES}/Microsoft DirectX SDK (February 2006)")
|
||||||
|
|
||||||
|
file(TO_CMAKE_PATH "$ENV{DXSDK_DIR}" ENV_DXSDK_DIR)
|
||||||
|
if(ENV_DXSDK_DIR)
|
||||||
|
list(APPEND DXSDK_DIRS ${ENV_DXSDK_DIR})
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
set(_lib_suffixes lib)
|
||||||
|
set(DXSDK_DIRS /mingw)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_path(DIRECTINPUT_INCLUDE_DIR
|
||||||
|
NAMES
|
||||||
|
dinput.h
|
||||||
|
PATHS
|
||||||
|
${DXSDK_DIRS}
|
||||||
|
HINTS
|
||||||
|
"${DIRECTINPUT_ROOT_DIR}"
|
||||||
|
PATH_SUFFIXES
|
||||||
|
include)
|
||||||
|
|
||||||
|
find_library(DIRECTINPUT_DXGUID_LIBRARY
|
||||||
|
NAMES
|
||||||
|
dxguid
|
||||||
|
PATHS
|
||||||
|
${DXSDK_DIRS}
|
||||||
|
HINTS
|
||||||
|
"${DIRECTINPUT_ROOT_DIR}"
|
||||||
|
PATH_SUFFIXES
|
||||||
|
${_lib_suffixes})
|
||||||
|
|
||||||
|
if(DIRECTINPUT_DXGUID_LIBRARY)
|
||||||
|
get_filename_component(_dinput_lib_dir
|
||||||
|
${DIRECTINPUT_DXGUID_LIBRARY}
|
||||||
|
PATH)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_library(DIRECTINPUT_DINPUT_LIBRARY
|
||||||
|
NAMES
|
||||||
|
dinput8
|
||||||
|
dinput
|
||||||
|
PATHS
|
||||||
|
${DXSDK_DIRS}
|
||||||
|
HINTS
|
||||||
|
"${_dinput_lib_dir}"
|
||||||
|
"${DIRECTINPUT_ROOT_DIR}"
|
||||||
|
PATH_SUFFIXES
|
||||||
|
${_lib_suffixes})
|
||||||
|
|
||||||
|
find_library(DIRECTINPUT_DXERR_LIBRARY
|
||||||
|
NAMES
|
||||||
|
dxerr
|
||||||
|
dxerr9
|
||||||
|
dxerr8
|
||||||
|
PATHS
|
||||||
|
${DXSDK_DIRS}
|
||||||
|
HINTS
|
||||||
|
"${_dinput_lib_dir}"
|
||||||
|
"${DIRECTINPUT_ROOT_DIR}"
|
||||||
|
PATH_SUFFIXES
|
||||||
|
${_lib_suffixes})
|
||||||
|
set(DIRECTINPUT_EXTRA_CHECK)
|
||||||
|
if(DIRECTINPUT_INCLUDE_DIR)
|
||||||
|
if(MSVC80)
|
||||||
|
set(DXSDK_DEPRECATION_BUILD 1962)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(DXSDK_DEPRECATION_BUILD)
|
||||||
|
include(CheckCSourceCompiles)
|
||||||
|
set(_dinput_old_includes ${CMAKE_REQUIRED_INCLUDES})
|
||||||
|
set(CMAKE_REQUIRED_INCLUDES "${DIRECTINPUT_INCLUDE_DIR}")
|
||||||
|
check_c_source_compiles(
|
||||||
|
"
|
||||||
|
#include <dxsdkver.h>
|
||||||
|
#if _DXSDK_BUILD_MAJOR >= ${DXSDK_DEPRECATION_BUILD}
|
||||||
|
#error
|
||||||
|
#else
|
||||||
|
int main(int argc, char * argv[]) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
"
|
||||||
|
DIRECTINPUT_SDK_SUPPORTS_COMPILER)
|
||||||
|
set(DIRECTINPUT_EXTRA_CHECK DIRECTINPUT_SDK_SUPPORTS_COMPILER)
|
||||||
|
set(CMAKE_REQUIRED_INCLUDES "${_dinput_old_includes}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(DirectInput
|
||||||
|
DEFAULT_MSG
|
||||||
|
DIRECTINPUT_DINPUT_LIBRARY
|
||||||
|
DIRECTINPUT_DXGUID_LIBRARY
|
||||||
|
DIRECTINPUT_DXERR_LIBRARY
|
||||||
|
DIRECTINPUT_INCLUDE_DIR
|
||||||
|
${DIRECTINPUT_EXTRA_CHECK})
|
||||||
|
|
||||||
|
if(DIRECTINPUT_FOUND)
|
||||||
|
set(DIRECTINPUT_LIBRARIES
|
||||||
|
"${DIRECTINPUT_DXGUID_LIBRARY}"
|
||||||
|
"${DIRECTINPUT_DXERR_LIBRARY}"
|
||||||
|
"${DIRECTINPUT_DINPUT_LIBRARY}")
|
||||||
|
|
||||||
|
set(DIRECTINPUT_INCLUDE_DIRS "${DIRECTINPUT_INCLUDE_DIR}")
|
||||||
|
|
||||||
|
mark_as_advanced(DIRECTINPUT_ROOT_DIR)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
mark_as_advanced(DIRECTINPUT_DINPUT_LIBRARY
|
||||||
|
DIRECTINPUT_DXGUID_LIBRARY
|
||||||
|
DIRECTINPUT_DXERR_LIBRARY
|
||||||
|
DIRECTINPUT_INCLUDE_DIR)
|
||||||
126
cmake/FindDirectShow.cmake
Normal file
126
cmake/FindDirectShow.cmake
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
# - Find Microsoft DirectShow sample files, library, and headers.
|
||||||
|
#
|
||||||
|
# DIRECTSHOW_INCLUDE_DIRS - where to find needed include file
|
||||||
|
# DIRECTSHOW_BASECLASS_DIR- Directory containing the DirectShow baseclass sample code.
|
||||||
|
# DIRECTSHOW_FOUND - True if DirectShow found.
|
||||||
|
#
|
||||||
|
# Requires these CMake modules:
|
||||||
|
# FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
|
||||||
|
#
|
||||||
|
# Initially in VRPN - Distributed under the Boost Software License, Version 1.0.
|
||||||
|
#
|
||||||
|
# Almost entirely re-written by:
|
||||||
|
# 2012 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||||
|
# http://academic.cleardefinition.com
|
||||||
|
# Iowa State University HCI Graduate Program/VRAC
|
||||||
|
#
|
||||||
|
# Copyright Iowa State University 2012.
|
||||||
|
# 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)
|
||||||
|
|
||||||
|
# Look for one of the sample files.
|
||||||
|
|
||||||
|
find_package(WindowsSDK)
|
||||||
|
find_package(DirectX QUIET)
|
||||||
|
|
||||||
|
set(DIRECTSHOW_WINDOWSSDK_ROOT
|
||||||
|
"${DIRECTSHOW_WINDOWSSDK_ROOT}"
|
||||||
|
CACHE
|
||||||
|
PATH
|
||||||
|
"A specific Windows SDK to use for DirectShow.")
|
||||||
|
|
||||||
|
if(MSVC AND CMAKE_CL_64)
|
||||||
|
set(DIRECTSHOW_LIB_SUBDIR /x64)
|
||||||
|
else()
|
||||||
|
set(DIRECTSHOW_LIB_SUBDIR)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(_acceptable_winsdk)
|
||||||
|
if(WINDOWSSDK_FOUND)
|
||||||
|
foreach(_sdkdir ${WINDOWSSDK_DIRS})
|
||||||
|
if(EXISTS "${_sdkdir}/Samples/Multimedia/DirectShow/BaseClasses/streams.h"
|
||||||
|
AND EXISTS "${_sdkdir}/Lib${DIRECTSHOW_LIB_SUBDIR}/strmiids.lib"
|
||||||
|
AND EXISTS "${_sdkdir}/Include/DShow.h")
|
||||||
|
list(APPEND _acceptable_winsdk "${_sdkdir}")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_path(DIRECTSHOW_BASECLASS_DIR
|
||||||
|
NAMES
|
||||||
|
streams.h
|
||||||
|
HINTS
|
||||||
|
"${DIRECTSHOW_WINDOWSSDK_ROOT}"
|
||||||
|
PATHS
|
||||||
|
${_acceptable_winsdk}
|
||||||
|
PATH_SUFFIXES
|
||||||
|
"Samples/Multimedia/DirectShow/BaseClasses")
|
||||||
|
|
||||||
|
find_path(DIRECTSHOW_WINDOWSSDK_INCLUDE_DIR
|
||||||
|
NAMES
|
||||||
|
DShow.h
|
||||||
|
HINTS
|
||||||
|
"${DIRECTSHOW_WINDOWSSDK_ROOT}"
|
||||||
|
PATHS
|
||||||
|
${_acceptable_winsdk}
|
||||||
|
PATH_SUFFIXES
|
||||||
|
"Include")
|
||||||
|
|
||||||
|
# This one we can grab from another SDK version.
|
||||||
|
find_path(DIRECTSHOW_QEDIT_INCLUDE_DIR
|
||||||
|
NAMES
|
||||||
|
qedit.h
|
||||||
|
HINTS
|
||||||
|
"${DIRECTSHOW_WINDOWSSDK_ROOT}"
|
||||||
|
PATHS
|
||||||
|
${WINDOWSSDK_DIRS}
|
||||||
|
PATH_SUFFIXES
|
||||||
|
"Include")
|
||||||
|
|
||||||
|
find_library(DIRECTSHOW_STRMIIDS_LIBRARY
|
||||||
|
NAMES
|
||||||
|
strmiids
|
||||||
|
HINTS
|
||||||
|
"${DIRECTSHOW_WINDOWSSDK_ROOT}"
|
||||||
|
PATHS
|
||||||
|
${_acceptable_winsdk}
|
||||||
|
PATH_SUFFIXES
|
||||||
|
"Lib${DIRECTSHOW_LIB_SUBDIR}")
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(DirectShow
|
||||||
|
DEFAULT_MSG
|
||||||
|
DIRECTSHOW_BASECLASS_DIR
|
||||||
|
DIRECTSHOW_WINDOWSSDK_INCLUDE_DIR
|
||||||
|
DIRECTSHOW_QEDIT_INCLUDE_DIR
|
||||||
|
DIRECTX_INCLUDE_DIR
|
||||||
|
DIRECTX_FOUND
|
||||||
|
DIRECTSHOW_STRMIIDS_LIBRARY)
|
||||||
|
|
||||||
|
if(DIRECTSHOW_FOUND)
|
||||||
|
set(DIRECTSHOW_INCLUDE_DIRS
|
||||||
|
# Baseclass must be before SDK so it gets the correct refclock.h
|
||||||
|
"${DIRECTSHOW_BASECLASS_DIR}"
|
||||||
|
"${DIRECTSHOW_WINDOWSSDK_INCLUDE_DIR}"
|
||||||
|
"${DIRECTX_INCLUDE_DIR}"
|
||||||
|
)
|
||||||
|
if(EXISTS "${DIRECTSHOW_WINDOWSSDK_INCLUDE_DIR}/atl/atlbase.h")
|
||||||
|
list(APPEND
|
||||||
|
DIRECTSHOW_INCLUDE_DIRS
|
||||||
|
"${DIRECTSHOW_WINDOWSSDK_INCLUDE_DIR}/atl")
|
||||||
|
endif()
|
||||||
|
if(NOT "${DIRECTSHOW_QEDIT_INCLUDE_DIR}" STREQUAL "${DIRECTSHOW_WINDOWSSDK_INCLUDE_DIR}")
|
||||||
|
# QEdit include dir might be an older SDK, so put it last.
|
||||||
|
list(APPEND DIRECTSHOW_INCLUDE_DIRS "${DIRECTSHOW_QEDIT_INCLUDE_DIR}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(DIRECTSHOW_LIBRARIES "${DIRECTSHOW_STRMIIDS_LIBRARY}")
|
||||||
|
|
||||||
|
mark_as_advanced(DIRECTSHOW_WINDOWSSDK_ROOT)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
mark_as_advanced(DIRECTSHOW_BASECLASS_DIR
|
||||||
|
DIRECTSHOW_WINDOWSSDK_INCLUDE_DIR
|
||||||
|
DIRECTSHOW_QEDIT_INCLUDE_DIR
|
||||||
|
DIRECTSHOW_STRMIIDS_LIBRARY)
|
||||||
244
cmake/FindDirectX.cmake
Normal file
244
cmake/FindDirectX.cmake
Normal file
@@ -0,0 +1,244 @@
|
|||||||
|
# - try to find part of DirectX SDK
|
||||||
|
#
|
||||||
|
# Cache Variables: (probably not for direct use in your scripts)
|
||||||
|
# DIRECTX_INCLUDE_DIR
|
||||||
|
#
|
||||||
|
# Variables you should use in your CMakeLists.txt:
|
||||||
|
# DIRECTX_DXGUID_LIBRARY
|
||||||
|
# DIRECTX_DXERR_LIBRARY
|
||||||
|
# DIRECTX_DINPUT_LIBRARY
|
||||||
|
# DIRECTX_DINPUT_INCLUDE_DIR
|
||||||
|
# DIRECTX_D3D9_LIBRARY
|
||||||
|
# DIRECTX_D3DXOF_LIBRARY
|
||||||
|
# DIRECTX_D3DX9_LIBRARIES
|
||||||
|
# DIRECTX_INCLUDE_DIRS
|
||||||
|
# DIRECTX_FOUND - if this is not true, do not attempt to use this library
|
||||||
|
#
|
||||||
|
# Requires these CMake modules:
|
||||||
|
# FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
|
||||||
|
# SelectLibraryConfigurations
|
||||||
|
#
|
||||||
|
# Original Author:
|
||||||
|
# 2012 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||||
|
# http://academic.cleardefinition.com
|
||||||
|
# Iowa State University HCI Graduate Program/VRAC
|
||||||
|
#
|
||||||
|
# Copyright Iowa State University 2012.
|
||||||
|
# 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(DIRECTX_ROOT_DIR
|
||||||
|
"${DIRECTX_ROOT_DIR}"
|
||||||
|
CACHE
|
||||||
|
PATH
|
||||||
|
"Root directory to search for DirectX")
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
file(TO_CMAKE_PATH "$ENV{ProgramFiles}" _PROG_FILES)
|
||||||
|
file(TO_CMAKE_PATH "$ENV{ProgramFiles(x86)}" _PROG_FILES_X86)
|
||||||
|
if(_PROG_FILES_X86)
|
||||||
|
set(_PROG_FILES "${_PROG_FILES_X86}")
|
||||||
|
endif()
|
||||||
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||||
|
set(_lib_suffixes lib/x64 lib)
|
||||||
|
else()
|
||||||
|
set(_lib_suffixes lib/x86 lib)
|
||||||
|
endif()
|
||||||
|
macro(_append_dxsdk_in_inclusive_range _low _high)
|
||||||
|
if((NOT MSVC_VERSION LESS ${_low}) AND (NOT MSVC_VERSION GREATER ${_high}))
|
||||||
|
list(APPEND DXSDK_DIRS ${ARGN})
|
||||||
|
endif()
|
||||||
|
endmacro()
|
||||||
|
_append_dxsdk_in_inclusive_range(1500 1600 "${_PROG_FILES}/Microsoft DirectX SDK (June 2010)")
|
||||||
|
_append_dxsdk_in_inclusive_range(1400 1600
|
||||||
|
"${_PROG_FILES}/Microsoft DirectX SDK (February 2010)"
|
||||||
|
"${_PROG_FILES}/Microsoft DirectX SDK (August 2009)"
|
||||||
|
"${_PROG_FILES}/Microsoft DirectX SDK (March 2009)"
|
||||||
|
"${_PROG_FILES}/Microsoft DirectX SDK (November 2008)"
|
||||||
|
"${_PROG_FILES}/Microsoft DirectX SDK (August 2008)"
|
||||||
|
"${_PROG_FILES}/Microsoft DirectX SDK (June 2008)"
|
||||||
|
"${_PROG_FILES}/Microsoft DirectX SDK (March 2008)")
|
||||||
|
_append_dxsdk_in_inclusive_range(1310 1500
|
||||||
|
"${_PROG_FILES}/Microsoft DirectX SDK (November 2007)"
|
||||||
|
"${_PROG_FILES}/Microsoft DirectX SDK (August 2007)"
|
||||||
|
"${_PROG_FILES}/Microsoft DirectX SDK (June 2007)"
|
||||||
|
"${_PROG_FILES}/Microsoft DirectX SDK (April 2007)"
|
||||||
|
"${_PROG_FILES}/Microsoft DirectX SDK (February 2007)"
|
||||||
|
"${_PROG_FILES}/Microsoft DirectX SDK (December 2006)"
|
||||||
|
"${_PROG_FILES}/Microsoft DirectX SDK (October 2006)"
|
||||||
|
"${_PROG_FILES}/Microsoft DirectX SDK (August 2006)"
|
||||||
|
"${_PROG_FILES}/Microsoft DirectX SDK (June 2006)"
|
||||||
|
"${_PROG_FILES}/Microsoft DirectX SDK (April 2006)"
|
||||||
|
"${_PROG_FILES}/Microsoft DirectX SDK (February 2006)")
|
||||||
|
|
||||||
|
file(TO_CMAKE_PATH "$ENV{DXSDK_DIR}" ENV_DXSDK_DIR)
|
||||||
|
if(ENV_DXSDK_DIR)
|
||||||
|
list(APPEND DXSDK_DIRS ${ENV_DXSDK_DIR})
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
set(_lib_suffixes lib)
|
||||||
|
set(DXSDK_DIRS /mingw)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_path(DIRECTX_INCLUDE_DIR
|
||||||
|
NAMES
|
||||||
|
dxdiag.h
|
||||||
|
dinput.h
|
||||||
|
dxerr8.h
|
||||||
|
PATHS
|
||||||
|
${DXSDK_DIRS}
|
||||||
|
HINTS
|
||||||
|
"${DIRECTX_ROOT_DIR}"
|
||||||
|
PATH_SUFFIXES
|
||||||
|
include)
|
||||||
|
find_path(DIRECTX_DINPUT_INCLUDE_DIR
|
||||||
|
NAMES
|
||||||
|
dinput.h
|
||||||
|
PATHS
|
||||||
|
${DXSDK_DIRS}
|
||||||
|
HINTS
|
||||||
|
"${DIRECTX_ROOT_DIR}"
|
||||||
|
PATH_SUFFIXES
|
||||||
|
include)
|
||||||
|
|
||||||
|
find_library(DIRECTX_DXGUID_LIBRARY
|
||||||
|
NAMES
|
||||||
|
dxguid
|
||||||
|
PATHS
|
||||||
|
${DXSDK_DIRS}
|
||||||
|
HINTS
|
||||||
|
"${DIRECTX_ROOT_DIR}"
|
||||||
|
PATH_SUFFIXES
|
||||||
|
${_lib_suffixes})
|
||||||
|
|
||||||
|
if(DIRECTX_DXGUID_LIBRARY)
|
||||||
|
get_filename_component(_dxsdk_lib_dir ${DIRECTX_DXGUID_LIBRARY} PATH)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_library(DIRECTX_DINPUT_LIBRARY
|
||||||
|
NAMES
|
||||||
|
dinput8
|
||||||
|
dinput
|
||||||
|
PATHS
|
||||||
|
${DXSDK_DIRS}
|
||||||
|
HINTS
|
||||||
|
"${_dxsdk_lib_dir}"
|
||||||
|
"${DIRECTX_ROOT_DIR}"
|
||||||
|
PATH_SUFFIXES
|
||||||
|
${_lib_suffixes})
|
||||||
|
|
||||||
|
find_library(DIRECTX_DXERR_LIBRARY
|
||||||
|
NAMES
|
||||||
|
dxerr
|
||||||
|
dxerr9
|
||||||
|
dxerr8
|
||||||
|
PATHS
|
||||||
|
${DXSDK_DIRS}
|
||||||
|
HINTS
|
||||||
|
"${_dxsdk_lib_dir}"
|
||||||
|
"${DIRECTX_ROOT_DIR}"
|
||||||
|
PATH_SUFFIXES
|
||||||
|
${_lib_suffixes})
|
||||||
|
|
||||||
|
find_library(DIRECTX_D3D9_LIBRARY
|
||||||
|
NAMES
|
||||||
|
d3d9
|
||||||
|
PATHS
|
||||||
|
${DXSDK_DIRS}
|
||||||
|
HINTS
|
||||||
|
"${_dxsdk_lib_dir}"
|
||||||
|
"${DIRECTX_ROOT_DIR}"
|
||||||
|
PATH_SUFFIXES
|
||||||
|
${_lib_suffixes})
|
||||||
|
|
||||||
|
find_library(DIRECTX_D3DXOF_LIBRARY
|
||||||
|
NAMES
|
||||||
|
d3dxof
|
||||||
|
PATHS
|
||||||
|
${DXSDK_DIRS}
|
||||||
|
HINTS
|
||||||
|
"${_dxsdk_lib_dir}"
|
||||||
|
"${DIRECTX_ROOT_DIR}"
|
||||||
|
PATH_SUFFIXES
|
||||||
|
${_lib_suffixes})
|
||||||
|
|
||||||
|
find_library(DIRECTX_D3DX9_LIBRARY_RELEASE
|
||||||
|
NAMES
|
||||||
|
d3dx9
|
||||||
|
PATHS
|
||||||
|
${DXSDK_DIRS}
|
||||||
|
HINTS
|
||||||
|
"${_dxsdk_lib_dir}"
|
||||||
|
"${DIRECTX_ROOT_DIR}"
|
||||||
|
PATH_SUFFIXES
|
||||||
|
${_lib_suffixes})
|
||||||
|
|
||||||
|
find_library(DIRECTX_D3DX9_LIBRARY_DEBUG
|
||||||
|
NAMES
|
||||||
|
d3dx9d
|
||||||
|
PATHS
|
||||||
|
${DXSDK_DIRS}
|
||||||
|
HINTS
|
||||||
|
"${_dxsdk_lib_dir}"
|
||||||
|
"${DIRECTX_ROOT_DIR}"
|
||||||
|
PATH_SUFFIXES
|
||||||
|
${_lib_suffixes})
|
||||||
|
|
||||||
|
include(SelectLibraryConfigurations)
|
||||||
|
select_library_configurations(DIRECTX_D3DX9)
|
||||||
|
|
||||||
|
set(DIRECTX_EXTRA_CHECK)
|
||||||
|
if(DIRECTX_INCLUDE_DIR)
|
||||||
|
if(MSVC80)
|
||||||
|
set(DXSDK_DEPRECATION_BUILD 1962)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(DXSDK_DEPRECATION_BUILD)
|
||||||
|
include(CheckCSourceCompiles)
|
||||||
|
set(_dinput_old_includes ${CMAKE_REQUIRED_INCLUDES})
|
||||||
|
set(CMAKE_REQUIRED_INCLUDES "${DIRECTX_INCLUDE_DIR}")
|
||||||
|
check_c_source_compiles("
|
||||||
|
#include <dxsdkver.h>
|
||||||
|
#if _DXSDK_BUILD_MAJOR >= ${DXSDK_DEPRECATION_BUILD}
|
||||||
|
#error
|
||||||
|
#else
|
||||||
|
int main(int argc, char * argv[]) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
"
|
||||||
|
DIRECTX_SDK_SUPPORTS_COMPILER)
|
||||||
|
set(DIRECTX_EXTRA_CHECK DIRECTX_SDK_SUPPORTS_COMPILER)
|
||||||
|
set(CMAKE_REQUIRED_INCLUDES "${_dinput_old_includes}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(DirectX
|
||||||
|
DEFAULT_MSG
|
||||||
|
DIRECTX_DXGUID_LIBRARY
|
||||||
|
DIRECTX_DINPUT_LIBRARY
|
||||||
|
DIRECTX_DXERR_LIBRARY
|
||||||
|
DIRECTX_INCLUDE_DIR
|
||||||
|
${DIRECTX_EXTRA_CHECK})
|
||||||
|
|
||||||
|
if(DIRECTX_FOUND)
|
||||||
|
set(DIRECTX_LIBRARIES
|
||||||
|
"${DIRECTX_DXGUID_LIBRARY}"
|
||||||
|
"${DIRECTX_DXERR_LIBRARY}"
|
||||||
|
"${DIRECTX_DINPUT_LIBRARY}")
|
||||||
|
|
||||||
|
set(DIRECTX_INCLUDE_DIRS "${DIRECTX_INCLUDE_DIR}")
|
||||||
|
|
||||||
|
mark_as_advanced(DIRECTX_ROOT_DIR)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
mark_as_advanced(DIRECTX_DINPUT_LIBRARY
|
||||||
|
DIRECTX_DXGUID_LIBRARY
|
||||||
|
DIRECTX_DXERR_LIBRARY
|
||||||
|
DIRECTX_D3D9_LIBRARY
|
||||||
|
DIRECTX_D3DXOF_LIBRARY
|
||||||
|
DIRECTX_D3DX9_LIBRARY_RELEASE
|
||||||
|
DIRECTX_D3DX9_LIBRARY_DEBUG
|
||||||
|
DIRECTX_INCLUDE_DIR)
|
||||||
@@ -36,17 +36,31 @@ find_program(GDB_COMMAND
|
|||||||
libexec)
|
libexec)
|
||||||
|
|
||||||
if(GDB_COMMAND)
|
if(GDB_COMMAND)
|
||||||
execute_process(COMMAND gdb --version
|
execute_process(COMMAND
|
||||||
COMMAND head -n 1
|
gdb
|
||||||
OUTPUT_VARIABLE GDB_VERSION
|
--version
|
||||||
|
COMMAND
|
||||||
|
head
|
||||||
|
-n
|
||||||
|
1
|
||||||
|
OUTPUT_VARIABLE
|
||||||
|
GDB_VERSION
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
string(REGEX REPLACE "[^0-9]*([0-9]+[0-9.]*).*" "\\1" GDB_VERSION "${GDB_VERSION}")
|
string(REGEX
|
||||||
|
REPLACE
|
||||||
|
"[^0-9]*([0-9]+[0-9.]*).*"
|
||||||
|
"\\1"
|
||||||
|
GDB_VERSION
|
||||||
|
"${GDB_VERSION}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# handle the QUIETLY and REQUIRED arguments and set xxx_FOUND to TRUE if
|
# handle the QUIETLY and REQUIRED arguments and set xxx_FOUND to TRUE if
|
||||||
# all listed variables are TRUE
|
# all listed variables are TRUE
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
find_package_handle_standard_args(GDB DEFAULT_MSG GDB_COMMAND GDB_VERSION)
|
find_package_handle_standard_args(GDB
|
||||||
|
DEFAULT_MSG
|
||||||
|
GDB_COMMAND
|
||||||
|
GDB_VERSION)
|
||||||
|
|
||||||
if(GDB_FOUND)
|
if(GDB_FOUND)
|
||||||
mark_as_advanced(GDB_ROOT_DIR)
|
mark_as_advanced(GDB_ROOT_DIR)
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ find_path(GHOST_INCLUDE_DIR
|
|||||||
|
|
||||||
find_library(GHOST_LIBRARY
|
find_library(GHOST_LIBRARY
|
||||||
GHOST40
|
GHOST40
|
||||||
|
GHOST31
|
||||||
PATHS
|
PATHS
|
||||||
${_dirs}
|
${_dirs}
|
||||||
HINTS
|
HINTS
|
||||||
@@ -47,6 +48,7 @@ find_library(GHOST_LIBRARY
|
|||||||
PATH_SUFFIXES
|
PATH_SUFFIXES
|
||||||
lib)
|
lib)
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
if(MSVC_VERSION GREATER 1300)
|
if(MSVC_VERSION GREATER 1300)
|
||||||
# .NET and newer: fake the STL headers
|
# .NET and newer: fake the STL headers
|
||||||
get_filename_component(_moddir "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
get_filename_component(_moddir "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||||
@@ -59,8 +61,14 @@ else()
|
|||||||
${_dirs}
|
${_dirs}
|
||||||
HINTS
|
HINTS
|
||||||
"${GHOST_ROOT_DIR}"
|
"${GHOST_ROOT_DIR}"
|
||||||
|
"${GHOST_INCLUDE_DIR}"
|
||||||
PATH_SUFFIXES
|
PATH_SUFFIXES
|
||||||
external/stl)
|
external/stl
|
||||||
|
stl)
|
||||||
|
endif()
|
||||||
|
set(_deps_check GHOST_STL_INCLUDE_DIR)
|
||||||
|
else()
|
||||||
|
set(_deps_check)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# handle the QUIETLY and REQUIRED arguments and set xxx_FOUND to TRUE if
|
# handle the QUIETLY and REQUIRED arguments and set xxx_FOUND to TRUE if
|
||||||
@@ -69,18 +77,14 @@ include(FindPackageHandleStandardArgs)
|
|||||||
find_package_handle_standard_args(GHOST
|
find_package_handle_standard_args(GHOST
|
||||||
DEFAULT_MSG
|
DEFAULT_MSG
|
||||||
GHOST_LIBRARY
|
GHOST_LIBRARY
|
||||||
GHOST_STL_INCLUDE_DIR
|
${_deps_check}
|
||||||
GHOST_INCLUDE_DIR)
|
GHOST_INCLUDE_DIR)
|
||||||
|
|
||||||
if(GHOST_FOUND)
|
if(GHOST_FOUND)
|
||||||
set(GHOST_LIBRARIES "${GHOST_LIBRARY}")
|
set(GHOST_LIBRARIES "${GHOST_LIBRARY}")
|
||||||
set(GHOST_INCLUDE_DIRS
|
set(GHOST_INCLUDE_DIRS "${GHOST_INCLUDE_DIR}")
|
||||||
"${GHOST_STL_INCLUDE_DIR}"
|
|
||||||
"${GHOST_INCLUDE_DIR}")
|
|
||||||
|
|
||||||
mark_as_advanced(GHOST_ROOT_DIR)
|
mark_as_advanced(GHOST_ROOT_DIR)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
mark_as_advanced(GHOST_LIBRARY
|
mark_as_advanced(GHOST_LIBRARY GHOST_STL_INCLUDE_DIR GHOST_INCLUDE_DIR)
|
||||||
GHOST_STL_INCLUDE_DIR
|
|
||||||
GHOST_INCLUDE_DIR)
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
# Useful configuration variables you might want to add to your cache:
|
# Useful configuration variables you might want to add to your cache:
|
||||||
# GMTL_ROOT_DIR - A directory prefix to search
|
# GMTL_ROOT_DIR - A directory prefix to search
|
||||||
# (a path that contains include/ as a subdirectory)
|
# (a path that contains include/ as a subdirectory)
|
||||||
# GMTL_ADDITIONAL_VERSIONS - Additional versions (outside of 0.5.1 to 0.6.2)
|
# GMTL_ADDITIONAL_VERSIONS - Additional versions (outside of 0.5.1 to 0.7.0)
|
||||||
# to use when constructing search names and paths
|
# to use when constructing search names and paths
|
||||||
#
|
#
|
||||||
# This script will use Flagpoll, if found, to provide hints to the location
|
# This script will use Flagpoll, if found, to provide hints to the location
|
||||||
@@ -24,11 +24,11 @@
|
|||||||
# and trigger an automatic re-run.
|
# and trigger an automatic re-run.
|
||||||
#
|
#
|
||||||
# Original Author:
|
# Original Author:
|
||||||
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
# 2009-2012 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||||
# http://academic.cleardefinition.com
|
# http://academic.cleardefinition.com
|
||||||
# Iowa State University HCI Graduate Program/VRAC
|
# Iowa State University HCI Graduate Program/VRAC
|
||||||
#
|
#
|
||||||
# Copyright Iowa State University 2009-2010.
|
# Copyright Iowa State University 2009-2012.
|
||||||
# Distributed under the Boost Software License, Version 1.0.
|
# Distributed under the Boost Software License, Version 1.0.
|
||||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
# http://www.boost.org/LICENSE_1_0.txt)
|
# http://www.boost.org/LICENSE_1_0.txt)
|
||||||
@@ -41,6 +41,7 @@ include(CheckVersion)
|
|||||||
|
|
||||||
set(GMTL_VERSIONS
|
set(GMTL_VERSIONS
|
||||||
${GMTL_ADDITIONAL_VERSIONS}
|
${GMTL_ADDITIONAL_VERSIONS}
|
||||||
|
0.7.0
|
||||||
0.6.2
|
0.6.2
|
||||||
0.6.1
|
0.6.1
|
||||||
0.6.0
|
0.6.0
|
||||||
|
|||||||
@@ -37,11 +37,15 @@
|
|||||||
# Brandon Newendorp <brandon@newendorp.com>
|
# Brandon Newendorp <brandon@newendorp.com>
|
||||||
|
|
||||||
set(_HUMAN "Gadgeteer 2.0")
|
set(_HUMAN "Gadgeteer 2.0")
|
||||||
set(_RELEASE_NAMES gadget-2_0 libgadget-2_0 gadget-2_0_0)
|
set(_FP_PKG_NAME gadgeteer)
|
||||||
set(_DEBUG_NAMES gadget_d-2_0 libgadget_d-2_0 gadget_d-2_0_0)
|
set(_RELEASE_NAMES)
|
||||||
|
set(_DEBUG_NAMES)
|
||||||
|
foreach(VER 2_0 2_0_0 2_0_1 2_0_2)
|
||||||
|
list(APPEND _RELEASE_NAMES gadget-${VER})
|
||||||
|
list(APPEND _DEBUG_NAMES gadget_d-${VER})
|
||||||
|
endforeach()
|
||||||
set(_DIR gadgeteer-2.0)
|
set(_DIR gadgeteer-2.0)
|
||||||
set(_HEADER gadget/gadgetConfig.h)
|
set(_HEADER gadget/gadgetConfig.h)
|
||||||
set(_FP_PKG_NAME gadgeteer)
|
|
||||||
|
|
||||||
include(SelectLibraryConfigurations)
|
include(SelectLibraryConfigurations)
|
||||||
include(CreateImportedTarget)
|
include(CreateImportedTarget)
|
||||||
|
|||||||
92
cmake/FindIDLJ.cmake
Normal file
92
cmake/FindIDLJ.cmake
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
# - try to find Java's IDLJ Interface Definition Language compiler.
|
||||||
|
#
|
||||||
|
# Ideally used with CMake 2.8.5 or newer for Java support using FindJava.cmake
|
||||||
|
# and UseJava.cmake
|
||||||
|
#
|
||||||
|
# Variables:
|
||||||
|
# Java_IDLJ_COMMAND, executable for idlj
|
||||||
|
# IDLJ_FOUND, If false, do not try to use this
|
||||||
|
#
|
||||||
|
# Function:
|
||||||
|
# java_idlj(varname idlfile [extra idlj args]) - Generates
|
||||||
|
# the Java source files from the IDL file you indicate, and
|
||||||
|
# appends filenames suitable to add to a add_jar() call to the
|
||||||
|
# variable you specified.
|
||||||
|
#
|
||||||
|
# Because the files generated from an IDL file are not entirely predictable,
|
||||||
|
# java_idlj runs idlj in the cmake step, rather than the build step, and triggers
|
||||||
|
# a CMake re-run when an idl file is modified. Already up-to-date generated source
|
||||||
|
# is not re-generated, however.
|
||||||
|
#
|
||||||
|
# Files are generated in a directory created specifically for
|
||||||
|
# the particular IDL file and the particular call, in the build directory -
|
||||||
|
# there should be no worries about overwriting files or picking up too much
|
||||||
|
# with the wildcard.
|
||||||
|
#
|
||||||
|
# You may wish to add the IDL file to your list of sources if you want it
|
||||||
|
# to appear in your IDE, but it is not necessary.
|
||||||
|
#
|
||||||
|
# Original Author:
|
||||||
|
# 2012 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||||
|
# http://academic.cleardefinition.com
|
||||||
|
# Iowa State University HCI Graduate Program/VRAC
|
||||||
|
#
|
||||||
|
# Copyright Iowa State University 2012.
|
||||||
|
# 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)
|
||||||
|
|
||||||
|
if(NOT JAVA_FOUND)
|
||||||
|
find_package(Java QUIET)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(JAVA_FOUND)
|
||||||
|
get_filename_component(JAVA_BIN_DIR "${Java_JAVAC_EXECUTABLE}" PATH)
|
||||||
|
find_program(Java_IDLJ_COMMAND
|
||||||
|
idlj
|
||||||
|
HINTS
|
||||||
|
${JAVA_BIN_DIR}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set xxx_FOUND to TRUE if
|
||||||
|
# all listed variables are TRUE
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(IDLJ
|
||||||
|
DEFAULT_MSG
|
||||||
|
Java_IDLJ_COMMAND
|
||||||
|
JAVA_FOUND)
|
||||||
|
|
||||||
|
if(IDLJ_FOUND)
|
||||||
|
function(java_idlj _varname _idlfile)
|
||||||
|
# Get some unique value we can use in a directory name
|
||||||
|
# TODO would be better to somehow munge the full path relative to CMAKE_CURRENT_SOURCE_DIR
|
||||||
|
# in case somebody has multiple idl files with the same name
|
||||||
|
get_filename_component(_idl_name "${_idlfile}" NAME_WE)
|
||||||
|
get_filename_component(_idl_abs "${_idlfile}" ABSOLUTE)
|
||||||
|
|
||||||
|
# Compute directory name and stamp filename
|
||||||
|
set(outdir "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/idlj/${_idl_name}.dir")
|
||||||
|
set(stampfile "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/idlj/${_idl_name}.stamp")
|
||||||
|
|
||||||
|
# Force re-cmake if idl file changes
|
||||||
|
configure_file("${_idl_abs}" "${stampfile}" COPY_ONLY)
|
||||||
|
|
||||||
|
if((NOT EXISTS "${outdir}") OR ("${_idl_abs}" IS_NEWER_THAN "${outdir}"))
|
||||||
|
file(REMOVE_RECURSE "${outdir}")
|
||||||
|
message(STATUS "Processing ${_idlfile} with Java's idlj")
|
||||||
|
execute_process(COMMAND
|
||||||
|
"${Java_IDLJ_COMMAND}" -fclient -fallTIE -td "${outdir}" ${ARGN} "${_idlfile}"
|
||||||
|
WORKING_DIRECTORY
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
|
endif()
|
||||||
|
file(GLOB_RECURSE _idl_output "${outdir}/*")
|
||||||
|
|
||||||
|
set(${_varname} ${_idl_output} PARENT_SCOPE)
|
||||||
|
|
||||||
|
# Clean up after ourselves on make clean
|
||||||
|
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${outdir}" "${stampfile}")
|
||||||
|
endfunction()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
mark_as_advanced(Java_IDLJ_COMMAND)
|
||||||
@@ -37,11 +37,15 @@
|
|||||||
|
|
||||||
|
|
||||||
set(_HUMAN "JCCL 1.4")
|
set(_HUMAN "JCCL 1.4")
|
||||||
set(_RELEASE_NAMES jccl-1_4 libjccl-1_4 jccl-1_4_0)
|
set(_FP_PKG_NAME jccl)
|
||||||
set(_DEBUG_NAMES jccl_d-1_4 libjccl_d-1_4 jccl_d-1_4_0)
|
set(_RELEASE_NAMES)
|
||||||
|
set(_DEBUG_NAMES)
|
||||||
|
foreach(VER 1_4 1_4_0 1_4_1 1_4_2)
|
||||||
|
list(APPEND _RELEASE_NAMES ${_FP_PKG_NAME}-${VER})
|
||||||
|
list(APPEND _DEBUG_NAMES ${_FP_PKG_NAME}_d-${VER})
|
||||||
|
endforeach()
|
||||||
set(_DIR jccl-1.4)
|
set(_DIR jccl-1.4)
|
||||||
set(_HEADER jccl/jcclConfig.h)
|
set(_HEADER jccl/jcclConfig.h)
|
||||||
set(_FP_PKG_NAME jccl)
|
|
||||||
|
|
||||||
include(SelectLibraryConfigurations)
|
include(SelectLibraryConfigurations)
|
||||||
include(CreateImportedTarget)
|
include(CreateImportedTarget)
|
||||||
|
|||||||
@@ -144,13 +144,15 @@ elseif(UNIX)
|
|||||||
string(TOLOWER "${CMAKE_SYSTEM_NAME}" _sysname)
|
string(TOLOWER "${CMAKE_SYSTEM_NAME}" _sysname)
|
||||||
file(TO_CMAKE_PATH "$ENV{JTTK_DEV_PATH}" _envloc)
|
file(TO_CMAKE_PATH "$ENV{JTTK_DEV_PATH}" _envloc)
|
||||||
prefix_list_glob(_jttklibs
|
prefix_list_glob(_jttklibs
|
||||||
"lib/${_sysname}_${BITS}${_compiler}/libJtTk*"
|
"/lib/${_sysname}_${BITS}${_compiler}/libJtTk*"
|
||||||
|
"${JTTK_ROOT_DIR}"
|
||||||
"/usr/"
|
"/usr/"
|
||||||
"/usr/local/"
|
"/usr/local/"
|
||||||
"/usr/local/siemens/"
|
"/usr/local/siemens/"
|
||||||
"/usr/local/ugs/")
|
"/usr/local/ugs/")
|
||||||
prefix_list_glob(_jttklibs2
|
prefix_list_glob(_jttklibs2
|
||||||
"dev/lib/${_sysname}_${BITS}${_compiler}/libJtTk*"
|
"/dev/lib/${_sysname}_${BITS}${_compiler}/libJtTk*"
|
||||||
|
"${JTTK_ROOT_DIR}"
|
||||||
"/usr/"
|
"/usr/"
|
||||||
"/usr/local/"
|
"/usr/local/"
|
||||||
"/usr/local/siemens/"
|
"/usr/local/siemens/"
|
||||||
|
|||||||
@@ -81,11 +81,9 @@ find_package_handle_standard_args(Libusb1
|
|||||||
LIBUSB1_INCLUDE_DIR)
|
LIBUSB1_INCLUDE_DIR)
|
||||||
|
|
||||||
if(LIBUSB1_FOUND)
|
if(LIBUSB1_FOUND)
|
||||||
set(LIBUSB1_LIBRARIES
|
set(LIBUSB1_LIBRARIES "${LIBUSB1_LIBRARY}")
|
||||||
"${LIBUSB1_LIBRARY}")
|
|
||||||
|
|
||||||
set(LIBUSB1_INCLUDE_DIRS
|
set(LIBUSB1_INCLUDE_DIRS "${LIBUSB1_INCLUDE_DIR}")
|
||||||
"${LIBUSB1_INCLUDE_DIR}")
|
|
||||||
|
|
||||||
mark_as_advanced(LIBUSB1_ROOT_DIR)
|
mark_as_advanced(LIBUSB1_ROOT_DIR)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -65,9 +65,7 @@ mark_as_advanced(LYX_COMMAND)
|
|||||||
function(lyx_export _format _extension _outvar)
|
function(lyx_export _format _extension _outvar)
|
||||||
set(_nowhere)
|
set(_nowhere)
|
||||||
set(_curdest _nowhere)
|
set(_curdest _nowhere)
|
||||||
set(_val_args
|
set(_val_args EXTRA_DEPS INPUT)
|
||||||
EXTRA_DEPS
|
|
||||||
INPUT)
|
|
||||||
set(_bool_args OUTPUT_TO_SOURCE_DIR)
|
set(_bool_args OUTPUT_TO_SOURCE_DIR)
|
||||||
foreach(_arg ${_val_args} ${_bool_args})
|
foreach(_arg ${_val_args} ${_bool_args})
|
||||||
set(${_arg})
|
set(${_arg})
|
||||||
|
|||||||
56
cmake/FindMarkdown.cmake
Normal file
56
cmake/FindMarkdown.cmake
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
# - try to find Markdown tool
|
||||||
|
#
|
||||||
|
# Cache Variables:
|
||||||
|
# MARKDOWN_EXECUTABLE
|
||||||
|
#
|
||||||
|
# Non-cache variables you might use in your CMakeLists.txt:
|
||||||
|
# MARKDOWN_FOUND
|
||||||
|
#
|
||||||
|
# Requires these CMake modules:
|
||||||
|
# FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
|
||||||
|
#
|
||||||
|
# Original Author:
|
||||||
|
# 2011 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||||
|
# http://academic.cleardefinition.com
|
||||||
|
# Iowa State University HCI Graduate Program/VRAC
|
||||||
|
#
|
||||||
|
# Copyright Iowa State University 2011.
|
||||||
|
# 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)
|
||||||
|
|
||||||
|
file(TO_CMAKE_PATH "${MARKDOWN_ROOT_DIR}" MARKDOWN_ROOT_DIR)
|
||||||
|
set(MARKDOWN_ROOT_DIR
|
||||||
|
"${MARKDOWN_ROOT_DIR}"
|
||||||
|
CACHE
|
||||||
|
PATH
|
||||||
|
"Path to search for Markdown")
|
||||||
|
|
||||||
|
if(MARKDOWN_EXECUTABLE AND NOT EXISTS "${MARKDOWN_EXECUTABLE}")
|
||||||
|
set(MARKDOWN_EXECUTABLE "notfound" CACHE PATH FORCE "")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# If we have a custom path, look there first.
|
||||||
|
if(MARKDOWN_ROOT_DIR)
|
||||||
|
find_program(MARKDOWN_EXECUTABLE
|
||||||
|
NAMES
|
||||||
|
markdown
|
||||||
|
PATHS
|
||||||
|
"${MARKDOWN_ROOT_DIR}"
|
||||||
|
PATH_SUFFIXES
|
||||||
|
bin
|
||||||
|
NO_DEFAULT_PATH)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_program(MARKDOWN_EXECUTABLE NAMES markdown)
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(Markdown
|
||||||
|
DEFAULT_MSG
|
||||||
|
MARKDOWN_EXECUTABLE)
|
||||||
|
|
||||||
|
if(MARKDOWN_FOUND)
|
||||||
|
mark_as_advanced(MARKDOWN_ROOT_DIR)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
mark_as_advanced(MARKDOWN_EXECUTABLE)
|
||||||
@@ -73,7 +73,11 @@ else()
|
|||||||
otherlibs/_graphics/include)
|
otherlibs/_graphics/include)
|
||||||
|
|
||||||
# library linkdir suffixes appended to OPENCV_BASE_DIR
|
# library linkdir suffixes appended to OPENCV_BASE_DIR
|
||||||
set(OPENCV_LIBDIR_SUFFIXES lib lib64 OpenCV/lib otherlibs/_graphics/lib)
|
set(OPENCV_LIBDIR_SUFFIXES
|
||||||
|
lib
|
||||||
|
lib64
|
||||||
|
OpenCV/lib
|
||||||
|
otherlibs/_graphics/lib)
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -3,12 +3,16 @@
|
|||||||
# Cache Variables: (probably not for direct use in your scripts)
|
# Cache Variables: (probably not for direct use in your scripts)
|
||||||
# HDAPI_INCLUDE_DIR
|
# HDAPI_INCLUDE_DIR
|
||||||
# HDAPI_LIBRARY
|
# HDAPI_LIBRARY
|
||||||
|
# HDAPI_LIBRARY_RELEASE
|
||||||
|
# HDAPI_LIBRARY_DEBUG
|
||||||
# HDAPI_HDU_INCLUDE_DIR
|
# HDAPI_HDU_INCLUDE_DIR
|
||||||
# HDAPI_HDU_LIBRARY
|
# HDAPI_HDU_LIBRARY
|
||||||
# HDAPI_HDU_LIBRARY_RELEASE
|
# HDAPI_HDU_LIBRARY_RELEASE
|
||||||
# HDAPI_HDU_LIBRARY_DEBUG
|
# HDAPI_HDU_LIBRARY_DEBUG
|
||||||
# HLAPI_INCLUDE_DIR
|
# HLAPI_INCLUDE_DIR
|
||||||
# HLAPI_LIBRARY
|
# HLAPI_LIBRARY
|
||||||
|
# HLAPI_LIBRARY_RELEASE
|
||||||
|
# HLAPI_LIBRARY_DEBUG
|
||||||
# HLAPI_HLU_INCLUDE_DIR
|
# HLAPI_HLU_INCLUDE_DIR
|
||||||
# HLAPI_HLU_LIBRARY
|
# HLAPI_HLU_LIBRARY
|
||||||
# HLAPI_HLU_LIBRARY_RELEASE
|
# HLAPI_HLU_LIBRARY_RELEASE
|
||||||
@@ -40,7 +44,7 @@
|
|||||||
# CMake 2.6.3 (uses "unset")
|
# CMake 2.6.3 (uses "unset")
|
||||||
#
|
#
|
||||||
# Original Author:
|
# Original Author:
|
||||||
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
# 2009-2012 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||||
# http://academic.cleardefinition.com
|
# http://academic.cleardefinition.com
|
||||||
# Iowa State University HCI Graduate Program/VRAC
|
# Iowa State University HCI Graduate Program/VRAC
|
||||||
#
|
#
|
||||||
@@ -77,8 +81,20 @@ set(_libsearchdirs)
|
|||||||
set(OPENHAPTICS_ENVIRONMENT)
|
set(OPENHAPTICS_ENVIRONMENT)
|
||||||
set(OPENHAPTICS_RUNTIME_LIBRARY_DIRS)
|
set(OPENHAPTICS_RUNTIME_LIBRARY_DIRS)
|
||||||
|
|
||||||
|
set(_dirs)
|
||||||
|
if(NOT "$ENV{OH_SDK_BASE}" STREQUAL "")
|
||||||
|
list(APPEND _dirs "$ENV{OH_SDK_BASE}")
|
||||||
|
elseif(NOT "$ENV{3DTOUCH_BASE}" STREQUAL "")
|
||||||
|
list(APPEND _dirs "$ENV{3DTOUCH_BASE}")
|
||||||
|
endif()
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
program_files_fallback_glob(_dirs "/Sensable/3DTouch*/")
|
program_files_fallback_glob(_pfdirs "/Sensable/3DTouch*/")
|
||||||
|
foreach(_OH_DEFAULT_LOCATION "C:/OpenHaptics/3.1" "C:/OpenHaptics/Academic/3.1")
|
||||||
|
if(EXISTS "${_OH_DEFAULT_LOCATION}")
|
||||||
|
list(APPEND _dirs "${_OH_DEFAULT_LOCATION}")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
set(_dirs "${_dirs};${_pfdirs}")
|
||||||
if(MSVC60)
|
if(MSVC60)
|
||||||
set(_vc "vc6")
|
set(_vc "vc6")
|
||||||
elseif(MSVC70 OR MSVC71)
|
elseif(MSVC70 OR MSVC71)
|
||||||
@@ -160,12 +176,26 @@ find_path(HDAPI_INCLUDE_DIR
|
|||||||
HINTS
|
HINTS
|
||||||
${_incsearchdirs})
|
${_incsearchdirs})
|
||||||
|
|
||||||
find_library(HDAPI_LIBRARY
|
find_library(HDAPI_LIBRARY_RELEASE
|
||||||
NAMES
|
NAMES
|
||||||
HD
|
HD
|
||||||
|
PATH_SUFFIXES
|
||||||
|
ReleaseAcademicEdition
|
||||||
|
Release
|
||||||
HINTS
|
HINTS
|
||||||
${_libsearchdirs})
|
${_libsearchdirs})
|
||||||
|
|
||||||
|
find_library(HDAPI_LIBRARY_DEBUG
|
||||||
|
NAMES
|
||||||
|
HD
|
||||||
|
PATH_SUFFIXES
|
||||||
|
DebugAcademicEdition
|
||||||
|
Debug
|
||||||
|
HINTS
|
||||||
|
${_libsearchdirs})
|
||||||
|
|
||||||
|
select_library_configurations(HDAPI)
|
||||||
|
|
||||||
###
|
###
|
||||||
# HDAPI: HDU
|
# HDAPI: HDU
|
||||||
###
|
###
|
||||||
@@ -230,6 +260,7 @@ if(OPENHAPTICS_NESTED_TARGETS OR NOT HDAPI_HDU_LIBRARY)
|
|||||||
STRING
|
STRING
|
||||||
"We will build the OpenHaptics HDU lib."
|
"We will build the OpenHaptics HDU lib."
|
||||||
FORCE)
|
FORCE)
|
||||||
|
set(HDAPI_HDU_LIBRARIES ${HDAPI_HDU_LIBRARY})
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -243,12 +274,25 @@ find_path(HLAPI_INCLUDE_DIR
|
|||||||
HINTS
|
HINTS
|
||||||
${_incsearchdirs})
|
${_incsearchdirs})
|
||||||
|
|
||||||
find_library(HLAPI_LIBRARY
|
find_library(HLAPI_LIBRARY_RELEASE
|
||||||
NAMES
|
NAMES
|
||||||
HL
|
HL
|
||||||
|
PATH_SUFFIXES
|
||||||
|
ReleaseAcademicEdition
|
||||||
|
Release
|
||||||
HINTS
|
HINTS
|
||||||
${_libsearchdirs})
|
${_libsearchdirs})
|
||||||
|
|
||||||
|
find_library(HLAPI_LIBRARY_DEBUG
|
||||||
|
NAMES
|
||||||
|
HL
|
||||||
|
PATH_SUFFIXES
|
||||||
|
DebugAcademicEdition
|
||||||
|
Debug
|
||||||
|
HINTS
|
||||||
|
${_libsearchdirs})
|
||||||
|
|
||||||
|
select_library_configurations(HLAPI)
|
||||||
|
|
||||||
###
|
###
|
||||||
# HLAPI: HLU
|
# HLAPI: HLU
|
||||||
@@ -314,63 +358,10 @@ if(OPENHAPTICS_NESTED_TARGETS OR NOT HLAPI_HLU_LIBRARY)
|
|||||||
STRING
|
STRING
|
||||||
"We will build the OpenHaptics HLU lib."
|
"We will build the OpenHaptics HLU lib."
|
||||||
FORCE)
|
FORCE)
|
||||||
|
set(HLAPI_HLU_LIBRARIES ${HLAPI_HLU_LIBRARY})
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
###
|
|
||||||
# Unix: check stdc++ version
|
|
||||||
###
|
|
||||||
|
|
||||||
if(UNIX
|
|
||||||
AND
|
|
||||||
HDAPI_LIBRARY
|
|
||||||
AND
|
|
||||||
HDAPI_PHANToMIO_LIBRARY
|
|
||||||
AND
|
|
||||||
HDAPI_INCLUDE_DIR)
|
|
||||||
find_file(OPENHAPTICS_LINKTEST_FILE
|
|
||||||
FindOpenHaptics.cpp
|
|
||||||
PATHS
|
|
||||||
${CMAKE_MODULE_PATH})
|
|
||||||
mark_as_advanced(OPENHAPTICS_LINKTEST_FILE)
|
|
||||||
|
|
||||||
try_compile(_result
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/FindOpenHaptics
|
|
||||||
"${OPENHAPTICS_LINKTEST_FILE}"
|
|
||||||
CMAKE_FLAGS
|
|
||||||
"-DLINK_LIBRARIES=${HDAPI_LIBRARY}\;${HDAPI_PHANToMIO_LIBRARY} -DINCLUDE_DIRECTORIES=${HDAPI_INCLUDE_DIR}")
|
|
||||||
if(NOT _result)
|
|
||||||
set(OPENHAPTICS_LIBSTDCPP_DIR
|
|
||||||
"${OPENHAPTICS_LIBSTDCPP_DIR}"
|
|
||||||
CACHE
|
|
||||||
PATH
|
|
||||||
"The path to search for a libstdc++ with GLIBCXX_3.4.9 defined.")
|
|
||||||
if(OPENHAPTICS_LIBSTDCPP_DIR)
|
|
||||||
mark_as_advanced(OPENHAPTICS_LIBSTDCPP_DIR)
|
|
||||||
endif()
|
|
||||||
find_library(OPENHAPTICS_LIBSTDCPP_LIBRARY
|
|
||||||
libstdc++
|
|
||||||
PATHS
|
|
||||||
${OPENHAPTICS_LIBSTDCPP_DIR}
|
|
||||||
NO_DEFAULT_PATH)
|
|
||||||
if(OPENHAPTICS_LIBSTDCPP_LIBRARY)
|
|
||||||
mark_as_advanced(OPENHAPTICS_LIBSTDCPP_LIBRARY)
|
|
||||||
endif()
|
|
||||||
list(APPEND _deps_check OPENHAPTICS_LIBSTDCPP_LIBRARY)
|
|
||||||
list(APPEND _deps_libs "${OPENHAPTICS_LIBSTDCPP_LIBRARY}")
|
|
||||||
|
|
||||||
get_filename_component(_stdcppdir
|
|
||||||
"${OPENHAPTICS_LIBSTDCPP_LIBRARY}"
|
|
||||||
PATH)
|
|
||||||
list(APPEND
|
|
||||||
OPENHAPTICS_ENVIRONMENT
|
|
||||||
"LD_LIBRARY_PATH=${_stdcppdir}:$LD_LIBRARY_PATH")
|
|
||||||
list(APPEND OPENHAPTICS_RUNTIME_LIBRARY_DIRS "${_stdcppdir}")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
###
|
###
|
||||||
# Add dependencies: Libraries
|
# Add dependencies: Libraries
|
||||||
###
|
###
|
||||||
@@ -448,10 +439,12 @@ if(OPENHAPTICS_FOUND)
|
|||||||
set(OPENHAPTICS_LIBRARY_DIRS)
|
set(OPENHAPTICS_LIBRARY_DIRS)
|
||||||
foreach(_lib
|
foreach(_lib
|
||||||
${_deps_check}
|
${_deps_check}
|
||||||
HDAPI_LIBRARY
|
HDAPI_LIBRARY_RELEASE
|
||||||
|
HDAPI_LIBRARY_DEBUG
|
||||||
HDAPI_HDU_LIBRARY_RELEASE
|
HDAPI_HDU_LIBRARY_RELEASE
|
||||||
HDAPI_HDU_LIBRARY_DEBUG
|
HDAPI_HDU_LIBRARY_DEBUG
|
||||||
HLAPI_LIBRARY
|
HLAPI_LIBRARY_RELEASE
|
||||||
|
HLAPI_LIBRARY_DEBUG
|
||||||
HLAPI_HLU_LIBRARY_RELEASE
|
HLAPI_HLU_LIBRARY_RELEASE
|
||||||
HLAPI_HLU_LIBRARY_DEBUG)
|
HLAPI_HLU_LIBRARY_DEBUG)
|
||||||
get_filename_component(_libdir ${${_lib}} PATH)
|
get_filename_component(_libdir ${${_lib}} PATH)
|
||||||
@@ -475,12 +468,14 @@ if(OPENHAPTICS_FOUND)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
mark_as_advanced(HDAPI_INCLUDE_DIR
|
mark_as_advanced(HDAPI_INCLUDE_DIR
|
||||||
HDAPI_LIBRARY
|
HDAPI_LIBRARY_RELEASE
|
||||||
|
HDAPI_LIBRARY_DEBUG
|
||||||
HDAPI_HDU_INCLUDE_DIR
|
HDAPI_HDU_INCLUDE_DIR
|
||||||
HDAPI_HDU_LIBRARY_RELEASE
|
HDAPI_HDU_LIBRARY_RELEASE
|
||||||
HDAPI_HDU_LIBRARY_DEBUG
|
HDAPI_HDU_LIBRARY_DEBUG
|
||||||
HLAPI_INCLUDE_DIR
|
HLAPI_INCLUDE_DIR
|
||||||
HLAPI_LIBRARY
|
HLAPI_LIBRARY_RELEASE
|
||||||
|
HLAPI_LIBRARY_DEBUG
|
||||||
HLAPI_HLU_INCLUDE_DIR
|
HLAPI_HLU_INCLUDE_DIR
|
||||||
HLAPI_HLU_LIBRARY_RELEASE
|
HLAPI_HLU_LIBRARY_RELEASE
|
||||||
HLAPI_HLU_LIBRARY_DEBUG)
|
HLAPI_HLU_LIBRARY_DEBUG)
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
/**
|
|
||||||
* \file FindOpenHaptics.cpp
|
|
||||||
* \brief C++ source file used by CMake module FindOpenHaptics.cmake
|
|
||||||
*
|
|
||||||
* \author
|
|
||||||
* Ryan Pavlik, 2009-2010
|
|
||||||
* <rpavlik@iastate.edu>
|
|
||||||
* http://academic.cleardefinition.com/
|
|
||||||
*
|
|
||||||
* Used to check stdc++ version
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <HD/hd.h>
|
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
153
cmake/FindPerformer.cmake
Normal file
153
cmake/FindPerformer.cmake
Normal file
@@ -0,0 +1,153 @@
|
|||||||
|
# - try to find the OpenGL Performer library
|
||||||
|
#
|
||||||
|
# Users may optionally supply:
|
||||||
|
# PERFORMER_ROOT_DIR - a prefix to start searching.
|
||||||
|
#
|
||||||
|
# Cache Variables: (probably not for direct use in your scripts)
|
||||||
|
# PERFORMER_INCLUDE_DIR
|
||||||
|
# PERFORMER_LIBRARY
|
||||||
|
# PERFORMER_PFUI_LIBRARY - doesn't get included in PERFORMER_LIBRARIES
|
||||||
|
# PERFORMER_PFDU_UTIL_LIBRARY - doesn't get included in PERFORMER_LIBRARIES
|
||||||
|
# PERFORMER_PFV_LIBRARY - doesn't get included in PERFORMER_LIBRARIES
|
||||||
|
#
|
||||||
|
# Non-cache variables you might use in your CMakeLists.txt:
|
||||||
|
# PERFORMER_FOUND
|
||||||
|
# PERFORMER_INCLUDE_DIRS
|
||||||
|
# PERFORMER_LIBRARIES
|
||||||
|
# PERFORMER_RUNTIME_LIBRARY_DIRS
|
||||||
|
#
|
||||||
|
# Requires these CMake modules:
|
||||||
|
# FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
|
||||||
|
#
|
||||||
|
# Original Author:
|
||||||
|
# 2012 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||||
|
# http://academic.cleardefinition.com
|
||||||
|
# Iowa State University HCI Graduate Program/VRAC
|
||||||
|
#
|
||||||
|
# Copyright Iowa State University 2012.
|
||||||
|
# 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(PERFORMER_ROOT_DIR
|
||||||
|
"${PERFORMER_ROOT_DIR}"
|
||||||
|
CACHE
|
||||||
|
PATH
|
||||||
|
"Path to search for OpenGL Performer library")
|
||||||
|
|
||||||
|
|
||||||
|
find_path(PERFORMER_INCLUDE_DIR
|
||||||
|
NAMES
|
||||||
|
pf.h
|
||||||
|
HINTS
|
||||||
|
"${PERFORMER_ROOT_DIR}"
|
||||||
|
PATH_SUFFIXES
|
||||||
|
include
|
||||||
|
include/Performer
|
||||||
|
Performer
|
||||||
|
PATHS
|
||||||
|
$ENV{PFROOT})
|
||||||
|
mark_as_advanced(PERFORMER_INCLUDE_DIR)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
set(_pf_libnameprefix lib)
|
||||||
|
find_library(PERFORMER_PFDU_UTIL_LIBRARY
|
||||||
|
NAMES
|
||||||
|
libpfdu-util
|
||||||
|
HINTS
|
||||||
|
"${PERFORMER_ROOT_DIR}"
|
||||||
|
PATH_SUFFIXES
|
||||||
|
lib
|
||||||
|
PATHS
|
||||||
|
$ENV{PFROOT})
|
||||||
|
else()
|
||||||
|
set(_pf_libnameprefix)
|
||||||
|
find_library(PERFORMER_PFDU_LIBRARY
|
||||||
|
NAMES
|
||||||
|
pfdu
|
||||||
|
HINTS
|
||||||
|
"${PERFORMER_ROOT_DIR}"
|
||||||
|
PATH_SUFFIXES
|
||||||
|
lib
|
||||||
|
PATHS
|
||||||
|
$ENV{PFROOT})
|
||||||
|
find_library(PERFORMER_PFUTIL_LIBRARY
|
||||||
|
NAMES
|
||||||
|
pfutil
|
||||||
|
HINTS
|
||||||
|
"${PERFORMER_ROOT_DIR}"
|
||||||
|
PATH_SUFFIXES
|
||||||
|
lib
|
||||||
|
PATHS
|
||||||
|
$ENV{PFROOT})
|
||||||
|
if(PERFORMER_PFDU_LIBRARY AND PERFORMER_PFUTIL_LIBRARY)
|
||||||
|
set(PERFORMER_PFDU_UTIL_LIBRARY
|
||||||
|
${PERFORMER_PFDU_LIBRARY}
|
||||||
|
${PERFORMER_PFUTIL_LIBRARY})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_library(PERFORMER_LIBRARY
|
||||||
|
NAMES
|
||||||
|
${_pf_libnameprefix}pf
|
||||||
|
HINTS
|
||||||
|
"${PERFORMER_ROOT_DIR}"
|
||||||
|
PATH_SUFFIXES
|
||||||
|
lib
|
||||||
|
PATHS
|
||||||
|
$ENV{PFROOT})
|
||||||
|
find_library(PERFORMER_PFUI_LIBRARY
|
||||||
|
NAMES
|
||||||
|
${_pf_libnameprefix}pfui
|
||||||
|
HINTS
|
||||||
|
"${PERFORMER_ROOT_DIR}"
|
||||||
|
PATH_SUFFIXES
|
||||||
|
lib
|
||||||
|
PATHS
|
||||||
|
$ENV{PFROOT})
|
||||||
|
find_library(PERFORMER_PFV_LIBRARY
|
||||||
|
NAMES
|
||||||
|
${_pf_libnameprefix}pfv
|
||||||
|
HINTS
|
||||||
|
"${PERFORMER_ROOT_DIR}"
|
||||||
|
PATH_SUFFIXES
|
||||||
|
lib
|
||||||
|
PATHS
|
||||||
|
$ENV{PFROOT})
|
||||||
|
|
||||||
|
###
|
||||||
|
# Prereq: OpenGL
|
||||||
|
###
|
||||||
|
|
||||||
|
find_package(OpenGL QUIET)
|
||||||
|
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set xxx_FOUND to TRUE if
|
||||||
|
# all listed variables are TRUE
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(Performer
|
||||||
|
DEFAULT_MSG
|
||||||
|
PERFORMER_LIBRARY
|
||||||
|
PERFORMER_PFUI_LIBRARY
|
||||||
|
PERFORMER_PFV_LIBRARY
|
||||||
|
PERFORMER_PFDU_UTIL_LIBRARY
|
||||||
|
PERFORMER_INCLUDE_DIR
|
||||||
|
OPENGL_FOUND)
|
||||||
|
|
||||||
|
if(PERFORMER_FOUND)
|
||||||
|
set(PERFORMER_INCLUDE_DIRS
|
||||||
|
"${OPENGL_INCLUDE_DIR}"
|
||||||
|
"${PERFORMER_INCLUDE_DIR}")
|
||||||
|
if(PERFORMER_INCLUDE_DIR MATCHES ".*Performer.*")
|
||||||
|
list(APPEND PERFORMER_INCLUDE_DIRS "${PERFORMER_INCLUDE_DIR}/..")
|
||||||
|
endif()
|
||||||
|
set(PERFORMER_LIBRARIES "${OPENGL_LIBRARY}" "${PERFORMER_LIBRARY}")
|
||||||
|
mark_as_advanced(PERFORMER_ROOT_DIR)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
mark_as_advanced(PERFORMER_LIBRARY
|
||||||
|
PERFORMER_PFUI_LIBRARY
|
||||||
|
PERFORMER_PFV_LIBRARY
|
||||||
|
PERFORMER_PFDU_LIBRARY
|
||||||
|
PERFORMER_PFUTIL_LIBRARY
|
||||||
|
PERFORMER_PFDU_UTIL_LIBRARY
|
||||||
|
PERFORMER_INCLUDE_DIR)
|
||||||
78
cmake/FindPerlModules.cmake
Normal file
78
cmake/FindPerlModules.cmake
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
# - try to find perl modules, passed as COMPONENTS
|
||||||
|
#
|
||||||
|
# Non-cache variable you might use in your CMakeLists.txt:
|
||||||
|
# PERLMODULES_FOUND
|
||||||
|
#
|
||||||
|
# Requires these CMake modules:
|
||||||
|
# FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
|
||||||
|
#
|
||||||
|
# Original Author:
|
||||||
|
# 2012 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||||
|
# http://academic.cleardefinition.com
|
||||||
|
# Iowa State University HCI Graduate Program/VRAC
|
||||||
|
#
|
||||||
|
# Copyright Iowa State University 2012.
|
||||||
|
# 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)
|
||||||
|
|
||||||
|
if(NOT PERL_FOUND)
|
||||||
|
find_package(Perl QUIET)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(_deps_check)
|
||||||
|
if(PERL_FOUND)
|
||||||
|
foreach(module ${PerlModules_FIND_COMPONENTS})
|
||||||
|
string(REPLACE "::" "/" modfilename "${module}.pm")
|
||||||
|
string(REPLACE "::" "_" modvarname "PERLMODULES_${module}_MODULE")
|
||||||
|
string(TOUPPER "${modvarname}" modvarname)
|
||||||
|
list(APPEND _deps_check ${modvarname})
|
||||||
|
if(NOT ${modvarname})
|
||||||
|
if(NOT PerlModules_FIND_QUIETLY)
|
||||||
|
message(STATUS "Checking for perl module ${module}")
|
||||||
|
endif()
|
||||||
|
execute_process(COMMAND
|
||||||
|
"${PERL_EXECUTABLE}"
|
||||||
|
"-e"
|
||||||
|
"use ${module}; print \$INC{\"${modfilename}\"}"
|
||||||
|
RESULT_VARIABLE result_code
|
||||||
|
OUTPUT_VARIABLE filename
|
||||||
|
ERROR_VARIABLE error_info
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
if(result_code EQUAL 0)
|
||||||
|
if(NOT PerlModules_FIND_QUIETLY)
|
||||||
|
message(STATUS
|
||||||
|
"Checking for perl module ${module} - found at ${filename}")
|
||||||
|
endif()
|
||||||
|
set(${modvarname}
|
||||||
|
"${filename}"
|
||||||
|
CACHE
|
||||||
|
FILEPATH
|
||||||
|
"Location found for module ${module}"
|
||||||
|
FORCE)
|
||||||
|
mark_as_advanced(${modvarname})
|
||||||
|
else()
|
||||||
|
if(NOT PerlModules_FIND_QUIETLY)
|
||||||
|
message(STATUS "Checking for perl module ${module} - failed")
|
||||||
|
endif()
|
||||||
|
set(${modvarname}
|
||||||
|
"NOTFOUND"
|
||||||
|
CACHE
|
||||||
|
FILEPATH
|
||||||
|
"No location found for module ${module}"
|
||||||
|
FORCE)
|
||||||
|
file(APPEND
|
||||||
|
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
||||||
|
"Determining if the Perl module ${module} exists failed with the following error output:\n"
|
||||||
|
"${error_info}\n\n")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(PerlModules
|
||||||
|
DEFAULT_MSG
|
||||||
|
PERL_FOUND
|
||||||
|
${_deps_check})
|
||||||
|
|
||||||
81
cmake/FindQVRPN.cmake
Normal file
81
cmake/FindQVRPN.cmake
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
# - try to find QVRPN library
|
||||||
|
#
|
||||||
|
# Of course, you may also just choose to make QVRPN a submodule of your
|
||||||
|
# project itself.
|
||||||
|
#
|
||||||
|
# Cache Variables:
|
||||||
|
# QVRPN_LIBRARY
|
||||||
|
# QVRPN_INCLUDE_DIR
|
||||||
|
#
|
||||||
|
# Non-cache variables you might use in your CMakeLists.txt:
|
||||||
|
# QVRPN_FOUND
|
||||||
|
# QVRPN_LIBRARIES
|
||||||
|
# QVRPN_INCLUDE_DIRS
|
||||||
|
#
|
||||||
|
# QVRPN_ROOT_DIR is searched preferentially for these files
|
||||||
|
#
|
||||||
|
# Requires these CMake modules:
|
||||||
|
# FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
|
||||||
|
#
|
||||||
|
# Refactored from FindVRPN.cmake by:
|
||||||
|
# Juan Sebastian Casallas <casallas@iastate.edu>
|
||||||
|
#
|
||||||
|
# FindVRPN.cmake Original Author:
|
||||||
|
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||||
|
# http://academic.cleardefinition.com
|
||||||
|
# Iowa State University HCI Graduate Program/VRAC
|
||||||
|
#
|
||||||
|
# Copyright Iowa State University 2009-2012.
|
||||||
|
# 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(QVRPN_ROOT_DIR
|
||||||
|
"${QVRPN_ROOT_DIR}"
|
||||||
|
CACHE
|
||||||
|
PATH
|
||||||
|
"Root directory to search for QVRPN")
|
||||||
|
|
||||||
|
if(CMAKE_SIZEOF_VOID_P MATCHES "8")
|
||||||
|
set(_LIBSUFFIXES /lib64 /lib)
|
||||||
|
else()
|
||||||
|
set(_LIBSUFFIXES /lib)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
###
|
||||||
|
# Configure QVRPN
|
||||||
|
###
|
||||||
|
|
||||||
|
find_path(QVRPN_INCLUDE_DIR
|
||||||
|
NAMES
|
||||||
|
vrpn_QMainloopContainer.h
|
||||||
|
PATH_SUFFIXES
|
||||||
|
include
|
||||||
|
include/qvrpn
|
||||||
|
HINTS
|
||||||
|
"${QVRPN_ROOT_DIR}")
|
||||||
|
|
||||||
|
find_library(QVRPN_LIBRARY
|
||||||
|
NAMES
|
||||||
|
qvrpn
|
||||||
|
PATH_SUFFIXES
|
||||||
|
${_libsuffixes}
|
||||||
|
HINTS
|
||||||
|
"${QVRPN_ROOT_DIR}")
|
||||||
|
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set xxx_FOUND to TRUE if
|
||||||
|
# all listed variables are TRUE
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(QVRPN
|
||||||
|
DEFAULT_MSG
|
||||||
|
QVRPN_LIBRARY
|
||||||
|
QVRPN_INCLUDE_DIR)
|
||||||
|
|
||||||
|
if(QVRPN_FOUND)
|
||||||
|
set(QVRPN_INCLUDE_DIRS "${QVRPN_INCLUDE_DIR}")
|
||||||
|
set(QVRPN_LIBRARIES "${QVRPN_LIBRARY}")
|
||||||
|
|
||||||
|
mark_as_advanced(QVRPN_ROOT_DIR)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
mark_as_advanced(QVRPN_LIBRARY QVRPN_INCLUDE_DIR)
|
||||||
@@ -37,11 +37,15 @@
|
|||||||
|
|
||||||
|
|
||||||
set(_HUMAN "Sonix 1.4")
|
set(_HUMAN "Sonix 1.4")
|
||||||
set(_RELEASE_NAMES sonix-1_4 libsonix-1_4 sonix-1_4_0)
|
set(_FP_PKG_NAME sonix)
|
||||||
set(_DEBUG_NAMES sonix_d-1_4 libsonix_d-1_4 sonix_d-1_4_0)
|
set(_RELEASE_NAMES)
|
||||||
|
set(_DEBUG_NAMES)
|
||||||
|
foreach(VER 1_4 1_4_0 1_4_1 1_4_2)
|
||||||
|
list(APPEND _RELEASE_NAMES ${_FP_PKG_NAME}-${VER})
|
||||||
|
list(APPEND _DEBUG_NAMES ${_FP_PKG_NAME}_d-${VER})
|
||||||
|
endforeach()
|
||||||
set(_DIR sonix-1.4)
|
set(_DIR sonix-1.4)
|
||||||
set(_HEADER snx/sonix.h)
|
set(_HEADER snx/sonix.h)
|
||||||
set(_FP_PKG_NAME sonix)
|
|
||||||
|
|
||||||
include(SelectLibraryConfigurations)
|
include(SelectLibraryConfigurations)
|
||||||
include(CreateImportedTarget)
|
include(CreateImportedTarget)
|
||||||
|
|||||||
@@ -70,7 +70,4 @@ endif()
|
|||||||
# handle the QUIETLY and REQUIRED arguments and set xxx_FOUND to TRUE if
|
# handle the QUIETLY and REQUIRED arguments and set xxx_FOUND to TRUE if
|
||||||
# all listed variables are TRUE
|
# all listed variables are TRUE
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
find_package_handle_standard_args(TR1
|
find_package_handle_standard_args(TR1 DEFAULT_MSG PLATFORM ${_check})
|
||||||
DEFAULT_MSG
|
|
||||||
PLATFORM
|
|
||||||
${_check})
|
|
||||||
|
|||||||
@@ -37,11 +37,15 @@
|
|||||||
|
|
||||||
|
|
||||||
set(_HUMAN "Tweek 1.4")
|
set(_HUMAN "Tweek 1.4")
|
||||||
set(_RELEASE_NAMES tweek-1_4 libtweek-1_4 tweek-1_4_0)
|
set(_FP_PKG_NAME sonix)
|
||||||
set(_DEBUG_NAMES tweek_d-1_4 libtweek_d-1_4 tweek_d-1_4_0)
|
set(_RELEASE_NAMES)
|
||||||
|
set(_DEBUG_NAMES)
|
||||||
|
foreach(VER 1_4 1_4_0 1_4_1 1_4_2)
|
||||||
|
list(APPEND _RELEASE_NAMES ${_FP_PKG_NAME}-${VER})
|
||||||
|
list(APPEND _DEBUG_NAMES ${_FP_PKG_NAME}_d-${VER})
|
||||||
|
endforeach()
|
||||||
set(_DIR tweek-1.4)
|
set(_DIR tweek-1.4)
|
||||||
set(_HEADER tweek/tweek.h)
|
set(_HEADER tweek/tweek.h)
|
||||||
set(_FP_PKG_NAME tweek)
|
|
||||||
|
|
||||||
include(SelectLibraryConfigurations)
|
include(SelectLibraryConfigurations)
|
||||||
include(CreateImportedTarget)
|
include(CreateImportedTarget)
|
||||||
|
|||||||
@@ -40,11 +40,15 @@
|
|||||||
# Brandon Newendorp <brandon@newendorp.com>
|
# Brandon Newendorp <brandon@newendorp.com>
|
||||||
|
|
||||||
set(_HUMAN "VPR 2.2")
|
set(_HUMAN "VPR 2.2")
|
||||||
set(_RELEASE_NAMES vpr-2_2 libvpr-2_2 vpr-2_2_0)
|
set(_FP_PKG_NAME vpr)
|
||||||
set(_DEBUG_NAMES vpr_d-2_2 libvpr_d-2_2 vpr_d-2_2_0)
|
set(_RELEASE_NAMES)
|
||||||
|
set(_DEBUG_NAMES)
|
||||||
|
foreach(VER 2_2 2_2_0 2_2_1 2_2_2)
|
||||||
|
list(APPEND _RELEASE_NAMES ${_FP_PKG_NAME}-${VER})
|
||||||
|
list(APPEND _DEBUG_NAMES ${_FP_PKG_NAME}_d-${VER})
|
||||||
|
endforeach()
|
||||||
set(_DIR vpr-2.2)
|
set(_DIR vpr-2.2)
|
||||||
set(_HEADER vpr/vpr.h)
|
set(_HEADER vpr/vpr.h)
|
||||||
set(_FP_PKG_NAME vpr)
|
|
||||||
|
|
||||||
include(SelectLibraryConfigurations)
|
include(SelectLibraryConfigurations)
|
||||||
include(CreateImportedTarget)
|
include(CreateImportedTarget)
|
||||||
@@ -193,10 +197,11 @@ if(UNIX AND NOT WIN32)
|
|||||||
if(NOT APPLE)
|
if(NOT APPLE)
|
||||||
find_library(VPR22_libuuid_LIBRARY NAMES uuid)
|
find_library(VPR22_libuuid_LIBRARY NAMES uuid)
|
||||||
mark_as_advanced(VPR22_libuuid_LIBRARY)
|
mark_as_advanced(VPR22_libuuid_LIBRARY)
|
||||||
list(APPEND _deps_check VPR22_libuuid_LIBRARY)
|
if(VPR22_libuuid_LIBRARY)
|
||||||
list(APPEND _deps_libs ${VPR22_libuuid_LIBRARY})
|
list(APPEND _deps_libs ${VPR22_libuuid_LIBRARY})
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
# handle the QUIETLY and REQUIRED arguments and set xxx_FOUND to TRUE if
|
# handle the QUIETLY and REQUIRED arguments and set xxx_FOUND to TRUE if
|
||||||
# all listed variables are TRUE
|
# all listed variables are TRUE
|
||||||
|
|||||||
@@ -45,11 +45,15 @@
|
|||||||
|
|
||||||
|
|
||||||
set(_HUMAN "VR Juggler 3.0 Core")
|
set(_HUMAN "VR Juggler 3.0 Core")
|
||||||
set(_RELEASE_NAMES vrj-3_0 libvrj-3_0 vrj-3_0_0)
|
set(_FP_PKG_NAME vrjuggler)
|
||||||
set(_DEBUG_NAMES vrj_d-3_0 libvrj_d-3_0 vrj_d-3_0_0)
|
set(_RELEASE_NAMES)
|
||||||
|
set(_DEBUG_NAMES)
|
||||||
|
foreach(VER 3_0 3_0_0 3_0_1 3_0_2)
|
||||||
|
list(APPEND _RELEASE_NAMES vrj-${VER})
|
||||||
|
list(APPEND _DEBUG_NAMES vrj_d-${VER})
|
||||||
|
endforeach()
|
||||||
set(_DIR vrjuggler-3.0)
|
set(_DIR vrjuggler-3.0)
|
||||||
set(_HEADER vrj/Kernel/Kernel.h)
|
set(_HEADER vrj/Kernel/Kernel.h)
|
||||||
set(_FP_PKG_NAME vrjuggler)
|
|
||||||
|
|
||||||
include(SelectLibraryConfigurations)
|
include(SelectLibraryConfigurations)
|
||||||
include(CreateImportedTarget)
|
include(CreateImportedTarget)
|
||||||
|
|||||||
@@ -38,10 +38,14 @@
|
|||||||
|
|
||||||
|
|
||||||
set(_HUMAN "VR Juggler 3.0 OpenGL Core")
|
set(_HUMAN "VR Juggler 3.0 OpenGL Core")
|
||||||
set(_RELEASE_NAMES vrj_ogl-3_0 libvrj_ogl-3_0 vrj_ogl-3_0_0)
|
|
||||||
set(_DEBUG_NAMES vrj_ogl_d-3_0 libvrj_ogl_d-3_0 vrj_ogl_d-3_0_0)
|
|
||||||
set(_DIR vrjuggler-3.0)
|
|
||||||
set(_FP_PKG_NAME vrjuggler-opengl)
|
set(_FP_PKG_NAME vrjuggler-opengl)
|
||||||
|
set(_RELEASE_NAMES)
|
||||||
|
set(_DEBUG_NAMES)
|
||||||
|
foreach(VER 3_0 3_0_0 3_0_1 3_0_2)
|
||||||
|
list(APPEND _RELEASE_NAMES vrj_ogl-${VER})
|
||||||
|
list(APPEND _DEBUG_NAMES vrj_ogl_d-${VER})
|
||||||
|
endforeach()
|
||||||
|
set(_DIR vrjuggler-3.0)
|
||||||
|
|
||||||
include(SelectLibraryConfigurations)
|
include(SelectLibraryConfigurations)
|
||||||
include(CreateImportedTarget)
|
include(CreateImportedTarget)
|
||||||
|
|||||||
@@ -171,7 +171,10 @@ endif()
|
|||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
find_package_handle_standard_args(VRJuggler
|
find_package_handle_standard_args(VRJuggler
|
||||||
DEFAULT_MSG VRJUGGLER_VERSION VRJUGGLER_LIBRARIES VRJUGGLER_FOUND)
|
DEFAULT_MSG
|
||||||
|
VRJUGGLER_VERSION
|
||||||
|
VRJUGGLER_LIBRARIES
|
||||||
|
VRJUGGLER_FOUND)
|
||||||
|
|
||||||
if(VRJUGGLER_FOUND)
|
if(VRJUGGLER_FOUND)
|
||||||
mark_as_advanced(VRJUGGLER_ROOT_DIR)
|
mark_as_advanced(VRJUGGLER_ROOT_DIR)
|
||||||
|
|||||||
@@ -334,6 +334,20 @@ if(VRJUGGLER30_FOUND)
|
|||||||
list(APPEND _plugin_dirs "${_libdir}/sonix-1.4/plugins/dbg")
|
list(APPEND _plugin_dirs "${_libdir}/sonix-1.4/plugins/dbg")
|
||||||
list(APPEND _plugin_dirs "${_libdir}/sonix-1.4/plugins/opt")
|
list(APPEND _plugin_dirs "${_libdir}/sonix-1.4/plugins/opt")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Find directories of JCCL plugins
|
||||||
|
if(EXISTS "${_libdir}/jccl/plugins")
|
||||||
|
list(APPEND _plugin_dirs "${_libdir}/jccl/plugins")
|
||||||
|
elseif(EXISTS "${_libdir}/jccl-1.4/plugins")
|
||||||
|
list(APPEND _plugin_dirs "${_libdir}/jccl-1.4/plugins")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Find directories of VR Juggler plugins
|
||||||
|
if(EXISTS "${_libdir}/vrjuggler/plugins")
|
||||||
|
list(APPEND _plugin_dirs "${_libdir}/vrjuggler/plugins")
|
||||||
|
elseif(EXISTS "${_libdir}/vrjuggler-3.0/plugins")
|
||||||
|
list(APPEND _plugin_dirs "${_libdir}/vrjuggler-3.0/plugins")
|
||||||
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# Grab the actual plugins
|
# Grab the actual plugins
|
||||||
@@ -341,7 +355,13 @@ if(VRJUGGLER30_FOUND)
|
|||||||
if(EXISTS "${_libdir}")
|
if(EXISTS "${_libdir}")
|
||||||
list(APPEND VRJUGGLER30_RUNTIME_LIBRARY_DIRS "${_libdir}")
|
list(APPEND VRJUGGLER30_RUNTIME_LIBRARY_DIRS "${_libdir}")
|
||||||
file(GLOB _plugins "${_libdir}/*${CMAKE_SHARED_LIBRARY_SUFFIX}")
|
file(GLOB _plugins "${_libdir}/*${CMAKE_SHARED_LIBRARY_SUFFIX}")
|
||||||
list(APPEND VRJUGGLER30_BUNDLE_PLUGINS ${_plugins})
|
foreach(_plugin ${_plugins})
|
||||||
|
if("${_plugin}" MATCHES "_d${CMAKE_SHARED_LIBRARY_SUFFIX}")
|
||||||
|
list(APPEND VRJUGGLER30_BUNDLE_PLUGINS_DEBUG ${_plugin})
|
||||||
|
else()
|
||||||
|
list(APPEND VRJUGGLER30_BUNDLE_PLUGINS ${_plugin})
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
@@ -391,19 +411,23 @@ function(install_vrjuggler30_data_files prefix)
|
|||||||
install(FILES "${base}/calibration.table" DESTINATION "${DEST}")
|
install(FILES "${base}/calibration.table" DESTINATION "${DEST}")
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(install_vrjuggler30_plugins prefix varForFilenames)
|
macro(_vrjuggler30_plugin_install _VAR)
|
||||||
set(DEST "${prefix}")
|
foreach(plugin ${${_VAR}})
|
||||||
|
|
||||||
set(out)
|
|
||||||
foreach(plugin ${VRJUGGLER30_BUNDLE_PLUGINS})
|
|
||||||
get_filename_component(full "${plugin}" ABSOLUTE)
|
get_filename_component(full "${plugin}" ABSOLUTE)
|
||||||
file(RELATIVE_PATH relloc "${VRJUGGLER30_VJ_BASE_DIR}" "${full}")
|
file(RELATIVE_PATH relloc "${VRJUGGLER30_VJ_BASE_DIR}" "${full}")
|
||||||
set(filedest "${DEST}/${relloc}")
|
set(filedest "${DEST}/${relloc}")
|
||||||
get_filename_component(path "${filedest}" PATH)
|
get_filename_component(path "${filedest}" PATH)
|
||||||
list(APPEND out "${filedest}")
|
list(APPEND out "${filedest}")
|
||||||
install(FILES "${full}" DESTINATION "${path}")
|
install(FILES "${full}" DESTINATION "${path}" ${ARGN})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
function(install_vrjuggler30_plugins prefix varForFilenames)
|
||||||
|
set(DEST "${prefix}")
|
||||||
|
|
||||||
|
set(out)
|
||||||
|
_vrjuggler30_plugin_install(VRJUGGLER30_BUNDLE_PLUGINS)
|
||||||
|
_vrjuggler30_plugin_install(VRJUGGLER30_BUNDLE_PLUGINS_DEBUG CONFIGURATIONS DEBUG)
|
||||||
set(${varForFilenames} ${out} PARENT_SCOPE)
|
set(${varForFilenames} ${out} PARENT_SCOPE)
|
||||||
|
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|||||||
@@ -7,8 +7,10 @@
|
|||||||
#
|
#
|
||||||
# Non-cache variables you might use in your CMakeLists.txt:
|
# Non-cache variables you might use in your CMakeLists.txt:
|
||||||
# VRPN_FOUND
|
# VRPN_FOUND
|
||||||
# VRPN_SERVER_LIBRARIES
|
# VRPN_SERVER_LIBRARIES - server libraries
|
||||||
# VRPN_LIBRARIES
|
# VRPN_LIBRARIES - client libraries
|
||||||
|
# VRPN_CLIENT_DEFINITIONS - definitions if you only use the client library
|
||||||
|
# VRPN_DEFINITIONS - Client-only definition if all we found was the client library.
|
||||||
# VRPN_INCLUDE_DIRS
|
# VRPN_INCLUDE_DIRS
|
||||||
#
|
#
|
||||||
# VRPN_ROOT_DIR is searched preferentially for these files
|
# VRPN_ROOT_DIR is searched preferentially for these files
|
||||||
@@ -17,11 +19,11 @@
|
|||||||
# FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
|
# FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
|
||||||
#
|
#
|
||||||
# Original Author:
|
# Original Author:
|
||||||
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
# 2009-2012 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||||
# http://academic.cleardefinition.com
|
# http://academic.cleardefinition.com
|
||||||
# Iowa State University HCI Graduate Program/VRAC
|
# Iowa State University HCI Graduate Program/VRAC
|
||||||
#
|
#
|
||||||
# Copyright Iowa State University 2009-2010.
|
# Copyright Iowa State University 2009-2012.
|
||||||
# Distributed under the Boost Software License, Version 1.0.
|
# Distributed under the Boost Software License, Version 1.0.
|
||||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
# http://www.boost.org/LICENSE_1_0.txt)
|
# http://www.boost.org/LICENSE_1_0.txt)
|
||||||
@@ -116,9 +118,19 @@ if(VRPN_FOUND)
|
|||||||
set(VRPN_LIBRARIES "${VRPN_LIBRARY}" ${_deps_libs})
|
set(VRPN_LIBRARIES "${VRPN_LIBRARY}" ${_deps_libs})
|
||||||
set(VRPN_SERVER_LIBRARIES "${VRPN_SERVER_LIBRARY}" ${_deps_libs})
|
set(VRPN_SERVER_LIBRARIES "${VRPN_SERVER_LIBRARY}" ${_deps_libs})
|
||||||
|
|
||||||
|
if(VRPN_LIBRARY)
|
||||||
|
set(VRPN_CLIENT_DEFINITIONS -DVRPN_CLIENT_ONLY)
|
||||||
|
else()
|
||||||
|
unset(VRPN_CLIENT_DEFINITIONS)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(VRPN_LIBRARY AND NOT VRPN_SERVER_LIBRARY)
|
||||||
|
set(VRPN_DEFINITIONS -DVRPN_CLIENT_ONLY)
|
||||||
|
else()
|
||||||
|
unset(VRPN_DEFINITIONS)
|
||||||
|
endif()
|
||||||
|
|
||||||
mark_as_advanced(VRPN_ROOT_DIR)
|
mark_as_advanced(VRPN_ROOT_DIR)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
mark_as_advanced(VRPN_LIBRARY
|
mark_as_advanced(VRPN_LIBRARY VRPN_SERVER_LIBRARY VRPN_INCLUDE_DIR)
|
||||||
VRPN_SERVER_LIBRARY
|
|
||||||
VRPN_INCLUDE_DIR)
|
|
||||||
|
|||||||
94
cmake/FindViewPoint.cmake
Normal file
94
cmake/FindViewPoint.cmake
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
# - try to find Arrington Research ViewPoint EyeTracker SDK
|
||||||
|
#
|
||||||
|
# Cache Variables: (probably not for direct use in your scripts)
|
||||||
|
# VIEWPOINT_INCLUDE_DIR
|
||||||
|
# VIEWPOINT_LIBRARY
|
||||||
|
# VIEWPOINT_RUNTIME_LIBRARY
|
||||||
|
#
|
||||||
|
# Non-cache variables you might use in your CMakeLists.txt:
|
||||||
|
# VIEWPOINT_FOUND
|
||||||
|
# VIEWPOINT_INCLUDE_DIRS
|
||||||
|
# VIEWPOINT_LIBRARIES
|
||||||
|
# VIEWPOINT_RUNTIME_LIBRARIES - aka the dll for installing
|
||||||
|
# VIEWPOINT_RUNTIME_LIBRARY_DIRS
|
||||||
|
#
|
||||||
|
# Requires these CMake modules:
|
||||||
|
# FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
|
||||||
|
#
|
||||||
|
# Original Author:
|
||||||
|
# 2012 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||||
|
# http://academic.cleardefinition.com
|
||||||
|
# Iowa State University HCI Graduate Program/VRAC
|
||||||
|
#
|
||||||
|
# Copyright Iowa State University 2012.
|
||||||
|
# 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(VIEWPOINT_ROOT_DIR
|
||||||
|
"${VIEWPOINT_ROOT_DIR}"
|
||||||
|
CACHE
|
||||||
|
PATH
|
||||||
|
"Directory to search for Arrington Research ViewPoint EyeTracker SDK")
|
||||||
|
|
||||||
|
if(CMAKE_SIZEOF_VOID_P MATCHES "8")
|
||||||
|
set(_LIBSUFFIXES /lib64 /lib)
|
||||||
|
else()
|
||||||
|
set(_LIBSUFFIXES /lib)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_library(VIEWPOINT_LIBRARY
|
||||||
|
NAMES
|
||||||
|
VPX_InterApp
|
||||||
|
PATHS
|
||||||
|
"${VIEWPOINT_ROOT_DIR}"
|
||||||
|
PATH_SUFFIXES
|
||||||
|
"${_LIBSUFFIXES}")
|
||||||
|
|
||||||
|
get_filename_component(_libdir "${VIEWPOINT_LIBRARY}" PATH)
|
||||||
|
|
||||||
|
find_path(VIEWPOINT_INCLUDE_DIR
|
||||||
|
NAMES
|
||||||
|
vpx.h
|
||||||
|
HINTS
|
||||||
|
"${_libdir}"
|
||||||
|
PATHS
|
||||||
|
"${VIEWPOINT_ROOT_DIR}"
|
||||||
|
PATH_SUFFIXES
|
||||||
|
include/)
|
||||||
|
|
||||||
|
set(_deps_check)
|
||||||
|
if(WIN32)
|
||||||
|
find_file(VIEWPOINT_RUNTIME_LIBRARY
|
||||||
|
NAMES
|
||||||
|
VPX_InterApp.dll
|
||||||
|
HINTS
|
||||||
|
"${_libdir}")
|
||||||
|
|
||||||
|
set(VIEWPOINT_RUNTIME_LIBRARIES "${VIEWPOINT_RUNTIME_LIBRARY}")
|
||||||
|
get_filename_component(VIEWPOINT_RUNTIME_LIBRARY_DIRS
|
||||||
|
"${VIEWPOINT_RUNTIME_LIBRARY}"
|
||||||
|
PATH)
|
||||||
|
list(APPEND _deps_check VIEWPOINT_RUNTIME_LIBRARY)
|
||||||
|
else()
|
||||||
|
get_filename_component(VIEWPOINT_RUNTIME_LIBRARY_DIRS
|
||||||
|
"${VIEWPOINT_LIBRARY}"
|
||||||
|
PATH)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(ViewPoint
|
||||||
|
DEFAULT_MSG
|
||||||
|
VIEWPOINT_LIBRARY
|
||||||
|
VIEWPOINT_INCLUDE_DIR
|
||||||
|
${_deps_check})
|
||||||
|
|
||||||
|
if(VIEWPOINT_FOUND)
|
||||||
|
set(VIEWPOINT_LIBRARIES "${VIEWPOINT_LIBRARY}")
|
||||||
|
set(VIEWPOINT_INCLUDE_DIRS "${VIEWPOINT_INCLUDE_DIR}")
|
||||||
|
mark_as_advanced(VIEWPOINT_ROOT_DIR)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
mark_as_advanced(VIEWPOINT_INCLUDE_DIR
|
||||||
|
VIEWPOINT_LIBRARY
|
||||||
|
VIEWPOINT_RUNTIME_LIBRARY)
|
||||||
@@ -74,6 +74,8 @@ if(WIN32)
|
|||||||
PATH)
|
PATH)
|
||||||
list(APPEND _deps_check WIIUSE_RUNTIME_LIBRARY)
|
list(APPEND _deps_check WIIUSE_RUNTIME_LIBRARY)
|
||||||
else()
|
else()
|
||||||
|
set(WIIUSE_RUNTIME_LIBRARY "${WIIUSE_LIBRARY}")
|
||||||
|
set(WIIUSE_RUNTIME_LIBRARIES "${WIIUSE_RUNTIME_LIBRARY}")
|
||||||
get_filename_component(WIIUSE_RUNTIME_LIBRARY_DIRS
|
get_filename_component(WIIUSE_RUNTIME_LIBRARY_DIRS
|
||||||
"${WIIUSE_LIBRARY}"
|
"${WIIUSE_LIBRARY}"
|
||||||
PATH)
|
PATH)
|
||||||
|
|||||||
@@ -51,7 +51,10 @@ endif()
|
|||||||
if(MSVC)
|
if(MSVC)
|
||||||
include(PrefixListGlob)
|
include(PrefixListGlob)
|
||||||
include(CleanDirectoryList)
|
include(CleanDirectoryList)
|
||||||
prefix_list_glob(_prefixed "*/" "$ENV{SYSTEMDRIVE}/WinDDK/" "c:/WinDDK/")
|
prefix_list_glob(_prefixed
|
||||||
|
"*/"
|
||||||
|
"$ENV{SYSTEMDRIVE}/WinDDK/"
|
||||||
|
"c:/WinDDK/")
|
||||||
clean_directory_list(_prefixed)
|
clean_directory_list(_prefixed)
|
||||||
find_library(WINHID_LIBRARY
|
find_library(WINHID_LIBRARY
|
||||||
NAMES
|
NAMES
|
||||||
@@ -138,13 +141,16 @@ if(WINHID_FOUND)
|
|||||||
endif()
|
endif()
|
||||||
if(NOT "${WINHID_MIN_WINDOWS_VER}" STREQUAL "${_winreq}")
|
if(NOT "${WINHID_MIN_WINDOWS_VER}" STREQUAL "${_winreq}")
|
||||||
if(NOT WinHID_FIND_QUIETLY)
|
if(NOT WinHID_FIND_QUIETLY)
|
||||||
message(STATUS "Linking against WINHID_LIBRARY will enforce this minimum version: ${_winreq}")
|
message(STATUS
|
||||||
|
"Linking against WINHID_LIBRARY will enforce this minimum version: ${_winreq}")
|
||||||
endif()
|
endif()
|
||||||
set(WINHID_MIN_WINDOWS_VER "${_winreq}" CACHE INTERNAL "" FORCE)
|
set(WINHID_MIN_WINDOWS_VER "${_winreq}" CACHE INTERNAL "" FORCE)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
set(WINHID_LIBRARIES "${WINHID_LIBRARY}")
|
set(WINHID_LIBRARIES "${WINHID_LIBRARY}")
|
||||||
set(WINHID_INCLUDE_DIRS "${WINHID_CRT_INCLUDE_DIR}" "${WINHID_INCLUDE_DIR}")
|
set(WINHID_INCLUDE_DIRS
|
||||||
|
"${WINHID_CRT_INCLUDE_DIR}"
|
||||||
|
"${WINHID_INCLUDE_DIR}")
|
||||||
mark_as_advanced(WINHID_ROOT_DIR)
|
mark_as_advanced(WINHID_ROOT_DIR)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
163
cmake/FindWindowsSDK.cmake
Normal file
163
cmake/FindWindowsSDK.cmake
Normal file
@@ -0,0 +1,163 @@
|
|||||||
|
# - Find the Windows SDK aka Platform SDK
|
||||||
|
#
|
||||||
|
# Variables:
|
||||||
|
# WINDOWSSDK_FOUND - if any version of the windows or platform SDK was found that is usable with the current version of visual studio
|
||||||
|
# WINDOWSSDK_LATEST_DIR
|
||||||
|
# WINDOWSSDK_LATEST_NAME
|
||||||
|
# WINDOWSSDK_FOUND_PREFERENCE - if we found an entry indicating a "preferred" SDK listed for this visual studio version
|
||||||
|
# WINDOWSSDK_PREFERRED_DIR
|
||||||
|
# WINDOWSSDK_PREFERRED_NAME
|
||||||
|
#
|
||||||
|
# WINDOWSSDK_DIRS - contains no duplicates, ordered most recent first.
|
||||||
|
# WINDOWSSDK_PREFERRED_FIRST_DIRS - contains no duplicates, ordered with preferred first, followed by the rest in descending recency
|
||||||
|
#
|
||||||
|
# Functions:
|
||||||
|
# windowssdk_name_lookup(<directory> <output variable>) - Find the name corresponding with the SDK directory you pass in, or
|
||||||
|
# NOTFOUND if not recognized. Your directory must be one of WINDOWSSDK_DIRS for this to work.
|
||||||
|
#
|
||||||
|
# Requires these CMake modules:
|
||||||
|
# FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
|
||||||
|
#
|
||||||
|
# Original Author:
|
||||||
|
# 2012 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||||
|
# http://academic.cleardefinition.com
|
||||||
|
# Iowa State University HCI Graduate Program/VRAC
|
||||||
|
#
|
||||||
|
# Copyright Iowa State University 2012.
|
||||||
|
# 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(_preferred_sdk_dirs)
|
||||||
|
set(_win_sdk_dirs)
|
||||||
|
set(_win_sdk_versanddirs)
|
||||||
|
if(MSVC_VERSION GREATER 1310) # Newer than VS .NET/VS Toolkit 2003
|
||||||
|
|
||||||
|
# Environment variable for SDK dir
|
||||||
|
if(EXISTS "$ENV{WindowsSDKDir}" AND (NOT "$ENV{WindowsSDKDir}" STREQUAL ""))
|
||||||
|
message(STATUS "Got $ENV{WindowsSDKDir} - Windows/Platform SDK directories: ${_win_sdk_dirs}")
|
||||||
|
list(APPEND _preferred_sdk_dirs "$ENV{WindowsSDKDir}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(MSVC_VERSION LESS 1600)
|
||||||
|
# Per-user current Windows SDK for VS2005/2008
|
||||||
|
get_filename_component(_sdkdir
|
||||||
|
"[HKEY_CURRENT_USER\\Software\\Microsoft\\Microsoft SDKs\\Windows;CurrentInstallFolder]"
|
||||||
|
ABSOLUTE)
|
||||||
|
if(EXISTS "${_sdkdir}")
|
||||||
|
list(APPEND _preferred_sdk_dirs "${_sdkdir}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# System-wide current Windows SDK for VS2005/2008
|
||||||
|
get_filename_component(_sdkdir
|
||||||
|
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows;CurrentInstallFolder]"
|
||||||
|
ABSOLUTE)
|
||||||
|
if(EXISTS "${_sdkdir}")
|
||||||
|
list(APPEND _preferred_sdk_dirs "${_sdkdir}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
foreach(_winsdkver v8.0A v7.1 v7.0A v6.1 v6.0A v6.0)
|
||||||
|
get_filename_component(_sdkdir
|
||||||
|
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\${_winsdkver};InstallationFolder]"
|
||||||
|
ABSOLUTE)
|
||||||
|
if(EXISTS "${_sdkdir}")
|
||||||
|
list(APPEND _win_sdk_dirs "${_sdkdir}")
|
||||||
|
list(APPEND
|
||||||
|
_win_sdk_versanddirs
|
||||||
|
"Windows SDK ${_winsdkver}"
|
||||||
|
"${_sdkdir}")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
if(MSVC_VERSION GREATER 1200)
|
||||||
|
foreach(_platformsdkinfo
|
||||||
|
"D2FF9F89-8AA2-4373-8A31-C838BF4DBBE1_Microsoft Platform SDK for Windows Server 2003 R2"
|
||||||
|
"8F9E5EF3-A9A5-491B-A889-C58EFFECE8B3_Microsoft Platform SDK for Windows Server 2003 SP1")
|
||||||
|
string(SUBSTRING "${_platformsdkinfo}" 0 36 _platformsdkguid)
|
||||||
|
string(SUBSTRING "${_platformsdkinfo}" 37 -1 _platformsdkname)
|
||||||
|
get_filename_component(_sdkdir
|
||||||
|
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MicrosoftSDK\\InstalledSDKs\\${_platformsdkguid};Install Dir]"
|
||||||
|
ABSOLUTE)
|
||||||
|
if(EXISTS "${_sdkdir}")
|
||||||
|
list(APPEND _win_sdk_dirs "${_sdkdir}")
|
||||||
|
list(APPEND _win_sdk_versanddirs "${_platformsdkname}" "${_sdkdir}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
get_filename_component(_sdkdir
|
||||||
|
"[HKEY_CURRENT_USER\\Software\\Microsoft\\MicrosoftSDK\\InstalledSDKs\\${_platformsdkguid};Install Dir]"
|
||||||
|
ABSOLUTE)
|
||||||
|
if(EXISTS "${_sdkdir}")
|
||||||
|
list(APPEND _win_sdk_dirs "${_sdkdir}")
|
||||||
|
list(APPEND _win_sdk_versanddirs "${_platformsdkname}" "${_sdkdir}")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(_win_sdk_versanddirs
|
||||||
|
"${_win_sdk_versanddirs}"
|
||||||
|
CACHE
|
||||||
|
INTERNAL
|
||||||
|
"mapping between windows sdk version locations and names"
|
||||||
|
FORCE)
|
||||||
|
|
||||||
|
function(windowssdk_name_lookup _dir _outvar)
|
||||||
|
list(FIND _win_sdk_versanddirs "${_dir}" _diridx)
|
||||||
|
math(EXPR _nameidx "${_diridx} - 1")
|
||||||
|
if(${_nameidx} GREATER -1)
|
||||||
|
list(GET _win_sdk_versanddirs ${_nameidx} _sdkname)
|
||||||
|
else()
|
||||||
|
set(_sdkname "NOTFOUND")
|
||||||
|
endif()
|
||||||
|
set(${_outvar} "${_sdkname}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
if(_win_sdk_dirs)
|
||||||
|
# Remove duplicates
|
||||||
|
list(REMOVE_DUPLICATES _win_sdk_dirs)
|
||||||
|
list(GET _win_sdk_dirs 0 WINDOWSSDK_LATEST_DIR)
|
||||||
|
windowssdk_name_lookup("${WINDOWSSDK_LATEST_DIR}"
|
||||||
|
WINDOWSSDK_LATEST_NAME)
|
||||||
|
set(WINDOWSSDK_DIRS ${_win_sdk_dirs})
|
||||||
|
endif()
|
||||||
|
if(_preferred_sdk_dirs)
|
||||||
|
list(GET _preferred_sdk_dirs 0 WINDOWSSDK_PREFERRED_DIR)
|
||||||
|
windowssdk_name_lookup("${WINDOWSSDK_LATEST_DIR}"
|
||||||
|
WINDOWSSDK_PREFERRED_NAME)
|
||||||
|
set(WINDOWSSDK_PREFERRED_FIRST_DIRS
|
||||||
|
${_preferred_sdk_dirs}
|
||||||
|
${_win_sdk_dirs})
|
||||||
|
list(REMOVE_DUPLICATES WINDOWSSDK_PREFERRED_FIRST_DIRS)
|
||||||
|
set(WINDOWSSDK_FOUND_PREFERENCE ON)
|
||||||
|
|
||||||
|
# In case a preferred dir was found that isn't found otherwise
|
||||||
|
#set(WINDOWSSDK_DIRS ${WINDOWSSDK_DIRS} ${WINDOWSSDK_PREFERRED_FIRST_DIRS})
|
||||||
|
#list(REMOVE_DUPLICATES WINDOWSSDK_DIRS)
|
||||||
|
else()
|
||||||
|
set(WINDOWSSDK_PREFERRED_DIR "${WINDOWSSDK_LATEST_DIR}")
|
||||||
|
set(WINDOWSSDK_PREFERRED_NAME "${WINDOWSSDK_LATEST_NAME}")
|
||||||
|
set(WINDOWSSDK_PREFERRED_FIRST_DIRS ${WINDOWSSDK_DIRS})
|
||||||
|
set(WINDOWSSDK_FOUND_PREFERENCE OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(WindowsSDK
|
||||||
|
"No compatible version of the Windows SDK or Platform SDK found."
|
||||||
|
WINDOWSSDK_DIRS)
|
||||||
|
|
||||||
|
if(WINDOWSSDK_FOUND)
|
||||||
|
if(NOT _winsdk_remembered_dirs STREQUAL WINDOWSSDK_DIRS)
|
||||||
|
set(_winsdk_remembered_dirs
|
||||||
|
"${WINDOWSSDK_DIRS}"
|
||||||
|
CACHE
|
||||||
|
INTERNAL
|
||||||
|
""
|
||||||
|
FORCE)
|
||||||
|
if(NOT WindowsSDK_FIND_QUIETLY)
|
||||||
|
foreach(_sdkdir ${WINDOWSSDK_DIRS})
|
||||||
|
windowssdk_name_lookup("${_sdkdir}" _sdkname)
|
||||||
|
message(STATUS " - Found ${_sdkname} at ${_sdkdir}")
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
@@ -39,6 +39,10 @@ set(CPPCHECK_ROOT_DIR
|
|||||||
set(_oldappbundlesetting ${CMAKE_FIND_APPBUNDLE})
|
set(_oldappbundlesetting ${CMAKE_FIND_APPBUNDLE})
|
||||||
set(CMAKE_FIND_APPBUNDLE NEVER)
|
set(CMAKE_FIND_APPBUNDLE NEVER)
|
||||||
|
|
||||||
|
if(CPPCHECK_EXECUTABLE AND NOT EXISTS "${CPPCHECK_EXECUTABLE}")
|
||||||
|
set(CPPCHECK_EXECUTABLE "notfound" CACHE PATH FORCE "")
|
||||||
|
endif()
|
||||||
|
|
||||||
# If we have a custom path, look there first.
|
# If we have a custom path, look there first.
|
||||||
if(CPPCHECK_ROOT_DIR)
|
if(CPPCHECK_ROOT_DIR)
|
||||||
find_program(CPPCHECK_EXECUTABLE
|
find_program(CPPCHECK_EXECUTABLE
|
||||||
@@ -57,37 +61,61 @@ find_program(CPPCHECK_EXECUTABLE NAMES cppcheck)
|
|||||||
# Restore original setting for appbundle finding
|
# Restore original setting for appbundle finding
|
||||||
set(CMAKE_FIND_APPBUNDLE ${_oldappbundlesetting})
|
set(CMAKE_FIND_APPBUNDLE ${_oldappbundlesetting})
|
||||||
|
|
||||||
if(CPPCHECK_EXECUTABLE)
|
|
||||||
# Find out where our test file is
|
# Find out where our test file is
|
||||||
get_filename_component(_cppcheckmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)
|
get_filename_component(_cppcheckmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)
|
||||||
set(_cppcheckdummyfile "${_cppcheckmoddir}/Findcppcheck.cpp")
|
set(_cppcheckdummyfile "${_cppcheckmoddir}/Findcppcheck.cpp")
|
||||||
|
if(NOT EXISTS "${_cppcheckdummyfile}")
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Missing file ${_cppcheckdummyfile} - should be alongside Findcppcheck.cmake, can be found at https://github.com/rpavlik/cmake-modules")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
function(_cppcheck_test_arg _resultvar _arg)
|
||||||
|
if(NOT CPPCHECK_EXECUTABLE)
|
||||||
|
set(${_resultvar} NO)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
execute_process(COMMAND
|
||||||
|
"${CPPCHECK_EXECUTABLE}"
|
||||||
|
"${_arg}"
|
||||||
|
"--quiet"
|
||||||
|
"${_cppcheckdummyfile}"
|
||||||
|
RESULT_VARIABLE
|
||||||
|
_cppcheck_result
|
||||||
|
OUTPUT_QUIET
|
||||||
|
ERROR_QUIET)
|
||||||
|
if("${_cppcheck_result}" EQUAL 0)
|
||||||
|
set(${_resultvar} YES PARENT_SCOPE)
|
||||||
|
else()
|
||||||
|
set(${_resultvar} NO PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(_cppcheck_set_arg_var _argvar _arg)
|
||||||
|
if("${${_argvar}}" STREQUAL "")
|
||||||
|
_cppcheck_test_arg(_cppcheck_arg "${_arg}")
|
||||||
|
if(_cppcheck_arg)
|
||||||
|
set(${_argvar} "${_arg}" PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
if(CPPCHECK_EXECUTABLE)
|
||||||
|
|
||||||
# Check for the two types of command line arguments by just trying them
|
# Check for the two types of command line arguments by just trying them
|
||||||
execute_process(COMMAND
|
_cppcheck_set_arg_var(CPPCHECK_STYLE_ARG "--enable=style")
|
||||||
"${CPPCHECK_EXECUTABLE}"
|
_cppcheck_set_arg_var(CPPCHECK_STYLE_ARG "--style")
|
||||||
"--enable=style"
|
if("${CPPCHECK_STYLE_ARG}" STREQUAL "--enable=style")
|
||||||
"--quiet"
|
|
||||||
"${_cppcheckdummyfile}"
|
_cppcheck_set_arg_var(CPPCHECK_UNUSEDFUNC_ARG
|
||||||
RESULT_VARIABLE
|
"--enable=unusedFunctions")
|
||||||
_cppcheck_new_result
|
_cppcheck_set_arg_var(CPPCHECK_INFORMATION_ARG "--enable=information")
|
||||||
OUTPUT_QUIET
|
_cppcheck_set_arg_var(CPPCHECK_MISSINGINCLUDE_ARG
|
||||||
ERROR_QUIET)
|
"--enable=missingInclude")
|
||||||
execute_process(COMMAND
|
_cppcheck_set_arg_var(CPPCHECK_POSIX_ARG "--enable=posix")
|
||||||
"${CPPCHECK_EXECUTABLE}"
|
_cppcheck_set_arg_var(CPPCHECK_POSSIBLEERROR_ARG
|
||||||
"--style"
|
"--enable=possibleError")
|
||||||
"--quiet"
|
_cppcheck_set_arg_var(CPPCHECK_POSSIBLEERROR_ARG "--enable=all")
|
||||||
"${_cppcheckdummyfile}"
|
|
||||||
RESULT_VARIABLE
|
|
||||||
_cppcheck_old_result
|
|
||||||
OUTPUT_QUIET
|
|
||||||
ERROR_QUIET)
|
|
||||||
if("${_cppcheck_new_result}" EQUAL 0)
|
|
||||||
# New arguments
|
|
||||||
set(CPPCHECK_UNUSEDFUNC_ARG "--enable=unusedFunctions")
|
|
||||||
set(CPPCHECK_POSSIBLEERROR_ARG "--enable=possibleError")
|
|
||||||
set(CPPCHECK_STYLE_ARG "--enable=style")
|
|
||||||
set(CPPCHECK_QUIET_ARG "--quiet")
|
|
||||||
set(CPPCHECK_INCLUDEPATH_ARG "-I")
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
set(CPPCHECK_TEMPLATE_ARG --template vs)
|
set(CPPCHECK_TEMPLATE_ARG --template vs)
|
||||||
set(CPPCHECK_FAIL_REGULAR_EXPRESSION "[(]error[)]")
|
set(CPPCHECK_FAIL_REGULAR_EXPRESSION "[(]error[)]")
|
||||||
@@ -97,19 +125,14 @@ if(CPPCHECK_EXECUTABLE)
|
|||||||
set(CPPCHECK_FAIL_REGULAR_EXPRESSION " error: ")
|
set(CPPCHECK_FAIL_REGULAR_EXPRESSION " error: ")
|
||||||
set(CPPCHECK_WARN_REGULAR_EXPRESSION " style: ")
|
set(CPPCHECK_WARN_REGULAR_EXPRESSION " style: ")
|
||||||
else()
|
else()
|
||||||
message(STATUS
|
|
||||||
"Warning: FindCppcheck doesn't know how to format error messages for your compiler!")
|
|
||||||
set(CPPCHECK_TEMPLATE_ARG --template gcc)
|
set(CPPCHECK_TEMPLATE_ARG --template gcc)
|
||||||
set(CPPCHECK_FAIL_REGULAR_EXPRESSION " error: ")
|
set(CPPCHECK_FAIL_REGULAR_EXPRESSION " error: ")
|
||||||
set(CPPCHECK_WARN_REGULAR_EXPRESSION " style: ")
|
set(CPPCHECK_WARN_REGULAR_EXPRESSION " style: ")
|
||||||
endif()
|
endif()
|
||||||
elseif("${_cppcheck_old_result}" EQUAL 0)
|
elseif("${CPPCHECK_STYLE_ARG}" STREQUAL "--style")
|
||||||
# Old arguments
|
# Old arguments
|
||||||
set(CPPCHECK_UNUSEDFUNC_ARG "--unused-functions")
|
_cppcheck_set_arg_var(CPPCHECK_UNUSEDFUNC_ARG "--unused-functions")
|
||||||
set(CPPCHECK_POSSIBLEERROR_ARG "--all")
|
_cppcheck_set_arg_var(CPPCHECK_POSSIBLEERROR_ARG "--all")
|
||||||
set(CPPCHECK_STYLE_ARG "--style")
|
|
||||||
set(CPPCHECK_QUIET_ARG "--quiet")
|
|
||||||
set(CPPCHECK_INCLUDEPATH_ARG "-I")
|
|
||||||
set(CPPCHECK_FAIL_REGULAR_EXPRESSION "error:")
|
set(CPPCHECK_FAIL_REGULAR_EXPRESSION "error:")
|
||||||
set(CPPCHECK_WARN_REGULAR_EXPRESSION "[(]style[)]")
|
set(CPPCHECK_WARN_REGULAR_EXPRESSION "[(]style[)]")
|
||||||
else()
|
else()
|
||||||
@@ -118,6 +141,8 @@ if(CPPCHECK_EXECUTABLE)
|
|||||||
"WARNING: Can't detect whether CPPCHECK wants new or old-style arguments!")
|
"WARNING: Can't detect whether CPPCHECK wants new or old-style arguments!")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(CPPCHECK_QUIET_ARG "--quiet")
|
||||||
|
set(CPPCHECK_INCLUDEPATH_ARG "-I")
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ include(SelectLibraryConfigurations)
|
|||||||
select_library_configurations(CPPUNIT)
|
select_library_configurations(CPPUNIT)
|
||||||
|
|
||||||
# Might want to look close to the library first for the includes.
|
# Might want to look close to the library first for the includes.
|
||||||
get_filename_component(_libdir "${MYSIMPLEPACKAGE_LIBRARY}" PATH)
|
get_filename_component(_libdir "${CPPUNIT_LIBRARY_RELEASE}" PATH)
|
||||||
|
|
||||||
find_path(CPPUNIT_INCLUDE_DIR
|
find_path(CPPUNIT_INCLUDE_DIR
|
||||||
NAMES
|
NAMES
|
||||||
|
|||||||
@@ -23,13 +23,21 @@ find_package(CUDA QUIET)
|
|||||||
file(TO_CMAKE_PATH "${CUDA_SDK_ROOT_DIR}/C/common" CUTIL_ROOT_DIR)
|
file(TO_CMAKE_PATH "${CUDA_SDK_ROOT_DIR}/C/common" CUTIL_ROOT_DIR)
|
||||||
|
|
||||||
if(NOT EXISTS "${CUTIL_ROOT_DIR}/src/cutil.cpp")
|
if(NOT EXISTS "${CUTIL_ROOT_DIR}/src/cutil.cpp")
|
||||||
set(CUDA_SDK_ROOT_DIR SDKDIR-NOTFOUND CACHE PATH "NVIDIA GPU Computing SDK dir" FORCE)
|
set(CUDA_SDK_ROOT_DIR
|
||||||
|
SDKDIR-NOTFOUND
|
||||||
|
CACHE
|
||||||
|
PATH
|
||||||
|
"NVIDIA GPU Computing SDK dir"
|
||||||
|
FORCE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# handle the QUIETLY and REQUIRED arguments and set xxx_FOUND to TRUE if
|
# handle the QUIETLY and REQUIRED arguments and set xxx_FOUND to TRUE if
|
||||||
# all listed variables are TRUE
|
# all listed variables are TRUE
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
find_package_handle_standard_args(cutil DEFAULT_MSG CUDA_SDK_ROOT_DIR CUDA_FOUND)
|
find_package_handle_standard_args(cutil
|
||||||
|
DEFAULT_MSG
|
||||||
|
CUDA_SDK_ROOT_DIR
|
||||||
|
CUDA_FOUND)
|
||||||
|
|
||||||
if(CUTIL_FOUND)
|
if(CUTIL_FOUND)
|
||||||
get_filename_component(_moddir "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
get_filename_component(_moddir "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||||
|
|||||||
@@ -106,11 +106,9 @@ function(get_compiler_info_string _var)
|
|||||||
set(_verstring "gcc${_gccver}")
|
set(_verstring "gcc${_gccver}")
|
||||||
|
|
||||||
else()
|
else()
|
||||||
# Some other compiler we don't handle yet.
|
# Some other compiler we don't handle in more detail yet.
|
||||||
message(STATUS
|
|
||||||
"WARNING: Not GCC or MSVC, so we invented a messy compiler info string")
|
|
||||||
string(REGEX REPLACE " " "_" _verstring "${CMAKE_GENERATOR}")
|
string(REGEX REPLACE " " "_" _verstring "${CMAKE_GENERATOR}")
|
||||||
set(_verstring "generator:${_verstring}")
|
set(_verstring "${CMAKE_CXX_COMPILER_ID}:generator:${_verstring}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Return _verstring
|
# Return _verstring
|
||||||
|
|||||||
@@ -3,16 +3,16 @@
|
|||||||
# These functions force a re-configure on each git commit so that you can
|
# These functions force a re-configure on each git commit so that you can
|
||||||
# trust the values of the variables in your build system.
|
# trust the values of the variables in your build system.
|
||||||
#
|
#
|
||||||
# get_git_head_revision(<refspecvar> <hashvar> [<additonal arguments to git describe> ...])
|
# get_git_head_revision(<refspecvar> <hashvar> [<additional arguments to git describe> ...])
|
||||||
#
|
#
|
||||||
# Returns the refspec and sha hash of the current head revision
|
# Returns the refspec and sha hash of the current head revision
|
||||||
#
|
#
|
||||||
# git_describe(<var> [<additonal arguments to git describe> ...])
|
# git_describe(<var> [<additional arguments to git describe> ...])
|
||||||
#
|
#
|
||||||
# Returns the results of git describe on the source tree, and adjusting
|
# Returns the results of git describe on the source tree, and adjusting
|
||||||
# the output so that it tests false if an error occurs.
|
# the output so that it tests false if an error occurs.
|
||||||
#
|
#
|
||||||
# git_get_exact_tag(<var> [<additonal arguments to git describe> ...])
|
# git_get_exact_tag(<var> [<additional arguments to git describe> ...])
|
||||||
#
|
#
|
||||||
# Returns the results of git describe --exact-match on the source tree,
|
# Returns the results of git describe --exact-match on the source tree,
|
||||||
# and adjusting the output so that it tests false if there was no exact
|
# and adjusting the output so that it tests false if there was no exact
|
||||||
@@ -40,21 +40,33 @@ set(__get_git_revision_description YES)
|
|||||||
get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)
|
get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)
|
||||||
|
|
||||||
function(get_git_head_revision _refspecvar _hashvar)
|
function(get_git_head_revision _refspecvar _hashvar)
|
||||||
set(GIT_DIR "${CMAKE_SOURCE_DIR}/.git")
|
set(GIT_PARENT_DIR "${CMAKE_SOURCE_DIR}")
|
||||||
if(NOT EXISTS "${GIT_DIR}")
|
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
|
||||||
# not in git
|
while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories
|
||||||
|
set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}")
|
||||||
|
get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH)
|
||||||
|
if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT)
|
||||||
|
# We have reached the root directory, we are not in git
|
||||||
set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
|
set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
|
||||||
set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
|
set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
|
||||||
|
endwhile()
|
||||||
set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data")
|
set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data")
|
||||||
if(NOT EXISTS "${GIT_DATA}")
|
if(NOT EXISTS "${GIT_DATA}")
|
||||||
file(MAKE_DIRECTORY "${GIT_DATA}")
|
file(MAKE_DIRECTORY "${GIT_DATA}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(NOT EXISTS "${GIT_DIR}/HEAD")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
set(HEAD_FILE "${GIT_DATA}/HEAD")
|
set(HEAD_FILE "${GIT_DATA}/HEAD")
|
||||||
configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY)
|
configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY)
|
||||||
|
|
||||||
configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in" "${GIT_DATA}/grabRef.cmake" @ONLY)
|
configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in"
|
||||||
|
"${GIT_DATA}/grabRef.cmake"
|
||||||
|
@ONLY)
|
||||||
include("${GIT_DATA}/grabRef.cmake")
|
include("${GIT_DATA}/grabRef.cmake")
|
||||||
|
|
||||||
set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE)
|
set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE)
|
||||||
@@ -85,10 +97,17 @@ function(git_describe _var)
|
|||||||
|
|
||||||
#message(STATUS "Arguments to execute_process: ${ARGN}")
|
#message(STATUS "Arguments to execute_process: ${ARGN}")
|
||||||
|
|
||||||
execute_process(COMMAND "${GIT_EXECUTABLE}" describe ${hash} ${ARGN}
|
execute_process(COMMAND
|
||||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
"${GIT_EXECUTABLE}"
|
||||||
RESULT_VARIABLE res
|
describe
|
||||||
OUTPUT_VARIABLE out
|
${hash}
|
||||||
|
${ARGN}
|
||||||
|
WORKING_DIRECTORY
|
||||||
|
"${CMAKE_SOURCE_DIR}"
|
||||||
|
RESULT_VARIABLE
|
||||||
|
res
|
||||||
|
OUTPUT_VARIABLE
|
||||||
|
out
|
||||||
ERROR_QUIET
|
ERROR_QUIET
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
if(NOT res EQUAL 0)
|
if(NOT res EQUAL 0)
|
||||||
|
|||||||
@@ -13,18 +13,26 @@
|
|||||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
# http://www.boost.org/LICENSE_1_0.txt)
|
# http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
set(HEAD_HASH)
|
||||||
|
|
||||||
file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024)
|
file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024)
|
||||||
|
|
||||||
string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS)
|
string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS)
|
||||||
if(HEAD_CONTENTS MATCHES "ref")
|
if(HEAD_CONTENTS MATCHES "ref")
|
||||||
# named branch
|
# named branch
|
||||||
string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}")
|
string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}")
|
||||||
|
if(EXISTS "@GIT_DIR@/${HEAD_REF}")
|
||||||
configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
|
configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
|
||||||
|
elseif(EXISTS "@GIT_DIR@/logs/${HEAD_REF}")
|
||||||
|
configure_file("@GIT_DIR@/logs/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
|
||||||
|
set(HEAD_HASH "${HEAD_REF}")
|
||||||
|
endif()
|
||||||
else()
|
else()
|
||||||
# detached HEAD
|
# detached HEAD
|
||||||
configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY)
|
configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(NOT HEAD_HASH)
|
||||||
file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024)
|
file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024)
|
||||||
string(STRIP "${HEAD_HASH}" HEAD_HASH)
|
string(STRIP "${HEAD_HASH}" HEAD_HASH)
|
||||||
|
endif()
|
||||||
|
|||||||
@@ -40,15 +40,15 @@ function(add_lua_target _target _dest)
|
|||||||
if(NOT LUA_TARGET_LUAC_EXECUTABLE)
|
if(NOT LUA_TARGET_LUAC_EXECUTABLE)
|
||||||
if(TARGET luac)
|
if(TARGET luac)
|
||||||
set(LUA_TARGET_LUAC_EXECUTABLE luac)
|
set(LUA_TARGET_LUAC_EXECUTABLE luac)
|
||||||
|
mark_as_advanced(LUA_TARGET_LUAC_EXECUTABLE)
|
||||||
else()
|
else()
|
||||||
find_program(LUA_TARGET_LUAC_EXECUTABLE
|
find_program(LUA_TARGET_LUAC_EXECUTABLE NAMES luac)
|
||||||
NAMES
|
|
||||||
luac)
|
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT LUA_TARGET_LUAC_EXECUTABLE)
|
if(NOT LUA_TARGET_LUAC_EXECUTABLE)
|
||||||
message(FATAL_ERROR "Can't find luac: please give LUA_TARGET_LUAC_EXECUTABLE a useful value - currently ${LUA_TARGET_LUAC_EXECUTABLE}")
|
message(FATAL_ERROR
|
||||||
|
"Can't find luac: please give LUA_TARGET_LUAC_EXECUTABLE a useful value - currently ${LUA_TARGET_LUAC_EXECUTABLE}")
|
||||||
endif()
|
endif()
|
||||||
mark_as_advanced(LUA_TARGET_LUAC_EXECUTABLE)
|
mark_as_advanced(LUA_TARGET_LUAC_EXECUTABLE)
|
||||||
|
|
||||||
@@ -60,7 +60,9 @@ function(add_lua_target _target _dest)
|
|||||||
get_filename_component(fullpath "${fn}" ABSOLUTE)
|
get_filename_component(fullpath "${fn}" ABSOLUTE)
|
||||||
get_filename_component(fn "${fn}" NAME)
|
get_filename_component(fn "${fn}" NAME)
|
||||||
else()
|
else()
|
||||||
get_filename_component(fullpath "${CMAKE_CURRENT_SOURCE_DIR}/${fn}" ABSOLUTE)
|
get_filename_component(fullpath
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/${fn}"
|
||||||
|
ABSOLUTE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Clean up output file name
|
# Clean up output file name
|
||||||
@@ -88,7 +90,11 @@ function(add_lua_target _target _dest)
|
|||||||
SOURCES ${SOURCES}
|
SOURCES ${SOURCES}
|
||||||
DEPENDS ${ALLFILES})
|
DEPENDS ${ALLFILES})
|
||||||
if(TARGET "${LUA_TARGET_LUAC_EXECUTABLE}")
|
if(TARGET "${LUA_TARGET_LUAC_EXECUTABLE}")
|
||||||
get_property(_luac_imported TARGET "${LUA_TARGET_LUAC_EXECUTABLE}" PROPERTY IMPORTED)
|
get_property(_luac_imported
|
||||||
|
TARGET
|
||||||
|
"${LUA_TARGET_LUAC_EXECUTABLE}"
|
||||||
|
PROPERTY
|
||||||
|
IMPORTED)
|
||||||
if(NOT _luac_imported)
|
if(NOT _luac_imported)
|
||||||
add_dependencies(${_target} ${LUA_TARGET_LUAC_EXECUTABLE})
|
add_dependencies(${_target} ${LUA_TARGET_LUAC_EXECUTABLE})
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -46,7 +46,8 @@ function(option_requires name desc)
|
|||||||
option(${name} "${desc}" ${default})
|
option(${name} "${desc}" ${default})
|
||||||
|
|
||||||
if(${name} AND (NOT OK))
|
if(${name} AND (NOT OK))
|
||||||
message(FATAL_ERROR "${name} enabled but these dependencies were not valid: ${missing}")
|
message(FATAL_ERROR
|
||||||
|
"${name} enabled but these dependencies were not valid: ${missing}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ Licenses
|
|||||||
|
|
||||||
The modules that I wrote myself are all subject to this license:
|
The modules that I wrote myself are all subject to this license:
|
||||||
|
|
||||||
> Copyright Iowa State University 2009-2010
|
> Copyright Iowa State University 2009-2012
|
||||||
>
|
>
|
||||||
> Distributed under the Boost Software License, Version 1.0.
|
> Distributed under the Boost Software License, Version 1.0.
|
||||||
>
|
>
|
||||||
|
|||||||
116
cmake/UseMarkdown.cmake
Normal file
116
cmake/UseMarkdown.cmake
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
# - Convert markdown source files to HTML as a custom target
|
||||||
|
#
|
||||||
|
# include(UseMarkdown)
|
||||||
|
# add_markdown_target(<target_name> <directory to copy to> <markdownfile> [<markdownfile>...] [RENAME <newname>])
|
||||||
|
# Relative paths for the destination directory are considered with
|
||||||
|
# with respect to CMAKE_CURRENT_BINARY_DIR. The RENAME argument is only
|
||||||
|
# valid with a single markdown file as input.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# install_markdown_target(<target_name> [extra arguments to INSTALL(FILES ...) ])
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Requires CMake 2.6 or newer (uses the 'function' command)
|
||||||
|
#
|
||||||
|
# Original Author:
|
||||||
|
# 2011 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||||
|
# http://academic.cleardefinition.com
|
||||||
|
# Iowa State University HCI Graduate Program/VRAC
|
||||||
|
#
|
||||||
|
# Copyright Iowa State University 2011-2012.
|
||||||
|
# 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)
|
||||||
|
|
||||||
|
if(__add_markdown_target)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
set(__add_markdown_target YES)
|
||||||
|
|
||||||
|
define_property(TARGET
|
||||||
|
PROPERTY
|
||||||
|
MARKDOWN_TARGET_OUTPUTS
|
||||||
|
BRIEF_DOCS
|
||||||
|
"Markdown target outputs"
|
||||||
|
FULL_DOCS
|
||||||
|
"Output files of a target created by add_markdown_target")
|
||||||
|
|
||||||
|
function(add_markdown_target _target _dest)
|
||||||
|
|
||||||
|
if(NOT ARGN)
|
||||||
|
message(WARNING
|
||||||
|
"In add_markdown_target call for target ${_target}, no source files were specified!")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_package(Markdown QUIET)
|
||||||
|
if(NOT MARKDOWN_EXECUTABLE)
|
||||||
|
message(FATAL_ERROR "Can't find a markdown conversion tool!")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(NEW_NAME)
|
||||||
|
list(FIND ARGN "RENAME" _renameloc)
|
||||||
|
if(_renameloc GREATER -1)
|
||||||
|
list(LENGTH ARGN _len)
|
||||||
|
if(NOT _len EQUAL 3)
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Specifying RENAME requires 1 input file and 1 output name!")
|
||||||
|
endif()
|
||||||
|
list(GET ARGN 2 NEW_NAME)
|
||||||
|
list(GET ARGN 0 ARGN)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(ALLFILES)
|
||||||
|
set(SOURCES)
|
||||||
|
foreach(fn ${ARGN})
|
||||||
|
# Produce an absolute path to the input file
|
||||||
|
if(IS_ABSOLUTE "${fn}")
|
||||||
|
get_filename_component(fullpath "${fn}" ABSOLUTE)
|
||||||
|
get_filename_component(fn "${fn}" NAME)
|
||||||
|
else()
|
||||||
|
get_filename_component(fullpath
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/${fn}"
|
||||||
|
ABSOLUTE)
|
||||||
|
endif()
|
||||||
|
get_filename_component(fn_noext "${fn}" NAME_WE)
|
||||||
|
|
||||||
|
# Clean up output file name
|
||||||
|
if(NEW_NAME)
|
||||||
|
get_filename_component(absout "${_dest}/${NEW_NAME}" ABSOLUTE)
|
||||||
|
else()
|
||||||
|
get_filename_component(absout "${_dest}/${fn_noext}.html" ABSOLUTE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_custom_command(OUTPUT "${absout}"
|
||||||
|
COMMAND
|
||||||
|
${CMAKE_COMMAND}
|
||||||
|
ARGS -E make_directory "${_dest}"
|
||||||
|
COMMAND
|
||||||
|
${MARKDOWN_EXECUTABLE}
|
||||||
|
ARGS "${fullpath}" > "${absout}"
|
||||||
|
MAIN_DEPENDENCY "${fullpath}"
|
||||||
|
VERBATIM
|
||||||
|
COMMENT "Converting Markdown ${fn} to HTML in ${absout}...")
|
||||||
|
list(APPEND SOURCES "${fullpath}")
|
||||||
|
list(APPEND ALLFILES "${absout}")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# Custom target depending on all the file copy commands
|
||||||
|
add_custom_target(${_target}
|
||||||
|
ALL
|
||||||
|
SOURCES ${SOURCES}
|
||||||
|
DEPENDS ${ALLFILES})
|
||||||
|
set_property(TARGET ${_target} PROPERTY MARKDOWN_TARGET_OUTPUTS "${ALLFILES}")
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(install_markdown_target _target)
|
||||||
|
get_target_property(_mtoutputs ${_target} MARKDOWN_TARGET_OUTPUTS)
|
||||||
|
if(NOT _mtoutputs)
|
||||||
|
message(WARNING
|
||||||
|
"install_markdown_target called on a target not created with add_markdown_target!")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Forward the call to install
|
||||||
|
install(FILES ${_mtoutputs} ${ARGN})
|
||||||
|
endfunction()
|
||||||
254
cmake/cmake-2.8.10-modules/CMakePackageConfigHelpers.cmake
Normal file
254
cmake/cmake-2.8.10-modules/CMakePackageConfigHelpers.cmake
Normal file
@@ -0,0 +1,254 @@
|
|||||||
|
# - CONFIGURE_PACKAGE_CONFIG_FILE(), WRITE_BASIC_PACKAGE_VERSION_FILE()
|
||||||
|
#
|
||||||
|
# CONFIGURE_PACKAGE_CONFIG_FILE(<input> <output> INSTALL_DESTINATION <path>
|
||||||
|
# [PATH_VARS <var1> <var2> ... <varN>]
|
||||||
|
# [NO_SET_AND_CHECK_MACRO]
|
||||||
|
# [NO_CHECK_REQUIRED_COMPONENTS_MACRO])
|
||||||
|
#
|
||||||
|
# CONFIGURE_PACKAGE_CONFIG_FILE() should be used instead of the plain
|
||||||
|
# configure_file() command when creating the <Name>Config.cmake or <Name>-config.cmake
|
||||||
|
# file for installing a project or library. It helps making the resulting package
|
||||||
|
# relocatable by avoiding hardcoded paths in the installed Config.cmake file.
|
||||||
|
#
|
||||||
|
# In a FooConfig.cmake file there may be code like this to make the
|
||||||
|
# install destinations know to the using project:
|
||||||
|
# set(FOO_INCLUDE_DIR "@CMAKE_INSTALL_FULL_INCLUDEDIR@" )
|
||||||
|
# set(FOO_DATA_DIR "@CMAKE_INSTALL_PREFIX@/@RELATIVE_DATA_INSTALL_DIR@" )
|
||||||
|
# set(FOO_ICONS_DIR "@CMAKE_INSTALL_PREFIX@/share/icons" )
|
||||||
|
# ...logic to determine installedPrefix from the own location...
|
||||||
|
# set(FOO_CONFIG_DIR "${installedPrefix}/@CONFIG_INSTALL_DIR@" )
|
||||||
|
# All 4 options shown above are not sufficient, since the first 3 hardcode
|
||||||
|
# the absolute directory locations, and the 4th case works only if the logic
|
||||||
|
# to determine the installedPrefix is correct, and if CONFIG_INSTALL_DIR contains
|
||||||
|
# a relative path, which in general cannot be guaranteed.
|
||||||
|
# This has the effect that the resulting FooConfig.cmake file would work poorly
|
||||||
|
# under Windows and OSX, where users are used to choose the install location
|
||||||
|
# of a binary package at install time, independent from how CMAKE_INSTALL_PREFIX
|
||||||
|
# was set at build/cmake time.
|
||||||
|
#
|
||||||
|
# Using CONFIGURE_PACKAGE_CONFIG_FILE() helps. If used correctly, it makes the
|
||||||
|
# resulting FooConfig.cmake file relocatable.
|
||||||
|
# Usage:
|
||||||
|
# 1. write a FooConfig.cmake.in file as you are used to
|
||||||
|
# 2. insert a line containing only the string "@PACKAGE_INIT@"
|
||||||
|
# 3. instead of set(FOO_DIR "@SOME_INSTALL_DIR@"), use set(FOO_DIR "@PACKAGE_SOME_INSTALL_DIR@")
|
||||||
|
# (this must be after the @PACKAGE_INIT@ line)
|
||||||
|
# 4. instead of using the normal configure_file(), use CONFIGURE_PACKAGE_CONFIG_FILE()
|
||||||
|
#
|
||||||
|
# The <input> and <output> arguments are the input and output file, the same way
|
||||||
|
# as in configure_file().
|
||||||
|
#
|
||||||
|
# The <path> given to INSTALL_DESTINATION must be the destination where the FooConfig.cmake
|
||||||
|
# file will be installed to. This can either be a relative or absolute path, both work.
|
||||||
|
#
|
||||||
|
# The variables <var1> to <varN> given as PATH_VARS are the variables which contain
|
||||||
|
# install destinations. For each of them the macro will create a helper variable
|
||||||
|
# PACKAGE_<var...>. These helper variables must be used
|
||||||
|
# in the FooConfig.cmake.in file for setting the installed location. They are calculated
|
||||||
|
# by CONFIGURE_PACKAGE_CONFIG_FILE() so that they are always relative to the
|
||||||
|
# installed location of the package. This works both for relative and also for absolute locations.
|
||||||
|
# For absolute locations it works only if the absolute location is a subdirectory
|
||||||
|
# of CMAKE_INSTALL_PREFIX.
|
||||||
|
#
|
||||||
|
# By default configure_package_config_file() also generates two helper macros,
|
||||||
|
# set_and_check() and check_required_components() into the FooConfig.cmake file.
|
||||||
|
#
|
||||||
|
# set_and_check() should be used instead of the normal set()
|
||||||
|
# command for setting directories and file locations. Additionally to setting the
|
||||||
|
# variable it also checks that the referenced file or directory actually exists
|
||||||
|
# and fails with a FATAL_ERROR otherwise. This makes sure that the created
|
||||||
|
# FooConfig.cmake file does not contain wrong references.
|
||||||
|
# When using the NO_SET_AND_CHECK_MACRO, this macro is not generated into the
|
||||||
|
# FooConfig.cmake file.
|
||||||
|
#
|
||||||
|
# check_required_components(<package_name>) should be called at the end of the
|
||||||
|
# FooConfig.cmake file if the package supports components.
|
||||||
|
# This macro checks whether all requested, non-optional components have been found,
|
||||||
|
# and if this is not the case, sets the Foo_FOUND variable to FALSE, so that the package
|
||||||
|
# is considered to be not found.
|
||||||
|
# It does that by testing the Foo_<Component>_FOUND variables for all requested
|
||||||
|
# required components.
|
||||||
|
# When using the NO_CHECK_REQUIRED_COMPONENTS option, this macro is not generated
|
||||||
|
# into the FooConfig.cmake file.
|
||||||
|
#
|
||||||
|
# For an example see below the documentation for WRITE_BASIC_PACKAGE_VERSION_FILE().
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# WRITE_BASIC_PACKAGE_VERSION_FILE( filename VERSION major.minor.patch COMPATIBILITY (AnyNewerVersion|SameMajorVersion|ExactVersion) )
|
||||||
|
#
|
||||||
|
# Writes a file for use as <package>ConfigVersion.cmake file to <filename>.
|
||||||
|
# See the documentation of find_package() for details on this.
|
||||||
|
# filename is the output filename, it should be in the build tree.
|
||||||
|
# major.minor.patch is the version number of the project to be installed
|
||||||
|
# The COMPATIBILITY mode AnyNewerVersion means that the installed package version
|
||||||
|
# will be considered compatible if it is newer or exactly the same as the requested version.
|
||||||
|
# This mode should be used for packages which are fully backward compatible,
|
||||||
|
# also across major versions.
|
||||||
|
# If SameMajorVersion is used instead, then the behaviour differs from AnyNewerVersion
|
||||||
|
# in that the major version number must be the same as requested, e.g. version 2.0 will
|
||||||
|
# not be considered compatible if 1.0 is requested.
|
||||||
|
# This mode should be used for packages which guarantee backward compatibility within the
|
||||||
|
# same major version.
|
||||||
|
# If ExactVersion is used, then the package is only considered compatible if the requested
|
||||||
|
# version matches exactly its own version number (not considering the tweak version).
|
||||||
|
# For example, version 1.2.3 of a package is only considered compatible to requested version 1.2.3.
|
||||||
|
# This mode is for packages without compatibility guarantees.
|
||||||
|
# If your project has more elaborated version matching rules, you will need to write your
|
||||||
|
# own custom ConfigVersion.cmake file instead of using this macro.
|
||||||
|
#
|
||||||
|
# Internally, this macro executes configure_file() to create the resulting
|
||||||
|
# version file. Depending on the COMPATIBLITY, either the file
|
||||||
|
# BasicConfigVersion-SameMajorVersion.cmake.in or BasicConfigVersion-AnyNewerVersion.cmake.in
|
||||||
|
# is used. Please note that these two files are internal to CMake and you should
|
||||||
|
# not call configure_file() on them yourself, but they can be used as starting
|
||||||
|
# point to create more sophisticted custom ConfigVersion.cmake files.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Example using both configure_package_config_file() and write_basic_package_version_file():
|
||||||
|
# CMakeLists.txt:
|
||||||
|
# set(INCLUDE_INSTALL_DIR include/ ... CACHE )
|
||||||
|
# set(LIB_INSTALL_DIR lib/ ... CACHE )
|
||||||
|
# set(SYSCONFIG_INSTALL_DIR etc/foo/ ... CACHE )
|
||||||
|
# ...
|
||||||
|
# include(CMakePackageConfigHelpers)
|
||||||
|
# configure_package_config_file(FooConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FooConfig.cmake
|
||||||
|
# INSTALL_DESTINATION ${LIB_INSTALL_DIR}/Foo/cmake
|
||||||
|
# PATH_VARS INCLUDE_INSTALL_DIR SYSCONFIG_INSTALL_DIR)
|
||||||
|
# write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/FooConfigVersion.cmake
|
||||||
|
# VERSION 1.2.3
|
||||||
|
# COMPATIBILITY SameMajorVersion )
|
||||||
|
# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/FooConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/FooConfigVersion.cmake
|
||||||
|
# DESTINATION ${LIB_INSTALL_DIR}/Foo/cmake )
|
||||||
|
#
|
||||||
|
# With a FooConfig.cmake.in:
|
||||||
|
# set(FOO_VERSION x.y.z)
|
||||||
|
# ...
|
||||||
|
# @PACKAGE_INIT@
|
||||||
|
# ...
|
||||||
|
# set_and_check(FOO_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@")
|
||||||
|
# set_and_check(FOO_SYSCONFIG_DIR "@PACKAGE_SYSCONFIG_INSTALL_DIR@")
|
||||||
|
#
|
||||||
|
# check_required_components(Foo)
|
||||||
|
|
||||||
|
|
||||||
|
#=============================================================================
|
||||||
|
# Copyright 2012 Alexander Neundorf <neundorf@kde.org>
|
||||||
|
#
|
||||||
|
# Distributed under the OSI-approved BSD License (the "License");
|
||||||
|
# see below.
|
||||||
|
#
|
||||||
|
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||||
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
# See the License for more information.
|
||||||
|
#=============================================================================
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
#
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# * Neither the names of Kitware, Inc., the Insight Software Consortium,
|
||||||
|
# nor the names of their contributors may be used to endorse or promote
|
||||||
|
# products derived from this software without specific prior written
|
||||||
|
# permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
#=============================================================================
|
||||||
|
|
||||||
|
include(CMakeParseArguments)
|
||||||
|
|
||||||
|
include(WriteBasicConfigVersionFile)
|
||||||
|
|
||||||
|
macro(WRITE_BASIC_PACKAGE_VERSION_FILE)
|
||||||
|
write_basic_config_version_file(${ARGN})
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
|
function(CONFIGURE_PACKAGE_CONFIG_FILE _inputFile _outputFile)
|
||||||
|
set(options NO_SET_AND_CHECK_MACRO NO_CHECK_REQUIRED_COMPONENTS_MACRO)
|
||||||
|
set(oneValueArgs INSTALL_DESTINATION )
|
||||||
|
set(multiValueArgs PATH_VARS )
|
||||||
|
|
||||||
|
cmake_parse_arguments(CCF "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||||
|
|
||||||
|
if(CCF_UNPARSED_ARGUMENTS)
|
||||||
|
message(FATAL_ERROR "Unknown keywords given to CONFIGURE_PACKAGE_CONFIG_FILE(): \"${CCF_UNPARSED_ARGUMENTS}\"")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT CCF_INSTALL_DESTINATION)
|
||||||
|
message(FATAL_ERROR "No INSTALL_DESTINATION given to CONFIGURE_PACKAGE_CONFIG_FILE()")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(IS_ABSOLUTE "${CCF_INSTALL_DESTINATION}")
|
||||||
|
set(absInstallDir "${CCF_INSTALL_DESTINATION}")
|
||||||
|
else()
|
||||||
|
set(absInstallDir "${CMAKE_INSTALL_PREFIX}/${CCF_INSTALL_DESTINATION}")
|
||||||
|
endif()
|
||||||
|
file(RELATIVE_PATH PACKAGE_RELATIVE_PATH "${absInstallDir}" "${CMAKE_INSTALL_PREFIX}" )
|
||||||
|
|
||||||
|
foreach(var ${CCF_PATH_VARS})
|
||||||
|
if(NOT DEFINED ${var})
|
||||||
|
message(FATAL_ERROR "Variable ${var} does not exist")
|
||||||
|
else()
|
||||||
|
if(IS_ABSOLUTE "${${var}}")
|
||||||
|
string(REPLACE "${CMAKE_INSTALL_PREFIX}" "\${PACKAGE_PREFIX_DIR}"
|
||||||
|
PACKAGE_${var} "${${var}}")
|
||||||
|
else()
|
||||||
|
set(PACKAGE_${var} "\${PACKAGE_PREFIX_DIR}/${${var}}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
set(PACKAGE_INIT "
|
||||||
|
####### Expanded from @PACKAGE_INIT@ by configure_package_config_file() #######
|
||||||
|
get_filename_component(PACKAGE_PREFIX_DIR \"\${CMAKE_CURRENT_LIST_DIR}/${PACKAGE_RELATIVE_PATH}\" ABSOLUTE)
|
||||||
|
")
|
||||||
|
|
||||||
|
if(NOT CCF_NO_SET_AND_CHECK_MACRO)
|
||||||
|
set(PACKAGE_INIT "${PACKAGE_INIT}
|
||||||
|
macro(set_and_check _var _file)
|
||||||
|
set(\${_var} \"\${_file}\")
|
||||||
|
if(NOT EXISTS \"\${_file}\")
|
||||||
|
message(FATAL_ERROR \"File or directory \${_file} referenced by variable \${_var} does not exist !\")
|
||||||
|
endif()
|
||||||
|
endmacro()
|
||||||
|
")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
if(NOT CCF_NO_CHECK_REQUIRED_COMPONENTS_MACRO)
|
||||||
|
set(PACKAGE_INIT "${PACKAGE_INIT}
|
||||||
|
macro(check_required_components _NAME)
|
||||||
|
foreach(comp \${\${_NAME}_FIND_COMPONENTS})
|
||||||
|
if(NOT \${_NAME}_\${comp}_FOUND)
|
||||||
|
if(\${_NAME}_FIND_REQUIRED_\${comp})
|
||||||
|
set(\${_NAME}_FOUND FALSE)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endmacro()
|
||||||
|
")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(PACKAGE_INIT "${PACKAGE_INIT}
|
||||||
|
####################################################################################")
|
||||||
|
|
||||||
|
configure_file("${_inputFile}" "${_outputFile}" @ONLY)
|
||||||
|
|
||||||
|
endfunction()
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/** @file list.h
|
/** @file
|
||||||
@brief Fake header to allow GHOST 4.09 use with MSVC 2005
|
@brief Fake header to allow GHOST 4.09 use with MSVC 2005
|
||||||
|
|
||||||
@date 2010
|
@date 2010
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/** @file list.h
|
/** @file
|
||||||
@brief Fake header to allow GHOST 4.09 use with MSVC 2005
|
@brief Fake header to allow GHOST 4.09 use with MSVC 2005
|
||||||
|
|
||||||
@date 2010
|
@date 2010
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/** @file set.h
|
/** @file
|
||||||
@brief Fake header to allow GHOST 4.09 use with MSVC 2005
|
@brief Fake header to allow GHOST 4.09 use with MSVC 2005
|
||||||
|
|
||||||
@date 2010
|
@date 2010
|
||||||
@@ -14,4 +14,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <functional>
|
||||||
using std::set;
|
using std::set;
|
||||||
|
using std::less;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/** @file vector.h
|
/** @file
|
||||||
@brief Fake header to allow GHOST 4.09 use with MSVC 2005
|
@brief Fake header to allow GHOST 4.09 use with MSVC 2005
|
||||||
|
|
||||||
@date 2010
|
@date 2010
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1,4 +1,4 @@
|
|||||||
cmake version 2.8.3
|
cmake version 2.8.6
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
Introduction
|
Introduction
|
||||||
|
|
||||||
@@ -645,6 +645,71 @@ a few.
|
|||||||
Boost Software License, Version 1.0. (See accompanying file
|
Boost Software License, Version 1.0. (See accompanying file
|
||||||
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
FindAdrienne
|
||||||
|
try to find Adrienne Electronics Corporation timecode card library
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
SDK available from the manufacturer: http://www.adrielec.com/
|
||||||
|
|
||||||
|
Cache Variables: (probably not for direct use in your scripts)
|
||||||
|
|
||||||
|
ADRIENNE_INCLUDE_DIR
|
||||||
|
ADRIENNE_LIBRARY
|
||||||
|
ADRIENNE_RUNTIME_LIBRARY
|
||||||
|
ADRIENNE_INCLUDE_FILE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Variables you might use in your CMakeLists.txt:
|
||||||
|
|
||||||
|
ADRIENNE_FOUND
|
||||||
|
ADRIENNE_INCLUDE_DIRS
|
||||||
|
ADRIENNE_LIBRARIES
|
||||||
|
ADRIENNE_RUNTIME_LIBRARIES - the AEC_NTTC.dll file
|
||||||
|
ADRIENNE_RUNTIME_LIBRARY_DIRS
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ADRIENNE_INCLUDE_FILENAME - this is probably AEC_NTTC.h, but it might also
|
||||||
|
be AECINTTC.H.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ADRIENNE_INCLUDE_HAS_EXTERN_C - Some (most) versions of the header already
|
||||||
|
wrap their definitions in extern "C" { }, but some do not.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ADRIENNE_DEFINITIONS - defines a quoted ADRIENNE_INCLUDE_FILENAME as above,
|
||||||
|
so you can write a line like #include ADRIENNE_INCLUDE_FILENAME
|
||||||
|
Also defines ADRIENNE_BEFORE_INCLUDE and ADRIENNE_AFTER_INCLUDE to handle
|
||||||
|
adding extern "C" { and } if the header file doesn't do so itself.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Variables that might be set by the user in the gui/command line to
|
||||||
|
help find the library:
|
||||||
|
|
||||||
|
ADRIENNE_ROOT_DIR - root of an Adrienne CD, disk, or extracted/copied contents
|
||||||
|
thereof.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Requires these CMake modules:
|
||||||
|
|
||||||
|
FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Original Author: 2012 Ryan Pavlik <rpavlik@iastate.edu>
|
||||||
|
<abiryan@ryand.net> http://academic.cleardefinition.com Iowa State
|
||||||
|
University HCI Graduate Program/VRAC
|
||||||
|
|
||||||
|
Copyright Iowa State University 2012. 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)
|
||||||
|
|
||||||
FindBluez
|
FindBluez
|
||||||
try to find Bluez
|
try to find Bluez
|
||||||
|
|
||||||
@@ -696,7 +761,7 @@ a few.
|
|||||||
|
|
||||||
CPPDOM_ROOT_DIR - A directory prefix to search
|
CPPDOM_ROOT_DIR - A directory prefix to search
|
||||||
(a path that contains include/ as a subdirectory)
|
(a path that contains include/ as a subdirectory)
|
||||||
CPPDOM_ADDITIONAL_VERSIONS - Additional versions (outside of 0.7.8 to 1.0.0)
|
CPPDOM_ADDITIONAL_VERSIONS - Additional versions (outside of 0.7.8 to 1.2.0)
|
||||||
to use when constructing search names and paths
|
to use when constructing search names and paths
|
||||||
|
|
||||||
|
|
||||||
@@ -713,11 +778,11 @@ a few.
|
|||||||
change this environment variable, because it cannot auto-detect this
|
change this environment variable, because it cannot auto-detect this
|
||||||
change and trigger an automatic re-run.
|
change and trigger an automatic re-run.
|
||||||
|
|
||||||
Original Author: 2009-2010 Ryan Pavlik <rpavlik@iastate.edu>
|
Original Author: 2009-2012 Ryan Pavlik <rpavlik@iastate.edu>
|
||||||
<abiryan@ryand.net> http://academic.cleardefinition.com Iowa State
|
<abiryan@ryand.net> http://academic.cleardefinition.com Iowa State
|
||||||
University HCI Graduate Program/VRAC
|
University HCI Graduate Program/VRAC
|
||||||
|
|
||||||
Copyright Iowa State University 2009-2010. Distributed under the
|
Copyright Iowa State University 2009-2012. Distributed under the
|
||||||
Boost Software License, Version 1.0. (See accompanying file
|
Boost Software License, Version 1.0. (See accompanying file
|
||||||
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
@@ -752,6 +817,110 @@ a few.
|
|||||||
Boost Software License, Version 1.0. (See accompanying file
|
Boost Software License, Version 1.0. (See accompanying file
|
||||||
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
FindDirectInput
|
||||||
|
try to find DirectInput library (part of DirectX SDK)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Cache Variables: (probably not for direct use in your scripts)
|
||||||
|
|
||||||
|
DIRECTINPUT_DXGUID_LIBRARY
|
||||||
|
DIRECTINPUT_DXERR_LIBRARY
|
||||||
|
DIRECTINPUT_DINPUT_LIBRARY
|
||||||
|
DIRECTINPUT_INCLUDE_DIR
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Non-cache variables you should use in your CMakeLists.txt:
|
||||||
|
|
||||||
|
DIRECTINPUT_LIBRARIES
|
||||||
|
DIRECTINPUT_INCLUDE_DIRS
|
||||||
|
DIRECTINPUT_FOUND - if this is not true, do not attempt to use this library
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Requires these CMake modules:
|
||||||
|
|
||||||
|
FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Original Author: 2011 Ryan Pavlik <rpavlik@iastate.edu>
|
||||||
|
<abiryan@ryand.net> http://academic.cleardefinition.com Iowa State
|
||||||
|
University HCI Graduate Program/VRAC
|
||||||
|
|
||||||
|
Copyright Iowa State University 2011. 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)
|
||||||
|
|
||||||
|
FindDirectShow
|
||||||
|
Find Microsoft DirectShow sample files, library, and headers.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
DIRECTSHOW_INCLUDE_DIRS - where to find needed include file
|
||||||
|
DIRECTSHOW_BASECLASS_DIR- Directory containing the DirectShow baseclass sample code.
|
||||||
|
DIRECTSHOW_FOUND - True if DirectShow found.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Requires these CMake modules:
|
||||||
|
|
||||||
|
FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Initially in VRPN - Distributed under the Boost Software License,
|
||||||
|
Version 1.0.
|
||||||
|
|
||||||
|
Almost entirely re-written by: 2012 Ryan Pavlik <rpavlik@iastate.edu>
|
||||||
|
<abiryan@ryand.net> http://academic.cleardefinition.com Iowa State
|
||||||
|
University HCI Graduate Program/VRAC
|
||||||
|
|
||||||
|
Copyright Iowa State University 2012. 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)
|
||||||
|
|
||||||
|
FindDirectX
|
||||||
|
try to find part of DirectX SDK
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Cache Variables: (probably not for direct use in your scripts)
|
||||||
|
|
||||||
|
DIRECTX_INCLUDE_DIR
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Variables you should use in your CMakeLists.txt:
|
||||||
|
|
||||||
|
DIRECTX_DXGUID_LIBRARY
|
||||||
|
DIRECTX_DXERR_LIBRARY
|
||||||
|
DIRECTX_DINPUT_LIBRARY
|
||||||
|
DIRECTX_DINPUT_INCLUDE_DIR
|
||||||
|
DIRECTX_D3D9_LIBRARY
|
||||||
|
DIRECTX_D3DXOF_LIBRARY
|
||||||
|
DIRECTX_D3DX9_LIBRARIES
|
||||||
|
DIRECTX_INCLUDE_DIRS
|
||||||
|
DIRECTX_FOUND - if this is not true, do not attempt to use this library
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Requires these CMake modules:
|
||||||
|
|
||||||
|
FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
|
||||||
|
SelectLibraryConfigurations
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Original Author: 2012 Ryan Pavlik <rpavlik@iastate.edu>
|
||||||
|
<abiryan@ryand.net> http://academic.cleardefinition.com Iowa State
|
||||||
|
University HCI Graduate Program/VRAC
|
||||||
|
|
||||||
|
Copyright Iowa State University 2012. 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)
|
||||||
|
|
||||||
FindFlagpoll
|
FindFlagpoll
|
||||||
try to find Flagpoll application, and offer package-finding services
|
try to find Flagpoll application, and offer package-finding services
|
||||||
|
|
||||||
@@ -913,7 +1082,7 @@ a few.
|
|||||||
|
|
||||||
GMTL_ROOT_DIR - A directory prefix to search
|
GMTL_ROOT_DIR - A directory prefix to search
|
||||||
(a path that contains include/ as a subdirectory)
|
(a path that contains include/ as a subdirectory)
|
||||||
GMTL_ADDITIONAL_VERSIONS - Additional versions (outside of 0.5.1 to 0.6.2)
|
GMTL_ADDITIONAL_VERSIONS - Additional versions (outside of 0.5.1 to 0.7.0)
|
||||||
to use when constructing search names and paths
|
to use when constructing search names and paths
|
||||||
|
|
||||||
|
|
||||||
@@ -930,11 +1099,11 @@ a few.
|
|||||||
change this environment variable, because it cannot auto-detect this
|
change this environment variable, because it cannot auto-detect this
|
||||||
change and trigger an automatic re-run.
|
change and trigger an automatic re-run.
|
||||||
|
|
||||||
Original Author: 2009-2010 Ryan Pavlik <rpavlik@iastate.edu>
|
Original Author: 2009-2012 Ryan Pavlik <rpavlik@iastate.edu>
|
||||||
<abiryan@ryand.net> http://academic.cleardefinition.com Iowa State
|
<abiryan@ryand.net> http://academic.cleardefinition.com Iowa State
|
||||||
University HCI Graduate Program/VRAC
|
University HCI Graduate Program/VRAC
|
||||||
|
|
||||||
Copyright Iowa State University 2009-2010. Distributed under the
|
Copyright Iowa State University 2009-2012. Distributed under the
|
||||||
Boost Software License, Version 1.0. (See accompanying file
|
Boost Software License, Version 1.0. (See accompanying file
|
||||||
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
@@ -1139,6 +1308,51 @@ a few.
|
|||||||
Boost Software License, Version 1.0. (See accompanying file
|
Boost Software License, Version 1.0. (See accompanying file
|
||||||
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
FindIDLJ
|
||||||
|
try to find Java's IDLJ Interface Definition Language compiler.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Ideally used with CMake 2.8.5 or newer for Java support using
|
||||||
|
FindJava.cmake and UseJava.cmake
|
||||||
|
|
||||||
|
Variables:
|
||||||
|
|
||||||
|
Java_IDLJ_COMMAND, executable for idlj
|
||||||
|
IDLJ_FOUND, If false, do not try to use this
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Function:
|
||||||
|
|
||||||
|
java_idlj(varname idlfile [extra idlj args]) - Generates
|
||||||
|
the Java source files from the IDL file you indicate, and
|
||||||
|
appends filenames suitable to add to a add_jar() call to the
|
||||||
|
variable you specified.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Because the files generated from an IDL file are not entirely
|
||||||
|
predictable, java_idlj runs idlj in the cmake step, rather than the
|
||||||
|
build step, and triggers a CMake re-run when an idl file is modified.
|
||||||
|
Already up-to-date generated source is not re-generated, however.
|
||||||
|
|
||||||
|
Files are generated in a directory created specifically for the
|
||||||
|
particular IDL file and the particular call, in the build directory -
|
||||||
|
there should be no worries about overwriting files or picking up too
|
||||||
|
much with the wildcard.
|
||||||
|
|
||||||
|
You may wish to add the IDL file to your list of sources if you want
|
||||||
|
it to appear in your IDE, but it is not necessary.
|
||||||
|
|
||||||
|
Original Author: 2012 Ryan Pavlik <rpavlik@iastate.edu>
|
||||||
|
<abiryan@ryand.net> http://academic.cleardefinition.com Iowa State
|
||||||
|
University HCI Graduate Program/VRAC
|
||||||
|
|
||||||
|
Copyright Iowa State University 2012. 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)
|
||||||
|
|
||||||
FindJCCL12
|
FindJCCL12
|
||||||
try to find JCCL 1.2 library
|
try to find JCCL 1.2 library
|
||||||
|
|
||||||
@@ -1451,6 +1665,37 @@ a few.
|
|||||||
Boost Software License, Version 1.0. (See accompanying file
|
Boost Software License, Version 1.0. (See accompanying file
|
||||||
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
FindMarkdown
|
||||||
|
try to find Markdown tool
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Cache Variables:
|
||||||
|
|
||||||
|
MARKDOWN_EXECUTABLE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Non-cache variables you might use in your CMakeLists.txt:
|
||||||
|
|
||||||
|
MARKDOWN_FOUND
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Requires these CMake modules:
|
||||||
|
|
||||||
|
FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Original Author: 2011 Ryan Pavlik <rpavlik@iastate.edu>
|
||||||
|
<abiryan@ryand.net> http://academic.cleardefinition.com Iowa State
|
||||||
|
University HCI Graduate Program/VRAC
|
||||||
|
|
||||||
|
Copyright Iowa State University 2011. 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)
|
||||||
|
|
||||||
FindOpenCV
|
FindOpenCV
|
||||||
------------------------------
|
------------------------------
|
||||||
|
|
||||||
@@ -1493,12 +1738,16 @@ a few.
|
|||||||
|
|
||||||
HDAPI_INCLUDE_DIR
|
HDAPI_INCLUDE_DIR
|
||||||
HDAPI_LIBRARY
|
HDAPI_LIBRARY
|
||||||
|
HDAPI_LIBRARY_RELEASE
|
||||||
|
HDAPI_LIBRARY_DEBUG
|
||||||
HDAPI_HDU_INCLUDE_DIR
|
HDAPI_HDU_INCLUDE_DIR
|
||||||
HDAPI_HDU_LIBRARY
|
HDAPI_HDU_LIBRARY
|
||||||
HDAPI_HDU_LIBRARY_RELEASE
|
HDAPI_HDU_LIBRARY_RELEASE
|
||||||
HDAPI_HDU_LIBRARY_DEBUG
|
HDAPI_HDU_LIBRARY_DEBUG
|
||||||
HLAPI_INCLUDE_DIR
|
HLAPI_INCLUDE_DIR
|
||||||
HLAPI_LIBRARY
|
HLAPI_LIBRARY
|
||||||
|
HLAPI_LIBRARY_RELEASE
|
||||||
|
HLAPI_LIBRARY_DEBUG
|
||||||
HLAPI_HLU_INCLUDE_DIR
|
HLAPI_HLU_INCLUDE_DIR
|
||||||
HLAPI_HLU_LIBRARY
|
HLAPI_HLU_LIBRARY
|
||||||
HLAPI_HLU_LIBRARY_RELEASE
|
HLAPI_HLU_LIBRARY_RELEASE
|
||||||
@@ -1537,7 +1786,7 @@ a few.
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
Original Author: 2009-2010 Ryan Pavlik <rpavlik@iastate.edu>
|
Original Author: 2009-2012 Ryan Pavlik <rpavlik@iastate.edu>
|
||||||
<abiryan@ryand.net> http://academic.cleardefinition.com Iowa State
|
<abiryan@ryand.net> http://academic.cleardefinition.com Iowa State
|
||||||
University HCI Graduate Program/VRAC
|
University HCI Graduate Program/VRAC
|
||||||
|
|
||||||
@@ -1581,6 +1830,118 @@ a few.
|
|||||||
Boost Software License, Version 1.0. (See accompanying file
|
Boost Software License, Version 1.0. (See accompanying file
|
||||||
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
FindPerformer
|
||||||
|
try to find the OpenGL Performer library
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Users may optionally supply:
|
||||||
|
|
||||||
|
PERFORMER_ROOT_DIR - a prefix to start searching.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Cache Variables: (probably not for direct use in your scripts)
|
||||||
|
|
||||||
|
PERFORMER_INCLUDE_DIR
|
||||||
|
PERFORMER_LIBRARY
|
||||||
|
PERFORMER_PFUI_LIBRARY - doesn't get included in PERFORMER_LIBRARIES
|
||||||
|
PERFORMER_PFDU_UTIL_LIBRARY - doesn't get included in PERFORMER_LIBRARIES
|
||||||
|
PERFORMER_PFV_LIBRARY - doesn't get included in PERFORMER_LIBRARIES
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Non-cache variables you might use in your CMakeLists.txt:
|
||||||
|
|
||||||
|
PERFORMER_FOUND
|
||||||
|
PERFORMER_INCLUDE_DIRS
|
||||||
|
PERFORMER_LIBRARIES
|
||||||
|
PERFORMER_RUNTIME_LIBRARY_DIRS
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Requires these CMake modules:
|
||||||
|
|
||||||
|
FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Original Author: 2012 Ryan Pavlik <rpavlik@iastate.edu>
|
||||||
|
<abiryan@ryand.net> http://academic.cleardefinition.com Iowa State
|
||||||
|
University HCI Graduate Program/VRAC
|
||||||
|
|
||||||
|
Copyright Iowa State University 2012. 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)
|
||||||
|
|
||||||
|
FindPerlModules
|
||||||
|
try to find perl modules, passed as COMPONENTS
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Non-cache variable you might use in your CMakeLists.txt:
|
||||||
|
|
||||||
|
PERLMODULES_FOUND
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Requires these CMake modules:
|
||||||
|
|
||||||
|
FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Original Author: 2012 Ryan Pavlik <rpavlik@iastate.edu>
|
||||||
|
<abiryan@ryand.net> http://academic.cleardefinition.com Iowa State
|
||||||
|
University HCI Graduate Program/VRAC
|
||||||
|
|
||||||
|
Copyright Iowa State University 2012. 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)
|
||||||
|
|
||||||
|
FindQVRPN
|
||||||
|
try to find QVRPN library
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Of course, you may also just choose to make QVRPN a submodule of your
|
||||||
|
project itself.
|
||||||
|
|
||||||
|
Cache Variables:
|
||||||
|
|
||||||
|
QVRPN_LIBRARY
|
||||||
|
QVRPN_INCLUDE_DIR
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Non-cache variables you might use in your CMakeLists.txt:
|
||||||
|
|
||||||
|
QVRPN_FOUND
|
||||||
|
QVRPN_LIBRARIES
|
||||||
|
QVRPN_INCLUDE_DIRS
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
QVRPN_ROOT_DIR is searched preferentially for these files
|
||||||
|
|
||||||
|
Requires these CMake modules:
|
||||||
|
|
||||||
|
FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Refactored from FindVRPN.cmake by: Juan Sebastian Casallas
|
||||||
|
<casallas@iastate.edu>
|
||||||
|
|
||||||
|
FindVRPN.cmake Original Author: 2009-2010 Ryan Pavlik
|
||||||
|
<rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||||
|
http://academic.cleardefinition.com Iowa State University HCI Graduate
|
||||||
|
Program/VRAC
|
||||||
|
|
||||||
|
Copyright Iowa State University 2009-2012. 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)
|
||||||
|
|
||||||
FindSonix12
|
FindSonix12
|
||||||
try to find Sonix 1.2 library
|
try to find Sonix 1.2 library
|
||||||
|
|
||||||
@@ -2416,8 +2777,10 @@ a few.
|
|||||||
Non-cache variables you might use in your CMakeLists.txt:
|
Non-cache variables you might use in your CMakeLists.txt:
|
||||||
|
|
||||||
VRPN_FOUND
|
VRPN_FOUND
|
||||||
VRPN_SERVER_LIBRARIES
|
VRPN_SERVER_LIBRARIES - server libraries
|
||||||
VRPN_LIBRARIES
|
VRPN_LIBRARIES - client libraries
|
||||||
|
VRPN_CLIENT_DEFINITIONS - definitions if you only use the client library
|
||||||
|
VRPN_DEFINITIONS - Client-only definition if all we found was the client library.
|
||||||
VRPN_INCLUDE_DIRS
|
VRPN_INCLUDE_DIRS
|
||||||
|
|
||||||
|
|
||||||
@@ -2430,14 +2793,51 @@ a few.
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
Original Author: 2009-2010 Ryan Pavlik <rpavlik@iastate.edu>
|
Original Author: 2009-2012 Ryan Pavlik <rpavlik@iastate.edu>
|
||||||
<abiryan@ryand.net> http://academic.cleardefinition.com Iowa State
|
<abiryan@ryand.net> http://academic.cleardefinition.com Iowa State
|
||||||
University HCI Graduate Program/VRAC
|
University HCI Graduate Program/VRAC
|
||||||
|
|
||||||
Copyright Iowa State University 2009-2010. Distributed under the
|
Copyright Iowa State University 2009-2012. Distributed under the
|
||||||
Boost Software License, Version 1.0. (See accompanying file
|
Boost Software License, Version 1.0. (See accompanying file
|
||||||
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
FindViewPoint
|
||||||
|
try to find Arrington Research ViewPoint EyeTracker SDK
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Cache Variables: (probably not for direct use in your scripts)
|
||||||
|
|
||||||
|
VIEWPOINT_INCLUDE_DIR
|
||||||
|
VIEWPOINT_LIBRARY
|
||||||
|
VIEWPOINT_RUNTIME_LIBRARY
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Non-cache variables you might use in your CMakeLists.txt:
|
||||||
|
|
||||||
|
VIEWPOINT_FOUND
|
||||||
|
VIEWPOINT_INCLUDE_DIRS
|
||||||
|
VIEWPOINT_LIBRARIES
|
||||||
|
VIEWPOINT_RUNTIME_LIBRARIES - aka the dll for installing
|
||||||
|
VIEWPOINT_RUNTIME_LIBRARY_DIRS
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Requires these CMake modules:
|
||||||
|
|
||||||
|
FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Original Author: 2012 Ryan Pavlik <rpavlik@iastate.edu>
|
||||||
|
<abiryan@ryand.net> http://academic.cleardefinition.com Iowa State
|
||||||
|
University HCI Graduate Program/VRAC
|
||||||
|
|
||||||
|
Copyright Iowa State University 2012. 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)
|
||||||
|
|
||||||
FindVirtuoseAPI
|
FindVirtuoseAPI
|
||||||
try to find Haption VirtuoseAPI library and include files
|
try to find Haption VirtuoseAPI library and include files
|
||||||
|
|
||||||
@@ -2578,6 +2978,48 @@ a few.
|
|||||||
Boost Software License, Version 1.0. (See accompanying file
|
Boost Software License, Version 1.0. (See accompanying file
|
||||||
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
FindWindowsSDK
|
||||||
|
Find the Windows SDK aka Platform SDK
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Variables:
|
||||||
|
|
||||||
|
WINDOWSSDK_FOUND - if any version of the windows or platform SDK was found that is usable with the current version of visual studio
|
||||||
|
WINDOWSSDK_LATEST_DIR
|
||||||
|
WINDOWSSDK_LATEST_NAME
|
||||||
|
WINDOWSSDK_FOUND_PREFERENCE - if we found an entry indicating a "preferred" SDK listed for this visual studio version
|
||||||
|
WINDOWSSDK_PREFERRED_DIR
|
||||||
|
WINDOWSSDK_PREFERRED_NAME
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
WINDOWSSDK_DIRS - contains no duplicates, ordered most recent first.
|
||||||
|
WINDOWSSDK_PREFERRED_FIRST_DIRS - contains no duplicates, ordered with preferred first, followed by the rest in descending recency
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Functions:
|
||||||
|
|
||||||
|
windowssdk_name_lookup(<directory> <output variable>) - Find the name corresponding with the SDK directory you pass in, or
|
||||||
|
NOTFOUND if not recognized. Your directory must be one of WINDOWSSDK_DIRS for this to work.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Requires these CMake modules:
|
||||||
|
|
||||||
|
FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Original Author: 2012 Ryan Pavlik <rpavlik@iastate.edu>
|
||||||
|
<abiryan@ryand.net> http://academic.cleardefinition.com Iowa State
|
||||||
|
University HCI Graduate Program/VRAC
|
||||||
|
|
||||||
|
Copyright Iowa State University 2012. 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)
|
||||||
|
|
||||||
Findargp
|
Findargp
|
||||||
try to find the argp library/component of glibc
|
try to find the argp library/component of glibc
|
||||||
|
|
||||||
@@ -3002,20 +3444,20 @@ a few.
|
|||||||
These functions force a re-configure on each git commit so that you
|
These functions force a re-configure on each git commit so that you
|
||||||
can trust the values of the variables in your build system.
|
can trust the values of the variables in your build system.
|
||||||
|
|
||||||
get_git_head_revision(<refspecvar> <hashvar> [<additonal arguments to git describe> ...])
|
get_git_head_revision(<refspecvar> <hashvar> [<additional arguments to git describe> ...])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Returns the refspec and sha hash of the current head revision
|
Returns the refspec and sha hash of the current head revision
|
||||||
|
|
||||||
git_describe(<var> [<additonal arguments to git describe> ...])
|
git_describe(<var> [<additional arguments to git describe> ...])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Returns the results of git describe on the source tree, and adjusting
|
Returns the results of git describe on the source tree, and adjusting
|
||||||
the output so that it tests false if an error occurs.
|
the output so that it tests false if an error occurs.
|
||||||
|
|
||||||
git_get_exact_tag(<var> [<additonal arguments to git describe> ...])
|
git_get_exact_tag(<var> [<additional arguments to git describe> ...])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -3463,6 +3905,37 @@ a few.
|
|||||||
Boost Software License, Version 1.0. (See accompanying file
|
Boost Software License, Version 1.0. (See accompanying file
|
||||||
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
UseMarkdown
|
||||||
|
Convert markdown source files to HTML as a custom target
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
include(UseMarkdown)
|
||||||
|
add_markdown_target(<target_name> <directory to copy to> <markdownfile> [<markdownfile>...] [RENAME <newname>])
|
||||||
|
Relative paths for the destination directory are considered with
|
||||||
|
with respect to CMAKE_CURRENT_BINARY_DIR. The RENAME argument is only
|
||||||
|
valid with a single markdown file as input.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
install_markdown_target(<target_name> [extra arguments to INSTALL(FILES ...) ])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Requires CMake 2.6 or newer (uses the 'function' command)
|
||||||
|
|
||||||
|
Original Author: 2011 Ryan Pavlik <rpavlik@iastate.edu>
|
||||||
|
<abiryan@ryand.net> http://academic.cleardefinition.com Iowa State
|
||||||
|
University HCI Graduate Program/VRAC
|
||||||
|
|
||||||
|
Copyright Iowa State University 2011-2012. 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)
|
||||||
|
|
||||||
UseTR1
|
UseTR1
|
||||||
Use settings to enable access to C++ TR1
|
Use settings to enable access to C++ TR1
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ foreach(filename ansi.hxx
|
|||||||
ehlc_timer.hxx
|
ehlc_timer.hxx
|
||||||
face.cpp
|
face.cpp
|
||||||
face.hxx
|
face.hxx
|
||||||
files.txt
|
|
||||||
frustum.cpp
|
frustum.cpp
|
||||||
frustum.hxx
|
frustum.hxx
|
||||||
hldeb.hxx
|
hldeb.hxx
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
# Original Author:
|
# Original Author:
|
||||||
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
# 2009-2012 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||||
# http://academic.cleardefinition.com
|
# http://academic.cleardefinition.com
|
||||||
# Iowa State University HCI Graduate Program/VRAC
|
# Iowa State University HCI Graduate Program/VRAC
|
||||||
#
|
#
|
||||||
# Copyright Iowa State University 2009-2010.
|
# Copyright Iowa State University 2009-2012.
|
||||||
# Distributed under the Boost Software License, Version 1.0.
|
# Distributed under the Boost Software License, Version 1.0.
|
||||||
# (See accompanying file ../LICENSE_1_0.txt or copy at
|
# (See accompanying file ../LICENSE_1_0.txt or copy at
|
||||||
# http://www.boost.org/LICENSE_1_0.txt)
|
# http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
add_proprietary_license("VR JuggLua"
|
add_permissive_license("VR JuggLua"
|
||||||
"Based in part on VR JuggLua, Copyright 2010 Iowa State University. This version of VR JuggLua is unreleased research software - NOT FOR REDISTRIBUTION.")
|
"Based in part on VR JuggLua, Copyright 2010-2012 Iowa State University. VR JuggLua is distributed under the Boost Software License, Version 1.0. See copy at http://www.boost.org/LICENSE_1_0.txt"
|
||||||
add_redistribution_warning("This version of VR JuggLua is unreleased research software - NOT FOR REDISTRIBUTION.")
|
"<https://github.com/vance-group/vr-jugglua>")
|
||||||
include("package-licensing/VRJuggler")
|
include("package-licensing/VRJuggler")
|
||||||
include("package-licensing/OpenSceneGraph")
|
include("package-licensing/OpenSceneGraph")
|
||||||
include("package-licensing/Lua")
|
include("package-licensing/Lua")
|
||||||
|
|||||||
@@ -123,18 +123,23 @@ void set_material(struct material_t* mptr);
|
|||||||
void resize_window(GLint new_width, GLint new_height);
|
void resize_window(GLint new_width, GLint new_height);
|
||||||
|
|
||||||
void handle_event(struct wiimote_t* wm) {
|
void handle_event(struct wiimote_t* wm) {
|
||||||
if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_PLUS))
|
if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_PLUS)) {
|
||||||
wiiuse_motion_sensing(wm, 1);
|
wiiuse_motion_sensing(wm, 1);
|
||||||
if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_MINUS))
|
}
|
||||||
|
if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_MINUS)) {
|
||||||
wiiuse_motion_sensing(wm, 0);
|
wiiuse_motion_sensing(wm, 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_UP))
|
if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_UP)) {
|
||||||
wiiuse_set_ir(wm, 1);
|
wiiuse_set_ir(wm, 1);
|
||||||
if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_DOWN))
|
}
|
||||||
|
if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_DOWN)) {
|
||||||
wiiuse_set_ir(wm, 0);
|
wiiuse_set_ir(wm, 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_B))
|
if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_B)) {
|
||||||
wiiuse_toggle_rumble(wm);
|
wiiuse_toggle_rumble(wm);
|
||||||
|
}
|
||||||
|
|
||||||
if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_ONE)) {
|
if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_ONE)) {
|
||||||
int level;
|
int level;
|
||||||
@@ -149,10 +154,11 @@ void handle_event(struct wiimote_t* wm) {
|
|||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_A)) {
|
if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_A)) {
|
||||||
if (render_mode == IR)
|
if (render_mode == IR) {
|
||||||
render_mode = TEAPOT;
|
render_mode = TEAPOT;
|
||||||
else
|
} else {
|
||||||
render_mode = IR;
|
render_mode = IR;
|
||||||
|
}
|
||||||
resize_window(width, height);
|
resize_window(width, height);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -167,8 +173,9 @@ void handle_event(struct wiimote_t* wm) {
|
|||||||
int can_render() {
|
int can_render() {
|
||||||
/* quick fps limit to ~60fps -- not too fancy, could be better */
|
/* quick fps limit to ~60fps -- not too fancy, could be better */
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
if (GetTickCount() < (last_render + 16))
|
if (GetTickCount() < (last_render + 16)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
last_render = GetTickCount();
|
last_render = GetTickCount();
|
||||||
return 1;
|
return 1;
|
||||||
#else
|
#else
|
||||||
@@ -182,13 +189,15 @@ int can_render() {
|
|||||||
++now.tv_sec;
|
++now.tv_sec;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (now.tv_sec > last_render.tv_sec)
|
if (now.tv_sec > last_render.tv_sec) {
|
||||||
elapsed_usec = ((now.tv_sec - last_render.tv_sec) * 1000000);
|
elapsed_usec = ((now.tv_sec - last_render.tv_sec) * 1000000);
|
||||||
|
}
|
||||||
|
|
||||||
if (now.tv_usec > last_render.tv_usec)
|
if (now.tv_usec > last_render.tv_usec) {
|
||||||
elapsed_usec += now.tv_usec - last_render.tv_usec;
|
elapsed_usec += now.tv_usec - last_render.tv_usec;
|
||||||
else
|
} else {
|
||||||
elapsed_usec += last_render.tv_usec - now.tv_usec;
|
elapsed_usec += last_render.tv_usec - now.tv_usec;
|
||||||
|
}
|
||||||
|
|
||||||
if (time(NULL) > last_sec) {
|
if (time(NULL) > last_sec) {
|
||||||
printf("fps: %i\n", fps);
|
printf("fps: %i\n", fps);
|
||||||
@@ -196,8 +205,9 @@ int can_render() {
|
|||||||
last_sec = time(NULL);
|
last_sec = time(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elapsed_usec < 16000)
|
if (elapsed_usec < 16000) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
last_render = now;
|
last_render = now;
|
||||||
++fps;
|
++fps;
|
||||||
@@ -210,8 +220,9 @@ void display() {
|
|||||||
int i, wm;
|
int i, wm;
|
||||||
float size = 5;
|
float size = 5;
|
||||||
|
|
||||||
if (!can_render())
|
if (!can_render()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
@@ -233,16 +244,18 @@ void display() {
|
|||||||
/* red ir */
|
/* red ir */
|
||||||
glColor3f(1.0, 0.0, 0.0);
|
glColor3f(1.0, 0.0, 0.0);
|
||||||
for (i = 0; i < 4; ++i) {
|
for (i = 0; i < 4; ++i) {
|
||||||
if (wiimotes[wm]->ir.dot[i].visible)
|
if (wiimotes[wm]->ir.dot[i].visible) {
|
||||||
DRAW_TRIANGLE(wiimotes[wm]->ir.dot[i].rx, wiimotes[wm]->ir.dot[i].ry, 0, size);
|
DRAW_TRIANGLE(wiimotes[wm]->ir.dot[i].rx, wiimotes[wm]->ir.dot[i].ry, 0, size);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* yellow corrected ir */
|
/* yellow corrected ir */
|
||||||
glColor3f(1.0, 1.0, 0.0);
|
glColor3f(1.0, 1.0, 0.0);
|
||||||
for (i = 0; i < 4; ++i) {
|
for (i = 0; i < 4; ++i) {
|
||||||
if (wiimotes[wm]->ir.dot[i].visible)
|
if (wiimotes[wm]->ir.dot[i].visible) {
|
||||||
DRAW_TRIANGLE(wiimotes[wm]->ir.dot[i].x, wiimotes[wm]->ir.dot[i].y, 0, size);
|
DRAW_TRIANGLE(wiimotes[wm]->ir.dot[i].x, wiimotes[wm]->ir.dot[i].y, 0, size);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* blue cursor */
|
/* blue cursor */
|
||||||
glColor3f(0.0, 0.0, 1.0);
|
glColor3f(0.0, 0.0, 1.0);
|
||||||
@@ -300,8 +313,9 @@ void resize_window(GLint new_width, GLint new_height) {
|
|||||||
width = new_width;
|
width = new_width;
|
||||||
height = new_height;
|
height = new_height;
|
||||||
|
|
||||||
if (new_height == 0)
|
if (new_height == 0) {
|
||||||
new_height = 1;
|
new_height = 1;
|
||||||
|
}
|
||||||
|
|
||||||
SDL_SetVideoMode(width, height, 16, SDL_RESIZABLE | SDL_OPENGL);
|
SDL_SetVideoMode(width, height, 16, SDL_RESIZABLE | SDL_OPENGL);
|
||||||
|
|
||||||
@@ -310,10 +324,11 @@ void resize_window(GLint new_width, GLint new_height) {
|
|||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
if (render_mode == IR)
|
if (render_mode == IR) {
|
||||||
gluOrtho2D(0, width, height, 0);
|
gluOrtho2D(0, width, height, 0);
|
||||||
else
|
} else {
|
||||||
gluPerspective(60.0f, (float)new_width / (float)new_height, 0.1f, 100.0f);
|
gluPerspective(60.0f, (float)new_width / (float)new_height, 0.1f, 100.0f);
|
||||||
|
}
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
@@ -321,9 +336,10 @@ void resize_window(GLint new_width, GLint new_height) {
|
|||||||
width = new_width;
|
width = new_width;
|
||||||
height = new_height;
|
height = new_height;
|
||||||
|
|
||||||
for (wm = 0; wm < MAX_WIIMOTES; ++wm)
|
for (wm = 0; wm < MAX_WIIMOTES; ++wm) {
|
||||||
wiiuse_set_ir_vres(wiimotes[wm], width, height);
|
wiiuse_set_ir_vres(wiimotes[wm], width, height);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
@@ -337,12 +353,13 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
|||||||
|
|
||||||
wiimotes = wiiuse_init(MAX_WIIMOTES);
|
wiimotes = wiiuse_init(MAX_WIIMOTES);
|
||||||
found = wiiuse_find(wiimotes, MAX_WIIMOTES, 5);
|
found = wiiuse_find(wiimotes, MAX_WIIMOTES, 5);
|
||||||
if (!found)
|
if (!found) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
connected = wiiuse_connect(wiimotes, MAX_WIIMOTES);
|
connected = wiiuse_connect(wiimotes, MAX_WIIMOTES);
|
||||||
if (connected)
|
if (connected) {
|
||||||
printf("Connected to %i wiimotes (of %i found).\n", connected, found);
|
printf("Connected to %i wiimotes (of %i found).\n", connected, found);
|
||||||
else {
|
} else {
|
||||||
printf("Failed to connect to any wiimote.\n");
|
printf("Failed to connect to any wiimote.\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -379,8 +396,9 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
|||||||
height = wiimotes[0]->ir.vres[1];
|
height = wiimotes[0]->ir.vres[1];
|
||||||
SDL_SetVideoMode(width, height, 16, SDL_RESIZABLE | SDL_OPENGL);
|
SDL_SetVideoMode(width, height, 16, SDL_RESIZABLE | SDL_OPENGL);
|
||||||
|
|
||||||
for (wm = 0; wm < MAX_WIIMOTES; ++wm)
|
for (wm = 0; wm < MAX_WIIMOTES; ++wm) {
|
||||||
wiiuse_set_ir_vres(wiimotes[wm], width, height);
|
wiiuse_set_ir_vres(wiimotes[wm], width, height);
|
||||||
|
}
|
||||||
|
|
||||||
/* set OpenGL stuff */
|
/* set OpenGL stuff */
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
@@ -406,21 +424,18 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
|||||||
|
|
||||||
if (SDL_PollEvent(&event)) {
|
if (SDL_PollEvent(&event)) {
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case SDL_VIDEORESIZE:
|
case SDL_VIDEORESIZE: {
|
||||||
{
|
|
||||||
/* resize the window */
|
/* resize the window */
|
||||||
resize_window(event.resize.w, event.resize.h);
|
resize_window(event.resize.w, event.resize.h);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_QUIT:
|
case SDL_QUIT: {
|
||||||
{
|
|
||||||
/* shutdown */
|
/* shutdown */
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
wiiuse_cleanup(wiimotes, MAX_WIIMOTES);
|
wiiuse_cleanup(wiimotes, MAX_WIIMOTES);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
default:
|
default: {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,12 +36,11 @@
|
|||||||
|
|
||||||
#include <stdio.h> /* for printf */
|
#include <stdio.h> /* for printf */
|
||||||
|
|
||||||
#ifndef WIN32
|
|
||||||
#include <unistd.h> /* for usleep */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "wiiuse.h" /* for wiimote_t, classic_ctrl_t, etc */
|
#include "wiiuse.h" /* for wiimote_t, classic_ctrl_t, etc */
|
||||||
|
|
||||||
|
#ifndef WIIUSE_WIN32
|
||||||
|
#include <unistd.h> /* for usleep */
|
||||||
|
#endif
|
||||||
|
|
||||||
#define MAX_WIIMOTES 4
|
#define MAX_WIIMOTES 4
|
||||||
|
|
||||||
@@ -58,57 +57,83 @@ void handle_event(struct wiimote_t* wm) {
|
|||||||
printf("\n\n--- EVENT [id %i] ---\n", wm->unid);
|
printf("\n\n--- EVENT [id %i] ---\n", wm->unid);
|
||||||
|
|
||||||
/* if a button is pressed, report it */
|
/* if a button is pressed, report it */
|
||||||
if (IS_PRESSED(wm, WIIMOTE_BUTTON_A)) printf("A pressed\n");
|
if (IS_PRESSED(wm, WIIMOTE_BUTTON_A)) {
|
||||||
if (IS_PRESSED(wm, WIIMOTE_BUTTON_B)) printf("B pressed\n");
|
printf("A pressed\n");
|
||||||
if (IS_PRESSED(wm, WIIMOTE_BUTTON_UP)) printf("UP pressed\n");
|
}
|
||||||
if (IS_PRESSED(wm, WIIMOTE_BUTTON_DOWN)) printf("DOWN pressed\n");
|
if (IS_PRESSED(wm, WIIMOTE_BUTTON_B)) {
|
||||||
if (IS_PRESSED(wm, WIIMOTE_BUTTON_LEFT)) printf("LEFT pressed\n");
|
printf("B pressed\n");
|
||||||
if (IS_PRESSED(wm, WIIMOTE_BUTTON_RIGHT)) printf("RIGHT pressed\n");
|
}
|
||||||
if (IS_PRESSED(wm, WIIMOTE_BUTTON_MINUS)) printf("MINUS pressed\n");
|
if (IS_PRESSED(wm, WIIMOTE_BUTTON_UP)) {
|
||||||
if (IS_PRESSED(wm, WIIMOTE_BUTTON_PLUS)) printf("PLUS pressed\n");
|
printf("UP pressed\n");
|
||||||
if (IS_PRESSED(wm, WIIMOTE_BUTTON_ONE)) printf("ONE pressed\n");
|
}
|
||||||
if (IS_PRESSED(wm, WIIMOTE_BUTTON_TWO)) printf("TWO pressed\n");
|
if (IS_PRESSED(wm, WIIMOTE_BUTTON_DOWN)) {
|
||||||
if (IS_PRESSED(wm, WIIMOTE_BUTTON_HOME)) printf("HOME pressed\n");
|
printf("DOWN pressed\n");
|
||||||
|
}
|
||||||
|
if (IS_PRESSED(wm, WIIMOTE_BUTTON_LEFT)) {
|
||||||
|
printf("LEFT pressed\n");
|
||||||
|
}
|
||||||
|
if (IS_PRESSED(wm, WIIMOTE_BUTTON_RIGHT)) {
|
||||||
|
printf("RIGHT pressed\n");
|
||||||
|
}
|
||||||
|
if (IS_PRESSED(wm, WIIMOTE_BUTTON_MINUS)) {
|
||||||
|
printf("MINUS pressed\n");
|
||||||
|
}
|
||||||
|
if (IS_PRESSED(wm, WIIMOTE_BUTTON_PLUS)) {
|
||||||
|
printf("PLUS pressed\n");
|
||||||
|
}
|
||||||
|
if (IS_PRESSED(wm, WIIMOTE_BUTTON_ONE)) {
|
||||||
|
printf("ONE pressed\n");
|
||||||
|
}
|
||||||
|
if (IS_PRESSED(wm, WIIMOTE_BUTTON_TWO)) {
|
||||||
|
printf("TWO pressed\n");
|
||||||
|
}
|
||||||
|
if (IS_PRESSED(wm, WIIMOTE_BUTTON_HOME)) {
|
||||||
|
printf("HOME pressed\n");
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Pressing minus will tell the wiimote we are no longer interested in movement.
|
* Pressing minus will tell the wiimote we are no longer interested in movement.
|
||||||
* This is useful because it saves battery power.
|
* This is useful because it saves battery power.
|
||||||
*/
|
*/
|
||||||
if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_MINUS))
|
if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_MINUS)) {
|
||||||
wiiuse_motion_sensing(wm, 0);
|
wiiuse_motion_sensing(wm, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Pressing plus will tell the wiimote we are interested in movement.
|
* Pressing plus will tell the wiimote we are interested in movement.
|
||||||
*/
|
*/
|
||||||
if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_PLUS))
|
if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_PLUS)) {
|
||||||
wiiuse_motion_sensing(wm, 1);
|
wiiuse_motion_sensing(wm, 1);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Pressing B will toggle the rumble
|
* Pressing B will toggle the rumble
|
||||||
*
|
*
|
||||||
* if B is pressed but is not held, toggle the rumble
|
* if B is pressed but is not held, toggle the rumble
|
||||||
*/
|
*/
|
||||||
if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_B))
|
if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_B)) {
|
||||||
wiiuse_toggle_rumble(wm);
|
wiiuse_toggle_rumble(wm);
|
||||||
|
}
|
||||||
|
|
||||||
if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_UP))
|
if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_UP)) {
|
||||||
wiiuse_set_ir(wm, 1);
|
wiiuse_set_ir(wm, 1);
|
||||||
if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_DOWN))
|
}
|
||||||
|
if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_DOWN)) {
|
||||||
wiiuse_set_ir(wm, 0);
|
wiiuse_set_ir(wm, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Motion+ support
|
* Motion+ support
|
||||||
*/
|
*/
|
||||||
if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_ONE))
|
if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_ONE)) {
|
||||||
{
|
if (WIIUSE_USING_EXP(wm)) {
|
||||||
if(WIIUSE_USING_EXP(wm))
|
|
||||||
wiiuse_set_motion_plus(wm, 2); // nunchuck pass-through
|
wiiuse_set_motion_plus(wm, 2); // nunchuck pass-through
|
||||||
else
|
} else {
|
||||||
wiiuse_set_motion_plus(wm, 1); // standalone
|
wiiuse_set_motion_plus(wm, 1); // standalone
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_TWO))
|
if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_TWO)) {
|
||||||
{
|
|
||||||
wiiuse_set_motion_plus(wm, 0); // off
|
wiiuse_set_motion_plus(wm, 0); // off
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,9 +156,10 @@ void handle_event(struct wiimote_t* wm) {
|
|||||||
/* go through each of the 4 possible IR sources */
|
/* go through each of the 4 possible IR sources */
|
||||||
for (; i < 4; ++i) {
|
for (; i < 4; ++i) {
|
||||||
/* check if the source is visible */
|
/* check if the source is visible */
|
||||||
if (wm->ir.dot[i].visible)
|
if (wm->ir.dot[i].visible) {
|
||||||
printf("IR source %i: (%u, %u)\n", i, wm->ir.dot[i].x, wm->ir.dot[i].y);
|
printf("IR source %i: (%u, %u)\n", i, wm->ir.dot[i].x, wm->ir.dot[i].y);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
printf("IR cursor: (%u, %u)\n", wm->ir.x, wm->ir.y);
|
printf("IR cursor: (%u, %u)\n", wm->ir.x, wm->ir.y);
|
||||||
printf("IR z distance: %f\n", wm->ir.z);
|
printf("IR z distance: %f\n", wm->ir.z);
|
||||||
@@ -144,8 +170,12 @@ void handle_event(struct wiimote_t* wm) {
|
|||||||
/* nunchuk */
|
/* nunchuk */
|
||||||
struct nunchuk_t* nc = (nunchuk_t*)&wm->exp.nunchuk;
|
struct nunchuk_t* nc = (nunchuk_t*)&wm->exp.nunchuk;
|
||||||
|
|
||||||
if (IS_PRESSED(nc, NUNCHUK_BUTTON_C)) printf("Nunchuk: C pressed\n");
|
if (IS_PRESSED(nc, NUNCHUK_BUTTON_C)) {
|
||||||
if (IS_PRESSED(nc, NUNCHUK_BUTTON_Z)) printf("Nunchuk: Z pressed\n");
|
printf("Nunchuk: C pressed\n");
|
||||||
|
}
|
||||||
|
if (IS_PRESSED(nc, NUNCHUK_BUTTON_Z)) {
|
||||||
|
printf("Nunchuk: Z pressed\n");
|
||||||
|
}
|
||||||
|
|
||||||
printf("nunchuk roll = %f\n", nc->orient.roll);
|
printf("nunchuk roll = %f\n", nc->orient.roll);
|
||||||
printf("nunchuk pitch = %f\n", nc->orient.pitch);
|
printf("nunchuk pitch = %f\n", nc->orient.pitch);
|
||||||
@@ -157,21 +187,51 @@ void handle_event(struct wiimote_t* wm) {
|
|||||||
/* classic controller */
|
/* classic controller */
|
||||||
struct classic_ctrl_t* cc = (classic_ctrl_t*)&wm->exp.classic;
|
struct classic_ctrl_t* cc = (classic_ctrl_t*)&wm->exp.classic;
|
||||||
|
|
||||||
if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_ZL)) printf("Classic: ZL pressed\n");
|
if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_ZL)) {
|
||||||
if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_B)) printf("Classic: B pressed\n");
|
printf("Classic: ZL pressed\n");
|
||||||
if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_Y)) printf("Classic: Y pressed\n");
|
}
|
||||||
if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_A)) printf("Classic: A pressed\n");
|
if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_B)) {
|
||||||
if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_X)) printf("Classic: X pressed\n");
|
printf("Classic: B pressed\n");
|
||||||
if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_ZR)) printf("Classic: ZR pressed\n");
|
}
|
||||||
if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_LEFT)) printf("Classic: LEFT pressed\n");
|
if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_Y)) {
|
||||||
if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_UP)) printf("Classic: UP pressed\n");
|
printf("Classic: Y pressed\n");
|
||||||
if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_RIGHT)) printf("Classic: RIGHT pressed\n");
|
}
|
||||||
if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_DOWN)) printf("Classic: DOWN pressed\n");
|
if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_A)) {
|
||||||
if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_FULL_L)) printf("Classic: FULL L pressed\n");
|
printf("Classic: A pressed\n");
|
||||||
if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_MINUS)) printf("Classic: MINUS pressed\n");
|
}
|
||||||
if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_HOME)) printf("Classic: HOME pressed\n");
|
if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_X)) {
|
||||||
if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_PLUS)) printf("Classic: PLUS pressed\n");
|
printf("Classic: X pressed\n");
|
||||||
if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_FULL_R)) printf("Classic: FULL R pressed\n");
|
}
|
||||||
|
if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_ZR)) {
|
||||||
|
printf("Classic: ZR pressed\n");
|
||||||
|
}
|
||||||
|
if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_LEFT)) {
|
||||||
|
printf("Classic: LEFT pressed\n");
|
||||||
|
}
|
||||||
|
if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_UP)) {
|
||||||
|
printf("Classic: UP pressed\n");
|
||||||
|
}
|
||||||
|
if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_RIGHT)) {
|
||||||
|
printf("Classic: RIGHT pressed\n");
|
||||||
|
}
|
||||||
|
if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_DOWN)) {
|
||||||
|
printf("Classic: DOWN pressed\n");
|
||||||
|
}
|
||||||
|
if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_FULL_L)) {
|
||||||
|
printf("Classic: FULL L pressed\n");
|
||||||
|
}
|
||||||
|
if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_MINUS)) {
|
||||||
|
printf("Classic: MINUS pressed\n");
|
||||||
|
}
|
||||||
|
if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_HOME)) {
|
||||||
|
printf("Classic: HOME pressed\n");
|
||||||
|
}
|
||||||
|
if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_PLUS)) {
|
||||||
|
printf("Classic: PLUS pressed\n");
|
||||||
|
}
|
||||||
|
if (IS_PRESSED(cc, CLASSIC_CTRL_BUTTON_FULL_R)) {
|
||||||
|
printf("Classic: FULL R pressed\n");
|
||||||
|
}
|
||||||
|
|
||||||
printf("classic L button pressed: %f\n", cc->l_shoulder);
|
printf("classic L button pressed: %f\n", cc->l_shoulder);
|
||||||
printf("classic R button pressed: %f\n", cc->r_shoulder);
|
printf("classic R button pressed: %f\n", cc->r_shoulder);
|
||||||
@@ -183,15 +243,33 @@ void handle_event(struct wiimote_t* wm) {
|
|||||||
/* guitar hero 3 guitar */
|
/* guitar hero 3 guitar */
|
||||||
struct guitar_hero_3_t* gh3 = (guitar_hero_3_t*)&wm->exp.gh3;
|
struct guitar_hero_3_t* gh3 = (guitar_hero_3_t*)&wm->exp.gh3;
|
||||||
|
|
||||||
if (IS_PRESSED(gh3, GUITAR_HERO_3_BUTTON_STRUM_UP)) printf("Guitar: Strum Up pressed\n");
|
if (IS_PRESSED(gh3, GUITAR_HERO_3_BUTTON_STRUM_UP)) {
|
||||||
if (IS_PRESSED(gh3, GUITAR_HERO_3_BUTTON_STRUM_DOWN)) printf("Guitar: Strum Down pressed\n");
|
printf("Guitar: Strum Up pressed\n");
|
||||||
if (IS_PRESSED(gh3, GUITAR_HERO_3_BUTTON_YELLOW)) printf("Guitar: Yellow pressed\n");
|
}
|
||||||
if (IS_PRESSED(gh3, GUITAR_HERO_3_BUTTON_GREEN)) printf("Guitar: Green pressed\n");
|
if (IS_PRESSED(gh3, GUITAR_HERO_3_BUTTON_STRUM_DOWN)) {
|
||||||
if (IS_PRESSED(gh3, GUITAR_HERO_3_BUTTON_BLUE)) printf("Guitar: Blue pressed\n");
|
printf("Guitar: Strum Down pressed\n");
|
||||||
if (IS_PRESSED(gh3, GUITAR_HERO_3_BUTTON_RED)) printf("Guitar: Red pressed\n");
|
}
|
||||||
if (IS_PRESSED(gh3, GUITAR_HERO_3_BUTTON_ORANGE)) printf("Guitar: Orange pressed\n");
|
if (IS_PRESSED(gh3, GUITAR_HERO_3_BUTTON_YELLOW)) {
|
||||||
if (IS_PRESSED(gh3, GUITAR_HERO_3_BUTTON_PLUS)) printf("Guitar: Plus pressed\n");
|
printf("Guitar: Yellow pressed\n");
|
||||||
if (IS_PRESSED(gh3, GUITAR_HERO_3_BUTTON_MINUS)) printf("Guitar: Minus pressed\n");
|
}
|
||||||
|
if (IS_PRESSED(gh3, GUITAR_HERO_3_BUTTON_GREEN)) {
|
||||||
|
printf("Guitar: Green pressed\n");
|
||||||
|
}
|
||||||
|
if (IS_PRESSED(gh3, GUITAR_HERO_3_BUTTON_BLUE)) {
|
||||||
|
printf("Guitar: Blue pressed\n");
|
||||||
|
}
|
||||||
|
if (IS_PRESSED(gh3, GUITAR_HERO_3_BUTTON_RED)) {
|
||||||
|
printf("Guitar: Red pressed\n");
|
||||||
|
}
|
||||||
|
if (IS_PRESSED(gh3, GUITAR_HERO_3_BUTTON_ORANGE)) {
|
||||||
|
printf("Guitar: Orange pressed\n");
|
||||||
|
}
|
||||||
|
if (IS_PRESSED(gh3, GUITAR_HERO_3_BUTTON_PLUS)) {
|
||||||
|
printf("Guitar: Plus pressed\n");
|
||||||
|
}
|
||||||
|
if (IS_PRESSED(gh3, GUITAR_HERO_3_BUTTON_MINUS)) {
|
||||||
|
printf("Guitar: Minus pressed\n");
|
||||||
|
}
|
||||||
|
|
||||||
printf("Guitar whammy bar: %f\n", gh3->whammy_bar);
|
printf("Guitar whammy bar: %f\n", gh3->whammy_bar);
|
||||||
printf("Guitar joystick angle: %f\n", gh3->js.ang);
|
printf("Guitar joystick angle: %f\n", gh3->js.ang);
|
||||||
@@ -208,8 +286,7 @@ void handle_event(struct wiimote_t* wm) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wm->exp.type == EXP_MOTION_PLUS ||
|
if (wm->exp.type == EXP_MOTION_PLUS ||
|
||||||
wm->exp.type == EXP_MOTION_PLUS_NUNCHUK)
|
wm->exp.type == EXP_MOTION_PLUS_NUNCHUK) {
|
||||||
{
|
|
||||||
printf("Motion+ angular rates (deg/sec): pitch:%03.2f roll:%03.2f yaw:%03.2f\n",
|
printf("Motion+ angular rates (deg/sec): pitch:%03.2f roll:%03.2f yaw:%03.2f\n",
|
||||||
wm->exp.mp.angle_rate_gyro.pitch,
|
wm->exp.mp.angle_rate_gyro.pitch,
|
||||||
wm->exp.mp.angle_rate_gyro.roll,
|
wm->exp.mp.angle_rate_gyro.roll,
|
||||||
@@ -241,8 +318,9 @@ void handle_read(struct wiimote_t* wm, byte* data, unsigned short len) {
|
|||||||
printf("\n\n--- DATA READ [wiimote id %i] ---\n", wm->unid);
|
printf("\n\n--- DATA READ [wiimote id %i] ---\n", wm->unid);
|
||||||
printf("finished read of size %i\n", len);
|
printf("finished read of size %i\n", len);
|
||||||
for (; i < len; ++i) {
|
for (; i < len; ++i) {
|
||||||
if (!(i%16))
|
if (!(i % 16)) {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
}
|
||||||
printf("%x ", data[i]);
|
printf("%x ", data[i]);
|
||||||
}
|
}
|
||||||
printf("\n\n");
|
printf("\n\n");
|
||||||
@@ -294,6 +372,20 @@ void test(struct wiimote_t* wm, byte* data, unsigned short len) {
|
|||||||
printf("test: %i [%x %x %x %x]\n", len, data[0], data[1], data[2], data[3]);
|
printf("test: %i [%x %x %x %x]\n", len, data[0], data[1], data[2], data[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
short any_wiimote_connected(wiimote** wm, int wiimotes) {
|
||||||
|
int i;
|
||||||
|
if (!wm) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < wiimotes; i++) {
|
||||||
|
if (wm[i] && WIIMOTE_IS_CONNECTED(wm[i])) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -340,9 +432,9 @@ int main(int argc, char** argv) {
|
|||||||
* This will return the number of established connections to the found wiimotes.
|
* This will return the number of established connections to the found wiimotes.
|
||||||
*/
|
*/
|
||||||
connected = wiiuse_connect(wiimotes, MAX_WIIMOTES);
|
connected = wiiuse_connect(wiimotes, MAX_WIIMOTES);
|
||||||
if (connected)
|
if (connected) {
|
||||||
printf("Connected to %i wiimotes (of %i found).\n", connected, found);
|
printf("Connected to %i wiimotes (of %i found).\n", connected, found);
|
||||||
else {
|
} else {
|
||||||
printf("Failed to connect to any wiimote.\n");
|
printf("Failed to connect to any wiimote.\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -358,7 +450,7 @@ int main(int argc, char** argv) {
|
|||||||
wiiuse_rumble(wiimotes[0], 1);
|
wiiuse_rumble(wiimotes[0], 1);
|
||||||
wiiuse_rumble(wiimotes[1], 1);
|
wiiuse_rumble(wiimotes[1], 1);
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIIUSE_WIN32
|
||||||
usleep(200000);
|
usleep(200000);
|
||||||
#else
|
#else
|
||||||
Sleep(200);
|
Sleep(200);
|
||||||
@@ -367,6 +459,13 @@ int main(int argc, char** argv) {
|
|||||||
wiiuse_rumble(wiimotes[0], 0);
|
wiiuse_rumble(wiimotes[0], 0);
|
||||||
wiiuse_rumble(wiimotes[1], 0);
|
wiiuse_rumble(wiimotes[1], 0);
|
||||||
|
|
||||||
|
printf("\nControls:\n");
|
||||||
|
printf("\tB toggles rumble.\n");
|
||||||
|
printf("\t+ to start Wiimote accelerometer reporting, - to stop\n");
|
||||||
|
printf("\tUP to start IR camera (sensor bar mode), DOWN to stop.\n");
|
||||||
|
printf("\t1 to start Motion+ reporting, 2 to stop.\n");
|
||||||
|
printf("\n\n");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Maybe I'm interested in the battery power of the 0th
|
* Maybe I'm interested in the battery power of the 0th
|
||||||
* wiimote. This should be WIIMOTE_ID_1 but to be sure
|
* wiimote. This should be WIIMOTE_ID_1 but to be sure
|
||||||
@@ -390,7 +489,7 @@ int main(int argc, char** argv) {
|
|||||||
* This function will set the event flag for each wiimote
|
* This function will set the event flag for each wiimote
|
||||||
* when the wiimote has things to report.
|
* when the wiimote has things to report.
|
||||||
*/
|
*/
|
||||||
while (1) {
|
while (any_wiimote_connected(wiimotes, MAX_WIIMOTES)) {
|
||||||
if (wiiuse_poll(wiimotes, MAX_WIIMOTES)) {
|
if (wiiuse_poll(wiimotes, MAX_WIIMOTES)) {
|
||||||
/*
|
/*
|
||||||
* This happens if something happened on any wiimote.
|
* This happens if something happened on any wiimote.
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ set(SOURCES
|
|||||||
wiiboard.c
|
wiiboard.c
|
||||||
classic.h
|
classic.h
|
||||||
definitions.h
|
definitions.h
|
||||||
|
definitions_os.h
|
||||||
dynamics.h
|
dynamics.h
|
||||||
events.h
|
events.h
|
||||||
guitar_hero_3.h
|
guitar_hero_3.h
|
||||||
@@ -26,13 +27,22 @@ set(API
|
|||||||
wiiuse.h)
|
wiiuse.h)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
list(APPEND SOURCES io_win.c)
|
list(APPEND SOURCES os_win.c)
|
||||||
set(CMAKE_DEBUG_POSTFIX _debug)
|
set(CMAKE_DEBUG_POSTFIX _debug)
|
||||||
elseif(APPLE)
|
elseif(APPLE)
|
||||||
list(APPEND SOURCES io_mac.h)
|
set(MAC_OBJC_SOURCES
|
||||||
list(APPEND SOURCES io_mac.m)
|
os_mac/os_mac.m
|
||||||
|
os_mac/os_mac_interface.m
|
||||||
|
os_mac/os_mac_find.m)
|
||||||
|
set(MAC_SOURCES
|
||||||
|
os_mac/os_mac.h
|
||||||
|
${MAC_OBJC_SOURCES})
|
||||||
|
list(APPEND SOURCES ${MAC_SOURCES})
|
||||||
|
# make sure we use the gcc for Objective-C files as well so that the
|
||||||
|
# sysroot and deployment target arguments are correctly passed to the compiler
|
||||||
|
set_source_files_properties(${MAC_OBJC_SOURCES} PROPERTIES LANGUAGE C)
|
||||||
else()
|
else()
|
||||||
list(APPEND SOURCES io_nix.c)
|
list(APPEND SOURCES os_nix.c)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
@@ -48,18 +58,20 @@ if(WIN32)
|
|||||||
elseif(LINUX)
|
elseif(LINUX)
|
||||||
target_link_libraries(wiiuse m ${BLUEZ_LIBRARIES})
|
target_link_libraries(wiiuse m ${BLUEZ_LIBRARIES})
|
||||||
elseif(APPLE)
|
elseif(APPLE)
|
||||||
|
# link libraries
|
||||||
find_library(IOBLUETOOTH_FRAMEWORK
|
find_library(IOBLUETOOTH_FRAMEWORK
|
||||||
NAMES
|
NAMES
|
||||||
IOBluetooth)
|
IOBluetooth)
|
||||||
|
|
||||||
find_library(COREFOUNDATION_FRAMEWORK
|
find_library(COREFOUNDATION_FRAMEWORK
|
||||||
NAMES
|
NAMES
|
||||||
CoreFoundation)
|
CoreFoundation)
|
||||||
|
|
||||||
find_library(FOUNDATION_FRAMEWORK
|
find_library(FOUNDATION_FRAMEWORK
|
||||||
NAMES
|
NAMES
|
||||||
Foundation)
|
Foundation)
|
||||||
target_link_libraries(wiiuse ${IOBLUETOOTH_FRAMEWORK} ${COREFOUNDATION_FRAMEWORK} ${FOUNDATION_FRAMEWORK})
|
target_link_libraries(wiiuse ${IOBLUETOOTH_FRAMEWORK} ${COREFOUNDATION_FRAMEWORK} ${FOUNDATION_FRAMEWORK})
|
||||||
|
|
||||||
|
# do not link Objective-C runtime with clang
|
||||||
|
set_target_properties(wiiuse PROPERTIES XCODE_ATTRIBUTE_CLANG_LINK_OBJC_RUNTIME "NO")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set_property(TARGET
|
set_property(TARGET
|
||||||
|
|||||||
@@ -77,9 +77,10 @@ int classic_ctrl_handshake(struct wiimote_t* wm, struct classic_ctrl_t* cc, byte
|
|||||||
wiiuse_read_data_cb(wm, handshake_expansion, handshake_buf, WM_EXP_MEM_CALIBR, EXP_HANDSHAKE_LEN);
|
wiiuse_read_data_cb(wm, handshake_expansion, handshake_buf, WM_EXP_MEM_CALIBR, EXP_HANDSHAKE_LEN);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} else
|
} else {
|
||||||
data += 16;
|
data += 16;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* joystick stuff */
|
/* joystick stuff */
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
/* this is wiiuse - used to distinguish from third party programs using wiiuse.h */
|
/* this is wiiuse - used to distinguish from third party programs using wiiuse.h */
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "os.h"
|
#include "definitions_os.h"
|
||||||
/** @addtogroup internal_general */
|
/** @addtogroup internal_general */
|
||||||
/** @{ */
|
/** @{ */
|
||||||
|
|
||||||
|
|||||||
51
src/definitions_os.h
Normal file
51
src/definitions_os.h
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* wiiuse
|
||||||
|
*
|
||||||
|
* Written By:
|
||||||
|
* Michael Laforest < para >
|
||||||
|
* Email: < thepara (--AT--) g m a i l [--DOT--] com >
|
||||||
|
*
|
||||||
|
* Copyright 2006-2007
|
||||||
|
*
|
||||||
|
* This file is part of wiiuse.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* $Header$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* @brief Operating system related definitions.
|
||||||
|
*
|
||||||
|
* This file is an attempt to separate operating system
|
||||||
|
* dependent functions and choose what should be used
|
||||||
|
* at compile time.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef DEFINITIONS_OS_H_INCLUDED
|
||||||
|
#define DEFINITIONS_OS_H_INCLUDED
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#include <float.h>
|
||||||
|
/* windows with visual c */
|
||||||
|
#define isnan(x) (_isnan(x))
|
||||||
|
#define isinf(x) (!_finite(x))
|
||||||
|
/* disable warnings I don't care about */
|
||||||
|
/*#pragma warning(disable:4273) */ /* inconsistent dll linkage */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* DEFINITIONS_OS_H_INCLUDED */
|
||||||
@@ -77,12 +77,21 @@ void calculate_orientation(struct accel_t* ac, struct vec3b_t* accel, struct ori
|
|||||||
z = ((float)accel->z - (float)ac->cal_zero.z) / zg;
|
z = ((float)accel->z - (float)ac->cal_zero.z) / zg;
|
||||||
|
|
||||||
/* make sure x,y,z are between -1 and 1 for the tan functions */
|
/* make sure x,y,z are between -1 and 1 for the tan functions */
|
||||||
if (x < -1.0f) x = -1.0f;
|
if (x < -1.0f) {
|
||||||
else if (x > 1.0f) x = 1.0f;
|
x = -1.0f;
|
||||||
if (y < -1.0f) y = -1.0f;
|
} else if (x > 1.0f) {
|
||||||
else if (y > 1.0f) y = 1.0f;
|
x = 1.0f;
|
||||||
if (z < -1.0f) z = -1.0f;
|
}
|
||||||
else if (z > 1.0f) z = 1.0f;
|
if (y < -1.0f) {
|
||||||
|
y = -1.0f;
|
||||||
|
} else if (y > 1.0f) {
|
||||||
|
y = 1.0f;
|
||||||
|
}
|
||||||
|
if (z < -1.0f) {
|
||||||
|
z = -1.0f;
|
||||||
|
} else if (z > 1.0f) {
|
||||||
|
z = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
/* if it is over 1g then it is probably accelerating and not reliable */
|
/* if it is over 1g then it is probably accelerating and not reliable */
|
||||||
if (abs(accel->x - ac->cal_zero.x) <= ac->cal_g.x) {
|
if (abs(accel->x - ac->cal_zero.x) <= ac->cal_g.x) {
|
||||||
@@ -180,11 +189,11 @@ void calc_joystick_state(struct joystick_t* js, float x, float y) {
|
|||||||
|
|
||||||
void apply_smoothing(struct accel_t* ac, struct orient_t* orient, int type) {
|
void apply_smoothing(struct accel_t* ac, struct orient_t* orient, int type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SMOOTH_ROLL:
|
case SMOOTH_ROLL: {
|
||||||
{
|
|
||||||
/* it's possible last iteration was nan or inf, so set it to 0 if that happened */
|
/* it's possible last iteration was nan or inf, so set it to 0 if that happened */
|
||||||
if (isnan(ac->st_roll) || isinf(ac->st_roll))
|
if (isnan(ac->st_roll) || isinf(ac->st_roll)) {
|
||||||
ac->st_roll = 0.0f;
|
ac->st_roll = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the sign changes (which will happen if going from -180 to 180)
|
* If the sign changes (which will happen if going from -180 to 180)
|
||||||
@@ -200,10 +209,10 @@ void apply_smoothing(struct accel_t* ac, struct orient_t* orient, int type) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SMOOTH_PITCH:
|
case SMOOTH_PITCH: {
|
||||||
{
|
if (isnan(ac->st_pitch) || isinf(ac->st_pitch)) {
|
||||||
if (isnan(ac->st_pitch) || isinf(ac->st_pitch))
|
|
||||||
ac->st_pitch = 0.0f;
|
ac->st_pitch = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
if (((ac->st_pitch < 0) && (orient->pitch > 0)) || ((ac->st_pitch > 0) && (orient->pitch < 0))) {
|
if (((ac->st_pitch < 0) && (orient->pitch > 0)) || ((ac->st_pitch > 0) && (orient->pitch < 0))) {
|
||||||
ac->st_pitch = orient->pitch;
|
ac->st_pitch = orient->pitch;
|
||||||
|
|||||||
294
src/events.c
294
src/events.c
@@ -44,21 +44,13 @@
|
|||||||
#include "nunchuk.h" /* for nunchuk_disconnected, etc */
|
#include "nunchuk.h" /* for nunchuk_disconnected, etc */
|
||||||
#include "wiiboard.h" /* for wii_board_disconnected, etc */
|
#include "wiiboard.h" /* for wii_board_disconnected, etc */
|
||||||
#include "motion_plus.h" /* for motion_plus_disconnected, etc */
|
#include "motion_plus.h" /* for motion_plus_disconnected, etc */
|
||||||
#include "io.h" /* for wiiuse_io_read on Windows, etc */
|
|
||||||
|
|
||||||
#ifndef WIIUSE_WIN32
|
#include "os.h" /* for wiiuse_os_poll */
|
||||||
#include <sys/time.h> /* for timeval */
|
|
||||||
#include <sys/select.h> /* for select, fd_set */
|
|
||||||
#include <unistd.h> /* for read */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <errno.h> /* for errno */
|
|
||||||
#include <stdio.h> /* for printf, perror */
|
#include <stdio.h> /* for printf, perror */
|
||||||
#include <stdlib.h> /* for free, malloc */
|
#include <stdlib.h> /* for free, malloc */
|
||||||
#include <string.h> /* for memcpy, memset */
|
#include <string.h> /* for memcpy, memset */
|
||||||
|
|
||||||
static void idle_cycle(struct wiimote_t* wm);
|
|
||||||
static void clear_dirty_reads(struct wiimote_t* wm);
|
|
||||||
static void event_data_read(struct wiimote_t* wm, byte* msg);
|
static void event_data_read(struct wiimote_t* wm, byte* msg);
|
||||||
static void event_data_write(struct wiimote_t *wm, byte *msg);
|
static void event_data_write(struct wiimote_t *wm, byte *msg);
|
||||||
static void event_status(struct wiimote_t* wm, byte* msg);
|
static void event_status(struct wiimote_t* wm, byte* msg);
|
||||||
@@ -80,141 +72,7 @@ static int state_changed(struct wiimote_t* wm);
|
|||||||
* the event variable will be set.
|
* the event variable will be set.
|
||||||
*/
|
*/
|
||||||
int wiiuse_poll(struct wiimote_t** wm, int wiimotes) {
|
int wiiuse_poll(struct wiimote_t** wm, int wiimotes) {
|
||||||
int evnt = 0;
|
return wiiuse_os_poll(wm, wiimotes);
|
||||||
|
|
||||||
#ifdef WIIUSE_BLUEZ
|
|
||||||
/*
|
|
||||||
* *nix
|
|
||||||
*/
|
|
||||||
struct timeval tv;
|
|
||||||
fd_set fds;
|
|
||||||
int r;
|
|
||||||
int i;
|
|
||||||
int highest_fd = -1;
|
|
||||||
|
|
||||||
if (!wm) return 0;
|
|
||||||
|
|
||||||
/* block select() for 1/2000th of a second */
|
|
||||||
tv.tv_sec = 0;
|
|
||||||
tv.tv_usec = 500;
|
|
||||||
|
|
||||||
FD_ZERO(&fds);
|
|
||||||
|
|
||||||
for (i = 0; i < wiimotes; ++i) {
|
|
||||||
/* only poll it if it is connected */
|
|
||||||
if (WIIMOTE_IS_SET(wm[i], WIIMOTE_STATE_CONNECTED)) {
|
|
||||||
FD_SET(wm[i]->in_sock, &fds);
|
|
||||||
|
|
||||||
/* find the highest fd of the connected wiimotes */
|
|
||||||
if (wm[i]->in_sock > highest_fd)
|
|
||||||
highest_fd = wm[i]->in_sock;
|
|
||||||
}
|
|
||||||
|
|
||||||
wm[i]->event = WIIUSE_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (highest_fd == -1)
|
|
||||||
/* nothing to poll */
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (select(highest_fd + 1, &fds, NULL, NULL, &tv) == -1) {
|
|
||||||
WIIUSE_ERROR("Unable to select() the wiimote interrupt socket(s).");
|
|
||||||
perror("Error Details");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* check each socket for an event */
|
|
||||||
for (i = 0; i < wiimotes; ++i) {
|
|
||||||
/* if this wiimote is not connected, skip it */
|
|
||||||
if (!WIIMOTE_IS_CONNECTED(wm[i]))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (FD_ISSET(wm[i]->in_sock, &fds)) {
|
|
||||||
/* clear out the event buffer */
|
|
||||||
memset(wm[i]->event_buf, 0, sizeof(wm[i]->event_buf));
|
|
||||||
|
|
||||||
/* clear out any old read requests */
|
|
||||||
clear_dirty_reads(wm[i]);
|
|
||||||
|
|
||||||
/* read the pending message into the buffer */
|
|
||||||
r = read(wm[i]->in_sock, wm[i]->event_buf, sizeof(wm[i]->event_buf));
|
|
||||||
if (r == -1) {
|
|
||||||
/* error reading data */
|
|
||||||
WIIUSE_ERROR("Receiving wiimote data (id %i).", wm[i]->unid);
|
|
||||||
perror("Error Details");
|
|
||||||
|
|
||||||
if (errno == ENOTCONN) {
|
|
||||||
/* this can happen if the bluetooth dongle is disconnected */
|
|
||||||
WIIUSE_ERROR("Bluetooth appears to be disconnected. Wiimote unid %i will be disconnected.", wm[i]->unid);
|
|
||||||
wiiuse_disconnect(wm[i]);
|
|
||||||
wiiuse_disconnected(wm[i]);
|
|
||||||
wm[i]->event = WIIUSE_UNEXPECTED_DISCONNECT;
|
|
||||||
}
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!r) {
|
|
||||||
/* remote disconnect */
|
|
||||||
wiiuse_disconnected(wm[i]);
|
|
||||||
evnt = 1;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* propagate the event */
|
|
||||||
propagate_event(wm[i], wm[i]->event_buf[1], wm[i]->event_buf+2);
|
|
||||||
evnt += (wm[i]->event != WIIUSE_NONE);
|
|
||||||
} else {
|
|
||||||
idle_cycle(wm[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#elif defined(WIIUSE_WIN32)
|
|
||||||
/*
|
|
||||||
* Windows
|
|
||||||
*/
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (!wm) return 0;
|
|
||||||
|
|
||||||
for (i = 0; i < wiimotes; ++i) {
|
|
||||||
wm[i]->event = WIIUSE_NONE;
|
|
||||||
|
|
||||||
if (wiiuse_io_read(wm[i])) {
|
|
||||||
/* propagate the event */
|
|
||||||
propagate_event(wm[i], wm[i]->event_buf[0], wm[i]->event_buf+1);
|
|
||||||
evnt += (wm[i]->event != WIIUSE_NONE);
|
|
||||||
|
|
||||||
/* clear out the event buffer */
|
|
||||||
memset(wm[i]->event_buf, 0, sizeof(wm[i]->event_buf));
|
|
||||||
} else {
|
|
||||||
idle_cycle(wm[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#elif defined(WIIUSE_MAC)
|
|
||||||
/*
|
|
||||||
* Mac
|
|
||||||
*/
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (!wm) return 0;
|
|
||||||
|
|
||||||
for (i = 0; i < wiimotes; ++i) {
|
|
||||||
wm[i]->event = WIIUSE_NONE;
|
|
||||||
|
|
||||||
if (wiiuse_io_read(wm[i])) {
|
|
||||||
/* propagate the event, messages should be read as in linux, starting from the second element */
|
|
||||||
propagate_event(wm[i], wm[i]->event_buf[1], wm[i]->event_buf+2);
|
|
||||||
evnt += (wm[i]->event != WIIUSE_NONE);
|
|
||||||
|
|
||||||
/* clear out the event buffer */
|
|
||||||
memset(wm[i]->event_buf, 0, sizeof(wm[i]->event_buf));
|
|
||||||
} else {
|
|
||||||
idle_cycle(wm[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return evnt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int wiiuse_update(struct wiimote_t** wiimotes, int nwiimotes, wiiuse_update_cb callback) {
|
int wiiuse_update(struct wiimote_t** wiimotes, int nwiimotes, wiiuse_update_cb callback) {
|
||||||
@@ -255,7 +113,7 @@ int wiiuse_update(struct wiimote_t** wiimotes, int nwiimotes, wiiuse_update_cb c
|
|||||||
*
|
*
|
||||||
* @param wm Pointer to a wiimote_t structure.
|
* @param wm Pointer to a wiimote_t structure.
|
||||||
*/
|
*/
|
||||||
static void idle_cycle(struct wiimote_t* wm) {
|
void idle_cycle(struct wiimote_t* wm) {
|
||||||
/*
|
/*
|
||||||
* Smooth the angles.
|
* Smooth the angles.
|
||||||
*
|
*
|
||||||
@@ -282,7 +140,7 @@ static void idle_cycle(struct wiimote_t* wm) {
|
|||||||
*
|
*
|
||||||
* @param wm Pointer to a wiimote_t structure.
|
* @param wm Pointer to a wiimote_t structure.
|
||||||
*/
|
*/
|
||||||
static void clear_dirty_reads(struct wiimote_t* wm) {
|
void clear_dirty_reads(struct wiimote_t* wm) {
|
||||||
struct read_req_t* req = wm->read_req;
|
struct read_req_t* req = wm->read_req;
|
||||||
|
|
||||||
while (req && req->dirty) {
|
while (req && req->dirty) {
|
||||||
@@ -326,14 +184,12 @@ void propagate_event(struct wiimote_t* wm, byte event, byte* msg) {
|
|||||||
save_state(wm);
|
save_state(wm);
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case WM_RPT_BTN:
|
case WM_RPT_BTN: {
|
||||||
{
|
|
||||||
/* button */
|
/* button */
|
||||||
wiiuse_pressed_buttons(wm, msg);
|
wiiuse_pressed_buttons(wm, msg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WM_RPT_BTN_ACC:
|
case WM_RPT_BTN_ACC: {
|
||||||
{
|
|
||||||
/* button - motion */
|
/* button - motion */
|
||||||
wiiuse_pressed_buttons(wm, msg);
|
wiiuse_pressed_buttons(wm, msg);
|
||||||
|
|
||||||
@@ -341,32 +197,28 @@ void propagate_event(struct wiimote_t* wm, byte event, byte* msg) {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WM_RPT_READ:
|
case WM_RPT_READ: {
|
||||||
{
|
|
||||||
/* data read */
|
/* data read */
|
||||||
event_data_read(wm, msg);
|
event_data_read(wm, msg);
|
||||||
|
|
||||||
/* yeah buttons may be pressed, but this wasn't an "event" */
|
/* yeah buttons may be pressed, but this wasn't an "event" */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case WM_RPT_CTRL_STATUS:
|
case WM_RPT_CTRL_STATUS: {
|
||||||
{
|
|
||||||
/* controller status */
|
/* controller status */
|
||||||
event_status(wm, msg);
|
event_status(wm, msg);
|
||||||
|
|
||||||
/* don't execute the event callback */
|
/* don't execute the event callback */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case WM_RPT_BTN_EXP:
|
case WM_RPT_BTN_EXP: {
|
||||||
{
|
|
||||||
/* button - expansion */
|
/* button - expansion */
|
||||||
wiiuse_pressed_buttons(wm, msg);
|
wiiuse_pressed_buttons(wm, msg);
|
||||||
handle_expansion(wm, msg + 2);
|
handle_expansion(wm, msg + 2);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WM_RPT_BTN_ACC_EXP:
|
case WM_RPT_BTN_ACC_EXP: {
|
||||||
{
|
|
||||||
/* button - motion - expansion */
|
/* button - motion - expansion */
|
||||||
wiiuse_pressed_buttons(wm, msg);
|
wiiuse_pressed_buttons(wm, msg);
|
||||||
|
|
||||||
@@ -376,8 +228,7 @@ void propagate_event(struct wiimote_t* wm, byte event, byte* msg) {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WM_RPT_BTN_ACC_IR:
|
case WM_RPT_BTN_ACC_IR: {
|
||||||
{
|
|
||||||
/* button - motion - ir */
|
/* button - motion - ir */
|
||||||
wiiuse_pressed_buttons(wm, msg);
|
wiiuse_pressed_buttons(wm, msg);
|
||||||
|
|
||||||
@@ -388,8 +239,7 @@ void propagate_event(struct wiimote_t* wm, byte event, byte* msg) {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WM_RPT_BTN_IR_EXP:
|
case WM_RPT_BTN_IR_EXP: {
|
||||||
{
|
|
||||||
/* button - ir - expansion */
|
/* button - ir - expansion */
|
||||||
wiiuse_pressed_buttons(wm, msg);
|
wiiuse_pressed_buttons(wm, msg);
|
||||||
handle_expansion(wm, msg + 12);
|
handle_expansion(wm, msg + 12);
|
||||||
@@ -399,8 +249,7 @@ void propagate_event(struct wiimote_t* wm, byte event, byte* msg) {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WM_RPT_BTN_ACC_IR_EXP:
|
case WM_RPT_BTN_ACC_IR_EXP: {
|
||||||
{
|
|
||||||
/* button - motion - ir - expansion */
|
/* button - motion - ir - expansion */
|
||||||
wiiuse_pressed_buttons(wm, msg);
|
wiiuse_pressed_buttons(wm, msg);
|
||||||
|
|
||||||
@@ -413,22 +262,21 @@ void propagate_event(struct wiimote_t* wm, byte event, byte* msg) {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WM_RPT_WRITE:
|
case WM_RPT_WRITE: {
|
||||||
{
|
|
||||||
event_data_write(wm, msg);
|
event_data_write(wm, msg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default: {
|
||||||
{
|
|
||||||
WIIUSE_WARNING("Unknown event, can not handle it [Code 0x%x].", event);
|
WIIUSE_WARNING("Unknown event, can not handle it [Code 0x%x].", event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* was there an event? */
|
/* was there an event? */
|
||||||
if (state_changed(wm))
|
if (state_changed(wm)) {
|
||||||
wm->event = WIIUSE_EVENT;
|
wm->event = WIIUSE_EVENT;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -476,8 +324,9 @@ static void event_data_read(struct wiimote_t* wm, byte* msg) {
|
|||||||
wiiuse_pressed_buttons(wm, msg);
|
wiiuse_pressed_buttons(wm, msg);
|
||||||
|
|
||||||
/* find the next non-dirty request */
|
/* find the next non-dirty request */
|
||||||
while (req && req->dirty)
|
while (req && req->dirty) {
|
||||||
req = req->next;
|
req = req->next;
|
||||||
|
}
|
||||||
|
|
||||||
/* if we don't have a request out then we didn't ask for this packet */
|
/* if we don't have a request out then we didn't ask for this packet */
|
||||||
if (!req) {
|
if (!req) {
|
||||||
@@ -487,12 +336,13 @@ static void event_data_read(struct wiimote_t* wm, byte* msg) {
|
|||||||
|
|
||||||
err = msg[2] & 0x0F;
|
err = msg[2] & 0x0F;
|
||||||
|
|
||||||
if (err == 0x08)
|
if (err == 0x08) {
|
||||||
WIIUSE_WARNING("Unable to read data - address does not exist.");
|
WIIUSE_WARNING("Unable to read data - address does not exist.");
|
||||||
else if (err == 0x07)
|
} else if (err == 0x07) {
|
||||||
WIIUSE_WARNING("Unable to read data - address is for write-only registers.");
|
WIIUSE_WARNING("Unable to read data - address is for write-only registers.");
|
||||||
else if (err)
|
} else if (err) {
|
||||||
WIIUSE_WARNING("Unable to read data - unknown error code %x.", err);
|
WIIUSE_WARNING("Unable to read data - unknown error code %x.", err);
|
||||||
|
}
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
/* this request errored out, so skip it and go to the next one */
|
/* this request errored out, so skip it and go to the next one */
|
||||||
@@ -502,8 +352,9 @@ static void event_data_read(struct wiimote_t* wm, byte* msg) {
|
|||||||
free(req);
|
free(req);
|
||||||
|
|
||||||
/* if another request exists send it to the wiimote */
|
/* if another request exists send it to the wiimote */
|
||||||
if (wm->read_req)
|
if (wm->read_req) {
|
||||||
wiiuse_send_next_pending_read_request(wm);
|
wiiuse_send_next_pending_read_request(wm);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -515,7 +366,9 @@ static void event_data_read(struct wiimote_t* wm, byte* msg) {
|
|||||||
req->wait -= len;
|
req->wait -= len;
|
||||||
if (req->wait >= req->size)
|
if (req->wait >= req->size)
|
||||||
/* this should never happen */
|
/* this should never happen */
|
||||||
|
{
|
||||||
req->wait = 0;
|
req->wait = 0;
|
||||||
|
}
|
||||||
|
|
||||||
WIIUSE_DEBUG("Received read packet:");
|
WIIUSE_DEBUG("Received read packet:");
|
||||||
WIIUSE_DEBUG(" Packet read offset: %i bytes", offset);
|
WIIUSE_DEBUG(" Packet read offset: %i bytes", offset);
|
||||||
@@ -531,8 +384,9 @@ static void event_data_read(struct wiimote_t* wm, byte* msg) {
|
|||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
printf("Read: ");
|
printf("Read: ");
|
||||||
for (; i < req->size - req->wait; ++i)
|
for (; i < req->size - req->wait; ++i) {
|
||||||
printf("%x ", req->buf[i]);
|
printf("%x ", req->buf[i]);
|
||||||
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -559,14 +413,14 @@ static void event_data_read(struct wiimote_t* wm, byte* msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* if another request exists send it to the wiimote */
|
/* if another request exists send it to the wiimote */
|
||||||
if (wm->read_req)
|
if (wm->read_req) {
|
||||||
wiiuse_send_next_pending_read_request(wm);
|
wiiuse_send_next_pending_read_request(wm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void event_data_write(struct wiimote_t *wm, byte *msg)
|
static void event_data_write(struct wiimote_t *wm, byte *msg) {
|
||||||
{
|
|
||||||
|
|
||||||
struct data_req_t* req = wm->data_req;
|
struct data_req_t* req = wm->data_req;
|
||||||
|
|
||||||
@@ -627,8 +481,9 @@ static void event_status(struct wiimote_t* wm, byte* msg) {
|
|||||||
struct data_req_t* req = wm->data_req;
|
struct data_req_t* req = wm->data_req;
|
||||||
|
|
||||||
/* initial handshake is not finished yet, ignore this */
|
/* initial handshake is not finished yet, ignore this */
|
||||||
if(WIIMOTE_IS_SET(wm, WIIMOTE_STATE_HANDSHAKE))
|
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_HANDSHAKE)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* An event occurred.
|
* An event occurred.
|
||||||
@@ -640,28 +495,45 @@ static void event_status(struct wiimote_t* wm, byte* msg) {
|
|||||||
wiiuse_pressed_buttons(wm, msg);
|
wiiuse_pressed_buttons(wm, msg);
|
||||||
|
|
||||||
/* find what LEDs are lit */
|
/* find what LEDs are lit */
|
||||||
if (msg[2] & WM_CTRL_STATUS_BYTE1_LED_1) led[0] = 1;
|
if (msg[2] & WM_CTRL_STATUS_BYTE1_LED_1) {
|
||||||
if (msg[2] & WM_CTRL_STATUS_BYTE1_LED_2) led[1] = 1;
|
led[0] = 1;
|
||||||
if (msg[2] & WM_CTRL_STATUS_BYTE1_LED_3) led[2] = 1;
|
}
|
||||||
if (msg[2] & WM_CTRL_STATUS_BYTE1_LED_4) led[3] = 1;
|
if (msg[2] & WM_CTRL_STATUS_BYTE1_LED_2) {
|
||||||
|
led[1] = 1;
|
||||||
|
}
|
||||||
|
if (msg[2] & WM_CTRL_STATUS_BYTE1_LED_3) {
|
||||||
|
led[2] = 1;
|
||||||
|
}
|
||||||
|
if (msg[2] & WM_CTRL_STATUS_BYTE1_LED_4) {
|
||||||
|
led[3] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* probe for Motion+ */
|
||||||
|
if (!WIIMOTE_IS_SET(wm, WIIMOTE_STATE_MPLUS_PRESENT)) {
|
||||||
|
wiiuse_probe_motion_plus(wm);
|
||||||
|
}
|
||||||
|
|
||||||
/* is an attachment connected to the expansion port? */
|
/* is an attachment connected to the expansion port? */
|
||||||
if ((msg[2] & WM_CTRL_STATUS_BYTE1_ATTACHMENT) == WM_CTRL_STATUS_BYTE1_ATTACHMENT)
|
if ((msg[2] & WM_CTRL_STATUS_BYTE1_ATTACHMENT) == WM_CTRL_STATUS_BYTE1_ATTACHMENT) {
|
||||||
|
WIIUSE_DEBUG("Attachment detected!");
|
||||||
attachment = 1;
|
attachment = 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* is the speaker enabled? */
|
/* is the speaker enabled? */
|
||||||
if ((msg[2] & WM_CTRL_STATUS_BYTE1_SPEAKER_ENABLED) == WM_CTRL_STATUS_BYTE1_SPEAKER_ENABLED)
|
if ((msg[2] & WM_CTRL_STATUS_BYTE1_SPEAKER_ENABLED) == WM_CTRL_STATUS_BYTE1_SPEAKER_ENABLED) {
|
||||||
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_SPEAKER);
|
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_SPEAKER);
|
||||||
|
}
|
||||||
|
|
||||||
/* is IR sensing enabled? */
|
/* is IR sensing enabled? */
|
||||||
if ((msg[2] & WM_CTRL_STATUS_BYTE1_IR_ENABLED) == WM_CTRL_STATUS_BYTE1_IR_ENABLED)
|
if ((msg[2] & WM_CTRL_STATUS_BYTE1_IR_ENABLED) == WM_CTRL_STATUS_BYTE1_IR_ENABLED) {
|
||||||
ir = 1;
|
ir = 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* find the battery level and normalize between 0 and 1 */
|
/* find the battery level and normalize between 0 and 1 */
|
||||||
wm->battery_level = (msg[5] / (float)WM_MAX_BATTERY_CODE);
|
wm->battery_level = (msg[5] / (float)WM_MAX_BATTERY_CODE);
|
||||||
|
|
||||||
/* expansion port */
|
/* expansion port */
|
||||||
if (attachment && !WIIMOTE_IS_SET(wm, WIIMOTE_STATE_EXP)) {
|
if (attachment && !WIIMOTE_IS_SET(wm, WIIMOTE_STATE_EXP) && !WIIMOTE_IS_SET(wm, WIIMOTE_STATE_EXP_HANDSHAKE)) {
|
||||||
/* send the initialization code for the attachment */
|
/* send the initialization code for the attachment */
|
||||||
handshake_expansion(wm, NULL, 0);
|
handshake_expansion(wm, NULL, 0);
|
||||||
exp_changed = 1;
|
exp_changed = 1;
|
||||||
@@ -683,8 +555,7 @@ static void event_status(struct wiimote_t* wm, byte* msg) {
|
|||||||
* We need to send a WIIMOTE_CMD_REPORT_TYPE packet to
|
* We need to send a WIIMOTE_CMD_REPORT_TYPE packet to
|
||||||
* reenable other incoming reports.
|
* reenable other incoming reports.
|
||||||
*/
|
*/
|
||||||
if (exp_changed && WIIMOTE_IS_SET(wm, WIIMOTE_STATE_IR))
|
if (exp_changed && WIIMOTE_IS_SET(wm, WIIMOTE_STATE_IR)) {
|
||||||
{
|
|
||||||
/*
|
/*
|
||||||
* Since the expansion status changed IR needs to
|
* Since the expansion status changed IR needs to
|
||||||
* be reset for the new IR report mode.
|
* be reset for the new IR report mode.
|
||||||
@@ -697,13 +568,16 @@ static void event_status(struct wiimote_t* wm, byte* msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* handling new Tx for changed exp */
|
/* handling new Tx for changed exp */
|
||||||
if(!req) return;
|
if (!req) {
|
||||||
if(!(req->state==REQ_SENT)) return;
|
return;
|
||||||
|
}
|
||||||
|
if (!(req->state == REQ_SENT)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
wm->data_req = req->next;
|
wm->data_req = req->next;
|
||||||
req->state = REQ_DONE;
|
req->state = REQ_DONE;
|
||||||
/* if(req->cb!=NULL) req->cb(wm,msg,6); */
|
/* if(req->cb!=NULL) req->cb(wm,msg,6); */
|
||||||
free(req);
|
free(req);
|
||||||
wiiuse_send_next_pending_write_request(wm);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -752,12 +626,12 @@ static void handle_expansion(struct wiimote_t* wm, byte* msg) {
|
|||||||
* a handshake with the expansion.
|
* a handshake with the expansion.
|
||||||
*/
|
*/
|
||||||
void handshake_expansion(struct wiimote_t* wm, byte* data, uint16_t len) {
|
void handshake_expansion(struct wiimote_t* wm, byte* data, uint16_t len) {
|
||||||
WIIUSE_DEBUG("handshake_expansion with state %d", wm->expansion_state);
|
|
||||||
int id;
|
int id;
|
||||||
byte val = 0;
|
byte val = 0;
|
||||||
byte buf = 0x00;
|
byte buf = 0x00;
|
||||||
byte* handshake_buf;
|
byte* handshake_buf;
|
||||||
int gotIt = 0;
|
int gotIt = 0;
|
||||||
|
WIIUSE_DEBUG("handshake_expansion with state %d", wm->expansion_state);
|
||||||
|
|
||||||
switch (wm->expansion_state) {
|
switch (wm->expansion_state) {
|
||||||
/* These two initialization writes disable the encryption */
|
/* These two initialization writes disable the encryption */
|
||||||
@@ -784,8 +658,9 @@ void handshake_expansion(struct wiimote_t* wm, byte* data, uint16_t len) {
|
|||||||
case 2:
|
case 2:
|
||||||
wm->expansion_state = 3;
|
wm->expansion_state = 3;
|
||||||
/* get the calibration data */
|
/* get the calibration data */
|
||||||
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_EXP))
|
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_EXP)) {
|
||||||
disable_expansion(wm);
|
disable_expansion(wm);
|
||||||
|
}
|
||||||
handshake_buf = malloc(EXP_HANDSHAKE_LEN * sizeof(byte));
|
handshake_buf = malloc(EXP_HANDSHAKE_LEN * sizeof(byte));
|
||||||
/* tell the wiimote to send expansion data */
|
/* tell the wiimote to send expansion data */
|
||||||
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_EXP);
|
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_EXP);
|
||||||
@@ -797,6 +672,7 @@ void handshake_expansion(struct wiimote_t* wm, byte* data, uint16_t len) {
|
|||||||
disable_expansion(wm);
|
disable_expansion(wm);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
wm->expansion_state = 0;
|
||||||
id = from_big_endian_uint32_t(data + 220);
|
id = from_big_endian_uint32_t(data + 220);
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case EXP_ID_CODE_NUNCHUK:
|
case EXP_ID_CODE_NUNCHUK:
|
||||||
@@ -866,8 +742,9 @@ void handshake_expansion(struct wiimote_t* wm, byte* data, uint16_t len) {
|
|||||||
*/
|
*/
|
||||||
void disable_expansion(struct wiimote_t* wm) {
|
void disable_expansion(struct wiimote_t* wm) {
|
||||||
WIIUSE_DEBUG("Disabling expansion");
|
WIIUSE_DEBUG("Disabling expansion");
|
||||||
if (!WIIMOTE_IS_SET(wm, WIIMOTE_STATE_EXP))
|
if (!WIIMOTE_IS_SET(wm, WIIMOTE_STATE_EXP)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* tell the associated module the expansion was removed */
|
/* tell the associated module the expansion was removed */
|
||||||
switch (wm->exp.type) {
|
switch (wm->exp.type) {
|
||||||
@@ -954,14 +831,12 @@ static void save_state(struct wiimote_t* wm) {
|
|||||||
|
|
||||||
case EXP_MOTION_PLUS:
|
case EXP_MOTION_PLUS:
|
||||||
case EXP_MOTION_PLUS_CLASSIC:
|
case EXP_MOTION_PLUS_CLASSIC:
|
||||||
case EXP_MOTION_PLUS_NUNCHUK:
|
case EXP_MOTION_PLUS_NUNCHUK: {
|
||||||
{
|
|
||||||
wm->lstate.drx = wm->exp.mp.raw_gyro.pitch;
|
wm->lstate.drx = wm->exp.mp.raw_gyro.pitch;
|
||||||
wm->lstate.dry = wm->exp.mp.raw_gyro.roll;
|
wm->lstate.dry = wm->exp.mp.raw_gyro.roll;
|
||||||
wm->lstate.drz = wm->exp.mp.raw_gyro.yaw;
|
wm->lstate.drz = wm->exp.mp.raw_gyro.yaw;
|
||||||
|
|
||||||
if(wm->exp.type == EXP_MOTION_PLUS_CLASSIC)
|
if (wm->exp.type == EXP_MOTION_PLUS_CLASSIC) {
|
||||||
{
|
|
||||||
wm->lstate.exp_ljs_ang = wm->exp.classic.ljs.ang;
|
wm->lstate.exp_ljs_ang = wm->exp.classic.ljs.ang;
|
||||||
wm->lstate.exp_ljs_mag = wm->exp.classic.ljs.mag;
|
wm->lstate.exp_ljs_mag = wm->exp.classic.ljs.mag;
|
||||||
wm->lstate.exp_rjs_ang = wm->exp.classic.rjs.ang;
|
wm->lstate.exp_rjs_ang = wm->exp.classic.rjs.ang;
|
||||||
@@ -1045,8 +920,7 @@ static int state_changed(struct wiimote_t* wm) {
|
|||||||
|
|
||||||
/* expansion */
|
/* expansion */
|
||||||
switch (wm->exp.type) {
|
switch (wm->exp.type) {
|
||||||
case EXP_NUNCHUK:
|
case EXP_NUNCHUK: {
|
||||||
{
|
|
||||||
STATE_CHANGED(wm->lstate.exp_ljs_ang, wm->exp.nunchuk.js.ang);
|
STATE_CHANGED(wm->lstate.exp_ljs_ang, wm->exp.nunchuk.js.ang);
|
||||||
STATE_CHANGED(wm->lstate.exp_ljs_mag, wm->exp.nunchuk.js.mag);
|
STATE_CHANGED(wm->lstate.exp_ljs_mag, wm->exp.nunchuk.js.mag);
|
||||||
STATE_CHANGED(wm->lstate.exp_btns, wm->exp.nunchuk.btns);
|
STATE_CHANGED(wm->lstate.exp_btns, wm->exp.nunchuk.btns);
|
||||||
@@ -1055,8 +929,7 @@ static int state_changed(struct wiimote_t* wm) {
|
|||||||
CROSS_THRESH_XYZ(wm->lstate.exp_accel, wm->exp.nunchuk.accel, wm->exp.nunchuk.accel_threshold);
|
CROSS_THRESH_XYZ(wm->lstate.exp_accel, wm->exp.nunchuk.accel, wm->exp.nunchuk.accel_threshold);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EXP_CLASSIC:
|
case EXP_CLASSIC: {
|
||||||
{
|
|
||||||
STATE_CHANGED(wm->lstate.exp_ljs_ang, wm->exp.classic.ljs.ang);
|
STATE_CHANGED(wm->lstate.exp_ljs_ang, wm->exp.classic.ljs.ang);
|
||||||
STATE_CHANGED(wm->lstate.exp_ljs_mag, wm->exp.classic.ljs.mag);
|
STATE_CHANGED(wm->lstate.exp_ljs_mag, wm->exp.classic.ljs.mag);
|
||||||
STATE_CHANGED(wm->lstate.exp_rjs_ang, wm->exp.classic.rjs.ang);
|
STATE_CHANGED(wm->lstate.exp_rjs_ang, wm->exp.classic.rjs.ang);
|
||||||
@@ -1066,16 +939,14 @@ static int state_changed(struct wiimote_t* wm) {
|
|||||||
STATE_CHANGED(wm->lstate.exp_btns, wm->exp.classic.btns);
|
STATE_CHANGED(wm->lstate.exp_btns, wm->exp.classic.btns);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EXP_GUITAR_HERO_3:
|
case EXP_GUITAR_HERO_3: {
|
||||||
{
|
|
||||||
STATE_CHANGED(wm->lstate.exp_ljs_ang, wm->exp.gh3.js.ang);
|
STATE_CHANGED(wm->lstate.exp_ljs_ang, wm->exp.gh3.js.ang);
|
||||||
STATE_CHANGED(wm->lstate.exp_ljs_mag, wm->exp.gh3.js.mag);
|
STATE_CHANGED(wm->lstate.exp_ljs_mag, wm->exp.gh3.js.mag);
|
||||||
STATE_CHANGED(wm->lstate.exp_r_shoulder, wm->exp.gh3.whammy_bar);
|
STATE_CHANGED(wm->lstate.exp_r_shoulder, wm->exp.gh3.whammy_bar);
|
||||||
STATE_CHANGED(wm->lstate.exp_btns, wm->exp.gh3.btns);
|
STATE_CHANGED(wm->lstate.exp_btns, wm->exp.gh3.btns);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EXP_WII_BOARD:
|
case EXP_WII_BOARD: {
|
||||||
{
|
|
||||||
STATE_CHANGED(wm->lstate.exp_wb_rtr, wm->exp.wb.tr);
|
STATE_CHANGED(wm->lstate.exp_wb_rtr, wm->exp.wb.tr);
|
||||||
STATE_CHANGED(wm->lstate.exp_wb_rtl, wm->exp.wb.tl);
|
STATE_CHANGED(wm->lstate.exp_wb_rtl, wm->exp.wb.tl);
|
||||||
STATE_CHANGED(wm->lstate.exp_wb_rbr, wm->exp.wb.br);
|
STATE_CHANGED(wm->lstate.exp_wb_rbr, wm->exp.wb.br);
|
||||||
@@ -1085,14 +956,12 @@ static int state_changed(struct wiimote_t* wm) {
|
|||||||
|
|
||||||
case EXP_MOTION_PLUS:
|
case EXP_MOTION_PLUS:
|
||||||
case EXP_MOTION_PLUS_CLASSIC:
|
case EXP_MOTION_PLUS_CLASSIC:
|
||||||
case EXP_MOTION_PLUS_NUNCHUK:
|
case EXP_MOTION_PLUS_NUNCHUK: {
|
||||||
{
|
|
||||||
STATE_CHANGED(wm->lstate.drx, wm->exp.mp.raw_gyro.pitch);
|
STATE_CHANGED(wm->lstate.drx, wm->exp.mp.raw_gyro.pitch);
|
||||||
STATE_CHANGED(wm->lstate.dry, wm->exp.mp.raw_gyro.roll);
|
STATE_CHANGED(wm->lstate.dry, wm->exp.mp.raw_gyro.roll);
|
||||||
STATE_CHANGED(wm->lstate.drz, wm->exp.mp.raw_gyro.yaw);
|
STATE_CHANGED(wm->lstate.drz, wm->exp.mp.raw_gyro.yaw);
|
||||||
|
|
||||||
if(wm->exp.type == EXP_MOTION_PLUS_CLASSIC)
|
if (wm->exp.type == EXP_MOTION_PLUS_CLASSIC) {
|
||||||
{
|
|
||||||
STATE_CHANGED(wm->lstate.exp_ljs_ang, wm->exp.classic.ljs.ang);
|
STATE_CHANGED(wm->lstate.exp_ljs_ang, wm->exp.classic.ljs.ang);
|
||||||
STATE_CHANGED(wm->lstate.exp_ljs_mag, wm->exp.classic.ljs.mag);
|
STATE_CHANGED(wm->lstate.exp_ljs_mag, wm->exp.classic.ljs.mag);
|
||||||
STATE_CHANGED(wm->lstate.exp_rjs_ang, wm->exp.classic.rjs.ang);
|
STATE_CHANGED(wm->lstate.exp_rjs_ang, wm->exp.classic.rjs.ang);
|
||||||
@@ -1111,8 +980,7 @@ static int state_changed(struct wiimote_t* wm) {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EXP_NONE:
|
case EXP_NONE: {
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,9 @@ void handshake_expansion(struct wiimote_t* wm, byte* data, uint16_t len);
|
|||||||
void disable_expansion(struct wiimote_t* wm);
|
void disable_expansion(struct wiimote_t* wm);
|
||||||
|
|
||||||
void propagate_event(struct wiimote_t* wm, byte event, byte* msg);
|
void propagate_event(struct wiimote_t* wm, byte event, byte* msg);
|
||||||
|
void idle_cycle(struct wiimote_t* wm);
|
||||||
|
|
||||||
|
void clear_dirty_reads(struct wiimote_t* wm);
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
#endif /* EVENTS_H_INCLUDED */
|
#endif /* EVENTS_H_INCLUDED */
|
||||||
|
|||||||
@@ -86,9 +86,10 @@ int guitar_hero_3_handshake(struct wiimote_t* wm, struct guitar_hero_3_t* gh3, b
|
|||||||
wiiuse_read_data_cb(wm, handshake_expansion, handshake_buf, WM_EXP_MEM_CALIBR, EXP_HANDSHAKE_LEN);
|
wiiuse_read_data_cb(wm, handshake_expansion, handshake_buf, WM_EXP_MEM_CALIBR, EXP_HANDSHAKE_LEN);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} else
|
} else {
|
||||||
data += 16;
|
data += 16;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* joystick stuff */
|
/* joystick stuff */
|
||||||
gh3->js.max.x = GUITAR_HERO_3_JS_MAX_X;
|
gh3->js.max.x = GUITAR_HERO_3_JS_MAX_X;
|
||||||
|
|||||||
269
src/io.c
269
src/io.c
@@ -30,27 +30,160 @@
|
|||||||
* @file
|
* @file
|
||||||
* @brief Handles device I/O (non-OS specific).
|
* @brief Handles device I/O (non-OS specific).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
#include "ir.h" /* for wiiuse_set_ir_mode */
|
#include "ir.h" /* for wiiuse_set_ir_mode */
|
||||||
|
#include "wiiuse_internal.h"
|
||||||
|
|
||||||
|
#include "os.h" /* for wiiuse_os_* */
|
||||||
|
|
||||||
#include <stdlib.h> /* for free, malloc */
|
#include <stdlib.h> /* for free, malloc */
|
||||||
|
|
||||||
|
/**
|
||||||
static void wiiuse_disable_motion_plus2(struct wiimote_t *wm,byte *data,unsigned short len)
|
* @brief Find a wiimote or wiimotes.
|
||||||
{
|
*
|
||||||
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_EXP_FAILED);
|
* @param wm An array of wiimote_t structures.
|
||||||
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_EXP_HANDSHAKE);
|
* @param max_wiimotes The number of wiimote structures in \a wm.
|
||||||
wiiuse_set_ir_mode(wm);
|
* @param timeout The number of seconds before the search times out.
|
||||||
|
*
|
||||||
wm->handshake_state++;
|
* @return The number of wiimotes found.
|
||||||
wiiuse_handshake(wm, NULL, 0);
|
*
|
||||||
|
* @see wiiuse_connect()
|
||||||
|
* @see wiiuse_os_find()
|
||||||
|
*
|
||||||
|
* This function will only look for wiimote devices. \n
|
||||||
|
* When a device is found the address in the structures will be set. \n
|
||||||
|
* You can then call wiiuse_connect() to connect to the found \n
|
||||||
|
* devices.
|
||||||
|
*
|
||||||
|
* This function only delegates to the platform-specific implementation
|
||||||
|
* wiiuse_os_find.
|
||||||
|
*
|
||||||
|
* This function is declared in wiiuse.h
|
||||||
|
*/
|
||||||
|
int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int timeout) {
|
||||||
|
return wiiuse_os_find(wm, max_wiimotes, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wiiuse_disable_motion_plus1(struct wiimote_t *wm,byte *data,unsigned short len)
|
/**
|
||||||
{
|
* @brief Connect to a wiimote or wiimotes once an address is known.
|
||||||
byte val = 0x00;
|
*
|
||||||
wiiuse_write_data_cb(wm, WM_EXP_MEM_ENABLE1, &val, 1, wiiuse_disable_motion_plus2);
|
* @param wm An array of wiimote_t structures.
|
||||||
|
* @param wiimotes The number of wiimote structures in \a wm.
|
||||||
|
*
|
||||||
|
* @return The number of wiimotes that successfully connected.
|
||||||
|
*
|
||||||
|
* @see wiiuse_find()
|
||||||
|
* @see wiiuse_disconnect()
|
||||||
|
* @see wiiuse_os_connect()
|
||||||
|
*
|
||||||
|
* Connect to a number of wiimotes when the address is already set
|
||||||
|
* in the wiimote_t structures. These addresses are normally set
|
||||||
|
* by the wiiuse_find() function, but can also be set manually.
|
||||||
|
*
|
||||||
|
* This function only delegates to the platform-specific implementation
|
||||||
|
* wiiuse_os_connect.
|
||||||
|
*
|
||||||
|
* This function is declared in wiiuse.h
|
||||||
|
*/
|
||||||
|
int wiiuse_connect(struct wiimote_t** wm, int wiimotes) {
|
||||||
|
return wiiuse_os_connect(wm, wiimotes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Disconnect a wiimote.
|
||||||
|
*
|
||||||
|
* @param wm Pointer to a wiimote_t structure.
|
||||||
|
*
|
||||||
|
* @see wiiuse_connect()
|
||||||
|
* @see wiiuse_os_disconnect()
|
||||||
|
*
|
||||||
|
* Note that this will not free the wiimote structure.
|
||||||
|
*
|
||||||
|
* This function only delegates to the platform-specific implementation
|
||||||
|
* wiiuse_os_disconnect.
|
||||||
|
*
|
||||||
|
* This function is declared in wiiuse.h
|
||||||
|
*/
|
||||||
|
void wiiuse_disconnect(struct wiimote_t* wm) {
|
||||||
|
wiiuse_os_disconnect(wm);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Wait until specified report arrives and return it
|
||||||
|
*
|
||||||
|
* @param wm Pointer to a wiimote_t structure.
|
||||||
|
* @param buffer Pre-allocated memory to store the received data
|
||||||
|
* @param bufferLength size of buffer in bytes
|
||||||
|
*
|
||||||
|
* Synchronous/blocking, this function will not return until it receives the specified
|
||||||
|
* report from the Wiimote.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void wiiuse_wait_report(struct wiimote_t *wm, int report, byte *buffer, int bufferLength) {
|
||||||
|
for (;;) {
|
||||||
|
if (wiiuse_os_read(wm, buffer, bufferLength) > 0) {
|
||||||
|
if (buffer[0] == report) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
WIIUSE_DEBUG("(id %i) dropping report 0x%x, waiting for 0x%x", wm->unid, buffer[0], report);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Read memory/register data synchronously
|
||||||
|
*
|
||||||
|
* @param wm Pointer to a wiimote_t structure.
|
||||||
|
* @param memory If set to non-zero, reads EEPROM, otherwise registers
|
||||||
|
* @param addr Address offset to read from
|
||||||
|
* @param size How many bytes to read
|
||||||
|
* @param data Pre-allocated memory to store the received data
|
||||||
|
*
|
||||||
|
* Synchronous/blocking read, this function will not return until it receives the specified
|
||||||
|
* amount of data from the Wiimote.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void wiiuse_read_data_sync(struct wiimote_t *wm, byte memory, unsigned addr, unsigned short size, byte *data) {
|
||||||
|
byte pkt[6];
|
||||||
|
byte buf[MAX_PAYLOAD];
|
||||||
|
unsigned n_full_reports;
|
||||||
|
unsigned last_report;
|
||||||
|
byte *output;
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* address in big endian first, the leading byte will
|
||||||
|
* be overwritten (only 3 bytes are sent)
|
||||||
|
*/
|
||||||
|
to_big_endian_uint32_t(pkt, addr);
|
||||||
|
|
||||||
|
/* read from registers or memory */
|
||||||
|
pkt[0] = (memory != 0) ? 0x00 : 0x04;
|
||||||
|
|
||||||
|
/* length in big endian */
|
||||||
|
to_big_endian_uint16_t(pkt + 4, size);
|
||||||
|
|
||||||
|
/* send */
|
||||||
|
wiiuse_send(wm, WM_CMD_READ_DATA, pkt, sizeof(pkt));
|
||||||
|
|
||||||
|
/* calculate how many 16B packets we have to get back */
|
||||||
|
n_full_reports = size / 16;
|
||||||
|
last_report = size % 16;
|
||||||
|
output = data;
|
||||||
|
|
||||||
|
for (i = 0; i < n_full_reports; ++i) {
|
||||||
|
wiiuse_wait_report(wm, WM_RPT_READ, buf, MAX_PAYLOAD);
|
||||||
|
memmove(output, buf + 6, 16);
|
||||||
|
output += 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* read the last incomplete packet */
|
||||||
|
if (last_report) {
|
||||||
|
wiiuse_wait_report(wm, WM_RPT_READ, buf, MAX_PAYLOAD);
|
||||||
|
memmove(output, buf + 6, last_report);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -66,18 +199,93 @@ static void wiiuse_disable_motion_plus1(struct wiimote_t *wm,byte *data,unsigned
|
|||||||
* The handshake will be concluded when the wiimote responds
|
* The handshake will be concluded when the wiimote responds
|
||||||
* with this data.
|
* with this data.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef WIIUSE_SYNC_HANDSHAKE
|
||||||
|
|
||||||
void wiiuse_handshake(struct wiimote_t* wm, byte* data, uint16_t len) {
|
void wiiuse_handshake(struct wiimote_t* wm, byte* data, uint16_t len) {
|
||||||
if (!wm) return;
|
/* send request to wiimote for accelerometer calibration */
|
||||||
|
byte buf[MAX_PAYLOAD];
|
||||||
|
|
||||||
|
/* step 0 - Reset wiimote */
|
||||||
|
{
|
||||||
|
//wiiuse_set_leds(wm, WIIMOTE_LED_NONE);
|
||||||
|
|
||||||
|
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE);
|
||||||
|
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_CONNECTED);
|
||||||
|
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_ACC);
|
||||||
|
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_IR);
|
||||||
|
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_RUMBLE);
|
||||||
|
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_EXP);
|
||||||
|
WIIMOTE_DISABLE_FLAG(wm, WIIUSE_CONTINUOUS);
|
||||||
|
|
||||||
|
wiiuse_set_report_type(wm);
|
||||||
|
wiiuse_millisleep(500);
|
||||||
|
|
||||||
|
WIIUSE_DEBUG("Wiimote reset!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* step 1 - calibration of accelerometers */
|
||||||
|
{
|
||||||
|
struct accel_t* accel = &wm->accel_calib;
|
||||||
|
|
||||||
|
wiiuse_read_data_sync(wm, 1, WM_MEM_OFFSET_CALIBRATION, 8, buf);
|
||||||
|
|
||||||
|
/* received read data */
|
||||||
|
accel->cal_zero.x = buf[0];
|
||||||
|
accel->cal_zero.y = buf[1];
|
||||||
|
accel->cal_zero.z = buf[2];
|
||||||
|
|
||||||
|
accel->cal_g.x = buf[4] - accel->cal_zero.x;
|
||||||
|
accel->cal_g.y = buf[5] - accel->cal_zero.y;
|
||||||
|
accel->cal_g.z = buf[6] - accel->cal_zero.z;
|
||||||
|
|
||||||
|
WIIUSE_DEBUG("Calibrated wiimote acc\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* step 2 - re-enable IR and ask for status */
|
||||||
|
{
|
||||||
|
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE_COMPLETE);
|
||||||
|
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE);
|
||||||
|
|
||||||
|
/* now enable IR if it was set before the handshake completed */
|
||||||
|
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_IR)) {
|
||||||
|
WIIUSE_DEBUG("Handshake finished, enabling IR.");
|
||||||
|
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_IR);
|
||||||
|
wiiuse_set_ir(wm, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
WIIUSE_DEBUG("Asking for status ...\n");
|
||||||
|
wm->event = WIIUSE_CONNECT;
|
||||||
|
wiiuse_status(wm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
static void wiiuse_disable_motion_plus1(struct wiimote_t *wm, byte *data, unsigned short len);
|
||||||
|
static void wiiuse_disable_motion_plus2(struct wiimote_t *wm, byte *data, unsigned short len);
|
||||||
|
|
||||||
|
void wiiuse_handshake(struct wiimote_t* wm, byte* data, uint16_t len) {
|
||||||
|
if (!wm) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (wm->handshake_state) {
|
switch (wm->handshake_state) {
|
||||||
case 0:
|
case 0: {
|
||||||
{
|
|
||||||
/* send request to wiimote for accelerometer calibration */
|
|
||||||
byte* buf;
|
byte* buf;
|
||||||
|
|
||||||
|
/* continuous reporting off, report to buttons only */
|
||||||
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE);
|
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE);
|
||||||
wiiuse_set_leds(wm, WIIMOTE_LED_NONE);
|
wiiuse_set_leds(wm, WIIMOTE_LED_NONE);
|
||||||
|
|
||||||
|
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_ACC);
|
||||||
|
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_IR);
|
||||||
|
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_RUMBLE);
|
||||||
|
WIIMOTE_DISABLE_FLAG(wm, WIIUSE_CONTINUOUS);
|
||||||
|
|
||||||
|
wiiuse_set_report_type(wm);
|
||||||
|
|
||||||
|
/* send request to wiimote for accelerometer calibration */
|
||||||
buf = (byte*)malloc(sizeof(byte) * 8);
|
buf = (byte*)malloc(sizeof(byte) * 8);
|
||||||
wiiuse_read_data_cb(wm, wiiuse_handshake, buf, WM_MEM_OFFSET_CALIBRATION, 7);
|
wiiuse_read_data_cb(wm, wiiuse_handshake, buf, WM_MEM_OFFSET_CALIBRATION, 7);
|
||||||
wm->handshake_state++;
|
wm->handshake_state++;
|
||||||
@@ -87,8 +295,7 @@ void wiiuse_handshake(struct wiimote_t* wm, byte* data, uint16_t len) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 1:
|
case 1: {
|
||||||
{
|
|
||||||
struct read_req_t* req = wm->read_req;
|
struct read_req_t* req = wm->read_req;
|
||||||
struct accel_t* accel = &wm->accel_calib;
|
struct accel_t* accel = &wm->accel_calib;
|
||||||
byte val;
|
byte val;
|
||||||
@@ -117,8 +324,7 @@ void wiiuse_handshake(struct wiimote_t* wm, byte* data, uint16_t len) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 2:
|
case 2: {
|
||||||
{
|
|
||||||
/* request the status of the wiimote to check for any expansion */
|
/* request the status of the wiimote to check for any expansion */
|
||||||
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE);
|
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE);
|
||||||
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE_COMPLETE);
|
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE_COMPLETE);
|
||||||
@@ -137,9 +343,24 @@ void wiiuse_handshake(struct wiimote_t* wm, byte* data, uint16_t len) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default: {
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void wiiuse_disable_motion_plus1(struct wiimote_t *wm, byte *data, unsigned short len) {
|
||||||
|
byte val = 0x00;
|
||||||
|
wiiuse_write_data_cb(wm, WM_EXP_MEM_ENABLE1, &val, 1, wiiuse_disable_motion_plus2);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void wiiuse_disable_motion_plus2(struct wiimote_t *wm, byte *data, unsigned short len) {
|
||||||
|
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_EXP_FAILED);
|
||||||
|
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_EXP_HANDSHAKE);
|
||||||
|
wiiuse_set_ir_mode(wm);
|
||||||
|
|
||||||
|
wm->handshake_state++;
|
||||||
|
wiiuse_handshake(wm, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
20
src/io.h
20
src/io.h
@@ -31,12 +31,8 @@
|
|||||||
* @brief Handles device I/O.
|
* @brief Handles device I/O.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef CONNECT_H_INCLUDED
|
#ifndef IO_H_INCLUDED
|
||||||
#define CONNECT_H_INCLUDED
|
#define IO_H_INCLUDED
|
||||||
|
|
||||||
#ifdef WIIUSE_BLUEZ
|
|
||||||
#include <bluetooth/bluetooth.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "wiiuse_internal.h"
|
#include "wiiuse_internal.h"
|
||||||
|
|
||||||
@@ -44,20 +40,16 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/** @defgroup internal_io Internal: Device I/O */
|
||||||
/** @defgroup internal_io Internal: Device IO */
|
|
||||||
/** @{ */
|
/** @{ */
|
||||||
void wiiuse_handshake(struct wiimote_t* wm, byte* data, uint16_t len);
|
void wiiuse_handshake(struct wiimote_t* wm, byte* data, uint16_t len);
|
||||||
|
|
||||||
void wiiuse_init_platform_fields(struct wiimote_t* wm);
|
void wiiuse_wait_report(struct wiimote_t *wm, int report, byte *buffer, int bufferLength);
|
||||||
void wiiuse_cleanup_platform_fields(struct wiimote_t* wm);
|
void wiiuse_read_data_sync(struct wiimote_t *wm, byte memory, unsigned addr, unsigned short size, byte *data);
|
||||||
|
|
||||||
int wiiuse_io_read(struct wiimote_t* wm);
|
|
||||||
int wiiuse_io_write(struct wiimote_t* wm, byte* buf, int len);
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* CONNECT_H_INCLUDED */
|
#endif /* IO_H_INCLUDED */
|
||||||
|
|||||||
107
src/io_mac.h
107
src/io_mac.h
@@ -1,107 +0,0 @@
|
|||||||
/*
|
|
||||||
* io_mac.h
|
|
||||||
*
|
|
||||||
* This file is based on io_mac.h from WiiC, written By:
|
|
||||||
* Gabriele Randelli
|
|
||||||
* Email: < randelli (--AT--) dis [--DOT--] uniroma1 [--DOT--] it >
|
|
||||||
*
|
|
||||||
* Copyright 2010
|
|
||||||
*
|
|
||||||
* This file is part of wiiuse.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* $Header$
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
* @brief I/O header file for MacOS.
|
|
||||||
*/
|
|
||||||
#ifndef IO_MAC_H
|
|
||||||
#define IO_MAC_H
|
|
||||||
|
|
||||||
#import <stdio.h>
|
|
||||||
#import <stdlib.h>
|
|
||||||
#import <unistd.h>
|
|
||||||
|
|
||||||
#define BLUETOOTH_VERSION_USE_CURRENT
|
|
||||||
|
|
||||||
#import <arpa/inet.h> /* htons() */
|
|
||||||
#import <IOBluetooth/IOBluetoothUtilities.h>
|
|
||||||
#import <IOBluetooth/objc/IOBluetoothDevice.h>
|
|
||||||
#import <IOBluetooth/objc/IOBluetoothHostController.h>
|
|
||||||
#import <IOBluetooth/objc/IOBluetoothDeviceInquiry.h>
|
|
||||||
#import <IOBluetooth/objc/IOBluetoothL2CAPChannel.h>
|
|
||||||
|
|
||||||
#import "wiiuse_internal.h"
|
|
||||||
#import "io.h"
|
|
||||||
|
|
||||||
@interface WiiSearch : NSObject
|
|
||||||
{
|
|
||||||
IOBluetoothDeviceInquiry* inquiry;
|
|
||||||
BOOL isDiscovering;
|
|
||||||
// Number of found wiimotes
|
|
||||||
int foundWiimotes;
|
|
||||||
// Maximum number of wiimotes to be searched
|
|
||||||
int maxWiimotes;
|
|
||||||
// The Wiimotes structure
|
|
||||||
wiimote** wiimotes;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL) isDiscovering;
|
|
||||||
- (void) setDiscovering:(BOOL) flag;
|
|
||||||
- (void) setWiimoteStruct:(wiimote**) wiimote_struct;
|
|
||||||
- (int) getFoundWiimotes;
|
|
||||||
- (IOReturn) start:(unsigned int) timeout maxWiimotes:(unsigned int) wiimotesNum;
|
|
||||||
- (IOReturn) stop;
|
|
||||||
- (IOReturn) close;
|
|
||||||
- (void) retrieveWiimoteInfo:(IOBluetoothDevice*) device;
|
|
||||||
- (void) deviceInquiryStarted:(IOBluetoothDeviceInquiry*) sender;
|
|
||||||
- (void) deviceInquiryDeviceFound:(IOBluetoothDeviceInquiry *) sender device:(IOBluetoothDevice *) device;
|
|
||||||
- (void) deviceInquiryComplete:(IOBluetoothDeviceInquiry*) sender error:(IOReturn) error aborted:(BOOL) aborted;
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
@interface WiiConnect : NSObject
|
|
||||||
{
|
|
||||||
// Buffer to store incoming data from the Wiimote
|
|
||||||
NSData* receivedMsg;
|
|
||||||
unsigned int msgLength;
|
|
||||||
|
|
||||||
// Reference to the relative wiimote struct (used only to complete handshaking)
|
|
||||||
wiimote* _wm;
|
|
||||||
BOOL isReading;
|
|
||||||
BOOL timeout;
|
|
||||||
BOOL disconnecting;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (IOBluetoothL2CAPChannel *) openL2CAPChannelWithPSM:(BluetoothL2CAPPSM) psm device:(IOBluetoothDevice*) device delegate:(id) delegate;
|
|
||||||
- (IOReturn) connectToWiimote:(wiimote*) wm;
|
|
||||||
- (void) l2capChannelData:(IOBluetoothL2CAPChannel*) channel data:(byte *) data length:(NSUInteger) length;
|
|
||||||
- (byte*) getNextMsg;
|
|
||||||
- (unsigned int) getMsgLength;
|
|
||||||
- (void) deleteMsg;
|
|
||||||
- (void) disconnected:(IOBluetoothUserNotification*) notification fromDevice:(IOBluetoothDevice*) device;
|
|
||||||
- (BOOL) isReading;
|
|
||||||
- (void) setReading:(BOOL) flag;
|
|
||||||
- (BOOL) isTimeout;
|
|
||||||
- (void) setTimeout:(BOOL) flag;
|
|
||||||
- (void) startTimerThread;
|
|
||||||
- (void) wakeUpMainThreadRunloop:(id)arg;
|
|
||||||
- (BOOL) isDisconnecting;
|
|
||||||
@end
|
|
||||||
|
|
||||||
#endif /* IO_MAC_H */
|
|
||||||
826
src/io_mac.m
826
src/io_mac.m
@@ -1,826 +0,0 @@
|
|||||||
/*
|
|
||||||
* io_mac.m
|
|
||||||
*
|
|
||||||
* This file is based on io_mac.m from WiiC, written By:
|
|
||||||
* Gabriele Randelli
|
|
||||||
* Email: < randelli (--AT--) dis [--DOT--] uniroma1 [--DOT--] it >
|
|
||||||
*
|
|
||||||
* Copyright 2010
|
|
||||||
*
|
|
||||||
* This file is part of wiiuse.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* $Header$
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
* @brief Handles device I/O for Mac.
|
|
||||||
*/
|
|
||||||
#ifdef __APPLE__
|
|
||||||
|
|
||||||
#import "io_mac.h"
|
|
||||||
#import "events.h"
|
|
||||||
|
|
||||||
@implementation WiiSearch
|
|
||||||
|
|
||||||
#pragma mark -
|
|
||||||
#pragma mark WiiSearch
|
|
||||||
- (id) init
|
|
||||||
{
|
|
||||||
self = [super init];
|
|
||||||
foundWiimotes = 0;
|
|
||||||
isDiscovering = NO;
|
|
||||||
if (self != nil) {
|
|
||||||
BluetoothHCIPowerState powerState;
|
|
||||||
IOBluetoothLocalDeviceGetPowerState(&powerState);
|
|
||||||
/*
|
|
||||||
* Calling IOBluetoothLocalDeviceAvailable has two advantages:
|
|
||||||
* 1. it sets up a event source in the run loop (bug for C version of the bluetooth api)
|
|
||||||
* 2. it checks for the availability of the BT hardware
|
|
||||||
*/
|
|
||||||
if (![IOBluetoothHostController defaultController] ||
|
|
||||||
powerState == kBluetoothHCIPowerStateOFF)
|
|
||||||
{
|
|
||||||
WIIUSE_DEBUG("Bluetooth hardware not available.");
|
|
||||||
[self release];
|
|
||||||
self = nil;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) dealloc
|
|
||||||
{
|
|
||||||
inquiry = 0;
|
|
||||||
WIIUSE_DEBUG("Wiimote Discovery released");
|
|
||||||
[super dealloc];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL) isDiscovering
|
|
||||||
{
|
|
||||||
return isDiscovering;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) setDiscovering:(BOOL) flag
|
|
||||||
{
|
|
||||||
isDiscovering = flag;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) setWiimoteStruct:(wiimote**) wiimote_struct
|
|
||||||
{
|
|
||||||
wiimotes = wiimote_struct;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (int) getFoundWiimotes
|
|
||||||
{
|
|
||||||
return foundWiimotes;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (IOReturn) start:(unsigned int) timeout maxWiimotes:(unsigned int) wiimotesNum
|
|
||||||
{
|
|
||||||
if (![IOBluetoothHostController defaultController]) {
|
|
||||||
WIIUSE_ERROR("Unable to find any bluetooth receiver on your host.");
|
|
||||||
return kIOReturnNotAttached;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we are currently discovering, we can't start a new discovery right now.
|
|
||||||
if ([self isDiscovering]) {
|
|
||||||
WIIUSE_INFO("Wiimote search is already in progress...");
|
|
||||||
return kIOReturnSuccess;
|
|
||||||
}
|
|
||||||
|
|
||||||
[self close];
|
|
||||||
maxWiimotes = wiimotesNum;
|
|
||||||
foundWiimotes = 0;
|
|
||||||
|
|
||||||
inquiry = [IOBluetoothDeviceInquiry inquiryWithDelegate:self];
|
|
||||||
// We set the search timeout
|
|
||||||
if(timeout == 0)
|
|
||||||
[inquiry setInquiryLength:5];
|
|
||||||
else if(timeout < 20)
|
|
||||||
[inquiry setInquiryLength:timeout];
|
|
||||||
else
|
|
||||||
[inquiry setInquiryLength:20];
|
|
||||||
[inquiry setSearchCriteria:kBluetoothServiceClassMajorAny majorDeviceClass:WM_DEV_MAJOR_CLASS minorDeviceClass:WM_DEV_MINOR_CLASS];
|
|
||||||
[inquiry setUpdateNewDeviceNames:NO];
|
|
||||||
|
|
||||||
IOReturn status = [inquiry start];
|
|
||||||
if (status == kIOReturnSuccess) {
|
|
||||||
[inquiry retain];
|
|
||||||
} else {
|
|
||||||
[self close];
|
|
||||||
WIIUSE_ERROR("Unable to search for bluetooth devices.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (IOReturn) stop
|
|
||||||
{
|
|
||||||
return [inquiry stop];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (IOReturn) close
|
|
||||||
{
|
|
||||||
IOReturn ret = kIOReturnSuccess;
|
|
||||||
|
|
||||||
ret = [inquiry stop];
|
|
||||||
[inquiry release];
|
|
||||||
inquiry = nil;
|
|
||||||
|
|
||||||
WIIUSE_DEBUG("Discovery closed");
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark -
|
|
||||||
#pragma mark IOBluetoothDeviceInquiry delegates
|
|
||||||
//*************** HANDLERS FOR WIIUSE_FIND FOR MACOSX *******************/
|
|
||||||
- (void) retrieveWiimoteInfo:(IOBluetoothDevice*) device
|
|
||||||
{
|
|
||||||
// We set the device reference (we must retain it to use it after the search)
|
|
||||||
wiimotes[foundWiimotes]->device = [[device retain] getDeviceRef];
|
|
||||||
wiimotes[foundWiimotes]->address = (CFStringRef)[[device getAddressString] retain];
|
|
||||||
|
|
||||||
// C String (common for Mac and Linux)
|
|
||||||
CFStringGetCString(wiimotes[foundWiimotes]->address,wiimotes[foundWiimotes]->bdaddr_str,18,kCFStringEncodingMacRoman);
|
|
||||||
|
|
||||||
WIIMOTE_ENABLE_STATE(wiimotes[foundWiimotes], WIIMOTE_STATE_DEV_FOUND);
|
|
||||||
WIIUSE_INFO("Found Wiimote (%s) [id %i].",CFStringGetCStringPtr(wiimotes[foundWiimotes]->address, kCFStringEncodingMacRoman),wiimotes[foundWiimotes]->unid);
|
|
||||||
++foundWiimotes;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) deviceInquiryStarted:(IOBluetoothDeviceInquiry*) sender
|
|
||||||
{
|
|
||||||
[self setDiscovering:YES];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) deviceInquiryDeviceFound:(IOBluetoothDeviceInquiry *) sender device:(IOBluetoothDevice *) device
|
|
||||||
{
|
|
||||||
if(foundWiimotes < maxWiimotes)
|
|
||||||
[self retrieveWiimoteInfo:device];
|
|
||||||
else
|
|
||||||
[inquiry stop];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) deviceInquiryComplete:(IOBluetoothDeviceInquiry*) sender error:(IOReturn) error aborted:(BOOL) aborted
|
|
||||||
{
|
|
||||||
// The inquiry has completed, we can now process what we have found
|
|
||||||
[self setDiscovering:NO];
|
|
||||||
|
|
||||||
// We stop the search because of errors
|
|
||||||
if ((error != kIOReturnSuccess) && !aborted) {
|
|
||||||
foundWiimotes = 0;
|
|
||||||
[self close];
|
|
||||||
WIIUSE_ERROR("Search not completed, because of unexpected errors. This error can be due to a short search timeout.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
foundWiimotes = [[inquiry foundDevices] count];
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation WiiConnect
|
|
||||||
#pragma mark -
|
|
||||||
#pragma mark WiiConnect
|
|
||||||
- (id) init
|
|
||||||
{
|
|
||||||
self = [super init];
|
|
||||||
receivedMsg = [[NSData alloc] init];
|
|
||||||
msgLength = 0;
|
|
||||||
_wm = 0;
|
|
||||||
isReading = NO;
|
|
||||||
timeout = NO;
|
|
||||||
disconnecting = NO;
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) dealloc
|
|
||||||
{
|
|
||||||
WIIUSE_DEBUG("Wiimote released");
|
|
||||||
if(receivedMsg)
|
|
||||||
[receivedMsg release];
|
|
||||||
receivedMsg = 0;
|
|
||||||
_wm = 0;
|
|
||||||
[super dealloc];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (byte*) getNextMsg
|
|
||||||
{
|
|
||||||
if(!receivedMsg)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return (byte*)[receivedMsg bytes];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) deleteMsg
|
|
||||||
{
|
|
||||||
if(receivedMsg) {
|
|
||||||
[receivedMsg release];
|
|
||||||
msgLength = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL) isDisconnecting
|
|
||||||
{
|
|
||||||
return disconnecting;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL) isReading
|
|
||||||
{
|
|
||||||
return isReading;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) setReading:(BOOL) flag
|
|
||||||
{
|
|
||||||
isReading = flag;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL) isTimeout
|
|
||||||
{
|
|
||||||
return timeout;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) setTimeout:(BOOL) flag
|
|
||||||
{
|
|
||||||
timeout = flag;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) startTimerThread
|
|
||||||
{
|
|
||||||
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
|
|
||||||
|
|
||||||
// Timer
|
|
||||||
sleep(1);
|
|
||||||
|
|
||||||
[pool drain];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) wakeUpMainThreadRunloop:(id)arg
|
|
||||||
{
|
|
||||||
// This method is executed on main thread!
|
|
||||||
// It doesn't need to do anything actually, just having it run will
|
|
||||||
// make sure the main thread stops running the runloop
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
- (IOBluetoothL2CAPChannel*) openL2CAPChannelWithPSM:(BluetoothL2CAPPSM) psm device:(IOBluetoothDevice*) device delegate:(id) delegate
|
|
||||||
{
|
|
||||||
IOBluetoothL2CAPChannel* channel = nil;
|
|
||||||
|
|
||||||
if ([device openL2CAPChannelSync:&channel withPSM:psm delegate:delegate] != kIOReturnSuccess)
|
|
||||||
channel = nil;
|
|
||||||
|
|
||||||
return channel;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (IOReturn) connectToWiimote:(wiimote*) wm
|
|
||||||
{
|
|
||||||
IOBluetoothDevice* device = [IOBluetoothDevice withDeviceRef:wm->device];
|
|
||||||
IOBluetoothL2CAPChannel* outCh = nil;
|
|
||||||
IOBluetoothL2CAPChannel* inCh = nil;
|
|
||||||
|
|
||||||
if(!device) {
|
|
||||||
WIIUSE_ERROR("Non existent device or already connected.");
|
|
||||||
return kIOReturnBadArgument;
|
|
||||||
}
|
|
||||||
|
|
||||||
outCh = [self openL2CAPChannelWithPSM:WM_OUTPUT_CHANNEL device:device delegate:self];
|
|
||||||
if (!outCh) {
|
|
||||||
WIIUSE_ERROR("Unable to open L2CAP output channel (id %i).", wm->unid);
|
|
||||||
[device closeConnection];
|
|
||||||
return kIOReturnNotOpen;
|
|
||||||
}
|
|
||||||
wm->outputCh = [[outCh retain] getL2CAPChannelRef];
|
|
||||||
usleep(20000);
|
|
||||||
|
|
||||||
inCh = [self openL2CAPChannelWithPSM:WM_INPUT_CHANNEL device:device delegate:self];
|
|
||||||
if (!inCh) {
|
|
||||||
WIIUSE_ERROR("Unable to open L2CAP input channel (id %i).", wm->unid);
|
|
||||||
[device closeConnection];
|
|
||||||
return kIOReturnNotOpen;
|
|
||||||
}
|
|
||||||
wm->inputCh = [[inCh retain] getL2CAPChannelRef];
|
|
||||||
usleep(20000);
|
|
||||||
|
|
||||||
IOBluetoothUserNotification* disconnectNotification = [device registerForDisconnectNotification:self selector:@selector(disconnected:fromDevice:)];
|
|
||||||
if(!disconnectNotification) {
|
|
||||||
WIIUSE_ERROR("Unable to register disconnection handler (id %i).", wm->unid);
|
|
||||||
[device closeConnection];
|
|
||||||
return kIOReturnNotOpen;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We store the reference to its relative structure (Used for completing the handshake step)
|
|
||||||
_wm = wm;
|
|
||||||
|
|
||||||
return kIOReturnSuccess;
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark -
|
|
||||||
#pragma mark IOBluetoothL2CAPChannel delegates
|
|
||||||
- (void) disconnected:(IOBluetoothUserNotification*) notification fromDevice:(IOBluetoothDevice*) device
|
|
||||||
{
|
|
||||||
[self deleteMsg];
|
|
||||||
[self setReading:NO];
|
|
||||||
disconnecting = YES;
|
|
||||||
|
|
||||||
// The wiimote_t struct must be re-initialized due to the disconnection
|
|
||||||
wiiuse_disconnected(_wm) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//*************** HANDLERS FOR WIIUSE_IO_READ FOR MACOSX *******************/
|
|
||||||
- (void) l2capChannelData:(IOBluetoothL2CAPChannel*) channel data:(byte *) data length:(NSUInteger) length
|
|
||||||
{
|
|
||||||
// This is done in case the output channel woke up this handler
|
|
||||||
if(!data) {
|
|
||||||
[self setReading:NO];
|
|
||||||
length = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This is called if we are receiving data before completing
|
|
||||||
* the handshaking, hence before calling wiiuse_poll
|
|
||||||
*/
|
|
||||||
if(WIIMOTE_IS_SET(_wm, WIIMOTE_STATE_HANDSHAKE))
|
|
||||||
propagate_event(_wm, data[1], data+2);
|
|
||||||
|
|
||||||
receivedMsg = [[NSData dataWithBytes:data length:length] retain];
|
|
||||||
msgLength = length;
|
|
||||||
|
|
||||||
// This is done when a message is successfully received. Stop the main loop after reading
|
|
||||||
[self setReading:NO];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (unsigned int) getMsgLength
|
|
||||||
{
|
|
||||||
return msgLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) l2capChannelReconfigured:(IOBluetoothL2CAPChannel*) l2capChannel
|
|
||||||
{
|
|
||||||
//NSLog(@"l2capChannelReconfigured");
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) l2capChannelWriteComplete:(IOBluetoothL2CAPChannel*) l2capChannel refcon:(void*) refcon status:(IOReturn) error
|
|
||||||
{
|
|
||||||
//NSLog(@"l2capChannelWriteComplete");
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) l2capChannelQueueSpaceAvailable:(IOBluetoothL2CAPChannel*) l2capChannel
|
|
||||||
{
|
|
||||||
//NSLog(@"l2capChannelQueueSpaceAvailable");
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) l2capChannelOpenComplete:(IOBluetoothL2CAPChannel*) l2capChannel status:(IOReturn) error
|
|
||||||
{
|
|
||||||
//NSLog(@"l2capChannelOpenComplete (PSM:0x%x)", [l2capChannel getPSM]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
#pragma mark -
|
|
||||||
#pragma mark Wiiuse
|
|
||||||
/**
|
|
||||||
* @brief Find a wiimote or wiimotes.
|
|
||||||
*
|
|
||||||
* @param wm An array of wiimote_t structures.
|
|
||||||
* @param max_wiimotes The number of wiimote structures in \a wm.
|
|
||||||
* @param timeout The number of seconds before the search times out.
|
|
||||||
*
|
|
||||||
* @return The number of wiimotes found.
|
|
||||||
*
|
|
||||||
* @see wiimote_connect()
|
|
||||||
*
|
|
||||||
* This function will only look for wiimote devices. \n
|
|
||||||
* When a device is found the address in the structures will be set. \n
|
|
||||||
* You can then call wiimote_connect() to connect to the found \n
|
|
||||||
* devices.
|
|
||||||
*
|
|
||||||
* This function is defined in wiiuse.h
|
|
||||||
*/
|
|
||||||
int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int timeout)
|
|
||||||
{
|
|
||||||
int found_wiimotes = 0;
|
|
||||||
|
|
||||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
|
||||||
WiiSearch* search = [[WiiSearch alloc] init];
|
|
||||||
[search setWiimoteStruct:wm];
|
|
||||||
|
|
||||||
if(timeout) { // Single search
|
|
||||||
[search start:timeout maxWiimotes:max_wiimotes];
|
|
||||||
|
|
||||||
NSRunLoop *theRL = [NSRunLoop currentRunLoop];
|
|
||||||
while ([search isDiscovering] && [theRL runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]);
|
|
||||||
|
|
||||||
found_wiimotes = [search getFoundWiimotes];
|
|
||||||
}
|
|
||||||
else { // Unlimited search
|
|
||||||
found_wiimotes = 0;
|
|
||||||
while(!found_wiimotes) {
|
|
||||||
[search start:timeout maxWiimotes:max_wiimotes];
|
|
||||||
|
|
||||||
NSRunLoop *theRL = [NSRunLoop currentRunLoop];
|
|
||||||
while ([search isDiscovering] && [theRL runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]);
|
|
||||||
|
|
||||||
found_wiimotes = [search getFoundWiimotes];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
WIIUSE_INFO("Found %i Wiimote device(s).", found_wiimotes);
|
|
||||||
|
|
||||||
[search release];
|
|
||||||
[pool drain];
|
|
||||||
|
|
||||||
return found_wiimotes;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//*************** HANDLERS FOR WIIUSE_DISCONNECT FOR MACOSX *******************/
|
|
||||||
/**
|
|
||||||
* @brief Disconnect a wiimote.
|
|
||||||
*
|
|
||||||
* @param wm Pointer to a wiimote_t structure.
|
|
||||||
*
|
|
||||||
* @see wiic_connect()
|
|
||||||
*
|
|
||||||
* Note that this will not free the wiimote structure.
|
|
||||||
*
|
|
||||||
* This function is defined in wiiuse.h
|
|
||||||
*/
|
|
||||||
void wiiuse_disconnect(struct wiimote_t* wm)
|
|
||||||
{
|
|
||||||
IOReturn error;
|
|
||||||
|
|
||||||
if (!wm || !WIIMOTE_IS_CONNECTED(wm))
|
|
||||||
return;
|
|
||||||
|
|
||||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
|
||||||
|
|
||||||
// Input Channel
|
|
||||||
if(wm->inputCh) {
|
|
||||||
IOBluetoothL2CAPChannel* inCh = [IOBluetoothL2CAPChannel withL2CAPChannelRef:wm->inputCh];
|
|
||||||
error = [inCh closeChannel];
|
|
||||||
[inCh setDelegate:nil];
|
|
||||||
if(error != kIOReturnSuccess)
|
|
||||||
WIIUSE_ERROR("Unable to close input channel (id %i).", wm->unid);
|
|
||||||
usleep(10000);
|
|
||||||
[inCh release];
|
|
||||||
inCh = nil;
|
|
||||||
wm->inputCh = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Output Channel
|
|
||||||
if(wm->outputCh) {
|
|
||||||
IOBluetoothL2CAPChannel* outCh = [IOBluetoothL2CAPChannel withL2CAPChannelRef:wm->outputCh];
|
|
||||||
error = [outCh closeChannel];
|
|
||||||
[outCh setDelegate:nil];
|
|
||||||
if(error != kIOReturnSuccess)
|
|
||||||
WIIUSE_ERROR("Unable to close output channel (id %i).", wm->unid);
|
|
||||||
usleep(10000);
|
|
||||||
[outCh release];
|
|
||||||
outCh = nil;
|
|
||||||
wm->outputCh = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Device
|
|
||||||
if(wm->device) {
|
|
||||||
IOBluetoothDevice* device = [IOBluetoothDevice withDeviceRef:wm->device];
|
|
||||||
error = [device closeConnection];
|
|
||||||
|
|
||||||
if(error != kIOReturnSuccess)
|
|
||||||
WIIUSE_ERROR("Unable to close the device connection (id %i).", wm->unid);
|
|
||||||
usleep(10000);
|
|
||||||
[device release];
|
|
||||||
device = nil;
|
|
||||||
wm->device = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
[pool drain];
|
|
||||||
|
|
||||||
wm->event = WIIUSE_NONE;
|
|
||||||
|
|
||||||
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_CONNECTED);
|
|
||||||
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Connect to a wiimote with a known address.
|
|
||||||
*
|
|
||||||
* @param wm Pointer to a wiimote_t structure.
|
|
||||||
* @param address The address of the device to connect to.
|
|
||||||
* If NULL, use the address in the struct set by wiic_find().
|
|
||||||
*
|
|
||||||
* @return 1 on success, 0 on failure
|
|
||||||
* This function is defined in io_mac.h
|
|
||||||
*/
|
|
||||||
static int wiiuse_connect_single(struct wiimote_t* wm, char* address)
|
|
||||||
{
|
|
||||||
// Skip if already connected or device not found
|
|
||||||
if(!wm || WIIMOTE_IS_CONNECTED(wm) || wm->device == 0) {
|
|
||||||
WIIUSE_ERROR("Non existent device or already connected.");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert the IP address
|
|
||||||
// FIXME - see if it is possible
|
|
||||||
|
|
||||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
|
||||||
WiiConnect* connect = [[[WiiConnect alloc] init] autorelease];
|
|
||||||
if([connect connectToWiimote:wm] == kIOReturnSuccess) {
|
|
||||||
WIIUSE_INFO("Connected to wiimote [id %i].", wm->unid);
|
|
||||||
// This is stored to retrieve incoming data
|
|
||||||
wm->connectionHandler = (void*)([connect retain]);
|
|
||||||
|
|
||||||
// Do the handshake
|
|
||||||
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_CONNECTED);
|
|
||||||
wiiuse_handshake(wm, NULL, 0);
|
|
||||||
wiiuse_set_report_type(wm);
|
|
||||||
|
|
||||||
[pool drain];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
[pool drain];
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Connect to a wiimote or wiimotes once an address is known.
|
|
||||||
*
|
|
||||||
* @param wm An array of wiimote_t structures.
|
|
||||||
* @param wiimotes The number of wiimote structures in \a wm.
|
|
||||||
*
|
|
||||||
* @return The number of wiimotes that successfully connected.
|
|
||||||
*
|
|
||||||
* @see wiic_find()
|
|
||||||
* @see wiic_connect_single()
|
|
||||||
* @see wiic_disconnect()
|
|
||||||
*
|
|
||||||
* Connect to a number of wiimotes when the address is already set
|
|
||||||
* in the wiimote_t structures. These addresses are normally set
|
|
||||||
* by the wiic_find() function, but can also be set manually.
|
|
||||||
* This function is defined in wiiuse.h
|
|
||||||
*/
|
|
||||||
int wiiuse_connect(struct wiimote_t** wm, int wiimotes)
|
|
||||||
{
|
|
||||||
int connected = 0;
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
for (; i < wiimotes; ++i) {
|
|
||||||
if(!(wm[i])) {
|
|
||||||
WIIUSE_ERROR("Trying to connect more Wiimotes than initialized");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!WIIMOTE_IS_SET(wm[i], WIIMOTE_STATE_DEV_FOUND))
|
|
||||||
// If the device address is not set, skip it
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (wiiuse_connect_single(wm[i], NULL))
|
|
||||||
++connected;
|
|
||||||
}
|
|
||||||
|
|
||||||
return connected;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Load Wii devices registered in the wiimotes.config file.
|
|
||||||
*
|
|
||||||
* @param wm An array of wiimote_t structures.
|
|
||||||
*
|
|
||||||
* @return The number of wiimotes successfully loaded.
|
|
||||||
*
|
|
||||||
* @see wiic_find()
|
|
||||||
* @see wiic_connect()
|
|
||||||
* @see wiic_connect_single()
|
|
||||||
* @see wiic_disconnect()
|
|
||||||
*
|
|
||||||
* From version 0.53, it is possible to register the MAC address of your
|
|
||||||
* Wii devices. This allows to automatically load them, without waiting for any
|
|
||||||
* search timeout. To register a new device, go to: <HOME_DIR>/.wiic/ and
|
|
||||||
* edit the file wiimotes.config, by adding the MAC address of the device
|
|
||||||
* you want to register (one line per MAC address).
|
|
||||||
* This function seems useful but it's not implemented in wiiuse
|
|
||||||
* TODO: Erase or implement elsewhere
|
|
||||||
*/
|
|
||||||
int wiiuse_load(struct wiimote_t** wm)
|
|
||||||
{
|
|
||||||
int loaded = 0;
|
|
||||||
int i = 0;
|
|
||||||
char str[200];
|
|
||||||
char configPath[100];
|
|
||||||
char* tmp = 0;
|
|
||||||
|
|
||||||
// Retrieve the HOME environment variable
|
|
||||||
tmp = getenv("HOME");
|
|
||||||
strcpy(configPath,tmp);
|
|
||||||
strncat(configPath,"/.wiic/wiimotes.config",22);
|
|
||||||
|
|
||||||
// Open the config file
|
|
||||||
FILE* fd = 0;
|
|
||||||
fd = fopen(configPath,"r");
|
|
||||||
if(!fd)
|
|
||||||
return loaded;
|
|
||||||
|
|
||||||
// Read line by line
|
|
||||||
while(fgets(str,sizeof(str),fd) != NULL && loaded < 1) {
|
|
||||||
int len = strlen(str)-1;
|
|
||||||
if(str[len] == '\n')
|
|
||||||
str[len] = 0;
|
|
||||||
loaded++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We initialize the device structure
|
|
||||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
|
||||||
for (; i < loaded; ++i) {
|
|
||||||
NSString* string = [NSString stringWithCString:str encoding:[NSString defaultCStringEncoding]];
|
|
||||||
BluetoothDeviceAddress deviceAddr;
|
|
||||||
IOBluetoothNSStringToDeviceAddress(string, &deviceAddr);
|
|
||||||
IOBluetoothDevice* device = [IOBluetoothDevice withAddress:&deviceAddr];
|
|
||||||
wm[i]->device = [[device retain] getDeviceRef];
|
|
||||||
wm[i]->address = (CFStringRef)[[device getAddressString] retain];
|
|
||||||
WIIMOTE_ENABLE_STATE(wm[i], WIIMOTE_STATE_DEV_FOUND);
|
|
||||||
WIIUSE_INFO("Loaded Wiimote (%s) [id %i].",CFStringGetCStringPtr(wm[i]->address, kCFStringEncodingMacRoman),wm[i]->unid);
|
|
||||||
}
|
|
||||||
[pool drain];
|
|
||||||
|
|
||||||
return loaded;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Defined in io.h
|
|
||||||
int wiiuse_io_read(struct wiimote_t* wm)
|
|
||||||
{
|
|
||||||
if (!WIIMOTE_IS_SET(wm, WIIMOTE_STATE_CONNECTED))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* If this wiimote is not connected, skip it */
|
|
||||||
if (!WIIMOTE_IS_CONNECTED(wm))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
|
||||||
|
|
||||||
WiiConnect* deviceHandler = 0;
|
|
||||||
deviceHandler = (WiiConnect*)(wm->connectionHandler);
|
|
||||||
|
|
||||||
/* If this wiimote is disconnecting, skip it */
|
|
||||||
if (!deviceHandler || [deviceHandler isDisconnecting]) {
|
|
||||||
[pool drain];
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run the main loop to get bt data
|
|
||||||
[deviceHandler setReading:YES];
|
|
||||||
[deviceHandler setTimeout:NO];
|
|
||||||
|
|
||||||
// We start the thread which manages the timeout to implement a non-blocking read
|
|
||||||
[NSThread detachNewThreadSelector:@selector(startTimerThread) toTarget:deviceHandler withObject:nil];
|
|
||||||
|
|
||||||
NSRunLoop *theRL = [NSRunLoop currentRunLoop];
|
|
||||||
// Two possible events: we receive and incoming message or there is a timeout
|
|
||||||
while([deviceHandler isReading] && ![deviceHandler isTimeout]) {
|
|
||||||
NSAutoreleasePool *pool_loop = [[NSAutoreleasePool alloc] init]; // This is used for fast release of NSDate, otherwise it leaks
|
|
||||||
[theRL runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
|
|
||||||
[pool_loop drain];
|
|
||||||
}
|
|
||||||
|
|
||||||
// In this case we have no incoming data (TIMEOUT)
|
|
||||||
if([deviceHandler isTimeout]) {
|
|
||||||
[pool drain];
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!(wm->connectionHandler)) {
|
|
||||||
WIIUSE_ERROR("Unable to find the connection handler (id %i).", wm->unid);
|
|
||||||
[pool drain];
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read next message
|
|
||||||
byte* buffer = 0;
|
|
||||||
unsigned int length = 0;
|
|
||||||
if(![deviceHandler isDisconnecting]) {
|
|
||||||
buffer = [deviceHandler getNextMsg];
|
|
||||||
length = [deviceHandler getMsgLength];
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!buffer || !length) {
|
|
||||||
[pool drain];
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Forward to WiiC
|
|
||||||
if(length < sizeof(wm->event_buf))
|
|
||||||
memcpy(wm->event_buf,buffer,length);
|
|
||||||
else {
|
|
||||||
WIIUSE_DEBUG("Received data are more than the buffer.... strange! (id %i)", wm->unid);
|
|
||||||
memcpy(wm->event_buf,buffer,sizeof(wm->event_buf));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Release the consumed message
|
|
||||||
[deviceHandler deleteMsg];
|
|
||||||
|
|
||||||
[pool drain];
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Defined in io.h
|
|
||||||
int wiiuse_io_write(struct wiimote_t* wm, byte* buf, int len)
|
|
||||||
{
|
|
||||||
unsigned int length = (unsigned int)len;
|
|
||||||
|
|
||||||
// Small check before writing
|
|
||||||
if(!wm || !(wm->outputCh)) {
|
|
||||||
WIIUSE_ERROR("Attempt to write over non-existent channel (id %i).", wm->unid);
|
|
||||||
perror("Error Details");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
|
||||||
|
|
||||||
IOBluetoothL2CAPChannel* channel = [IOBluetoothL2CAPChannel withL2CAPChannelRef:wm->outputCh];
|
|
||||||
IOReturn error = [channel writeSync:buf length:length];
|
|
||||||
|
|
||||||
if (error != kIOReturnSuccess)
|
|
||||||
{
|
|
||||||
WIIUSE_ERROR("Unable to write over the output channel (id %i).", wm->unid);
|
|
||||||
WIIUSE_INFO("Attempting to reopen the output channel (id %i).", wm->unid);
|
|
||||||
|
|
||||||
IOReturn error = [channel closeChannel];
|
|
||||||
if (error != kIOReturnSuccess)
|
|
||||||
WIIUSE_ERROR("Unable to close the output channel (id %i).", wm->unid);
|
|
||||||
[channel setDelegate:nil];
|
|
||||||
usleep(10000);
|
|
||||||
[channel release];
|
|
||||||
wm->outputCh = 0;
|
|
||||||
|
|
||||||
WiiConnect* connect = (WiiConnect*)(wm->connectionHandler);
|
|
||||||
|
|
||||||
IOBluetoothDevice* device = [IOBluetoothDevice withDeviceRef:wm->device];
|
|
||||||
channel = [connect openL2CAPChannelWithPSM:WM_OUTPUT_CHANNEL device:device delegate:connect];
|
|
||||||
if (!channel) {
|
|
||||||
WIIUSE_ERROR("Unable to open L2CAP output channel (id %i).", wm->unid);
|
|
||||||
[device closeConnection];
|
|
||||||
return kIOReturnNotOpen;
|
|
||||||
}
|
|
||||||
wm->outputCh = [[channel retain] getL2CAPChannelRef];
|
|
||||||
usleep(20000);
|
|
||||||
|
|
||||||
WIIUSE_INFO("Attempting to write again through the output channel (id %i).", wm->unid);
|
|
||||||
error = [channel writeSync:buf length:length];
|
|
||||||
if (error != kIOReturnSuccess)
|
|
||||||
{
|
|
||||||
WIIUSE_ERROR("Unable to write again over the output channel (id %i).", wm->unid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
usleep(10000);
|
|
||||||
|
|
||||||
[pool drain];
|
|
||||||
|
|
||||||
return (error == kIOReturnSuccess ? len : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wiiuse_init_platform_fields(struct wiimote_t* wm)
|
|
||||||
{
|
|
||||||
wm->device = nil;
|
|
||||||
wm->address = nil;
|
|
||||||
wm->inputCh = nil;
|
|
||||||
wm->outputCh = 0;
|
|
||||||
wm->disconnectionRef = nil;
|
|
||||||
wm->connectionHandler = NULL;
|
|
||||||
memset (wm->bdaddr_str,'\0',18);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wiiuse_cleanup_platform_fields(struct wiimote_t* wm)
|
|
||||||
{
|
|
||||||
/* TODO isn't this already done in wiiuse_disconnect ? */
|
|
||||||
wm->device = nil;
|
|
||||||
wm->address = nil;
|
|
||||||
wm->inputCh = nil;
|
|
||||||
wm->outputCh = 0;
|
|
||||||
wm->disconnectionRef = nil;
|
|
||||||
wm->connectionHandler = NULL;
|
|
||||||
memset (wm->bdaddr_str,'\0',18);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
131
src/ir.c
131
src/ir.c
@@ -57,15 +57,21 @@ static const byte WM_IR_BLOCK2_LEVEL4[] = "\x35\x03";
|
|||||||
static const byte WM_IR_BLOCK1_LEVEL5[] = "\x07\x00\x00\x71\x01\x00\x72\x00\x20";
|
static const byte WM_IR_BLOCK1_LEVEL5[] = "\x07\x00\x00\x71\x01\x00\x72\x00\x20";
|
||||||
static const byte WM_IR_BLOCK2_LEVEL5[] = "\x1f\x03";
|
static const byte WM_IR_BLOCK2_LEVEL5[] = "\x1f\x03";
|
||||||
|
|
||||||
void wiiuse_set_ir_mode(struct wiimote_t *wm)
|
void wiiuse_set_ir_mode(struct wiimote_t *wm) {
|
||||||
{
|
|
||||||
byte buf = 0x00;
|
byte buf = 0x00;
|
||||||
|
|
||||||
if(!wm) return;
|
if (!wm) {
|
||||||
if(!WIIMOTE_IS_SET(wm,WIIMOTE_STATE_IR)) return;
|
return;
|
||||||
|
}
|
||||||
|
if (!WIIMOTE_IS_SET(wm, WIIMOTE_STATE_IR)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(WIIMOTE_IS_SET(wm,WIIMOTE_STATE_EXP)) buf = WM_IR_TYPE_BASIC;
|
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_EXP)) {
|
||||||
else buf = WM_IR_TYPE_EXTENDED;
|
buf = WM_IR_TYPE_BASIC;
|
||||||
|
} else {
|
||||||
|
buf = WM_IR_TYPE_EXTENDED;
|
||||||
|
}
|
||||||
wiiuse_write_data(wm, WM_REG_IR_MODENUM, &buf, 1);
|
wiiuse_write_data(wm, WM_REG_IR_MODENUM, &buf, 1);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -80,8 +86,9 @@ void wiiuse_set_ir(struct wiimote_t* wm, int status) {
|
|||||||
const byte* block2 = NULL;
|
const byte* block2 = NULL;
|
||||||
int ir_level;
|
int ir_level;
|
||||||
|
|
||||||
if (!wm)
|
if (!wm) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Wait for the handshake to finish first.
|
* Wait for the handshake to finish first.
|
||||||
@@ -108,13 +115,15 @@ void wiiuse_set_ir(struct wiimote_t* wm, int status) {
|
|||||||
|
|
||||||
if (status) {
|
if (status) {
|
||||||
/* if already enabled then stop */
|
/* if already enabled then stop */
|
||||||
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_IR))
|
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_IR)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_IR);
|
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_IR);
|
||||||
} else {
|
} else {
|
||||||
/* if already disabled then stop */
|
/* if already disabled then stop */
|
||||||
if (!WIIMOTE_IS_SET(wm, WIIMOTE_STATE_IR))
|
if (!WIIMOTE_IS_SET(wm, WIIMOTE_STATE_IR)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_IR);
|
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_IR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,10 +150,11 @@ void wiiuse_set_ir(struct wiimote_t* wm, int status) {
|
|||||||
wiiuse_write_data(wm, WM_REG_IR_BLOCK2, (byte*)block2, 2);
|
wiiuse_write_data(wm, WM_REG_IR_BLOCK2, (byte*)block2, 2);
|
||||||
|
|
||||||
/* set the IR mode */
|
/* set the IR mode */
|
||||||
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_EXP))
|
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_EXP)) {
|
||||||
buf = WM_IR_TYPE_BASIC;
|
buf = WM_IR_TYPE_BASIC;
|
||||||
else
|
} else {
|
||||||
buf = WM_IR_TYPE_EXTENDED;
|
buf = WM_IR_TYPE_EXTENDED;
|
||||||
|
}
|
||||||
wiiuse_write_data(wm, WM_REG_IR_MODENUM, &buf, 1);
|
wiiuse_write_data(wm, WM_REG_IR_MODENUM, &buf, 1);
|
||||||
|
|
||||||
wiiuse_millisleep(50);
|
wiiuse_millisleep(50);
|
||||||
@@ -201,7 +211,9 @@ static int get_ir_sens(struct wiimote_t* wm, const byte** block1, const byte** b
|
|||||||
* @param status 1 to enable, 0 to disable.
|
* @param status 1 to enable, 0 to disable.
|
||||||
*/
|
*/
|
||||||
void wiiuse_set_ir_vres(struct wiimote_t* wm, unsigned int x, unsigned int y) {
|
void wiiuse_set_ir_vres(struct wiimote_t* wm, unsigned int x, unsigned int y) {
|
||||||
if (!wm) return;
|
if (!wm) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
wm->ir.vres[0] = (x - 1);
|
wm->ir.vres[0] = (x - 1);
|
||||||
wm->ir.vres[1] = (y - 1);
|
wm->ir.vres[1] = (y - 1);
|
||||||
@@ -214,7 +226,9 @@ void wiiuse_set_ir_vres(struct wiimote_t* wm, unsigned int x, unsigned int y) {
|
|||||||
* @param wm Pointer to a wiimote_t structure.
|
* @param wm Pointer to a wiimote_t structure.
|
||||||
*/
|
*/
|
||||||
void wiiuse_set_ir_position(struct wiimote_t* wm, enum ir_position_t pos) {
|
void wiiuse_set_ir_position(struct wiimote_t* wm, enum ir_position_t pos) {
|
||||||
if (!wm) return;
|
if (!wm) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
wm->ir.pos = pos;
|
wm->ir.pos = pos;
|
||||||
|
|
||||||
@@ -223,20 +237,22 @@ void wiiuse_set_ir_position(struct wiimote_t* wm, enum ir_position_t pos) {
|
|||||||
case WIIUSE_IR_ABOVE:
|
case WIIUSE_IR_ABOVE:
|
||||||
wm->ir.offset[0] = 0;
|
wm->ir.offset[0] = 0;
|
||||||
|
|
||||||
if (wm->ir.aspect == WIIUSE_ASPECT_16_9)
|
if (wm->ir.aspect == WIIUSE_ASPECT_16_9) {
|
||||||
wm->ir.offset[1] = WM_ASPECT_16_9_Y / 2 - 70;
|
wm->ir.offset[1] = WM_ASPECT_16_9_Y / 2 - 70;
|
||||||
else if (wm->ir.aspect == WIIUSE_ASPECT_4_3)
|
} else if (wm->ir.aspect == WIIUSE_ASPECT_4_3) {
|
||||||
wm->ir.offset[1] = WM_ASPECT_4_3_Y / 2 - 100;
|
wm->ir.offset[1] = WM_ASPECT_4_3_Y / 2 - 100;
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case WIIUSE_IR_BELOW:
|
case WIIUSE_IR_BELOW:
|
||||||
wm->ir.offset[0] = 0;
|
wm->ir.offset[0] = 0;
|
||||||
|
|
||||||
if (wm->ir.aspect == WIIUSE_ASPECT_16_9)
|
if (wm->ir.aspect == WIIUSE_ASPECT_16_9) {
|
||||||
wm->ir.offset[1] = -WM_ASPECT_16_9_Y / 2 + 100;
|
wm->ir.offset[1] = -WM_ASPECT_16_9_Y / 2 + 100;
|
||||||
else if (wm->ir.aspect == WIIUSE_ASPECT_4_3)
|
} else if (wm->ir.aspect == WIIUSE_ASPECT_4_3) {
|
||||||
wm->ir.offset[1] = -WM_ASPECT_4_3_Y / 2 + 70;
|
wm->ir.offset[1] = -WM_ASPECT_4_3_Y / 2 + 70;
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -253,7 +269,9 @@ void wiiuse_set_ir_position(struct wiimote_t* wm, enum ir_position_t pos) {
|
|||||||
* @param aspect Either WIIUSE_ASPECT_16_9 or WIIUSE_ASPECT_4_3
|
* @param aspect Either WIIUSE_ASPECT_16_9 or WIIUSE_ASPECT_4_3
|
||||||
*/
|
*/
|
||||||
void wiiuse_set_aspect_ratio(struct wiimote_t* wm, enum aspect_t aspect) {
|
void wiiuse_set_aspect_ratio(struct wiimote_t* wm, enum aspect_t aspect) {
|
||||||
if (!wm) return;
|
if (!wm) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
wm->ir.aspect = aspect;
|
wm->ir.aspect = aspect;
|
||||||
|
|
||||||
@@ -283,10 +301,16 @@ void wiiuse_set_ir_sensitivity(struct wiimote_t* wm, int level) {
|
|||||||
const byte* block1 = NULL;
|
const byte* block1 = NULL;
|
||||||
const byte* block2 = NULL;
|
const byte* block2 = NULL;
|
||||||
|
|
||||||
if (!wm) return;
|
if (!wm) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (level > 5) level = 5;
|
if (level > 5) {
|
||||||
if (level < 1) level = 1;
|
level = 5;
|
||||||
|
}
|
||||||
|
if (level < 1) {
|
||||||
|
level = 1;
|
||||||
|
}
|
||||||
|
|
||||||
WIIMOTE_DISABLE_STATE(wm, (WIIMOTE_STATE_IR_SENS_LVL1 |
|
WIIMOTE_DISABLE_STATE(wm, (WIIMOTE_STATE_IR_SENS_LVL1 |
|
||||||
WIIMOTE_STATE_IR_SENS_LVL2 |
|
WIIMOTE_STATE_IR_SENS_LVL2 |
|
||||||
@@ -348,9 +372,9 @@ void calculate_basic_ir(struct wiimote_t* wm, byte* data) {
|
|||||||
|
|
||||||
/* set each IR spot to visible if spot is in range */
|
/* set each IR spot to visible if spot is in range */
|
||||||
for (i = 0; i < 4; ++i) {
|
for (i = 0; i < 4; ++i) {
|
||||||
if (dot[i].ry == 1023)
|
if (dot[i].ry == 1023) {
|
||||||
dot[i].visible = 0;
|
dot[i].visible = 0;
|
||||||
else {
|
} else {
|
||||||
dot[i].visible = 1;
|
dot[i].visible = 1;
|
||||||
dot[i].size = 0; /* since we don't know the size, set it as 0 */
|
dot[i].size = 0; /* since we don't know the size, set it as 0 */
|
||||||
}
|
}
|
||||||
@@ -377,11 +401,12 @@ void calculate_extended_ir(struct wiimote_t* wm, byte* data) {
|
|||||||
dot[i].size = data[(3 * i) + 2] & 0x0F;
|
dot[i].size = data[(3 * i) + 2] & 0x0F;
|
||||||
|
|
||||||
/* if in range set to visible */
|
/* if in range set to visible */
|
||||||
if (dot[i].ry == 1023)
|
if (dot[i].ry == 1023) {
|
||||||
dot[i].visible = 0;
|
dot[i].visible = 0;
|
||||||
else
|
} else {
|
||||||
dot[i].visible = 1;
|
dot[i].visible = 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
interpret_ir_data(wm);
|
interpret_ir_data(wm);
|
||||||
}
|
}
|
||||||
@@ -398,24 +423,26 @@ static void interpret_ir_data(struct wiimote_t* wm) {
|
|||||||
float roll = 0.0f;
|
float roll = 0.0f;
|
||||||
int last_num_dots = wm->ir.num_dots;
|
int last_num_dots = wm->ir.num_dots;
|
||||||
|
|
||||||
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_ACC))
|
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_ACC)) {
|
||||||
roll = wm->orient.roll;
|
roll = wm->orient.roll;
|
||||||
|
}
|
||||||
|
|
||||||
/* count visible dots */
|
/* count visible dots */
|
||||||
wm->ir.num_dots = 0;
|
wm->ir.num_dots = 0;
|
||||||
for (i = 0; i < 4; ++i) {
|
for (i = 0; i < 4; ++i) {
|
||||||
if (dot[i].visible)
|
if (dot[i].visible) {
|
||||||
wm->ir.num_dots++;
|
wm->ir.num_dots++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (wm->ir.num_dots) {
|
switch (wm->ir.num_dots) {
|
||||||
case 0:
|
case 0: {
|
||||||
{
|
|
||||||
wm->ir.state = 0;
|
wm->ir.state = 0;
|
||||||
|
|
||||||
/* reset the dot ordering */
|
/* reset the dot ordering */
|
||||||
for (i = 0; i < 4; ++i)
|
for (i = 0; i < 4; ++i) {
|
||||||
dot[i].order = 0;
|
dot[i].order = 0;
|
||||||
|
}
|
||||||
|
|
||||||
wm->ir.x = 0;
|
wm->ir.x = 0;
|
||||||
wm->ir.y = 0;
|
wm->ir.y = 0;
|
||||||
@@ -423,8 +450,7 @@ static void interpret_ir_data(struct wiimote_t* wm) {
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case 1:
|
case 1: {
|
||||||
{
|
|
||||||
fix_rotated_ir_dots(wm->ir.dot, roll);
|
fix_rotated_ir_dots(wm->ir.dot, roll);
|
||||||
|
|
||||||
if (wm->ir.state < 2) {
|
if (wm->ir.state < 2) {
|
||||||
@@ -459,10 +485,13 @@ static void interpret_ir_data(struct wiimote_t* wm) {
|
|||||||
|
|
||||||
if (dot[i].order == 1)
|
if (dot[i].order == 1)
|
||||||
/* visible is the left dot - estimate where the right is */
|
/* visible is the left dot - estimate where the right is */
|
||||||
|
{
|
||||||
ox = (int32_t)(dot[i].x + wm->ir.distance);
|
ox = (int32_t)(dot[i].x + wm->ir.distance);
|
||||||
else if (dot[i].order == 2)
|
} else if (dot[i].order == 2)
|
||||||
/* visible is the right dot - estimate where the left is */
|
/* visible is the right dot - estimate where the left is */
|
||||||
|
{
|
||||||
ox = (int32_t)(dot[i].x - wm->ir.distance);
|
ox = (int32_t)(dot[i].x - wm->ir.distance);
|
||||||
|
}
|
||||||
|
|
||||||
x = ((signed int)dot[i].x + ox) / 2;
|
x = ((signed int)dot[i].x + ox) / 2;
|
||||||
y = dot[i].y;
|
y = dot[i].y;
|
||||||
@@ -486,8 +515,7 @@ static void interpret_ir_data(struct wiimote_t* wm) {
|
|||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
case 4:
|
case 4: {
|
||||||
{
|
|
||||||
/*
|
/*
|
||||||
* Two (or more) dots known and seen.
|
* Two (or more) dots known and seen.
|
||||||
* Average them together to estimate the true location.
|
* Average them together to estimate the true location.
|
||||||
@@ -521,8 +549,7 @@ static void interpret_ir_data(struct wiimote_t* wm) {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default: {
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -534,8 +561,9 @@ static void interpret_ir_data(struct wiimote_t* wm) {
|
|||||||
WIIUSE_DEBUG("IR sensitivity: %i", ir_level);
|
WIIUSE_DEBUG("IR sensitivity: %i", ir_level);
|
||||||
WIIUSE_DEBUG("IR visible dots: %i", wm->ir.num_dots);
|
WIIUSE_DEBUG("IR visible dots: %i", wm->ir.num_dots);
|
||||||
for (i = 0; i < 4; ++i)
|
for (i = 0; i < 4; ++i)
|
||||||
if (dot[i].visible)
|
if (dot[i].visible) {
|
||||||
WIIUSE_DEBUG("IR[%i][order %i] (%.3i, %.3i) -> (%.3i, %.3i)", i, dot[i].order, dot[i].rx, dot[i].ry, dot[i].x, dot[i].y);
|
WIIUSE_DEBUG("IR[%i][order %i] (%.3i, %.3i) -> (%.3i, %.3i)", i, dot[i].order, dot[i].rx, dot[i].ry, dot[i].x, dot[i].y);
|
||||||
|
}
|
||||||
WIIUSE_DEBUG("IR[absolute]: (%i, %i)", wm->ir.x, wm->ir.y);
|
WIIUSE_DEBUG("IR[absolute]: (%i, %i)", wm->ir.x, wm->ir.y);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -579,8 +607,9 @@ static void fix_rotated_ir_dots(struct ir_dot_t* dot, float ang) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
for (i = 0; i < 4; ++i) {
|
for (i = 0; i < 4; ++i) {
|
||||||
if (!dot[i].visible)
|
if (!dot[i].visible) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
x = dot[i].rx - (1024 / 2);
|
x = dot[i].rx - (1024 / 2);
|
||||||
y = dot[i].ry - (768 / 2);
|
y = dot[i].ry - (768 / 2);
|
||||||
@@ -629,20 +658,23 @@ static void reorder_ir_dots(struct ir_dot_t* dot) {
|
|||||||
int i, j, order;
|
int i, j, order;
|
||||||
|
|
||||||
/* reset the dot ordering */
|
/* reset the dot ordering */
|
||||||
for (i = 0; i < 4; ++i)
|
for (i = 0; i < 4; ++i) {
|
||||||
dot[i].order = 0;
|
dot[i].order = 0;
|
||||||
|
}
|
||||||
|
|
||||||
for (order = 1; order < 5; ++order) {
|
for (order = 1; order < 5; ++order) {
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
for (; !dot[i].visible || dot[i].order; ++i)
|
for (; !dot[i].visible || dot[i].order; ++i)
|
||||||
if (i >= 3)
|
if (i >= 3) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (j = 0; j < 4; ++j) {
|
for (j = 0; j < 4; ++j) {
|
||||||
if (dot[j].visible && !dot[j].order && (dot[j].x < dot[i].x))
|
if (dot[j].visible && !dot[j].order && (dot[j].x < dot[i].x)) {
|
||||||
i = j;
|
i = j;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dot[i].order = order;
|
dot[i].order = order;
|
||||||
}
|
}
|
||||||
@@ -659,16 +691,20 @@ static float ir_distance(struct ir_dot_t* dot) {
|
|||||||
int xd, yd;
|
int xd, yd;
|
||||||
|
|
||||||
for (i1 = 0; i1 < 4; ++i1)
|
for (i1 = 0; i1 < 4; ++i1)
|
||||||
if (dot[i1].visible)
|
if (dot[i1].visible) {
|
||||||
break;
|
break;
|
||||||
if (i1 == 4)
|
}
|
||||||
|
if (i1 == 4) {
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
for (i2 = i1 + 1; i2 < 4; ++i2)
|
for (i2 = i1 + 1; i2 < 4; ++i2)
|
||||||
if (dot[i2].visible)
|
if (dot[i2].visible) {
|
||||||
break;
|
break;
|
||||||
if (i2 == 4)
|
}
|
||||||
|
if (i2 == 4) {
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
xd = dot[i2].x - dot[i1].x;
|
xd = dot[i2].x - dot[i1].x;
|
||||||
yd = dot[i2].y - dot[i1].y;
|
yd = dot[i2].y - dot[i1].y;
|
||||||
@@ -709,8 +745,7 @@ static int ir_correct_for_bounds(int* x, int* y, enum aspect_t aspect, int offse
|
|||||||
if ((*x >= x0)
|
if ((*x >= x0)
|
||||||
&& (*x <= (x0 + xs))
|
&& (*x <= (x0 + xs))
|
||||||
&& (*y >= y0)
|
&& (*y >= y0)
|
||||||
&& (*y <= (y0 + ys)))
|
&& (*y <= (y0 + ys))) {
|
||||||
{
|
|
||||||
*x -= offset_x;
|
*x -= offset_x;
|
||||||
*y -= offset_y;
|
*y -= offset_y;
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include "motion_plus.h"
|
#include "motion_plus.h"
|
||||||
|
|
||||||
|
#include "io.h" /* for wiiuse_read */
|
||||||
#include "events.h" /* for disable_expansion */
|
#include "events.h" /* for disable_expansion */
|
||||||
#include "ir.h" /* for wiiuse_set_ir_mode */
|
#include "ir.h" /* for wiiuse_set_ir_mode */
|
||||||
#include "nunchuk.h" /* for nunchuk_pressed_buttons */
|
#include "nunchuk.h" /* for nunchuk_pressed_buttons */
|
||||||
@@ -42,15 +43,70 @@ static void wiiuse_calibrate_motion_plus(struct motion_plus_t *mp);
|
|||||||
static void calculate_gyro_rates(struct motion_plus_t* mp);
|
static void calculate_gyro_rates(struct motion_plus_t* mp);
|
||||||
|
|
||||||
|
|
||||||
void wiiuse_motion_plus_handshake(struct wiimote_t *wm,byte *data,unsigned short len)
|
void wiiuse_probe_motion_plus(struct wiimote_t *wm) {
|
||||||
{
|
byte buf[MAX_PAYLOAD];
|
||||||
uint32_t val;
|
unsigned id;
|
||||||
if(data == NULL)
|
|
||||||
{
|
wiiuse_read_data_sync(wm, 0, WM_EXP_MOTION_PLUS_IDENT, 6, buf);
|
||||||
wiiuse_read_data_cb(wm, wiiuse_motion_plus_handshake, wm->motion_plus_id, WM_EXP_ID, 6);
|
|
||||||
|
/* check error code */
|
||||||
|
if (buf[4] & 0x0f) {
|
||||||
|
WIIUSE_DEBUG("No Motion+ available, stopping probe.");
|
||||||
|
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_MPLUS_PRESENT);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
/* decode the id */
|
||||||
|
id = from_big_endian_uint32_t(buf + 2);
|
||||||
|
|
||||||
|
if (id != EXP_ID_CODE_INACTIVE_MOTION_PLUS &&
|
||||||
|
id != EXP_ID_CODE_NLA_MOTION_PLUS &&
|
||||||
|
id != EXP_ID_CODE_NLA_MOTION_PLUS_NUNCHUK &&
|
||||||
|
id != EXP_ID_CODE_NLA_MOTION_PLUS_CLASSIC) {
|
||||||
|
/* we have read something weird */
|
||||||
|
WIIUSE_DEBUG("Motion+ ID doesn't match, probably not connected.");
|
||||||
|
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_MPLUS_PRESENT);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
WIIUSE_DEBUG("Detected inactive Motion+!");
|
||||||
|
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_MPLUS_PRESENT);
|
||||||
|
|
||||||
|
/* init M+ */
|
||||||
|
buf[0] = 0x55;
|
||||||
|
wiiuse_write_data(wm, WM_EXP_MOTION_PLUS_INIT, buf, 1);
|
||||||
|
|
||||||
|
/* Init whatever is hanging on the pass-through port */
|
||||||
|
buf[0] = 0x55;
|
||||||
|
wiiuse_write_data(wm, WM_EXP_MEM_ENABLE1, buf, 1);
|
||||||
|
|
||||||
|
buf[0] = 0x00;
|
||||||
|
wiiuse_write_data(wm, WM_EXP_MEM_ENABLE2, buf, 1);
|
||||||
|
|
||||||
|
/* Init gyroscope data */
|
||||||
|
wm->exp.mp.cal_gyro.roll = 0;
|
||||||
|
wm->exp.mp.cal_gyro.pitch = 0;
|
||||||
|
wm->exp.mp.cal_gyro.yaw = 0;
|
||||||
|
wm->exp.mp.orient.roll = 0.0;
|
||||||
|
wm->exp.mp.orient.pitch = 0.0;
|
||||||
|
wm->exp.mp.orient.yaw = 0.0;
|
||||||
|
wm->exp.mp.raw_gyro_threshold = 10;
|
||||||
|
|
||||||
|
wm->exp.mp.nc = &(wm->exp.nunchuk);
|
||||||
|
wm->exp.mp.classic = &(wm->exp.classic);
|
||||||
|
wm->exp.nunchuk.flags = &wm->flags;
|
||||||
|
|
||||||
|
wm->exp.mp.ext = 0;
|
||||||
|
|
||||||
|
wiiuse_set_ir_mode(wm);
|
||||||
|
wiiuse_set_report_type(wm);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wiiuse_motion_plus_handshake(struct wiimote_t *wm, byte *data, unsigned short len) {
|
||||||
|
uint32_t val;
|
||||||
|
if (data == NULL) {
|
||||||
|
wiiuse_read_data_cb(wm, wiiuse_motion_plus_handshake, wm->motion_plus_id, WM_EXP_ID, 6);
|
||||||
|
} else {
|
||||||
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_EXP_FAILED);
|
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_EXP_FAILED);
|
||||||
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_EXP_HANDSHAKE);
|
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_EXP_HANDSHAKE);
|
||||||
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_EXP); /* tell wiimote to include exp. data in reports */
|
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_EXP); /* tell wiimote to include exp. data in reports */
|
||||||
@@ -59,13 +115,11 @@ void wiiuse_motion_plus_handshake(struct wiimote_t *wm,byte *data,unsigned short
|
|||||||
|
|
||||||
if (val == EXP_ID_CODE_MOTION_PLUS ||
|
if (val == EXP_ID_CODE_MOTION_PLUS ||
|
||||||
val == EXP_ID_CODE_MOTION_PLUS_NUNCHUK ||
|
val == EXP_ID_CODE_MOTION_PLUS_NUNCHUK ||
|
||||||
val == EXP_ID_CODE_MOTION_PLUS_CLASSIC)
|
val == EXP_ID_CODE_MOTION_PLUS_CLASSIC) {
|
||||||
{
|
|
||||||
/* handshake done */
|
/* handshake done */
|
||||||
wm->event = WIIUSE_MOTION_PLUS_ACTIVATED;
|
wm->event = WIIUSE_MOTION_PLUS_ACTIVATED;
|
||||||
|
|
||||||
switch(val)
|
switch (val) {
|
||||||
{
|
|
||||||
case EXP_ID_CODE_MOTION_PLUS:
|
case EXP_ID_CODE_MOTION_PLUS:
|
||||||
wm->exp.type = EXP_MOTION_PLUS;
|
wm->exp.type = EXP_MOTION_PLUS;
|
||||||
break;
|
break;
|
||||||
@@ -108,16 +162,14 @@ void wiiuse_motion_plus_handshake(struct wiimote_t *wm,byte *data,unsigned short
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wiiuse_set_motion_plus_clear2(struct wiimote_t *wm,byte *data,unsigned short len)
|
static void wiiuse_set_motion_plus_clear2(struct wiimote_t *wm, byte *data, unsigned short len) {
|
||||||
{
|
|
||||||
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_EXP_FAILED);
|
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_EXP_FAILED);
|
||||||
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_EXP_HANDSHAKE);
|
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_EXP_HANDSHAKE);
|
||||||
wiiuse_set_ir_mode(wm);
|
wiiuse_set_ir_mode(wm);
|
||||||
wiiuse_status(wm);
|
wiiuse_status(wm);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wiiuse_set_motion_plus_clear1(struct wiimote_t *wm,byte *data,unsigned short len)
|
static void wiiuse_set_motion_plus_clear1(struct wiimote_t *wm, byte *data, unsigned short len) {
|
||||||
{
|
|
||||||
byte val = 0x00;
|
byte val = 0x00;
|
||||||
wiiuse_write_data_cb(wm, WM_EXP_MEM_ENABLE1, &val, 1, wiiuse_set_motion_plus_clear2);
|
wiiuse_write_data_cb(wm, WM_EXP_MEM_ENABLE1, &val, 1, wiiuse_set_motion_plus_clear2);
|
||||||
}
|
}
|
||||||
@@ -129,32 +181,31 @@ static void wiiuse_set_motion_plus_clear1(struct wiimote_t *wm,byte *data,unsign
|
|||||||
* @param status 0 - off, 1 - on, standalone, 2 - nunchuk pass-through
|
* @param status 0 - off, 1 - on, standalone, 2 - nunchuk pass-through
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void wiiuse_set_motion_plus(struct wiimote_t *wm, int status)
|
void wiiuse_set_motion_plus(struct wiimote_t *wm, int status) {
|
||||||
{
|
|
||||||
byte val;
|
byte val;
|
||||||
|
|
||||||
if(status && !WIIMOTE_IS_SET(wm,WIIMOTE_STATE_EXP_HANDSHAKE))
|
if (!WIIMOTE_IS_SET(wm, WIIMOTE_STATE_MPLUS_PRESENT) ||
|
||||||
{
|
WIIMOTE_IS_SET(wm, WIIMOTE_STATE_EXP_HANDSHAKE)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status) {
|
||||||
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_EXP_HANDSHAKE);
|
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_EXP_HANDSHAKE);
|
||||||
val = (status == 1) ? 0x04 : 0x05;
|
val = (status == 1) ? 0x04 : 0x05;
|
||||||
wiiuse_write_data_cb(wm, WM_EXP_MOTION_PLUS_ENABLE, &val, 1, wiiuse_motion_plus_handshake);
|
wiiuse_write_data_cb(wm, WM_EXP_MOTION_PLUS_ENABLE, &val, 1, wiiuse_motion_plus_handshake);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
disable_expansion(wm);
|
disable_expansion(wm);
|
||||||
val = 0x55;
|
val = 0x55;
|
||||||
wiiuse_write_data_cb(wm, WM_EXP_MEM_ENABLE1, &val, 1, wiiuse_set_motion_plus_clear1);
|
wiiuse_write_data_cb(wm, WM_EXP_MEM_ENABLE1, &val, 1, wiiuse_set_motion_plus_clear1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void motion_plus_disconnected(struct motion_plus_t* mp)
|
void motion_plus_disconnected(struct motion_plus_t* mp) {
|
||||||
{
|
|
||||||
WIIUSE_DEBUG("Motion plus disconnected");
|
WIIUSE_DEBUG("Motion plus disconnected");
|
||||||
memset(mp, 0, sizeof(struct motion_plus_t));
|
memset(mp, 0, sizeof(struct motion_plus_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
void motion_plus_event(struct motion_plus_t* mp, int exp_type, byte* msg)
|
void motion_plus_event(struct motion_plus_t* mp, int exp_type, byte* msg) {
|
||||||
{
|
|
||||||
/*
|
/*
|
||||||
* Pass-through modes interleave data from the gyro
|
* Pass-through modes interleave data from the gyro
|
||||||
* with the expansion data. This extracts the tag
|
* with the expansion data. This extracts the tag
|
||||||
@@ -163,8 +214,7 @@ void motion_plus_event(struct motion_plus_t* mp, int exp_type, byte* msg)
|
|||||||
int isMPFrame = (1 << 1) & msg[5];
|
int isMPFrame = (1 << 1) & msg[5];
|
||||||
mp->ext = msg[4] & 0x1; /* extension attached to pass-through port? */
|
mp->ext = msg[4] & 0x1; /* extension attached to pass-through port? */
|
||||||
|
|
||||||
if (mp->ext == 0 || isMPFrame) /* reading gyro frame */
|
if (mp->ext == 0 || isMPFrame) { /* reading gyro frame */
|
||||||
{
|
|
||||||
/* Check if the gyroscope is in fast or slow mode (0 if rotating fast, 1 if slow or still) */
|
/* Check if the gyroscope is in fast or slow mode (0 if rotating fast, 1 if slow or still) */
|
||||||
mp->acc_mode = ((msg[4] & 0x2) << 1) | ((msg[3] & 0x1) << 1) | ((msg[3] & 0x2) >> 1);
|
mp->acc_mode = ((msg[4] & 0x2) << 1) | ((msg[3] & 0x1) << 1) | ((msg[3] & 0x2) >> 1);
|
||||||
|
|
||||||
@@ -181,8 +231,7 @@ void motion_plus_event(struct motion_plus_t* mp, int exp_type, byte* msg)
|
|||||||
(mp->raw_gyro.yaw < 0x3fff) &&
|
(mp->raw_gyro.yaw < 0x3fff) &&
|
||||||
!(mp->cal_gyro.roll) &&
|
!(mp->cal_gyro.roll) &&
|
||||||
!(mp->cal_gyro.pitch) &&
|
!(mp->cal_gyro.pitch) &&
|
||||||
!(mp->cal_gyro.yaw))
|
!(mp->cal_gyro.yaw)) {
|
||||||
{
|
|
||||||
wiiuse_calibrate_motion_plus(mp);
|
wiiuse_calibrate_motion_plus(mp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,11 +239,9 @@ void motion_plus_event(struct motion_plus_t* mp, int exp_type, byte* msg)
|
|||||||
calculate_gyro_rates(mp);
|
calculate_gyro_rates(mp);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
/* expansion frame */
|
/* expansion frame */
|
||||||
if (exp_type == EXP_MOTION_PLUS_NUNCHUK)
|
if (exp_type == EXP_MOTION_PLUS_NUNCHUK) {
|
||||||
{
|
|
||||||
/* ok, this is nunchuck, re-encode it as regular nunchuck packet */
|
/* ok, this is nunchuck, re-encode it as regular nunchuck packet */
|
||||||
|
|
||||||
/* get button states */
|
/* get button states */
|
||||||
@@ -219,13 +266,11 @@ void motion_plus_event(struct motion_plus_t* mp, int exp_type, byte* msg)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (exp_type == EXP_MOTION_PLUS_CLASSIC)
|
else if (exp_type == EXP_MOTION_PLUS_CLASSIC) {
|
||||||
{
|
|
||||||
WIIUSE_ERROR("Classic controller pass-through is not implemented!\n");
|
WIIUSE_ERROR("Classic controller pass-through is not implemented!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
WIIUSE_ERROR("Unsupported mode passed to motion_plus_event() !\n");
|
WIIUSE_ERROR("Unsupported mode passed to motion_plus_event() !\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -239,8 +284,7 @@ void motion_plus_event(struct motion_plus_t* mp, int exp_type, byte* msg)
|
|||||||
* This should be called only after receiving the first values
|
* This should be called only after receiving the first values
|
||||||
* from the Motion Plus.
|
* from the Motion Plus.
|
||||||
*/
|
*/
|
||||||
void wiiuse_calibrate_motion_plus(struct motion_plus_t *mp)
|
void wiiuse_calibrate_motion_plus(struct motion_plus_t *mp) {
|
||||||
{
|
|
||||||
mp->cal_gyro.roll = mp->raw_gyro.roll;
|
mp->cal_gyro.roll = mp->raw_gyro.roll;
|
||||||
mp->cal_gyro.pitch = mp->raw_gyro.pitch;
|
mp->cal_gyro.pitch = mp->raw_gyro.pitch;
|
||||||
mp->cal_gyro.yaw = mp->raw_gyro.yaw;
|
mp->cal_gyro.yaw = mp->raw_gyro.yaw;
|
||||||
@@ -249,8 +293,7 @@ void wiiuse_calibrate_motion_plus(struct motion_plus_t *mp)
|
|||||||
mp->orient.yaw = 0.0;
|
mp->orient.yaw = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void calculate_gyro_rates(struct motion_plus_t* mp)
|
static void calculate_gyro_rates(struct motion_plus_t* mp) {
|
||||||
{
|
|
||||||
short int tmp_r, tmp_p, tmp_y;
|
short int tmp_r, tmp_p, tmp_y;
|
||||||
float tmp_roll, tmp_pitch, tmp_yaw;
|
float tmp_roll, tmp_pitch, tmp_yaw;
|
||||||
|
|
||||||
@@ -260,28 +303,34 @@ static void calculate_gyro_rates(struct motion_plus_t* mp)
|
|||||||
tmp_y = mp->raw_gyro.yaw - mp->cal_gyro.yaw;
|
tmp_y = mp->raw_gyro.yaw - mp->cal_gyro.yaw;
|
||||||
|
|
||||||
/* We convert to degree/sec according to fast/slow mode */
|
/* We convert to degree/sec according to fast/slow mode */
|
||||||
if (mp->acc_mode & 0x04)
|
if (mp->acc_mode & 0x04) {
|
||||||
tmp_roll = (float)tmp_r / 20.0f;
|
tmp_roll = (float)tmp_r / 20.0f;
|
||||||
else
|
} else {
|
||||||
tmp_roll = (float)tmp_r / 4.0f;
|
tmp_roll = (float)tmp_r / 4.0f;
|
||||||
|
}
|
||||||
|
|
||||||
if (mp->acc_mode & 0x02)
|
if (mp->acc_mode & 0x02) {
|
||||||
tmp_pitch = (float)tmp_p / 20.0f;
|
tmp_pitch = (float)tmp_p / 20.0f;
|
||||||
else
|
} else {
|
||||||
tmp_pitch = (float)tmp_p / 4.0f;
|
tmp_pitch = (float)tmp_p / 4.0f;
|
||||||
|
}
|
||||||
|
|
||||||
if (mp->acc_mode & 0x01)
|
if (mp->acc_mode & 0x01) {
|
||||||
tmp_yaw = (float)tmp_y / 20.0f;
|
tmp_yaw = (float)tmp_y / 20.0f;
|
||||||
else
|
} else {
|
||||||
tmp_yaw = (float)tmp_y / 4.0f;
|
tmp_yaw = (float)tmp_y / 4.0f;
|
||||||
|
}
|
||||||
|
|
||||||
/* Simple filtering */
|
/* Simple filtering */
|
||||||
if (fabs(tmp_roll) < 0.5f)
|
if (fabs(tmp_roll) < 0.5f) {
|
||||||
tmp_roll = 0.0f;
|
tmp_roll = 0.0f;
|
||||||
if (fabs(tmp_pitch) < 0.5f)
|
}
|
||||||
|
if (fabs(tmp_pitch) < 0.5f) {
|
||||||
tmp_pitch = 0.0f;
|
tmp_pitch = 0.0f;
|
||||||
if (fabs(tmp_yaw) < 0.5f)
|
}
|
||||||
|
if (fabs(tmp_yaw) < 0.5f) {
|
||||||
tmp_yaw = 0.0f;
|
tmp_yaw = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
mp->angle_rate_gyro.roll = tmp_roll;
|
mp->angle_rate_gyro.roll = tmp_roll;
|
||||||
mp->angle_rate_gyro.pitch = tmp_pitch;
|
mp->angle_rate_gyro.pitch = tmp_pitch;
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ void motion_plus_event(struct motion_plus_t* mp, int exp_type, byte* msg);
|
|||||||
|
|
||||||
void wiiuse_motion_plus_handshake(struct wiimote_t *wm, byte *data, unsigned short len);
|
void wiiuse_motion_plus_handshake(struct wiimote_t *wm, byte *data, unsigned short len);
|
||||||
|
|
||||||
|
void wiiuse_probe_motion_plus(struct wiimote_t *wm);
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -77,9 +77,10 @@ int nunchuk_handshake(struct wiimote_t* wm, struct nunchuk_t* nc, byte* data, un
|
|||||||
wiiuse_read_data_cb(wm, handshake_expansion, handshake_buf, WM_EXP_MEM_CALIBR, EXP_HANDSHAKE_LEN);
|
wiiuse_read_data_cb(wm, handshake_expansion, handshake_buf, WM_EXP_MEM_CALIBR, EXP_HANDSHAKE_LEN);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} else
|
} else {
|
||||||
data += 16;
|
data += 16;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
nc->accel_calib.cal_zero.x = data[0];
|
nc->accel_calib.cal_zero.x = data[0];
|
||||||
nc->accel_calib.cal_zero.y = data[1];
|
nc->accel_calib.cal_zero.y = data[1];
|
||||||
@@ -177,7 +178,9 @@ void nunchuk_pressed_buttons(struct nunchuk_t* nc, byte now) {
|
|||||||
* See wiiuse_set_orient_threshold() for details.
|
* See wiiuse_set_orient_threshold() for details.
|
||||||
*/
|
*/
|
||||||
void wiiuse_set_nunchuk_orient_threshold(struct wiimote_t* wm, float threshold) {
|
void wiiuse_set_nunchuk_orient_threshold(struct wiimote_t* wm, float threshold) {
|
||||||
if (!wm) return;
|
if (!wm) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
wm->exp.nunchuk.orient_threshold = threshold;
|
wm->exp.nunchuk.orient_threshold = threshold;
|
||||||
}
|
}
|
||||||
@@ -192,7 +195,9 @@ void wiiuse_set_nunchuk_orient_threshold(struct wiimote_t* wm, float threshold)
|
|||||||
* See wiiuse_set_orient_threshold() for details.
|
* See wiiuse_set_orient_threshold() for details.
|
||||||
*/
|
*/
|
||||||
void wiiuse_set_nunchuk_accel_threshold(struct wiimote_t* wm, int threshold) {
|
void wiiuse_set_nunchuk_accel_threshold(struct wiimote_t* wm, int threshold) {
|
||||||
if (!wm) return;
|
if (!wm) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
wm->exp.nunchuk.accel_threshold = threshold;
|
wm->exp.nunchuk.accel_threshold = threshold;
|
||||||
}
|
}
|
||||||
|
|||||||
45
src/os.h
45
src/os.h
@@ -26,26 +26,39 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file
|
* @file
|
||||||
* @brief Operating system related definitions.
|
* @brief Handles device I/O.
|
||||||
*
|
|
||||||
* This file is an attempt to separate operating system
|
|
||||||
* dependent functions and choose what should be used
|
|
||||||
* at compile time.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef OS_H_INCLUDED
|
#ifndef PLATFORM_H_INCLUDED
|
||||||
#define OS_H_INCLUDED
|
#define PLATFORM_H_INCLUDED
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#include "wiiuse_internal.h"
|
||||||
#include <float.h>
|
|
||||||
/* windows with visual c */
|
#ifdef __cplusplus
|
||||||
#define isnan(x) (_isnan(x))
|
extern "C" {
|
||||||
#define isinf(x) (!_finite(x))
|
|
||||||
/* disable warnings I don't care about */
|
|
||||||
/*#pragma warning(disable:4273) */ /* inconsistent dll linkage */
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* OS_H_INCLUDED */
|
|
||||||
|
/** @defgroup internal_io Internal: Platform-specific Device I/O */
|
||||||
|
/** @{ */
|
||||||
|
void wiiuse_init_platform_fields(struct wiimote_t* wm);
|
||||||
|
void wiiuse_cleanup_platform_fields(struct wiimote_t* wm);
|
||||||
|
|
||||||
|
int wiiuse_os_find(struct wiimote_t** wm, int max_wiimotes, int timeout);
|
||||||
|
|
||||||
|
int wiiuse_os_connect(struct wiimote_t** wm, int wiimotes);
|
||||||
|
void wiiuse_os_disconnect(struct wiimote_t* wm);
|
||||||
|
|
||||||
|
int wiiuse_os_poll(struct wiimote_t** wm, int wiimotes);
|
||||||
|
/* buf[0] will be the report type, buf+1 the rest of the report */
|
||||||
|
int wiiuse_os_read(struct wiimote_t* wm, byte* buf, int len);
|
||||||
|
int wiiuse_os_write(struct wiimote_t* wm, byte report_type, byte* buf, int len);
|
||||||
|
/** @} */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* PLATFORM_H_INCLUDED */
|
||||||
|
|||||||
92
src/os_mac/os_mac.h
Normal file
92
src/os_mac/os_mac.h
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
/*
|
||||||
|
* wiiuse
|
||||||
|
*
|
||||||
|
* Written By:
|
||||||
|
* Michael Laforest < para >
|
||||||
|
* Email: < thepara (--AT--) g m a i l [--DOT--] com >
|
||||||
|
*
|
||||||
|
* Copyright 2006-2007
|
||||||
|
*
|
||||||
|
* This file is part of wiiuse.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* $Header$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* @brief Handles device I/O for Mac OS X.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
|
||||||
|
|
||||||
|
#define BLUETOOTH_VERSION_USE_CURRENT
|
||||||
|
|
||||||
|
#import <IOBluetooth/objc/IOBluetoothDevice.h>
|
||||||
|
#import <IOBluetooth/objc/IOBluetoothL2CAPChannel.h>
|
||||||
|
|
||||||
|
#import "../wiiuse_internal.h"
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7
|
||||||
|
#define WIIUSE_MAC_OS_X_VERSION_10_7_OR_ABOVE 1
|
||||||
|
#else
|
||||||
|
#define WIIUSE_MAC_OS_X_VERSION_10_7_OR_ABOVE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@interface WiiuseWiimote : NSObject<IOBluetoothL2CAPChannelDelegate> {
|
||||||
|
wiimote* wm; // reference to the C wiimote struct
|
||||||
|
|
||||||
|
IOBluetoothDevice* device;
|
||||||
|
IOBluetoothL2CAPChannel* controlChannel;
|
||||||
|
IOBluetoothL2CAPChannel* interruptChannel;
|
||||||
|
|
||||||
|
IOBluetoothUserNotification* disconnectNotification;
|
||||||
|
|
||||||
|
NSMutableArray* receivedData; // a queue of NSObject<WiiuseReceivedMessage>*
|
||||||
|
NSLock* receivedDataLock;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) initWithPtr: (wiimote*) wm device: (IOBluetoothDevice*) device;
|
||||||
|
|
||||||
|
- (IOReturn) connect;
|
||||||
|
- (void) disconnect;
|
||||||
|
|
||||||
|
- (int) readBuffer: (byte*) buffer length: (NSUInteger) bufferLength;
|
||||||
|
- (int) writeReport: (byte) report_type buffer: (byte*) buffer length: (NSUInteger) length;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
@protocol WiiuseReceivedMessage <NSObject>
|
||||||
|
- (int) applyToStruct: (wiimote*) wm buffer: (byte*) buffer length: (NSUInteger) bufferLength; // <0: not copied, 0: copied empty, >0: copied
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface WiiuseReceivedData : NSObject<WiiuseReceivedMessage> {
|
||||||
|
NSData* data;
|
||||||
|
}
|
||||||
|
- (id) initWithBytes: (void*) bytes length: (NSUInteger) length;
|
||||||
|
- (id) initWithData: (NSData*) data;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface WiiuseDisconnectionMessage : NSObject<WiiuseReceivedMessage> {
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __APPLE__
|
||||||
351
src/os_mac/os_mac.m
Normal file
351
src/os_mac/os_mac.m
Normal file
@@ -0,0 +1,351 @@
|
|||||||
|
/*
|
||||||
|
* wiiuse
|
||||||
|
*
|
||||||
|
* Written By:
|
||||||
|
* Michael Laforest < para >
|
||||||
|
* Email: < thepara (--AT--) g m a i l [--DOT--] com >
|
||||||
|
*
|
||||||
|
* Copyright 2006-2007
|
||||||
|
*
|
||||||
|
* This file is part of wiiuse.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* $Header$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* @brief Handles device I/O for Mac OS X.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
|
||||||
|
#import "os_mac.h"
|
||||||
|
|
||||||
|
#import "../events.h"
|
||||||
|
|
||||||
|
#import <IOBluetooth/IOBluetoothUtilities.h>
|
||||||
|
#import <IOBluetooth/objc/IOBluetoothDevice.h>
|
||||||
|
#import <IOBluetooth/objc/IOBluetoothHostController.h>
|
||||||
|
#import <IOBluetooth/objc/IOBluetoothDeviceInquiry.h>
|
||||||
|
#import <IOBluetooth/objc/IOBluetoothL2CAPChannel.h>
|
||||||
|
|
||||||
|
|
||||||
|
@implementation WiiuseWiimote
|
||||||
|
|
||||||
|
#pragma mark init, dealloc
|
||||||
|
|
||||||
|
- (id) initWithPtr: (wiimote*) wm_ device:(IOBluetoothDevice *)device_ {
|
||||||
|
self = [super init];
|
||||||
|
if(self) {
|
||||||
|
wm = wm_;
|
||||||
|
|
||||||
|
device = [device_ retain];
|
||||||
|
controlChannel = nil;
|
||||||
|
interruptChannel = nil;
|
||||||
|
|
||||||
|
disconnectNotification = nil;
|
||||||
|
|
||||||
|
receivedData = [[NSMutableArray alloc] initWithCapacity: 2];
|
||||||
|
receivedDataLock = [[NSLock alloc] init];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) dealloc {
|
||||||
|
wm = NULL;
|
||||||
|
|
||||||
|
[interruptChannel release];
|
||||||
|
[controlChannel release];
|
||||||
|
[device release];
|
||||||
|
|
||||||
|
[disconnectNotification unregister];
|
||||||
|
[disconnectNotification release];
|
||||||
|
|
||||||
|
[receivedData release];
|
||||||
|
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark connect, disconnect
|
||||||
|
|
||||||
|
- (BOOL) connectChannel: (IOBluetoothL2CAPChannel**) pChannel PSM: (BluetoothL2CAPPSM) psm {
|
||||||
|
if ([device openL2CAPChannelSync:pChannel withPSM:psm delegate:self] != kIOReturnSuccess) {
|
||||||
|
WIIUSE_ERROR("Unable to open L2CAP channel [id %i].", wm->unid);
|
||||||
|
*pChannel = nil;
|
||||||
|
return NO;
|
||||||
|
} else {
|
||||||
|
[*pChannel retain];
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (IOReturn) connect {
|
||||||
|
if(!device) {
|
||||||
|
WIIUSE_ERROR("Missing device.");
|
||||||
|
return kIOReturnBadArgument;
|
||||||
|
}
|
||||||
|
|
||||||
|
// open channels
|
||||||
|
if(![self connectChannel:&controlChannel PSM:kBluetoothL2CAPPSMHIDControl]) {
|
||||||
|
[self disconnect];
|
||||||
|
return kIOReturnNotOpen;
|
||||||
|
} else if(![self connectChannel:&interruptChannel PSM:kBluetoothL2CAPPSMHIDInterrupt]) {
|
||||||
|
[self disconnect];
|
||||||
|
return kIOReturnNotOpen;
|
||||||
|
}
|
||||||
|
|
||||||
|
// register for device disconnection
|
||||||
|
disconnectNotification = [device registerForDisconnectNotification:self selector:@selector(disconnected:fromDevice:)];
|
||||||
|
if(!disconnectNotification) {
|
||||||
|
WIIUSE_ERROR("Unable to register disconnection handler [id %i].", wm->unid);
|
||||||
|
[self disconnect];
|
||||||
|
return kIOReturnNotOpen;
|
||||||
|
}
|
||||||
|
|
||||||
|
return kIOReturnSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) disconnectChannel: (IOBluetoothL2CAPChannel**) pChannel {
|
||||||
|
if(!pChannel) return;
|
||||||
|
|
||||||
|
if([*pChannel closeChannel] != kIOReturnSuccess)
|
||||||
|
WIIUSE_ERROR("Unable to close channel [id %i].", wm ? wm->unid : -1);
|
||||||
|
[*pChannel release];
|
||||||
|
*pChannel = nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) disconnect {
|
||||||
|
// channels
|
||||||
|
[self disconnectChannel:&interruptChannel];
|
||||||
|
[self disconnectChannel:&controlChannel];
|
||||||
|
|
||||||
|
// device
|
||||||
|
if([device closeConnection] != kIOReturnSuccess)
|
||||||
|
WIIUSE_ERROR("Unable to close the device connection [id %i].", wm ? wm->unid : -1);
|
||||||
|
[device release];
|
||||||
|
device = nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) disconnected:(IOBluetoothUserNotification*) notification fromDevice:(IOBluetoothDevice*) device {
|
||||||
|
|
||||||
|
WiiuseDisconnectionMessage* message = [[WiiuseDisconnectionMessage alloc] init];
|
||||||
|
[receivedDataLock lock];
|
||||||
|
[receivedData addObject:message];
|
||||||
|
[receivedDataLock unlock];
|
||||||
|
[message release];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark read, write
|
||||||
|
|
||||||
|
// <0: nothing received, else: length of data received (can be 0 in case of disconnection message)
|
||||||
|
- (int) checkForAvailableDataForBuffer: (byte*) buffer length: (NSUInteger) bufferLength {
|
||||||
|
int result = -1;
|
||||||
|
|
||||||
|
[receivedDataLock lock];
|
||||||
|
if([receivedData count]) {
|
||||||
|
// look at first item in queue
|
||||||
|
NSObject<WiiuseReceivedMessage>* firstMessage = [receivedData objectAtIndex:0];
|
||||||
|
result = [firstMessage applyToStruct:wm buffer: buffer length: bufferLength];
|
||||||
|
if(result >= 0)
|
||||||
|
[receivedData removeObjectAtIndex:0];
|
||||||
|
}
|
||||||
|
[receivedDataLock unlock];
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) waitForIncomingData: (NSTimeInterval) duration {
|
||||||
|
NSDate* timeoutDate = [NSDate dateWithTimeIntervalSinceNow: duration];
|
||||||
|
NSRunLoop *theRL = [NSRunLoop currentRunLoop];
|
||||||
|
while (true) {
|
||||||
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // This is used for fast release of NSDate, otherwise it leaks
|
||||||
|
if(![theRL runMode:NSDefaultRunLoopMode beforeDate:timeoutDate]) {
|
||||||
|
WIIUSE_ERROR("Could not start run loop while waiting for read [id %i].", wm->unid);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
[pool drain];
|
||||||
|
|
||||||
|
[receivedDataLock lock];
|
||||||
|
NSUInteger count = [receivedData count];
|
||||||
|
[receivedDataLock unlock];
|
||||||
|
if(count) {
|
||||||
|
// received some data, stop waiting
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if([timeoutDate isLessThanOrEqualTo:[NSDate date]]) {
|
||||||
|
// timeout
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// result = length of data copied to event buffer
|
||||||
|
- (int) readBuffer:(byte *)buffer length:(NSUInteger)bufferLength {
|
||||||
|
// is there already some data to read?
|
||||||
|
int result = [self checkForAvailableDataForBuffer: buffer length: bufferLength];
|
||||||
|
if(result < 0) {
|
||||||
|
// wait a short amount of time, until data becomes available or a timeout is reached
|
||||||
|
[self waitForIncomingData:1];
|
||||||
|
|
||||||
|
// check again
|
||||||
|
result = [self checkForAvailableDataForBuffer: buffer length: bufferLength];
|
||||||
|
}
|
||||||
|
|
||||||
|
return result >= 0 ? result : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (int) writeReport: (byte) report_type buffer: (byte*) buffer length: (NSUInteger) length {
|
||||||
|
if(interruptChannel == nil) {
|
||||||
|
WIIUSE_ERROR("Attempted to write to nil interrupt channel [id %i].", wm->unid);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
byte write_buffer[MAX_PAYLOAD];
|
||||||
|
write_buffer[0] = WM_SET_DATA | WM_BT_OUTPUT;
|
||||||
|
write_buffer[1] = report_type;
|
||||||
|
memcpy(write_buffer+2, buffer, length);
|
||||||
|
|
||||||
|
IOReturn error = [interruptChannel writeSync:write_buffer length:length+2];
|
||||||
|
if (error != kIOReturnSuccess) {
|
||||||
|
WIIUSE_ERROR("Error writing to interrupt channel [id %i].", wm->unid);
|
||||||
|
|
||||||
|
WIIUSE_DEBUG("Attempting to reopen the interrupt channel [id %i].", wm->unid);
|
||||||
|
[self disconnectChannel:&interruptChannel];
|
||||||
|
[self connectChannel:&interruptChannel PSM:kBluetoothL2CAPPSMHIDInterrupt];
|
||||||
|
if(!interruptChannel) {
|
||||||
|
WIIUSE_ERROR("Error reopening the interrupt channel [id %i].", wm->unid);
|
||||||
|
[self disconnect];
|
||||||
|
} else {
|
||||||
|
WIIUSE_DEBUG("Attempting to write again to the interrupt channel [id %i].", wm->unid);
|
||||||
|
error = [interruptChannel writeSync:write_buffer length:length+2];
|
||||||
|
if (error != kIOReturnSuccess)
|
||||||
|
WIIUSE_ERROR("Unable to write again to the interrupt channel [id %i].", wm->unid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (error == kIOReturnSuccess) ? length : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark IOBluetoothL2CAPChannelDelegate
|
||||||
|
|
||||||
|
- (void) l2capChannelData:(IOBluetoothL2CAPChannel*)channel data:(void*)data_ length:(NSUInteger)length {
|
||||||
|
|
||||||
|
byte* data = (byte*) data_;
|
||||||
|
|
||||||
|
// This is done in case the control channel woke up this handler
|
||||||
|
#if WIIUSE_MAC_OS_X_VERSION_10_7_OR_ABOVE
|
||||||
|
BluetoothL2CAPPSM psm = channel.PSM;
|
||||||
|
#else
|
||||||
|
BluetoothL2CAPPSM psm = [channel getPSM];
|
||||||
|
#endif
|
||||||
|
if(!data || (psm == kBluetoothL2CAPPSMHIDControl)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// copy the data into the buffer
|
||||||
|
// on Mac, we ignore the first byte
|
||||||
|
WiiuseReceivedData* newData = [[WiiuseReceivedData alloc] initWithBytes: data+1 length: length-1];
|
||||||
|
[receivedDataLock lock];
|
||||||
|
[receivedData addObject: newData];
|
||||||
|
[receivedDataLock unlock];
|
||||||
|
[newData release];
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !WIIUSE_MAC_OS_X_VERSION_10_7_OR_ABOVE
|
||||||
|
// the following delegate methods were required on 10.6. They are here to get rid of 10.6 compiler warnings.
|
||||||
|
- (void)l2capChannelOpenComplete:(IOBluetoothL2CAPChannel*)l2capChannel status:(IOReturn)error {
|
||||||
|
/* no-op */
|
||||||
|
}
|
||||||
|
- (void)l2capChannelClosed:(IOBluetoothL2CAPChannel*)l2capChannel {
|
||||||
|
/* no-op */
|
||||||
|
}
|
||||||
|
- (void)l2capChannelReconfigured:(IOBluetoothL2CAPChannel*)l2capChannel {
|
||||||
|
/* no-op */
|
||||||
|
}
|
||||||
|
- (void)l2capChannelWriteComplete:(IOBluetoothL2CAPChannel*)l2capChannel refcon:(void*)refcon status:(IOReturn)error {
|
||||||
|
/* no-op */
|
||||||
|
}
|
||||||
|
- (void)l2capChannelQueueSpaceAvailable:(IOBluetoothL2CAPChannel*)l2capChannel {
|
||||||
|
/* no-op */
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
#pragma mark WiiuseReceivedMessage
|
||||||
|
|
||||||
|
@implementation WiiuseReceivedData
|
||||||
|
|
||||||
|
- (id) initWithData:(NSData *)data_ {
|
||||||
|
self = [super init];
|
||||||
|
if (self) {
|
||||||
|
data = [data_ retain];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
- (id) initWithBytes: (void*) bytes length: (NSUInteger) length {
|
||||||
|
NSData* data_ = [[NSData alloc] initWithBytes:bytes length:length];
|
||||||
|
id result = [self initWithData: data_];
|
||||||
|
[data_ release];
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) dealloc {
|
||||||
|
[data release];
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (int) applyToStruct:(wiimote *)wm buffer:(byte *)buffer length:(NSUInteger)bufferLength {
|
||||||
|
byte* bytes = (byte*) [data bytes];
|
||||||
|
NSUInteger length = [data length];
|
||||||
|
if(length > bufferLength) {
|
||||||
|
WIIUSE_WARNING("Received data was longer than event buffer. Dropping excess bytes.");
|
||||||
|
length = bufferLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
// log the received data
|
||||||
|
#ifdef WITH_WIIUSE_DEBUG
|
||||||
|
{
|
||||||
|
printf("[DEBUG] (id %i) RECV: (%.2x) ", wm->unid, bytes[0]);
|
||||||
|
int x;
|
||||||
|
for (x = 1; x < length; ++x)
|
||||||
|
printf("%.2x ", bytes[x]);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// copy to struct
|
||||||
|
memcpy(buffer, bytes, length);
|
||||||
|
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation WiiuseDisconnectionMessage
|
||||||
|
|
||||||
|
- (int) applyToStruct:(wiimote *)wm buffer:(byte *)buffer length:(NSUInteger)bufferLength {
|
||||||
|
wiiuse_disconnected(wm);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __APPLE__
|
||||||
240
src/os_mac/os_mac_find.m
Normal file
240
src/os_mac/os_mac_find.m
Normal file
@@ -0,0 +1,240 @@
|
|||||||
|
/*
|
||||||
|
* wiiuse
|
||||||
|
*
|
||||||
|
* Written By:
|
||||||
|
* Michael Laforest < para >
|
||||||
|
* Email: < thepara (--AT--) g m a i l [--DOT--] com >
|
||||||
|
*
|
||||||
|
* Copyright 2006-2007
|
||||||
|
*
|
||||||
|
* This file is part of wiiuse.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* $Header$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* @brief Handles device I/O for Mac OS X.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
|
||||||
|
#import "os_mac.h"
|
||||||
|
|
||||||
|
#import "../io.h"
|
||||||
|
#import "../events.h"
|
||||||
|
#import "../os.h"
|
||||||
|
|
||||||
|
#import <IOBluetooth/IOBluetoothUtilities.h>
|
||||||
|
#import <IOBluetooth/objc/IOBluetoothDevice.h>
|
||||||
|
#import <IOBluetooth/objc/IOBluetoothHostController.h>
|
||||||
|
#import <IOBluetooth/objc/IOBluetoothDeviceInquiry.h>
|
||||||
|
#if !WIIUSE_MAC_OS_X_VERSION_10_7_OR_ABOVE
|
||||||
|
#import <IOBluetooth/IOBluetoothUserLib.h> // IOBluetoothLocalDeviceGetPowerState
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
#pragma mark WiiuseDeviceInquiry
|
||||||
|
|
||||||
|
#if WIIUSE_MAC_OS_X_VERSION_10_7_OR_ABOVE
|
||||||
|
@interface WiiuseDeviceInquiry : NSObject<IOBluetoothDeviceInquiryDelegate> {
|
||||||
|
#else
|
||||||
|
@interface WiiuseDeviceInquiry : NSObject {
|
||||||
|
#endif
|
||||||
|
wiimote** wiimotes;
|
||||||
|
NSUInteger maxDevices;
|
||||||
|
int timeout;
|
||||||
|
|
||||||
|
BOOL _running;
|
||||||
|
NSUInteger _foundDevices;
|
||||||
|
BOOL _inquiryComplete;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) initWithMemory:(wiimote**)wiimotes maxDevices:(int)maxDevices timeout:(int)timeout;
|
||||||
|
- (int) run;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation WiiuseDeviceInquiry
|
||||||
|
|
||||||
|
- (id) initWithMemory:(wiimote**)wiimotes_ maxDevices:(int)maxDevices_ timeout:(int)timeout_ {
|
||||||
|
self = [super init];
|
||||||
|
if(self) {
|
||||||
|
|
||||||
|
BluetoothHCIPowerState powerState = kBluetoothHCIPowerStateUnintialized;
|
||||||
|
#if WIIUSE_MAC_OS_X_VERSION_10_7_OR_ABOVE
|
||||||
|
if([IOBluetoothHostController defaultController])
|
||||||
|
powerState = [IOBluetoothHostController defaultController].powerState;
|
||||||
|
#else
|
||||||
|
// yes it is deprecated. no, there is no alternative (on 10.6).
|
||||||
|
IOBluetoothLocalDeviceGetPowerState(&powerState);
|
||||||
|
#endif
|
||||||
|
if (![IOBluetoothHostController defaultController] ||
|
||||||
|
powerState != kBluetoothHCIPowerStateON)
|
||||||
|
{
|
||||||
|
WIIUSE_DEBUG("Bluetooth hardware not available.");
|
||||||
|
[self release];
|
||||||
|
self = nil;
|
||||||
|
} else {
|
||||||
|
wiimotes = wiimotes_;
|
||||||
|
maxDevices = maxDevices_;
|
||||||
|
timeout = timeout_;
|
||||||
|
_running = NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
// creates and starts inquiry. the returned object is in the current autorelease pool.
|
||||||
|
- (IOBluetoothDeviceInquiry*) start {
|
||||||
|
|
||||||
|
// reset state variables
|
||||||
|
_foundDevices = 0;
|
||||||
|
_inquiryComplete = NO;
|
||||||
|
|
||||||
|
// create inquiry
|
||||||
|
IOBluetoothDeviceInquiry* inquiry = [IOBluetoothDeviceInquiry inquiryWithDelegate: self];
|
||||||
|
|
||||||
|
// refine search & set timeout
|
||||||
|
[inquiry setSearchCriteria:kBluetoothServiceClassMajorAny
|
||||||
|
majorDeviceClass:WM_DEV_MAJOR_CLASS
|
||||||
|
minorDeviceClass:WM_DEV_MINOR_CLASS];
|
||||||
|
[inquiry setUpdateNewDeviceNames: NO];
|
||||||
|
if(timeout > 0)
|
||||||
|
[inquiry setInquiryLength:timeout];
|
||||||
|
|
||||||
|
// start inquiry
|
||||||
|
IOReturn status = [inquiry start];
|
||||||
|
if (status != kIOReturnSuccess) {
|
||||||
|
WIIUSE_ERROR("Unable to start bluetooth device inquiry.");
|
||||||
|
if(![inquiry stop]) {
|
||||||
|
WIIUSE_ERROR("Unable to stop bluetooth device inquiry.");
|
||||||
|
} else {
|
||||||
|
WIIUSE_DEBUG("Bluetooth device inquiry stopped.");
|
||||||
|
}
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
return inquiry;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) wait {
|
||||||
|
// wait for the inquiry to complete
|
||||||
|
NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
|
||||||
|
while(!_inquiryComplete &&
|
||||||
|
[runLoop runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]) {
|
||||||
|
// no-op
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSUInteger) collectResultsOf: (IOBluetoothDeviceInquiry*) inquiry {
|
||||||
|
// stop the inquiry
|
||||||
|
if(![inquiry stop])
|
||||||
|
WIIUSE_ERROR("Unable to stop bluetooth device inquiry.");
|
||||||
|
|
||||||
|
// read found device information
|
||||||
|
NSArray* devices = [inquiry foundDevices];
|
||||||
|
NSUInteger i;
|
||||||
|
for(i = 0; i < [devices count]; i++) {
|
||||||
|
IOBluetoothDevice* device = [devices objectAtIndex:i];
|
||||||
|
|
||||||
|
// save the device in the wiimote structure
|
||||||
|
wiimotes[i]->objc_wm = (void*) [[WiiuseWiimote alloc] initWithPtr:wiimotes[i] device: device];
|
||||||
|
|
||||||
|
// mark as found
|
||||||
|
WIIMOTE_ENABLE_STATE(wiimotes[i], WIIMOTE_STATE_DEV_FOUND);
|
||||||
|
NSString* address = IOBluetoothNSStringFromDeviceAddress([device getAddress]);
|
||||||
|
const char* address_str = [address cStringUsingEncoding:NSMacOSRomanStringEncoding];
|
||||||
|
WIIUSE_INFO("Found Wiimote (%s) [id %i]", address_str, wiimotes[i]->unid);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [devices count];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (int) run {
|
||||||
|
int result = -1;
|
||||||
|
|
||||||
|
if(maxDevices == 0) {
|
||||||
|
result = 0;
|
||||||
|
} else if(!_running) {
|
||||||
|
_running = YES;
|
||||||
|
|
||||||
|
if (![IOBluetoothHostController defaultController]) {
|
||||||
|
WIIUSE_ERROR("Unable to find any bluetooth receiver on your host.");
|
||||||
|
} else {
|
||||||
|
IOBluetoothDeviceInquiry* inquiry = [self start];
|
||||||
|
if(inquiry) {
|
||||||
|
[self wait];
|
||||||
|
result = [self collectResultsOf: inquiry];
|
||||||
|
WIIUSE_INFO("Found %i Wiimote device(s).", result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_running = NO;
|
||||||
|
} else { // if(_running)
|
||||||
|
WIIUSE_ERROR("Device inquiry already running - won't start it again.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark IOBluetoothDeviceInquiryDelegate
|
||||||
|
|
||||||
|
- (void) deviceInquiryDeviceFound:(IOBluetoothDeviceInquiry *) inquiry device:(IOBluetoothDevice *) device {
|
||||||
|
|
||||||
|
WIIUSE_DEBUG("Found a wiimote");
|
||||||
|
|
||||||
|
_foundDevices++;
|
||||||
|
if(_foundDevices >= maxDevices) {
|
||||||
|
// reached maximum number of devices
|
||||||
|
_inquiryComplete = YES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) deviceInquiryComplete:(IOBluetoothDeviceInquiry*) inquiry error:(IOReturn) error aborted:(BOOL) aborted
|
||||||
|
{
|
||||||
|
WIIUSE_DEBUG("Inquiry complete, error=%i, aborted=%s", error, aborted ? "YES" : "NO");
|
||||||
|
|
||||||
|
// mark completion
|
||||||
|
_inquiryComplete = YES;
|
||||||
|
|
||||||
|
// print error message if we stop due to an error
|
||||||
|
if ((error != kIOReturnSuccess) && !aborted) {
|
||||||
|
WIIUSE_ERROR("Bluetooth device inquiry not completed due to unexpected errors. Try increasing the timeout.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
#pragma mark public interface
|
||||||
|
|
||||||
|
int wiiuse_os_find(struct wiimote_t** wm, int max_wiimotes, int timeout) {
|
||||||
|
int result;
|
||||||
|
|
||||||
|
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
|
||||||
|
WiiuseDeviceInquiry* inquiry = [[WiiuseDeviceInquiry alloc] initWithMemory:wm maxDevices:max_wiimotes timeout:timeout];
|
||||||
|
result = [inquiry run];
|
||||||
|
[inquiry release];
|
||||||
|
|
||||||
|
[pool drain];
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // __APPLE__
|
||||||
222
src/os_mac/os_mac_interface.m
Normal file
222
src/os_mac/os_mac_interface.m
Normal file
@@ -0,0 +1,222 @@
|
|||||||
|
/*
|
||||||
|
* wiiuse
|
||||||
|
*
|
||||||
|
* Written By:
|
||||||
|
* Michael Laforest < para >
|
||||||
|
* Email: < thepara (--AT--) g m a i l [--DOT--] com >
|
||||||
|
*
|
||||||
|
* Copyright 2006-2007
|
||||||
|
*
|
||||||
|
* This file is part of wiiuse.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* $Header$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* @brief C function interface to os_mac.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
|
||||||
|
#import "os_mac.h"
|
||||||
|
|
||||||
|
#import "../io.h"
|
||||||
|
#import "../events.h"
|
||||||
|
#import "../os.h"
|
||||||
|
|
||||||
|
#import <IOBluetooth/IOBluetoothUtilities.h>
|
||||||
|
#import <IOBluetooth/objc/IOBluetoothDevice.h>
|
||||||
|
#import <IOBluetooth/objc/IOBluetoothHostController.h>
|
||||||
|
#import <IOBluetooth/objc/IOBluetoothDeviceInquiry.h>
|
||||||
|
#import <IOBluetooth/objc/IOBluetoothL2CAPChannel.h>
|
||||||
|
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
#pragma mark find
|
||||||
|
|
||||||
|
// See os_mac_find.m
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
#pragma mark connect, disconnect
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Connect to a wiimote with a known address.
|
||||||
|
*
|
||||||
|
* @param wm Pointer to a wiimote_t structure.
|
||||||
|
*
|
||||||
|
* @see wiimote_os_connect()
|
||||||
|
* @see wiimote_os_find()
|
||||||
|
*
|
||||||
|
* @return 1 on success, 0 on failure
|
||||||
|
*/
|
||||||
|
static short wiiuse_os_connect_single(struct wiimote_t* wm) {
|
||||||
|
// Skip if already connected or device not found
|
||||||
|
if(!wm) {
|
||||||
|
WIIUSE_ERROR("No Wiimote given.");
|
||||||
|
return 0;
|
||||||
|
} else if(wm && (!WIIMOTE_IS_SET(wm, WIIMOTE_STATE_DEV_FOUND) || wm->objc_wm == NULL)) {
|
||||||
|
WIIUSE_ERROR("Tried to connect Wiimote without an address.");
|
||||||
|
return 0;
|
||||||
|
} else if(WIIMOTE_IS_CONNECTED(wm)) {
|
||||||
|
WIIUSE_WARNING("Wiimote [id %i] is already connected.", wm->unid);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
WIIUSE_DEBUG("Connecting to Wiimote [id %i].", wm->unid);
|
||||||
|
|
||||||
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
short result = 0;
|
||||||
|
|
||||||
|
// connect
|
||||||
|
WiiuseWiimote* objc_wm = (WiiuseWiimote*) wm->objc_wm;
|
||||||
|
if([objc_wm connect] == kIOReturnSuccess) {
|
||||||
|
WIIUSE_INFO("Connected to Wiimote [id %i].", wm->unid);
|
||||||
|
|
||||||
|
// save the connect structure to retrieve data later on
|
||||||
|
wm->objc_wm = (void*)objc_wm;
|
||||||
|
|
||||||
|
// save the connection status
|
||||||
|
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_CONNECTED);
|
||||||
|
|
||||||
|
// Do the handshake
|
||||||
|
wiiuse_handshake(wm, NULL, 0);
|
||||||
|
wiiuse_set_report_type(wm);
|
||||||
|
|
||||||
|
result = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
[pool drain];
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wiiuse_os_connect(struct wiimote_t** wm, int wiimotes) {
|
||||||
|
int connected = 0;
|
||||||
|
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < wiimotes; ++i) {
|
||||||
|
if(wm[i] == NULL) {
|
||||||
|
WIIUSE_ERROR("Trying to connect to non-initialized Wiimote.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!WIIMOTE_IS_SET(wm[i], WIIMOTE_STATE_DEV_FOUND) || !wm[i]->objc_wm) {
|
||||||
|
// If the device is not found, skip it
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wiiuse_os_connect_single(wm[i]))
|
||||||
|
++connected;
|
||||||
|
}
|
||||||
|
|
||||||
|
return connected;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wiiuse_os_disconnect(struct wiimote_t* wm) {
|
||||||
|
if (!wm || !WIIMOTE_IS_CONNECTED(wm) || !wm->objc_wm)
|
||||||
|
return;
|
||||||
|
|
||||||
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
[((WiiuseWiimote*)wm->objc_wm) disconnect];
|
||||||
|
[pool drain];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
#pragma mark poll, read, write
|
||||||
|
|
||||||
|
int wiiuse_os_poll(struct wiimote_t** wm, int wiimotes) {
|
||||||
|
int i;
|
||||||
|
byte read_buffer[MAX_PAYLOAD];
|
||||||
|
int evnt = 0;
|
||||||
|
|
||||||
|
if (!wm) return 0;
|
||||||
|
|
||||||
|
for (i = 0; i < wiimotes; ++i) {
|
||||||
|
wm[i]->event = WIIUSE_NONE;
|
||||||
|
|
||||||
|
/* clear out the buffer */
|
||||||
|
memset(read_buffer, 0, sizeof(read_buffer));
|
||||||
|
/* read */
|
||||||
|
if (wiiuse_os_read(wm[i], read_buffer, sizeof(read_buffer))) {
|
||||||
|
/* propagate the event */
|
||||||
|
propagate_event(wm[i], read_buffer[0], read_buffer+1);
|
||||||
|
} else {
|
||||||
|
/* send out any waiting writes */
|
||||||
|
wiiuse_send_next_pending_write_request(wm[i]);
|
||||||
|
idle_cycle(wm[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
evnt += (wm[i]->event != WIIUSE_NONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return evnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wiiuse_os_read(struct wiimote_t* wm, byte* buf, int len) {
|
||||||
|
if(!wm || !wm->objc_wm) return 0;
|
||||||
|
if(!WIIMOTE_IS_CONNECTED(wm)) {
|
||||||
|
WIIUSE_ERROR("Attempting to read from unconnected Wiimote");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
|
||||||
|
WiiuseWiimote* objc_wm = (WiiuseWiimote*) wm->objc_wm;
|
||||||
|
int result = [objc_wm readBuffer: buf length: len];
|
||||||
|
|
||||||
|
[pool drain];
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wiiuse_os_write(struct wiimote_t* wm, byte report_type, byte* buf, int len) {
|
||||||
|
if(!wm || !wm->objc_wm) return 0;
|
||||||
|
if(!WIIMOTE_IS_CONNECTED(wm)) {
|
||||||
|
WIIUSE_ERROR("Attempting to write to unconnected Wiimote");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
|
||||||
|
WiiuseWiimote* objc_wm = (WiiuseWiimote*) wm->objc_wm;
|
||||||
|
int result = [objc_wm writeReport: report_type buffer: buf length: (NSUInteger)len];
|
||||||
|
|
||||||
|
[pool drain];
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
#pragma mark platform fields
|
||||||
|
|
||||||
|
void wiiuse_init_platform_fields(struct wiimote_t* wm) {
|
||||||
|
wm->objc_wm = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wiiuse_cleanup_platform_fields(struct wiimote_t* wm) {
|
||||||
|
if(!wm) return;
|
||||||
|
WiiuseWiimote* objc_wm = (WiiuseWiimote*) wm->objc_wm;
|
||||||
|
|
||||||
|
// disconnect
|
||||||
|
// Note: this should already have happened, because this function
|
||||||
|
// is called once the device is disconnected. This is just paranoia.
|
||||||
|
[objc_wm disconnect];
|
||||||
|
|
||||||
|
// release WiiuseWiimote object
|
||||||
|
[objc_wm release];
|
||||||
|
wm->objc_wm = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // __APPLE__
|
||||||
@@ -32,6 +32,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
|
#include "events.h"
|
||||||
|
#include "os.h"
|
||||||
|
|
||||||
#ifdef WIIUSE_BLUEZ
|
#ifdef WIIUSE_BLUEZ
|
||||||
|
|
||||||
@@ -44,28 +46,13 @@
|
|||||||
#include <stdio.h> /* for perror */
|
#include <stdio.h> /* for perror */
|
||||||
#include <string.h> /* for memset */
|
#include <string.h> /* for memset */
|
||||||
#include <sys/socket.h> /* for connect, socket */
|
#include <sys/socket.h> /* for connect, socket */
|
||||||
|
#include <sys/time.h> /* for struct timeval */
|
||||||
#include <unistd.h> /* for close, write */
|
#include <unistd.h> /* for close, write */
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
static int wiiuse_connect_single(struct wiimote_t* wm, char* address);
|
static int wiiuse_os_connect_single(struct wiimote_t* wm, char* address);
|
||||||
|
|
||||||
/**
|
int wiiuse_os_find(struct wiimote_t** wm, int max_wiimotes, int timeout) {
|
||||||
* @brief Find a wiimote or wiimotes.
|
|
||||||
*
|
|
||||||
* @param wm An array of wiimote_t structures.
|
|
||||||
* @param max_wiimotes The number of wiimote structures in \a wm.
|
|
||||||
* @param timeout The number of seconds before the search times out.
|
|
||||||
*
|
|
||||||
* @return The number of wiimotes found.
|
|
||||||
*
|
|
||||||
* @see wiimote_connect()
|
|
||||||
*
|
|
||||||
* This function will only look for wiimote devices. \n
|
|
||||||
* When a device is found the address in the structures will be set. \n
|
|
||||||
* You can then call wiimote_connect() to connect to the found \n
|
|
||||||
* devices.
|
|
||||||
*/
|
|
||||||
int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int timeout) {
|
|
||||||
int device_id;
|
int device_id;
|
||||||
int device_sock;
|
int device_sock;
|
||||||
inquiry_info scan_info_arr[128];
|
inquiry_info scan_info_arr[128];
|
||||||
@@ -114,8 +101,7 @@ int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int timeout) {
|
|||||||
for (i = 0; (i < found_devices) && (found_wiimotes < max_wiimotes); ++i) {
|
for (i = 0; (i < found_devices) && (found_wiimotes < max_wiimotes); ++i) {
|
||||||
if ((scan_info[i].dev_class[0] == WM_DEV_CLASS_0) &&
|
if ((scan_info[i].dev_class[0] == WM_DEV_CLASS_0) &&
|
||||||
(scan_info[i].dev_class[1] == WM_DEV_CLASS_1) &&
|
(scan_info[i].dev_class[1] == WM_DEV_CLASS_1) &&
|
||||||
(scan_info[i].dev_class[2] == WM_DEV_CLASS_2))
|
(scan_info[i].dev_class[2] == WM_DEV_CLASS_2)) {
|
||||||
{
|
|
||||||
/* found a device */
|
/* found a device */
|
||||||
ba2str(&scan_info[i].bdaddr, wm[found_wiimotes]->bdaddr_str);
|
ba2str(&scan_info[i].bdaddr, wm[found_wiimotes]->bdaddr_str);
|
||||||
|
|
||||||
@@ -133,33 +119,24 @@ int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int timeout) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Connect to a wiimote or wiimotes once an address is known.
|
* @see wiiuse_connect()
|
||||||
*
|
* @see wiiuse_os_connect_single()
|
||||||
* @param wm An array of wiimote_t structures.
|
|
||||||
* @param wiimotes The number of wiimote structures in \a wm.
|
|
||||||
*
|
|
||||||
* @return The number of wiimotes that successfully connected.
|
|
||||||
*
|
|
||||||
* @see wiiuse_find()
|
|
||||||
* @see wiiuse_connect_single()
|
|
||||||
* @see wiiuse_disconnect()
|
|
||||||
*
|
|
||||||
* Connect to a number of wiimotes when the address is already set
|
|
||||||
* in the wiimote_t structures. These addresses are normally set
|
|
||||||
* by the wiiuse_find() function, but can also be set manually.
|
|
||||||
*/
|
*/
|
||||||
int wiiuse_connect(struct wiimote_t** wm, int wiimotes) {
|
int wiiuse_os_connect(struct wiimote_t** wm, int wiimotes) {
|
||||||
int connected = 0;
|
int connected = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for (; i < wiimotes; ++i) {
|
for (; i < wiimotes; ++i) {
|
||||||
if (!WIIMOTE_IS_SET(wm[i], WIIMOTE_STATE_DEV_FOUND))
|
if (!WIIMOTE_IS_SET(wm[i], WIIMOTE_STATE_DEV_FOUND))
|
||||||
/* if the device address is not set, skip it */
|
/* if the device address is not set, skip it */
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (wiiuse_connect_single(wm[i], NULL))
|
if (wiiuse_os_connect_single(wm[i], NULL)) {
|
||||||
++connected;
|
++connected;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return connected;
|
return connected;
|
||||||
}
|
}
|
||||||
@@ -170,24 +147,25 @@ int wiiuse_connect(struct wiimote_t** wm, int wiimotes) {
|
|||||||
*
|
*
|
||||||
* @param wm Pointer to a wiimote_t structure.
|
* @param wm Pointer to a wiimote_t structure.
|
||||||
* @param address The address of the device to connect to.
|
* @param address The address of the device to connect to.
|
||||||
* If NULL, use the address in the struct set by wiiuse_find().
|
* If NULL, use the address in the struct set by wiiuse_os_find().
|
||||||
*
|
*
|
||||||
* @return 1 on success, 0 on failure
|
* @return 1 on success, 0 on failure
|
||||||
*/
|
*/
|
||||||
static int wiiuse_connect_single(struct wiimote_t* wm, char* address) {
|
static int wiiuse_os_connect_single(struct wiimote_t* wm, char* address) {
|
||||||
struct sockaddr_l2 addr;
|
struct sockaddr_l2 addr;
|
||||||
memset(&addr, 0, sizeof(addr));
|
memset(&addr, 0, sizeof(addr));
|
||||||
|
|
||||||
if (!wm || WIIMOTE_IS_CONNECTED(wm))
|
if (!wm || WIIMOTE_IS_CONNECTED(wm)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
addr.l2_family = AF_BLUETOOTH;
|
addr.l2_family = AF_BLUETOOTH;
|
||||||
bdaddr_t *bdaddr = &wm->bdaddr;
|
bdaddr_t *bdaddr = &wm->bdaddr;
|
||||||
if (address)
|
if (address)
|
||||||
/* use provided address */
|
/* use provided address */
|
||||||
str2ba(address, &addr.l2_bdaddr);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
str2ba(address, &addr.l2_bdaddr);
|
||||||
|
} else {
|
||||||
/** @todo this line doesn't make sense
|
/** @todo this line doesn't make sense
|
||||||
bacmp(bdaddr, BDADDR_ANY);*/
|
bacmp(bdaddr, BDADDR_ANY);*/
|
||||||
/* use address of device discovered */
|
/* use address of device discovered */
|
||||||
@@ -199,8 +177,9 @@ static int wiiuse_connect_single(struct wiimote_t* wm, char* address) {
|
|||||||
* OUTPUT CHANNEL
|
* OUTPUT CHANNEL
|
||||||
*/
|
*/
|
||||||
wm->out_sock = socket(AF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP);
|
wm->out_sock = socket(AF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP);
|
||||||
if (wm->out_sock == -1)
|
if (wm->out_sock == -1) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
addr.l2_psm = htobs(WM_OUTPUT_CHANNEL);
|
addr.l2_psm = htobs(WM_OUTPUT_CHANNEL);
|
||||||
|
|
||||||
@@ -241,19 +220,10 @@ static int wiiuse_connect_single(struct wiimote_t* wm, char* address) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wiiuse_os_disconnect(struct wiimote_t* wm) {
|
||||||
/**
|
if (!wm || WIIMOTE_IS_CONNECTED(wm)) {
|
||||||
* @brief Disconnect a wiimote.
|
|
||||||
*
|
|
||||||
* @param wm Pointer to a wiimote_t structure.
|
|
||||||
*
|
|
||||||
* @see wiiuse_connect()
|
|
||||||
*
|
|
||||||
* Note that this will not free the wiimote structure.
|
|
||||||
*/
|
|
||||||
void wiiuse_disconnect(struct wiimote_t* wm) {
|
|
||||||
if (!wm || WIIMOTE_IS_CONNECTED(wm))
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
close(wm->out_sock);
|
close(wm->out_sock);
|
||||||
close(wm->in_sock);
|
close(wm->in_sock);
|
||||||
@@ -267,14 +237,138 @@ void wiiuse_disconnect(struct wiimote_t* wm) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int wiiuse_io_read(struct wiimote_t* wm) {
|
int wiiuse_os_poll(struct wiimote_t** wm, int wiimotes) {
|
||||||
/* not used */
|
int evnt;
|
||||||
|
struct timeval tv;
|
||||||
|
fd_set fds;
|
||||||
|
int r;
|
||||||
|
int i;
|
||||||
|
byte read_buffer[MAX_PAYLOAD];
|
||||||
|
int highest_fd = -1;
|
||||||
|
|
||||||
|
evnt = 0;
|
||||||
|
if (!wm) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* block select() for 1/2000th of a second */
|
||||||
|
tv.tv_sec = 0;
|
||||||
|
tv.tv_usec = 500;
|
||||||
|
|
||||||
int wiiuse_io_write(struct wiimote_t* wm, byte* buf, int len) {
|
FD_ZERO(&fds);
|
||||||
return write(wm->out_sock, buf, len);
|
|
||||||
|
for (i = 0; i < wiimotes; ++i) {
|
||||||
|
/* only poll it if it is connected */
|
||||||
|
if (WIIMOTE_IS_SET(wm[i], WIIMOTE_STATE_CONNECTED)) {
|
||||||
|
FD_SET(wm[i]->in_sock, &fds);
|
||||||
|
|
||||||
|
/* find the highest fd of the connected wiimotes */
|
||||||
|
if (wm[i]->in_sock > highest_fd) {
|
||||||
|
highest_fd = wm[i]->in_sock;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wm[i]->event = WIIUSE_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (highest_fd == -1)
|
||||||
|
/* nothing to poll */
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (select(highest_fd + 1, &fds, NULL, NULL, &tv) == -1) {
|
||||||
|
WIIUSE_ERROR("Unable to select() the wiimote interrupt socket(s).");
|
||||||
|
perror("Error Details");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check each socket for an event */
|
||||||
|
for (i = 0; i < wiimotes; ++i) {
|
||||||
|
/* if this wiimote is not connected, skip it */
|
||||||
|
if (!WIIMOTE_IS_CONNECTED(wm[i])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FD_ISSET(wm[i]->in_sock, &fds)) {
|
||||||
|
/* clear out the event buffer */
|
||||||
|
memset(read_buffer, 0, sizeof(read_buffer));
|
||||||
|
|
||||||
|
/* clear out any old read data */
|
||||||
|
clear_dirty_reads(wm[i]);
|
||||||
|
|
||||||
|
/* read the pending message into the buffer */
|
||||||
|
r = wiiuse_os_read(wm[i], read_buffer, sizeof(read_buffer));
|
||||||
|
if (r > 0) {
|
||||||
|
/* propagate the event */
|
||||||
|
propagate_event(wm[i], read_buffer[0], read_buffer + 1);
|
||||||
|
evnt += (wm[i]->event != WIIUSE_NONE);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* send out any waiting writes */
|
||||||
|
wiiuse_send_next_pending_write_request(wm[i]);
|
||||||
|
idle_cycle(wm[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return evnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wiiuse_os_read(struct wiimote_t* wm, byte* buf, int len) {
|
||||||
|
int rc;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
rc = read(wm->in_sock, buf, len);
|
||||||
|
|
||||||
|
if (rc == -1) {
|
||||||
|
/* error reading data */
|
||||||
|
WIIUSE_ERROR("Receiving wiimote data (id %i).", wm->unid);
|
||||||
|
perror("Error Details");
|
||||||
|
|
||||||
|
if (errno == ENOTCONN) {
|
||||||
|
/* this can happen if the bluetooth dongle is disconnected */
|
||||||
|
WIIUSE_ERROR("Bluetooth appears to be disconnected. Wiimote unid %i will be disconnected.", wm->unid);
|
||||||
|
wiiuse_os_disconnect(wm);
|
||||||
|
wiiuse_disconnected(wm);
|
||||||
|
}
|
||||||
|
} else if (rc == 0) {
|
||||||
|
/* remote disconnect */
|
||||||
|
wiiuse_disconnected(wm);
|
||||||
|
} else {
|
||||||
|
/* read successful */
|
||||||
|
/* on *nix we ignore the first byte */
|
||||||
|
memmove(buf, buf + 1, len - 1);
|
||||||
|
|
||||||
|
/* log the received data */
|
||||||
|
#ifdef WITH_WIIUSE_DEBUG
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
printf("[DEBUG] (id %i) RECV: (%.2x) ", wm->unid, buf[0]);
|
||||||
|
for (i = 1; i < rc; i++) {
|
||||||
|
printf("%.2x ", buf[i]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wiiuse_os_write(struct wiimote_t* wm, byte report_type, byte* buf, int len) {
|
||||||
|
int rc;
|
||||||
|
byte write_buffer[MAX_PAYLOAD];
|
||||||
|
|
||||||
|
write_buffer[0] = WM_SET_REPORT | WM_BT_OUTPUT;
|
||||||
|
write_buffer[1] = report_type;
|
||||||
|
memcpy(write_buffer + 2, buf, len);
|
||||||
|
rc = write(wm->out_sock, write_buffer, len + 2);
|
||||||
|
|
||||||
|
if (rc < 0) {
|
||||||
|
wiiuse_disconnected(wm);
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wiiuse_init_platform_fields(struct wiimote_t* wm) {
|
void wiiuse_init_platform_fields(struct wiimote_t* wm) {
|
||||||
@@ -33,6 +33,8 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
|
#include "events.h"
|
||||||
|
#include "os.h"
|
||||||
|
|
||||||
#ifdef WIIUSE_WIN32
|
#ifdef WIIUSE_WIN32
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -52,7 +54,7 @@ extern "C" {
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int timeout) {
|
int wiiuse_os_find(struct wiimote_t** wm, int max_wiimotes, int timeout) {
|
||||||
GUID device_id;
|
GUID device_id;
|
||||||
HANDLE dev;
|
HANDLE dev;
|
||||||
HDEVINFO device_info;
|
HDEVINFO device_info;
|
||||||
@@ -82,8 +84,9 @@ int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int timeout) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* query the next hid device info */
|
/* query the next hid device info */
|
||||||
if (!SetupDiEnumDeviceInterfaces(device_info, NULL, &device_id, index, &device_data))
|
if (!SetupDiEnumDeviceInterfaces(device_info, NULL, &device_id, index, &device_data)) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* get the size of the data block required */
|
/* get the size of the data block required */
|
||||||
i = SetupDiGetDeviceInterfaceDetail(device_info, &device_data, NULL, 0, &len, NULL);
|
i = SetupDiGetDeviceInterfaceDetail(device_info, &device_data, NULL, 0, &len, NULL);
|
||||||
@@ -91,16 +94,18 @@ int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int timeout) {
|
|||||||
detail_data->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
|
detail_data->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
|
||||||
|
|
||||||
/* query the data for this device */
|
/* query the data for this device */
|
||||||
if (!SetupDiGetDeviceInterfaceDetail(device_info, &device_data, detail_data, len, NULL, NULL))
|
if (!SetupDiGetDeviceInterfaceDetail(device_info, &device_data, detail_data, len, NULL, NULL)) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* open the device */
|
/* open the device */
|
||||||
dev = CreateFile(detail_data->DevicePath,
|
dev = CreateFile(detail_data->DevicePath,
|
||||||
(GENERIC_READ | GENERIC_WRITE),
|
(GENERIC_READ | GENERIC_WRITE),
|
||||||
(FILE_SHARE_READ | FILE_SHARE_WRITE),
|
(FILE_SHARE_READ | FILE_SHARE_WRITE),
|
||||||
NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
|
NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
|
||||||
if (dev == INVALID_HANDLE_VALUE)
|
if (dev == INVALID_HANDLE_VALUE) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* get device attributes */
|
/* get device attributes */
|
||||||
attr.Size = sizeof(attr);
|
attr.Size = sizeof(attr);
|
||||||
@@ -129,16 +134,18 @@ int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int timeout) {
|
|||||||
WIIUSE_INFO("Connected to wiimote [id %i].", wm[found]->unid);
|
WIIUSE_INFO("Connected to wiimote [id %i].", wm[found]->unid);
|
||||||
|
|
||||||
++found;
|
++found;
|
||||||
if (found >= max_wiimotes)
|
if (found >= max_wiimotes) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* not a wiimote */
|
/* not a wiimote */
|
||||||
CloseHandle(dev);
|
CloseHandle(dev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (detail_data)
|
if (detail_data) {
|
||||||
free(detail_data);
|
free(detail_data);
|
||||||
|
}
|
||||||
|
|
||||||
SetupDiDestroyDeviceInfoList(device_info);
|
SetupDiDestroyDeviceInfoList(device_info);
|
||||||
|
|
||||||
@@ -146,24 +153,27 @@ int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int timeout) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int wiiuse_connect(struct wiimote_t** wm, int wiimotes) {
|
int wiiuse_os_connect(struct wiimote_t** wm, int wiimotes) {
|
||||||
int connected = 0;
|
int connected = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for (; i < wiimotes; ++i) {
|
for (; i < wiimotes; ++i) {
|
||||||
if (!wm[i])
|
if (!wm[i]) {
|
||||||
continue;
|
continue;
|
||||||
if (WIIMOTE_IS_SET(wm[i], WIIMOTE_STATE_CONNECTED))
|
}
|
||||||
|
if (WIIMOTE_IS_SET(wm[i], WIIMOTE_STATE_CONNECTED)) {
|
||||||
++connected;
|
++connected;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return connected;
|
return connected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void wiiuse_disconnect(struct wiimote_t* wm) {
|
void wiiuse_os_disconnect(struct wiimote_t* wm) {
|
||||||
if (!wm || WIIMOTE_IS_CONNECTED(wm))
|
if (!wm || WIIMOTE_IS_CONNECTED(wm)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CloseHandle(wm->dev_handle);
|
CloseHandle(wm->dev_handle);
|
||||||
wm->dev_handle = 0;
|
wm->dev_handle = 0;
|
||||||
@@ -177,13 +187,43 @@ void wiiuse_disconnect(struct wiimote_t* wm) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int wiiuse_io_read(struct wiimote_t* wm) {
|
int wiiuse_os_poll(struct wiimote_t** wm, int wiimotes) {
|
||||||
|
int i;
|
||||||
|
byte read_buffer[MAX_PAYLOAD];
|
||||||
|
int evnt = 0;
|
||||||
|
|
||||||
|
if (!wm) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < wiimotes; ++i) {
|
||||||
|
wm[i]->event = WIIUSE_NONE;
|
||||||
|
|
||||||
|
/* clear out the buffer */
|
||||||
|
memset(read_buffer, 0, sizeof(read_buffer));
|
||||||
|
/* read */
|
||||||
|
if (wiiuse_os_read(wm[i], read_buffer, sizeof(read_buffer))) {
|
||||||
|
/* propagate the event */
|
||||||
|
propagate_event(wm[i], read_buffer[0], read_buffer + 1);
|
||||||
|
evnt += (wm[i]->event != WIIUSE_NONE);
|
||||||
|
} else {
|
||||||
|
/* send out any waiting writes */
|
||||||
|
wiiuse_send_next_pending_write_request(wm[i]);
|
||||||
|
idle_cycle(wm[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return evnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wiiuse_os_read(struct wiimote_t* wm, byte* buf, int len) {
|
||||||
DWORD b, r;
|
DWORD b, r;
|
||||||
|
|
||||||
if (!wm || !WIIMOTE_IS_CONNECTED(wm))
|
if (!wm || !WIIMOTE_IS_CONNECTED(wm)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!ReadFile(wm->dev_handle, wm->event_buf, sizeof(wm->event_buf), &b, &wm->hid_overlap)) {
|
if (!ReadFile(wm->dev_handle, buf, len, &b, &wm->hid_overlap)) {
|
||||||
/* partial read */
|
/* partial read */
|
||||||
b = GetLastError();
|
b = GetLastError();
|
||||||
|
|
||||||
@@ -197,8 +237,9 @@ int wiiuse_io_read(struct wiimote_t* wm) {
|
|||||||
if (r == WAIT_TIMEOUT) {
|
if (r == WAIT_TIMEOUT) {
|
||||||
/* timeout - cancel and continue */
|
/* timeout - cancel and continue */
|
||||||
|
|
||||||
if (*wm->event_buf)
|
if (*buf) {
|
||||||
WIIUSE_WARNING("Packet ignored. This may indicate a problem (timeout is %i ms).", wm->timeout);
|
WIIUSE_WARNING("Packet ignored. This may indicate a problem (timeout is %i ms).", wm->timeout);
|
||||||
|
}
|
||||||
|
|
||||||
CancelIo(wm->dev_handle);
|
CancelIo(wm->dev_handle);
|
||||||
ResetEvent(wm->hid_overlap.hEvent);
|
ResetEvent(wm->hid_overlap.hEvent);
|
||||||
@@ -208,33 +249,50 @@ int wiiuse_io_read(struct wiimote_t* wm) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GetOverlappedResult(wm->dev_handle, &wm->hid_overlap, &b, 0))
|
if (!GetOverlappedResult(wm->dev_handle, &wm->hid_overlap, &b, 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* log the received data */
|
||||||
|
#ifdef WITH_WIIUSE_DEBUG
|
||||||
|
{
|
||||||
|
DWORD i;
|
||||||
|
printf("[DEBUG] (id %i) RECV: (%.2x) ", wm->unid, buf[0]);
|
||||||
|
for (i = 1; i < b; i++) {
|
||||||
|
printf("%.2x ", buf[i]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
ResetEvent(wm->hid_overlap.hEvent);
|
ResetEvent(wm->hid_overlap.hEvent);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int wiiuse_io_write(struct wiimote_t* wm, byte* buf, int len) {
|
int wiiuse_os_write(struct wiimote_t* wm, byte report_type, byte* buf, int len) {
|
||||||
DWORD bytes;
|
DWORD bytes;
|
||||||
int i;
|
int i;
|
||||||
|
byte write_buffer[MAX_PAYLOAD];
|
||||||
|
|
||||||
if (!wm || !WIIMOTE_IS_CONNECTED(wm))
|
if (!wm || !WIIMOTE_IS_CONNECTED(wm)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
write_buffer[0] = report_type;
|
||||||
|
memcpy(write_buffer + 1, buf, len);
|
||||||
|
|
||||||
switch (wm->stack) {
|
switch (wm->stack) {
|
||||||
case WIIUSE_STACK_UNKNOWN:
|
case WIIUSE_STACK_UNKNOWN: {
|
||||||
{
|
|
||||||
/* try to auto-detect the stack type */
|
/* try to auto-detect the stack type */
|
||||||
if (i = WriteFile(wm->dev_handle, buf, 22, &bytes, &wm->hid_overlap)) {
|
if (i = WriteFile(wm->dev_handle, write_buffer, 22, &bytes, &wm->hid_overlap)) {
|
||||||
/* bluesoleil will always return 1 here, even if it's not connected */
|
/* bluesoleil will always return 1 here, even if it's not connected */
|
||||||
wm->stack = WIIUSE_STACK_BLUESOLEIL;
|
wm->stack = WIIUSE_STACK_BLUESOLEIL;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i = HidD_SetOutputReport(wm->dev_handle, buf, len)) {
|
if (i = HidD_SetOutputReport(wm->dev_handle, write_buffer, len + 1)) {
|
||||||
wm->stack = WIIUSE_STACK_MS;
|
wm->stack = WIIUSE_STACK_MS;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@@ -244,10 +302,10 @@ int wiiuse_io_write(struct wiimote_t* wm, byte* buf, int len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case WIIUSE_STACK_MS:
|
case WIIUSE_STACK_MS:
|
||||||
return HidD_SetOutputReport(wm->dev_handle, buf, len);
|
return HidD_SetOutputReport(wm->dev_handle, write_buffer, len + 1);
|
||||||
|
|
||||||
case WIIUSE_STACK_BLUESOLEIL:
|
case WIIUSE_STACK_BLUESOLEIL:
|
||||||
return WriteFile(wm->dev_handle, buf, 22, &bytes, &wm->hid_overlap);
|
return WriteFile(wm->dev_handle, write_buffer, 22, &bytes, &wm->hid_overlap);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -53,12 +53,11 @@ int wii_board_handshake(struct wiimote_t* wm, struct wii_board_t* wb, byte* data
|
|||||||
#ifdef WITH_WIIUSE_DEBUG
|
#ifdef WITH_WIIUSE_DEBUG
|
||||||
int i;
|
int i;
|
||||||
printf("DECRYPTED DATA WIIBOARD\n");
|
printf("DECRYPTED DATA WIIBOARD\n");
|
||||||
for (i = 0; i < len; ++i)
|
for (i = 0; i < len; ++i) {
|
||||||
{
|
if (i % 16 == 0) {
|
||||||
if(i%16==0)
|
if (i != 0) {
|
||||||
{
|
|
||||||
if(i!=0)
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
printf("%X: ", 0x4a40000 + 32 + i);
|
printf("%X: ", 0x4a40000 + 32 + i);
|
||||||
}
|
}
|
||||||
@@ -143,6 +142,5 @@ void wii_board_event(struct wii_board_t* wb, byte* msg) {
|
|||||||
/**
|
/**
|
||||||
@todo not implemented!
|
@todo not implemented!
|
||||||
*/
|
*/
|
||||||
void wiiuse_set_wii_board_calib(struct wiimote_t *wm)
|
void wiiuse_set_wii_board_calib(struct wiimote_t *wm) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|||||||
235
src/wiiuse.c
235
src/wiiuse.c
@@ -37,6 +37,7 @@
|
|||||||
|
|
||||||
#include "wiiuse_internal.h"
|
#include "wiiuse_internal.h"
|
||||||
#include "io.h" /* for wiiuse_handshake, etc */
|
#include "io.h" /* for wiiuse_handshake, etc */
|
||||||
|
#include "os.h" /* for wiiuse_os_* */
|
||||||
|
|
||||||
#include <stdio.h> /* for printf, FILE */
|
#include <stdio.h> /* for printf, FILE */
|
||||||
#include <stdlib.h> /* for malloc, free */
|
#include <stdlib.h> /* for malloc, free */
|
||||||
@@ -66,8 +67,7 @@ FILE* logtarget[4];
|
|||||||
*
|
*
|
||||||
* The default <code>FILE*</code> for all loglevels is <code>stderr</code>
|
* The default <code>FILE*</code> for all loglevels is <code>stderr</code>
|
||||||
*/
|
*/
|
||||||
void wiiuse_set_output(enum wiiuse_loglevel loglevel, FILE *logfile)
|
void wiiuse_set_output(enum wiiuse_loglevel loglevel, FILE *logfile) {
|
||||||
{
|
|
||||||
logtarget[(int)loglevel] = logfile;
|
logtarget[(int)loglevel] = logfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,13 +77,15 @@ void wiiuse_set_output(enum wiiuse_loglevel loglevel, FILE *logfile)
|
|||||||
void wiiuse_cleanup(struct wiimote_t** wm, int wiimotes) {
|
void wiiuse_cleanup(struct wiimote_t** wm, int wiimotes) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
if (!wm)
|
if (!wm) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
WIIUSE_INFO("wiiuse clean up...");
|
WIIUSE_INFO("wiiuse clean up...");
|
||||||
|
|
||||||
for (; i < wiimotes; ++i) {
|
for (; i < wiimotes; ++i) {
|
||||||
wiiuse_disconnect(wm[i]);
|
wiiuse_disconnect(wm[i]);
|
||||||
|
wiiuse_cleanup_platform_fields(wm[i]);
|
||||||
free(wm[i]);
|
free(wm[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,8 +131,9 @@ struct wiimote_t** wiiuse_init(int wiimotes) {
|
|||||||
logtarget[2] = stderr;
|
logtarget[2] = stderr;
|
||||||
logtarget[3] = stderr;
|
logtarget[3] = stderr;
|
||||||
|
|
||||||
if (!wiimotes)
|
if (!wiimotes) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
wm = malloc(sizeof(struct wiimote_t*) * wiimotes);
|
wm = malloc(sizeof(struct wiimote_t*) * wiimotes);
|
||||||
|
|
||||||
@@ -168,7 +171,9 @@ struct wiimote_t** wiiuse_init(int wiimotes) {
|
|||||||
* @param wm Pointer to a wiimote_t structure.
|
* @param wm Pointer to a wiimote_t structure.
|
||||||
*/
|
*/
|
||||||
void wiiuse_disconnected(struct wiimote_t* wm) {
|
void wiiuse_disconnected(struct wiimote_t* wm) {
|
||||||
if (!wm) return;
|
if (!wm) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
WIIUSE_INFO("Wiimote disconnected [id %i].", wm->unid);
|
WIIUSE_INFO("Wiimote disconnected [id %i].", wm->unid);
|
||||||
|
|
||||||
@@ -176,16 +181,15 @@ void wiiuse_disconnected(struct wiimote_t* wm) {
|
|||||||
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_CONNECTED);
|
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_CONNECTED);
|
||||||
|
|
||||||
/* reset a bunch of stuff */
|
/* reset a bunch of stuff */
|
||||||
wiiuse_cleanup_platform_fields(wm);
|
|
||||||
|
|
||||||
wm->leds = 0;
|
wm->leds = 0;
|
||||||
wm->state = WIIMOTE_INIT_STATES;
|
wm->state = WIIMOTE_INIT_STATES;
|
||||||
wm->read_req = NULL;
|
wm->read_req = NULL;
|
||||||
|
#ifndef WIIUSE_SYNC_HANDSHAKE
|
||||||
wm->handshake_state = 0;
|
wm->handshake_state = 0;
|
||||||
|
#endif
|
||||||
wm->btns = 0;
|
wm->btns = 0;
|
||||||
wm->btns_held = 0;
|
wm->btns_held = 0;
|
||||||
wm->btns_released = 0;
|
wm->btns_released = 0;
|
||||||
memset(wm->event_buf, 0, sizeof(wm->event_buf));
|
|
||||||
|
|
||||||
wm->event = WIIUSE_DISCONNECT;
|
wm->event = WIIUSE_DISCONNECT;
|
||||||
}
|
}
|
||||||
@@ -200,8 +204,9 @@ void wiiuse_disconnected(struct wiimote_t* wm) {
|
|||||||
void wiiuse_rumble(struct wiimote_t* wm, int status) {
|
void wiiuse_rumble(struct wiimote_t* wm, int status) {
|
||||||
byte buf;
|
byte buf;
|
||||||
|
|
||||||
if (!wm || !WIIMOTE_IS_CONNECTED(wm))
|
if (!wm || !WIIMOTE_IS_CONNECTED(wm)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* make sure to keep the current lit leds */
|
/* make sure to keep the current lit leds */
|
||||||
buf = wm->leds;
|
buf = wm->leds;
|
||||||
@@ -217,8 +222,9 @@ void wiiuse_rumble(struct wiimote_t* wm, int status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* preserve IR state */
|
/* preserve IR state */
|
||||||
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_IR))
|
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_IR)) {
|
||||||
buf |= 0x04;
|
buf |= 0x04;
|
||||||
|
}
|
||||||
|
|
||||||
wiiuse_send(wm, WM_CMD_RUMBLE, &buf, 1);
|
wiiuse_send(wm, WM_CMD_RUMBLE, &buf, 1);
|
||||||
}
|
}
|
||||||
@@ -230,7 +236,9 @@ void wiiuse_rumble(struct wiimote_t* wm, int status) {
|
|||||||
* @param wm Pointer to a wiimote_t structure.
|
* @param wm Pointer to a wiimote_t structure.
|
||||||
*/
|
*/
|
||||||
void wiiuse_toggle_rumble(struct wiimote_t* wm) {
|
void wiiuse_toggle_rumble(struct wiimote_t* wm) {
|
||||||
if (!wm) return;
|
if (!wm) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
wiiuse_rumble(wm, !WIIMOTE_IS_SET(wm, WIIMOTE_STATE_RUMBLE));
|
wiiuse_rumble(wm, !WIIMOTE_IS_SET(wm, WIIMOTE_STATE_RUMBLE));
|
||||||
}
|
}
|
||||||
@@ -247,15 +255,17 @@ void wiiuse_toggle_rumble(struct wiimote_t* wm) {
|
|||||||
void wiiuse_set_leds(struct wiimote_t* wm, int leds) {
|
void wiiuse_set_leds(struct wiimote_t* wm, int leds) {
|
||||||
byte buf;
|
byte buf;
|
||||||
|
|
||||||
if (!wm || !WIIMOTE_IS_CONNECTED(wm))
|
if (!wm || !WIIMOTE_IS_CONNECTED(wm)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* remove the lower 4 bits because they control rumble */
|
/* remove the lower 4 bits because they control rumble */
|
||||||
wm->leds = (leds & 0xF0);
|
wm->leds = (leds & 0xF0);
|
||||||
|
|
||||||
/* make sure if the rumble is on that we keep it on */
|
/* make sure if the rumble is on that we keep it on */
|
||||||
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_RUMBLE))
|
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_RUMBLE)) {
|
||||||
wm->leds |= 0x01;
|
wm->leds |= 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
buf = wm->leds;
|
buf = wm->leds;
|
||||||
|
|
||||||
@@ -274,10 +284,11 @@ void wiiuse_set_leds(struct wiimote_t* wm, int leds) {
|
|||||||
* by default.
|
* by default.
|
||||||
*/
|
*/
|
||||||
void wiiuse_motion_sensing(struct wiimote_t* wm, int status) {
|
void wiiuse_motion_sensing(struct wiimote_t* wm, int status) {
|
||||||
if (status)
|
if (status) {
|
||||||
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_ACC);
|
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_ACC);
|
||||||
else
|
} else {
|
||||||
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_ACC);
|
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_ACC);
|
||||||
|
}
|
||||||
|
|
||||||
wiiuse_set_report_type(wm);
|
wiiuse_set_report_type(wm);
|
||||||
}
|
}
|
||||||
@@ -299,34 +310,46 @@ int wiiuse_set_report_type(struct wiimote_t* wm) {
|
|||||||
byte buf[2];
|
byte buf[2];
|
||||||
int motion, exp, ir;
|
int motion, exp, ir;
|
||||||
|
|
||||||
if (!wm || !WIIMOTE_IS_CONNECTED(wm))
|
if (!wm || !WIIMOTE_IS_CONNECTED(wm)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
buf[0] = (WIIMOTE_IS_FLAG_SET(wm, WIIUSE_CONTINUOUS) ? 0x04 : 0x00); /* set to 0x04 for continuous reporting */
|
buf[0] = (WIIMOTE_IS_FLAG_SET(wm, WIIUSE_CONTINUOUS) ? 0x04 : 0x00); /* set to 0x04 for continuous reporting */
|
||||||
buf[1] = 0x00;
|
buf[1] = 0x00;
|
||||||
|
|
||||||
/* if rumble is enabled, make sure we keep it */
|
/* if rumble is enabled, make sure we keep it */
|
||||||
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_RUMBLE))
|
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_RUMBLE)) {
|
||||||
buf[0] |= 0x01;
|
buf[0] |= 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
motion = WIIMOTE_IS_SET(wm, WIIMOTE_STATE_ACC);
|
motion = WIIMOTE_IS_SET(wm, WIIMOTE_STATE_ACC);
|
||||||
exp = WIIMOTE_IS_SET(wm, WIIMOTE_STATE_EXP);
|
exp = WIIMOTE_IS_SET(wm, WIIMOTE_STATE_EXP);
|
||||||
ir = WIIMOTE_IS_SET(wm, WIIMOTE_STATE_IR);
|
ir = WIIMOTE_IS_SET(wm, WIIMOTE_STATE_IR);
|
||||||
|
|
||||||
if (motion && ir && exp) buf[1] = WM_RPT_BTN_ACC_IR_EXP;
|
if (motion && ir && exp) {
|
||||||
else if (motion && exp) buf[1] = WM_RPT_BTN_ACC_EXP;
|
buf[1] = WM_RPT_BTN_ACC_IR_EXP;
|
||||||
else if (motion && ir) buf[1] = WM_RPT_BTN_ACC_IR;
|
} else if (motion && exp) {
|
||||||
else if (ir && exp) buf[1] = WM_RPT_BTN_IR_EXP;
|
buf[1] = WM_RPT_BTN_ACC_EXP;
|
||||||
else if (ir) buf[1] = WM_RPT_BTN_ACC_IR;
|
} else if (motion && ir) {
|
||||||
else if (exp) buf[1] = WM_RPT_BTN_EXP;
|
buf[1] = WM_RPT_BTN_ACC_IR;
|
||||||
else if (motion) buf[1] = WM_RPT_BTN_ACC;
|
} else if (ir && exp) {
|
||||||
else buf[1] = WM_RPT_BTN;
|
buf[1] = WM_RPT_BTN_IR_EXP;
|
||||||
|
} else if (ir) {
|
||||||
|
buf[1] = WM_RPT_BTN_ACC_IR;
|
||||||
|
} else if (exp) {
|
||||||
|
buf[1] = WM_RPT_BTN_EXP;
|
||||||
|
} else if (motion) {
|
||||||
|
buf[1] = WM_RPT_BTN_ACC;
|
||||||
|
} else {
|
||||||
|
buf[1] = WM_RPT_BTN;
|
||||||
|
}
|
||||||
|
|
||||||
WIIUSE_DEBUG("Setting report type: 0x%x", buf[1]);
|
WIIUSE_DEBUG("Setting report type: 0x%x", buf[1]);
|
||||||
|
|
||||||
exp = wiiuse_send(wm, WM_CMD_REPORT_TYPE, buf, 2);
|
exp = wiiuse_send(wm, WM_CMD_REPORT_TYPE, buf, 2);
|
||||||
if (exp <= 0)
|
if (exp <= 0) {
|
||||||
return exp;
|
return exp;
|
||||||
|
}
|
||||||
|
|
||||||
return buf[1];
|
return buf[1];
|
||||||
}
|
}
|
||||||
@@ -352,15 +375,18 @@ int wiiuse_set_report_type(struct wiimote_t* wm) {
|
|||||||
int wiiuse_read_data_cb(struct wiimote_t* wm, wiiuse_read_cb read_cb, byte* buffer, unsigned int addr, uint16_t len) {
|
int wiiuse_read_data_cb(struct wiimote_t* wm, wiiuse_read_cb read_cb, byte* buffer, unsigned int addr, uint16_t len) {
|
||||||
struct read_req_t* req;
|
struct read_req_t* req;
|
||||||
|
|
||||||
if (!wm || !WIIMOTE_IS_CONNECTED(wm))
|
if (!wm || !WIIMOTE_IS_CONNECTED(wm)) {
|
||||||
return 0;
|
return 0;
|
||||||
if (!buffer || !len)
|
}
|
||||||
|
if (!buffer || !len) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* make this request structure */
|
/* make this request structure */
|
||||||
req = (struct read_req_t*)malloc(sizeof(struct read_req_t));
|
req = (struct read_req_t*)malloc(sizeof(struct read_req_t));
|
||||||
if (req == NULL)
|
if (req == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
req->cb = read_cb;
|
req->cb = read_cb;
|
||||||
req->buf = buffer;
|
req->buf = buffer;
|
||||||
req->addr = addr;
|
req->addr = addr;
|
||||||
@@ -380,7 +406,9 @@ int wiiuse_read_data_cb(struct wiimote_t* wm, wiiuse_read_cb read_cb, byte* buff
|
|||||||
wiiuse_send_next_pending_read_request(wm);
|
wiiuse_send_next_pending_read_request(wm);
|
||||||
} else {
|
} else {
|
||||||
struct read_req_t* nptr = wm->read_req;
|
struct read_req_t* nptr = wm->read_req;
|
||||||
for (; nptr->next; nptr = nptr->next);
|
for (; nptr->next; nptr = nptr->next) {
|
||||||
|
;
|
||||||
|
}
|
||||||
nptr->next = req;
|
nptr->next = req;
|
||||||
|
|
||||||
WIIUSE_DEBUG("Added pending data read request.");
|
WIIUSE_DEBUG("Added pending data read request.");
|
||||||
@@ -424,16 +452,21 @@ void wiiuse_send_next_pending_read_request(struct wiimote_t* wm) {
|
|||||||
byte buf[6];
|
byte buf[6];
|
||||||
struct read_req_t* req;
|
struct read_req_t* req;
|
||||||
|
|
||||||
if (!wm || !WIIMOTE_IS_CONNECTED(wm))
|
if (!wm || !WIIMOTE_IS_CONNECTED(wm)) {
|
||||||
return;
|
return;
|
||||||
if (!wm->read_req) return;
|
}
|
||||||
|
if (!wm->read_req) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* skip over dirty ones since they have already been read */
|
/* skip over dirty ones since they have already been read */
|
||||||
req = wm->read_req;
|
req = wm->read_req;
|
||||||
while (req && req->dirty)
|
while (req && req->dirty) {
|
||||||
req = req->next;
|
req = req->next;
|
||||||
if (!req)
|
}
|
||||||
|
if (!req) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* the offset is in big endian */
|
/* the offset is in big endian */
|
||||||
to_big_endian_uint32_t(buf, req->addr);
|
to_big_endian_uint32_t(buf, req->addr);
|
||||||
@@ -456,8 +489,9 @@ void wiiuse_send_next_pending_read_request(struct wiimote_t* wm) {
|
|||||||
void wiiuse_status(struct wiimote_t* wm) {
|
void wiiuse_status(struct wiimote_t* wm) {
|
||||||
byte buf = 0;
|
byte buf = 0;
|
||||||
|
|
||||||
if (!wm || !WIIMOTE_IS_CONNECTED(wm))
|
if (!wm || !WIIMOTE_IS_CONNECTED(wm)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
WIIUSE_DEBUG("Requested wiimote status.");
|
WIIUSE_DEBUG("Requested wiimote status.");
|
||||||
|
|
||||||
@@ -476,15 +510,18 @@ void wiiuse_status(struct wiimote_t* wm) {
|
|||||||
*/
|
*/
|
||||||
struct wiimote_t* wiiuse_get_by_id(struct wiimote_t** wm, int wiimotes, int unid) {
|
struct wiimote_t* wiiuse_get_by_id(struct wiimote_t** wm, int wiimotes, int unid) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
if (!wm)
|
if (!wm) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
for (; i < wiimotes; ++i) {
|
for (; i < wiimotes; ++i) {
|
||||||
if (!wm[i])
|
if (!wm[i]) {
|
||||||
continue;
|
continue;
|
||||||
if (wm[i]->unid == unid)
|
}
|
||||||
|
if (wm[i]->unid == unid) {
|
||||||
return wm[i];
|
return wm[i];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -502,10 +539,12 @@ int wiiuse_write_data(struct wiimote_t* wm, unsigned int addr, const byte* data,
|
|||||||
byte buf[21] = {0}; /* the payload is always 23 */
|
byte buf[21] = {0}; /* the payload is always 23 */
|
||||||
|
|
||||||
byte * bufPtr = buf;
|
byte * bufPtr = buf;
|
||||||
if (!wm || !WIIMOTE_IS_CONNECTED(wm))
|
if (!wm || !WIIMOTE_IS_CONNECTED(wm)) {
|
||||||
return 0;
|
return 0;
|
||||||
if (!data || !len)
|
}
|
||||||
|
if (!data || !len) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
WIIUSE_DEBUG("Writing %i bytes to memory location 0x%x...", len, addr);
|
WIIUSE_DEBUG("Writing %i bytes to memory location 0x%x...", len, addr);
|
||||||
|
|
||||||
@@ -513,8 +552,9 @@ int wiiuse_write_data(struct wiimote_t* wm, unsigned int addr, const byte* data,
|
|||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
printf("Write data is: ");
|
printf("Write data is: ");
|
||||||
for (; i < len; ++i)
|
for (; i < len; ++i) {
|
||||||
printf("%x ", data[i]);
|
printf("%x ", data[i]);
|
||||||
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -548,12 +588,15 @@ int wiiuse_write_data(struct wiimote_t* wm, unsigned int addr, const byte* data,
|
|||||||
* to a pending list and be sent out when the previous
|
* to a pending list and be sent out when the previous
|
||||||
* finishes.
|
* finishes.
|
||||||
*/
|
*/
|
||||||
int wiiuse_write_data_cb(struct wiimote_t *wm, unsigned int addr, byte *data, byte len, wiiuse_write_cb write_cb)
|
int wiiuse_write_data_cb(struct wiimote_t *wm, unsigned int addr, byte *data, byte len, wiiuse_write_cb write_cb) {
|
||||||
{
|
|
||||||
struct data_req_t* req;
|
struct data_req_t* req;
|
||||||
|
|
||||||
if(!wm || !WIIMOTE_IS_CONNECTED(wm)) return 0;
|
if (!wm || !WIIMOTE_IS_CONNECTED(wm)) {
|
||||||
if( !data || !len ) return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
if (!data || !len) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
req = (struct data_req_t*)malloc(sizeof(struct data_req_t));
|
req = (struct data_req_t*)malloc(sizeof(struct data_req_t));
|
||||||
req->cb = write_cb;
|
req->cb = write_cb;
|
||||||
@@ -574,7 +617,9 @@ int wiiuse_write_data_cb(struct wiimote_t *wm, unsigned int addr, byte *data, by
|
|||||||
} else {
|
} else {
|
||||||
struct data_req_t* nptr = wm->data_req;
|
struct data_req_t* nptr = wm->data_req;
|
||||||
WIIUSE_DEBUG("chaud2fois");
|
WIIUSE_DEBUG("chaud2fois");
|
||||||
for (; nptr->next; nptr = nptr->next);
|
for (; nptr->next; nptr = nptr->next) {
|
||||||
|
;
|
||||||
|
}
|
||||||
nptr->next = req;
|
nptr->next = req;
|
||||||
|
|
||||||
WIIUSE_DEBUG("Added pending data write request.");
|
WIIUSE_DEBUG("Added pending data write request.");
|
||||||
@@ -595,14 +640,19 @@ WIIUSE_DEBUG("chaud2fois");
|
|||||||
void wiiuse_send_next_pending_write_request(struct wiimote_t* wm) {
|
void wiiuse_send_next_pending_write_request(struct wiimote_t* wm) {
|
||||||
struct data_req_t* req;
|
struct data_req_t* req;
|
||||||
|
|
||||||
if (!wm || !WIIMOTE_IS_CONNECTED(wm))
|
if (!wm || !WIIMOTE_IS_CONNECTED(wm)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
req = wm->data_req;
|
req = wm->data_req;
|
||||||
if (!req)
|
if (!req) {
|
||||||
return;
|
return;
|
||||||
if (!req->data || !req->len)
|
}
|
||||||
|
if (!req->data || !req->len) {
|
||||||
return;
|
return;
|
||||||
if(req->state!=REQ_READY) return;
|
}
|
||||||
|
if (req->state != REQ_READY) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
wiiuse_write_data(wm, req->addr, req->data, req->len);
|
wiiuse_write_data(wm, req->addr, req->data, req->len);
|
||||||
|
|
||||||
@@ -615,65 +665,38 @@ void wiiuse_send_next_pending_write_request(struct wiimote_t* wm) {
|
|||||||
*
|
*
|
||||||
* @param wm Pointer to a wiimote_t structure.
|
* @param wm Pointer to a wiimote_t structure.
|
||||||
* @param report_type The report type to send (WIIMOTE_CMD_LED, WIIMOTE_CMD_RUMBLE, etc). Found in wiiuse.h
|
* @param report_type The report type to send (WIIMOTE_CMD_LED, WIIMOTE_CMD_RUMBLE, etc). Found in wiiuse.h
|
||||||
* @param msg The payload.
|
* @param msg The payload. Might be changed by the callee.
|
||||||
* @param len Length of the payload in bytes.
|
* @param len Length of the payload in bytes.
|
||||||
*
|
*
|
||||||
* This function should replace any write()s directly to the wiimote device.
|
* This function should replace any write()s directly to the wiimote device.
|
||||||
*/
|
*/
|
||||||
int wiiuse_send(struct wiimote_t* wm, byte report_type, byte* msg, int len) {
|
int wiiuse_send(struct wiimote_t* wm, byte report_type, byte* msg, int len) {
|
||||||
byte buf[32]; /* no payload is better than this */
|
|
||||||
int rumble = 0;
|
|
||||||
|
|
||||||
#ifdef WIIUSE_WIN32
|
|
||||||
buf[0] = report_type;
|
|
||||||
#else
|
|
||||||
buf[0] = WM_SET_REPORT | WM_BT_OUTPUT;
|
|
||||||
buf[1] = report_type;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
switch (report_type) {
|
switch (report_type) {
|
||||||
case WM_CMD_LED:
|
case WM_CMD_LED:
|
||||||
case WM_CMD_RUMBLE:
|
case WM_CMD_RUMBLE:
|
||||||
case WM_CMD_CTRL_STATUS:
|
case WM_CMD_CTRL_STATUS: {
|
||||||
{
|
|
||||||
/* Rumble flag for: 0x11, 0x13, 0x14, 0x15, 0x19 or 0x1a */
|
/* Rumble flag for: 0x11, 0x13, 0x14, 0x15, 0x19 or 0x1a */
|
||||||
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_RUMBLE))
|
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_RUMBLE)) {
|
||||||
rumble = 1;
|
msg[0] |= 0x01;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef WIIUSE_WIN32
|
|
||||||
memcpy(buf+2, msg, len);
|
|
||||||
if (rumble)
|
|
||||||
buf[2] |= 0x01;
|
|
||||||
#else
|
|
||||||
memcpy(buf+1, msg, len);
|
|
||||||
if (rumble)
|
|
||||||
buf[1] |= 0x01;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef WITH_WIIUSE_DEBUG
|
#ifdef WITH_WIIUSE_DEBUG
|
||||||
{
|
{
|
||||||
int x = 2;
|
int x;
|
||||||
printf("[DEBUG] (id %i) SEND: (%x) %.2x ", wm->unid, buf[0], buf[1]);
|
printf("[DEBUG] (id %i) SEND: (%.2x) %.2x ", wm->unid, report_type, msg[0]);
|
||||||
#ifndef WIIUSE_WIN32
|
for (x = 1; x < len; ++x) {
|
||||||
for (; x < len+2; ++x)
|
printf("%.2x ", msg[x]);
|
||||||
#else
|
}
|
||||||
for (; x < len+1; ++x)
|
|
||||||
#endif
|
|
||||||
printf("%.2x ", buf[x]);
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef WIIUSE_WIN32
|
return wiiuse_os_write(wm, report_type, msg, len);
|
||||||
return wiiuse_io_write(wm, buf, len+2);
|
|
||||||
#else
|
|
||||||
return wiiuse_io_write(wm, buf, len+1);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -690,7 +713,9 @@ int wiiuse_send(struct wiimote_t* wm, byte report_type, byte* msg, int len) {
|
|||||||
* Flags are defined in wiiuse.h.
|
* Flags are defined in wiiuse.h.
|
||||||
*/
|
*/
|
||||||
int wiiuse_set_flags(struct wiimote_t* wm, int enable, int disable) {
|
int wiiuse_set_flags(struct wiimote_t* wm, int enable, int disable) {
|
||||||
if (!wm) return 0;
|
if (!wm) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* remove mutually exclusive flags */
|
/* remove mutually exclusive flags */
|
||||||
enable &= ~disable;
|
enable &= ~disable;
|
||||||
@@ -719,15 +744,18 @@ int wiiuse_set_flags(struct wiimote_t* wm, int enable, int disable) {
|
|||||||
float wiiuse_set_smooth_alpha(struct wiimote_t* wm, float alpha) {
|
float wiiuse_set_smooth_alpha(struct wiimote_t* wm, float alpha) {
|
||||||
float old;
|
float old;
|
||||||
|
|
||||||
if (!wm) return 0.0f;
|
if (!wm) {
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
old = wm->accel_calib.st_alpha;
|
old = wm->accel_calib.st_alpha;
|
||||||
|
|
||||||
wm->accel_calib.st_alpha = alpha;
|
wm->accel_calib.st_alpha = alpha;
|
||||||
|
|
||||||
/* if there is a nunchuk set that too */
|
/* if there is a nunchuk set that too */
|
||||||
if (wm->exp.type == EXP_NUNCHUK)
|
if (wm->exp.type == EXP_NUNCHUK) {
|
||||||
wm->exp.nunchuk.accel_calib.st_alpha = alpha;
|
wm->exp.nunchuk.accel_calib.st_alpha = alpha;
|
||||||
|
}
|
||||||
|
|
||||||
return old;
|
return old;
|
||||||
}
|
}
|
||||||
@@ -744,10 +772,13 @@ void wiiuse_set_bluetooth_stack(struct wiimote_t** wm, int wiimotes, enum win_bt
|
|||||||
#ifdef WIIUSE_WIN32
|
#ifdef WIIUSE_WIN32
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!wm) return;
|
if (!wm) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < wiimotes; ++i)
|
for (i = 0; i < wiimotes; ++i) {
|
||||||
wm[i]->stack = type;
|
wm[i]->stack = type;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -763,7 +794,9 @@ void wiiuse_set_bluetooth_stack(struct wiimote_t** wm, int wiimotes, enum win_bt
|
|||||||
* the angle has to change by a full degree to generate an event.
|
* the angle has to change by a full degree to generate an event.
|
||||||
*/
|
*/
|
||||||
void wiiuse_set_orient_threshold(struct wiimote_t* wm, float threshold) {
|
void wiiuse_set_orient_threshold(struct wiimote_t* wm, float threshold) {
|
||||||
if (!wm) return;
|
if (!wm) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
wm->orient_threshold = threshold;
|
wm->orient_threshold = threshold;
|
||||||
}
|
}
|
||||||
@@ -776,7 +809,9 @@ void wiiuse_set_orient_threshold(struct wiimote_t* wm, float threshold) {
|
|||||||
* @param threshold The decimal place that should be considered a significant change.
|
* @param threshold The decimal place that should be considered a significant change.
|
||||||
*/
|
*/
|
||||||
void wiiuse_set_accel_threshold(struct wiimote_t* wm, int threshold) {
|
void wiiuse_set_accel_threshold(struct wiimote_t* wm, int threshold) {
|
||||||
if (!wm) return;
|
if (!wm) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
wm->accel_threshold = threshold;
|
wm->accel_threshold = threshold;
|
||||||
}
|
}
|
||||||
@@ -788,9 +823,13 @@ void wiiuse_set_accel_threshold(struct wiimote_t* wm, int threshold) {
|
|||||||
* @param wm Pointer to a wiimote_t structure.
|
* @param wm Pointer to a wiimote_t structure.
|
||||||
*/
|
*/
|
||||||
void wiiuse_resync(struct wiimote_t* wm) {
|
void wiiuse_resync(struct wiimote_t* wm) {
|
||||||
if (!wm) return;
|
if (!wm) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef WIIUSE_SYNC_HANDSHAKE
|
||||||
wm->handshake_state = 0;
|
wm->handshake_state = 0;
|
||||||
|
#endif
|
||||||
wiiuse_handshake(wm, NULL, 0);
|
wiiuse_handshake(wm, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -807,7 +846,9 @@ void wiiuse_set_timeout(struct wiimote_t** wm, int wiimotes, byte normal_timeout
|
|||||||
#ifdef WIIUSE_WIN32
|
#ifdef WIIUSE_WIN32
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!wm) return;
|
if (!wm) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < wiimotes; ++i) {
|
for (i = 0; i < wiimotes; ++i) {
|
||||||
wm[i]->normal_timeout = normal_timeout;
|
wm[i]->normal_timeout = normal_timeout;
|
||||||
|
|||||||
67
src/wiiuse.h
67
src/wiiuse.h
@@ -99,11 +99,6 @@
|
|||||||
/* nix */
|
/* nix */
|
||||||
#include <bluetooth/bluetooth.h>
|
#include <bluetooth/bluetooth.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef WIIUSE_MAC
|
|
||||||
/* mac */
|
|
||||||
#include <CoreFoundation/CoreFoundation.h> /*CFRunLoops and CFNumberRef in Bluetooth classes*/
|
|
||||||
#include <IOBluetooth/IOBluetoothUserLib.h> /*IOBluetoothDeviceRef and IOBluetoothL2CAPChannelRef*/
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef WCONST
|
#ifndef WCONST
|
||||||
#define WCONST const
|
#define WCONST const
|
||||||
@@ -124,6 +119,33 @@
|
|||||||
/** @defgroup publicapi External API */
|
/** @defgroup publicapi External API */
|
||||||
/** @{ */
|
/** @{ */
|
||||||
|
|
||||||
|
/** @name Wiimote state flags and macros */
|
||||||
|
/** @{ */
|
||||||
|
#define WIIMOTE_STATE_DEV_FOUND 0x0001
|
||||||
|
#define WIIMOTE_STATE_HANDSHAKE 0x0002 /* actual connection exists but no handshake yet */
|
||||||
|
#define WIIMOTE_STATE_HANDSHAKE_COMPLETE 0x0004 /* actual connection exists but no handshake yet */
|
||||||
|
#define WIIMOTE_STATE_CONNECTED 0x0008
|
||||||
|
#define WIIMOTE_STATE_RUMBLE 0x0010
|
||||||
|
#define WIIMOTE_STATE_ACC 0x0020
|
||||||
|
#define WIIMOTE_STATE_EXP 0x0040
|
||||||
|
#define WIIMOTE_STATE_IR 0x0080
|
||||||
|
#define WIIMOTE_STATE_SPEAKER 0x0100
|
||||||
|
#define WIIMOTE_STATE_IR_SENS_LVL1 0x0200
|
||||||
|
#define WIIMOTE_STATE_IR_SENS_LVL2 0x0400
|
||||||
|
#define WIIMOTE_STATE_IR_SENS_LVL3 0x0800
|
||||||
|
#define WIIMOTE_STATE_IR_SENS_LVL4 0x1000
|
||||||
|
#define WIIMOTE_STATE_IR_SENS_LVL5 0x2000
|
||||||
|
#define WIIMOTE_STATE_EXP_HANDSHAKE 0x10000 /* actual M+ connection exists but no handshake yet */
|
||||||
|
#define WIIMOTE_STATE_EXP_EXTERN 0x20000 /* actual M+ connection exists but handshake failed */
|
||||||
|
#define WIIMOTE_STATE_EXP_FAILED 0x40000 /* actual M+ connection exists but handshake failed */
|
||||||
|
#define WIIMOTE_STATE_MPLUS_PRESENT 0x80000 /* Motion+ is connected */
|
||||||
|
|
||||||
|
#define WIIMOTE_ID(wm) (wm->unid)
|
||||||
|
|
||||||
|
#define WIIMOTE_IS_SET(wm, s) ((wm->state & (s)) == (s))
|
||||||
|
#define WIIMOTE_IS_CONNECTED(wm) (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_CONNECTED))
|
||||||
|
/** @} */
|
||||||
|
|
||||||
/** @name LED bit masks */
|
/** @name LED bit masks */
|
||||||
/** @{ */
|
/** @{ */
|
||||||
#define WIIMOTE_LED_NONE 0x00
|
#define WIIMOTE_LED_NONE 0x00
|
||||||
@@ -285,12 +307,6 @@ typedef enum ir_position_t {
|
|||||||
#define WIIUSE_IS_LED_SET(wm, num) ((wm->leds & WIIMOTE_LED_##num) == WIIMOTE_LED_##num)
|
#define WIIUSE_IS_LED_SET(wm, num) ((wm->leds & WIIMOTE_LED_##num) == WIIMOTE_LED_##num)
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
/*
|
|
||||||
* Largest known payload is 21 bytes.
|
|
||||||
* Add 2 for the prefix and round up to a power of 2.
|
|
||||||
*/
|
|
||||||
#define MAX_PAYLOAD 32
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is left over from an old hack, but it may actually
|
* This is left over from an old hack, but it may actually
|
||||||
* be a useful feature to keep so it wasn't removed.
|
* be a useful feature to keep so it wasn't removed.
|
||||||
@@ -300,6 +316,9 @@ typedef enum ir_position_t {
|
|||||||
#define WIIMOTE_EXP_TIMEOUT 10
|
#define WIIMOTE_EXP_TIMEOUT 10
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define WIIUSE_SYNC_HANDSHAKE
|
||||||
|
|
||||||
|
|
||||||
typedef unsigned char byte;
|
typedef unsigned char byte;
|
||||||
typedef char sbyte;
|
typedef char sbyte;
|
||||||
|
|
||||||
@@ -547,8 +566,7 @@ typedef struct guitar_hero_3_t {
|
|||||||
/**
|
/**
|
||||||
* @brief Motion Plus expansion device
|
* @brief Motion Plus expansion device
|
||||||
*/
|
*/
|
||||||
typedef struct motion_plus_t
|
typedef struct motion_plus_t {
|
||||||
{
|
|
||||||
byte ext; /**< is there a device on the pass-through port? */
|
byte ext; /**< is there a device on the pass-through port? */
|
||||||
|
|
||||||
struct ang3s_t raw_gyro; /**< current raw gyroscope data */
|
struct ang3s_t raw_gyro; /**< current raw gyroscope data */
|
||||||
@@ -702,6 +720,7 @@ typedef struct wiimote_t {
|
|||||||
#ifdef WIIUSE_BLUEZ
|
#ifdef WIIUSE_BLUEZ
|
||||||
/** @name Linux-specific (BlueZ) members */
|
/** @name Linux-specific (BlueZ) members */
|
||||||
/** @{ */
|
/** @{ */
|
||||||
|
WCONST char bdaddr_str[18]; /**< readable bt address */
|
||||||
WCONST bdaddr_t bdaddr; /**< bt address */
|
WCONST bdaddr_t bdaddr; /**< bt address */
|
||||||
WCONST int out_sock; /**< output socket */
|
WCONST int out_sock; /**< output socket */
|
||||||
WCONST int in_sock; /**< input socket */
|
WCONST int in_sock; /**< input socket */
|
||||||
@@ -723,19 +742,7 @@ typedef struct wiimote_t {
|
|||||||
#ifdef WIIUSE_MAC
|
#ifdef WIIUSE_MAC
|
||||||
/** @name Mac OS X-specific members */
|
/** @name Mac OS X-specific members */
|
||||||
/** @{ */
|
/** @{ */
|
||||||
WCONST IOBluetoothDeviceRef device; /** Device reference object */
|
WCONST void* objc_wm; /** WiiuseWiimote* as opaque pointer */
|
||||||
WCONST CFStringRef address; /** MacOS-like device address string */
|
|
||||||
WCONST IOBluetoothL2CAPChannelRef inputCh; /** Input L2CAP channel */
|
|
||||||
WCONST IOBluetoothL2CAPChannelRef outputCh; /** Output L2CAP channel */
|
|
||||||
WCONST IOBluetoothUserNotificationRef disconnectionRef; /** Disconnection Notification Reference **/
|
|
||||||
WCONST void* connectionHandler; /** Wiimote connection handler for MACOSX **/
|
|
||||||
/** @} */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(WIIUSE_BLUEZ) || defined(WIIUSE_MAC)
|
|
||||||
/** @name Linux (BlueZ) and Mac OS X shared members */
|
|
||||||
/** @{ */
|
|
||||||
WCONST char bdaddr_str[18]; /**< readable bt address */
|
|
||||||
/** @} */
|
/** @} */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -745,7 +752,9 @@ typedef struct wiimote_t {
|
|||||||
|
|
||||||
WCONST int flags; /**< options flag */
|
WCONST int flags; /**< options flag */
|
||||||
|
|
||||||
|
#ifndef WIIUSE_SYNC_HANDSHAKE
|
||||||
WCONST byte handshake_state; /**< the state of the connection handshake */
|
WCONST byte handshake_state; /**< the state of the connection handshake */
|
||||||
|
#endif
|
||||||
WCONST byte expansion_state; /**< the state of the expansion handshake */
|
WCONST byte expansion_state; /**< the state of the expansion handshake */
|
||||||
WCONST struct data_req_t* data_req; /**< list of data read requests */
|
WCONST struct data_req_t* data_req; /**< list of data read requests */
|
||||||
|
|
||||||
@@ -769,7 +778,6 @@ typedef struct wiimote_t {
|
|||||||
WCONST struct wiimote_state_t lstate; /**< last saved state */
|
WCONST struct wiimote_state_t lstate; /**< last saved state */
|
||||||
|
|
||||||
WCONST WIIUSE_EVENT_TYPE event; /**< type of event that occurred */
|
WCONST WIIUSE_EVENT_TYPE event; /**< type of event that occurred */
|
||||||
WCONST byte event_buf[MAX_PAYLOAD]; /**< event buffer */
|
|
||||||
WCONST byte motion_plus_id[6];
|
WCONST byte motion_plus_id[6];
|
||||||
} wiimote;
|
} wiimote;
|
||||||
|
|
||||||
@@ -808,8 +816,7 @@ typedef void (*wiiuse_update_cb)(struct wiimote_callback_data_t* wm);
|
|||||||
*/
|
*/
|
||||||
typedef void (*wiiuse_write_cb)(struct wiimote_t* wm, unsigned char* data, unsigned short len);
|
typedef void (*wiiuse_write_cb)(struct wiimote_t* wm, unsigned char* data, unsigned short len);
|
||||||
|
|
||||||
typedef enum data_req_s
|
typedef enum data_req_s {
|
||||||
{
|
|
||||||
REQ_READY = 0,
|
REQ_READY = 0,
|
||||||
REQ_SENT,
|
REQ_SENT,
|
||||||
REQ_DONE
|
REQ_DONE
|
||||||
@@ -896,7 +903,7 @@ WIIUSE_EXPORT extern void wiiuse_resync(struct wiimote_t* wm);
|
|||||||
WIIUSE_EXPORT extern void wiiuse_set_timeout(struct wiimote_t** wm, int wiimotes, byte normal_timeout, byte exp_timeout);
|
WIIUSE_EXPORT extern void wiiuse_set_timeout(struct wiimote_t** wm, int wiimotes, byte normal_timeout, byte exp_timeout);
|
||||||
WIIUSE_EXPORT extern void wiiuse_set_accel_threshold(struct wiimote_t* wm, int threshold);
|
WIIUSE_EXPORT extern void wiiuse_set_accel_threshold(struct wiimote_t* wm, int threshold);
|
||||||
|
|
||||||
/* connect.c */
|
/* io.c */
|
||||||
WIIUSE_EXPORT extern int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int timeout);
|
WIIUSE_EXPORT extern int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int timeout);
|
||||||
WIIUSE_EXPORT extern int wiiuse_connect(struct wiimote_t** wm, int wiimotes);
|
WIIUSE_EXPORT extern int wiiuse_connect(struct wiimote_t** wm, int wiimotes);
|
||||||
WIIUSE_EXPORT extern void wiiuse_disconnect(struct wiimote_t* wm);
|
WIIUSE_EXPORT extern void wiiuse_disconnect(struct wiimote_t* wm);
|
||||||
|
|||||||
@@ -104,6 +104,7 @@
|
|||||||
#define WM_INPUT_CHANNEL 0x13
|
#define WM_INPUT_CHANNEL 0x13
|
||||||
|
|
||||||
#define WM_SET_REPORT 0x50
|
#define WM_SET_REPORT 0x50
|
||||||
|
#define WM_SET_DATA 0xA0
|
||||||
|
|
||||||
/* commands */
|
/* commands */
|
||||||
#define WM_CMD_LED 0x11
|
#define WM_CMD_LED 0x11
|
||||||
@@ -172,6 +173,7 @@
|
|||||||
#define WM_EXP_MEM_ENABLE1 0x04A400F0
|
#define WM_EXP_MEM_ENABLE1 0x04A400F0
|
||||||
#define WM_EXP_MEM_ENABLE2 0x04A400FB
|
#define WM_EXP_MEM_ENABLE2 0x04A400FB
|
||||||
#define WM_EXP_MEM_CALIBR 0x04A40020
|
#define WM_EXP_MEM_CALIBR 0x04A40020
|
||||||
|
#define WM_EXP_MOTION_PLUS_IDENT 0x04A600FA
|
||||||
#define WM_EXP_MOTION_PLUS_ENABLE 0x04A600FE
|
#define WM_EXP_MOTION_PLUS_ENABLE 0x04A600FE
|
||||||
#define WM_EXP_MOTION_PLUS_INIT 0x04A600F0
|
#define WM_EXP_MOTION_PLUS_INIT 0x04A600F0
|
||||||
#define WM_REG_IR 0x04B00030
|
#define WM_REG_IR 0x04B00030
|
||||||
@@ -209,10 +211,16 @@
|
|||||||
#define EXP_ID_CODE_WII_BOARD 0xA4200402
|
#define EXP_ID_CODE_WII_BOARD 0xA4200402
|
||||||
#define EXP_ID_CODE_CLASSIC_CONTROLLER 0xA4200101
|
#define EXP_ID_CODE_CLASSIC_CONTROLLER 0xA4200101
|
||||||
#define EXP_ID_CODE_GUITAR 0xA4200103
|
#define EXP_ID_CODE_GUITAR 0xA4200103
|
||||||
#define EXP_ID_CODE_MOTION_PLUS 0xa4200405
|
#define EXP_ID_CODE_MOTION_PLUS 0xA4200405
|
||||||
#define EXP_ID_CODE_MOTION_PLUS_NUNCHUK 0xA4200505 /** Motion Plus ID in Nunchuck passthrough mode */
|
#define EXP_ID_CODE_MOTION_PLUS_NUNCHUK 0xA4200505 /** Motion Plus ID in Nunchuck passthrough mode */
|
||||||
#define EXP_ID_CODE_MOTION_PLUS_CLASSIC 0xA4200705 /** Motion Plus ID in Classic control. passthrough */
|
#define EXP_ID_CODE_MOTION_PLUS_CLASSIC 0xA4200705 /** Motion Plus ID in Classic control. passthrough */
|
||||||
|
|
||||||
|
/* decrypted M+ codes at 0x04A600FA */
|
||||||
|
#define EXP_ID_CODE_INACTIVE_MOTION_PLUS 0xA6200005 /** Inactive Motion Plus ID */
|
||||||
|
#define EXP_ID_CODE_NLA_MOTION_PLUS 0xA6200405 /** No longer active Motion Plus ID */
|
||||||
|
#define EXP_ID_CODE_NLA_MOTION_PLUS_NUNCHUK 0xA6200505 /** No longer active Motion Plus ID in Nunchuck passthrough mode */
|
||||||
|
#define EXP_ID_CODE_NLA_MOTION_PLUS_CLASSIC 0xA6200705 /** No longer active Motion Plus ID in Classic control. passthrough */
|
||||||
|
|
||||||
#define EXP_HANDSHAKE_LEN 224
|
#define EXP_HANDSHAKE_LEN 224
|
||||||
|
|
||||||
/********************
|
/********************
|
||||||
@@ -221,31 +229,9 @@
|
|||||||
*
|
*
|
||||||
********************/
|
********************/
|
||||||
|
|
||||||
/* wiimote state flags - (some duplicated in wiiuse.h)*/
|
|
||||||
#define WIIMOTE_STATE_DEV_FOUND 0x0001
|
|
||||||
#define WIIMOTE_STATE_HANDSHAKE 0x0002 /* actual connection exists but no handshake yet */
|
|
||||||
#define WIIMOTE_STATE_HANDSHAKE_COMPLETE 0x0004 /* actual connection exists but no handshake yet */
|
|
||||||
#define WIIMOTE_STATE_CONNECTED 0x0008
|
|
||||||
#define WIIMOTE_STATE_RUMBLE 0x0010
|
|
||||||
#define WIIMOTE_STATE_ACC 0x0020
|
|
||||||
#define WIIMOTE_STATE_EXP 0x0040
|
|
||||||
#define WIIMOTE_STATE_IR 0x0080
|
|
||||||
#define WIIMOTE_STATE_SPEAKER 0x0100
|
|
||||||
#define WIIMOTE_STATE_IR_SENS_LVL1 0x0200
|
|
||||||
#define WIIMOTE_STATE_IR_SENS_LVL2 0x0400
|
|
||||||
#define WIIMOTE_STATE_IR_SENS_LVL3 0x0800
|
|
||||||
#define WIIMOTE_STATE_IR_SENS_LVL4 0x1000
|
|
||||||
#define WIIMOTE_STATE_IR_SENS_LVL5 0x2000
|
|
||||||
#define WIIMOTE_STATE_EXP_HANDSHAKE 0x10000 /* actual M+ connection exists but no handshake yet */
|
|
||||||
#define WIIMOTE_STATE_EXP_EXTERN 0x20000 /* actual M+ connection exists but handshake failed */
|
|
||||||
#define WIIMOTE_STATE_EXP_FAILED 0x40000 /* actual M+ connection exists but handshake failed */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define WIIMOTE_INIT_STATES (WIIMOTE_STATE_IR_SENS_LVL3)
|
#define WIIMOTE_INIT_STATES (WIIMOTE_STATE_IR_SENS_LVL3)
|
||||||
|
|
||||||
/* macro to manage states */
|
/* macro to manage states */
|
||||||
#define WIIMOTE_IS_SET(wm, s) ((wm->state & (s)) == (s))
|
|
||||||
#define WIIMOTE_ENABLE_STATE(wm, s) (wm->state |= (s))
|
#define WIIMOTE_ENABLE_STATE(wm, s) (wm->state |= (s))
|
||||||
#define WIIMOTE_DISABLE_STATE(wm, s) (wm->state &= ~(s))
|
#define WIIMOTE_DISABLE_STATE(wm, s) (wm->state &= ~(s))
|
||||||
#define WIIMOTE_TOGGLE_STATE(wm, s) ((wm->state & (s)) ? WIIMOTE_DISABLE_STATE(wm, s) : WIIMOTE_ENABLE_STATE(wm, s))
|
#define WIIMOTE_TOGGLE_STATE(wm, s) ((wm->state & (s)) ? WIIMOTE_DISABLE_STATE(wm, s) : WIIMOTE_ENABLE_STATE(wm, s))
|
||||||
@@ -257,9 +243,11 @@
|
|||||||
|
|
||||||
#define NUNCHUK_IS_FLAG_SET(wm, s) ((*(wm->flags) & (s)) == (s))
|
#define NUNCHUK_IS_FLAG_SET(wm, s) ((*(wm->flags) & (s)) == (s))
|
||||||
|
|
||||||
/* misc macros */
|
/*
|
||||||
#define WIIMOTE_ID(wm) (wm->unid)
|
* Largest known payload is 21 bytes.
|
||||||
#define WIIMOTE_IS_CONNECTED(wm) (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_CONNECTED))
|
* Add 1 (Win32) or 2 (Mac, *nix) for the prefix and round up to a power of 2.
|
||||||
|
*/
|
||||||
|
#define MAX_PAYLOAD 32
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Smooth tilt calculations are computed with the
|
* Smooth tilt calculations are computed with the
|
||||||
|
|||||||
Reference in New Issue
Block a user