Skip to content

Commit

Permalink
it compiles; also addressed a TODO in hidapi_parser.c
Browse files Browse the repository at this point in the history
  • Loading branch information
beatboxchad committed Mar 29, 2024
1 parent c7e320d commit 57c5dfe
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 48 deletions.
9 changes: 0 additions & 9 deletions external_libraries/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,6 @@ endif()
set( EXAMPLE_TEST OFF )
set( EXAMPLE_OSC OFF )

if(SC_HIDAPI)
add_subdirectory(hidapi)
message(STATUS "Building with HID support")
elseif(MINGW AND (${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 5.3.0))
message(WARNING "SC is by default built without HID-support if a MinGW/gcc-version below 5.3 is used. Please consult the Readme on how to enable it (easy).")
else()
message(STATUS "HID support disabled")
endif()

if(WIN32)
add_library(portmidi portmidi/pm_common/pminternal.h
portmidi/pm_common/pmutil.c
Expand Down
12 changes: 7 additions & 5 deletions lang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,8 @@ endif(WIN32)

if(SC_HIDAPI)
list(APPEND sclang_sources LangPrimSource/SC_HID_api.cpp)
include_directories(
${CMAKE_SOURCE_DIR}/external_libraries/hidapi/hidapi
${CMAKE_SOURCE_DIR}/external_libraries/hidapi/hidapi_parser
)
find_package(hidapi REQUIRED GLOBAL)
add_subdirectory(hidapi_parser)
add_definitions(-DSC_HIDAPI)
endif(SC_HIDAPI)

Expand Down Expand Up @@ -231,14 +229,18 @@ endif()

if(SC_HIDAPI)
target_compile_definitions(libsclang PRIVATE HAVE_HIDAPI)
target_link_libraries( libsclang hidapi hidapi_parser )
target_link_libraries( libsclang hidapi::hidapi hidapi_parser )

if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" AND HID_HIDRAW)
target_link_libraries( libsclang ${UDEV_LIBRARIES})
endif()
if(HID_LIBUSB)
target_link_libraries( libsclang ${LIBUSB_1_LIBRARIES})
endif()

# hidapi2osc
include_directories(${CMAKE_SOURCE_DIR}/tools/hidapi2osc)

endif()

target_link_libraries(libsclang boost_thread_lib boost_system_lib boost_regex_lib boost_filesystem_lib)
Expand Down
14 changes: 2 additions & 12 deletions lang/hidapi_parser/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
message(STATUS " hidapi_parser" )


# message( "hidapi parser source dir is: ${hidapi_SOURCE_DIR}" )
#
# set( hidapi_parser_INCLUDE_DIRS ${hidapi_SOURCE_DIR}/hidapi_parser/)
# # set( hidapi_LIBS ${UDEV_LIBRARIES})
# set( hidapi_parser_SRCS hidapi_parser.c )
#
# message( "hidapi_parser include dirs are: ${hidapi_parser_INCLUDE_DIRS}" )

include_directories( ${hidapi_SOURCE_DIR}/hidapi/ )
add_library( hidapi_parser STATIC hidapi_parser.c )
target_link_libraries( hidapi )
target_link_libraries(hidapi_parser hidapi::hidapi m)
target_include_directories(hidapi_parser PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
3 changes: 1 addition & 2 deletions lang/hidapi_parser/hidapi_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -748,10 +748,9 @@ float hid_element_map_logical( struct hid_device_element * element ){
return result;
}

/** TODO: this needs a linking with the math library */
float hid_element_resolution( struct hid_device_element * element ){
float result = 0;
// result = ( element->logical_max - element->logical_min) / ( ( element->phys_max - element->phys_min) * pow(10, element->unit_exponent) );
result = ( element->logical_max - element->logical_min) / ( ( element->phys_max - element->phys_min) * pow(10, element->unit_exponent) );
return result;
}

Expand Down
6 changes: 6 additions & 0 deletions testsuite/sclang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ foreach(test ${tests})
set(test_target ${test_name}_run)
add_test(NAME ${test_target} COMMAND sclang -l ${CMAKE_BINARY_DIR}/build_sclang.cfg ${test})
endforeach()

if(SC_HIDAPI)
add_subdirectory(hidparsertest)
message(STATUS "Building HID tests")
endif()

4 changes: 1 addition & 3 deletions testsuite/sclang/hidparsertest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ message(STATUS " hidparsertest" )

include_directories(
${CMAKE_BINARY_DIR}
${hidapi_SOURCE_DIR}/hidapi/
${hidapi_SOURCE_DIR}/hidapi_parser/
)

add_executable( hidparsertest hidparsertest.c )

target_link_libraries(hidparsertest hidapi hidapi_parser ${EXTRA_LIBS} m)
target_link_libraries(hidparsertest hidapi::hidapi hidapi_parser ${EXTRA_LIBS} m)

install(TARGETS hidparsertest DESTINATION bin)
20 changes: 3 additions & 17 deletions tools/hidapi2osc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,18 @@ include(FindPkgConfig)
# pkg_check_modules
pkg_check_modules(liblo REQUIRED liblo)

# add_subdirectory( ${hidapi_source} )

# message( "osc: hidapi include dirs are: ${hidapi_INCLUDE_DIRS}" )
# message( "osc: hidapi parser include dirs are: ${hidapi_parser_INCLUDE_DIRS}" )

include_directories(
${CMAKE_BINARY_DIR}
${liblo_INCLUDE_DIRS}
${hidapi_SOURCE_DIR}/hidapi/
${hidapi_SOURCE_DIR}/hidapi_parser/
)
find_package(hidapi_parser REQUIRED)

link_directories(
${liblo_LIBRARY_DIRS}
)


##########################################################################
# sdl2osc
# hidapi2osc
##########################################################################

set(hidapi2osc_SRCS
hidapi2osc.cpp
)

add_executable( hidapi2osc ${hidapi2osc_SRCS} )
add_executable( hidapi2osc hidapi2osc.cpp)

target_link_libraries(hidapi2osc ${liblo_LIBRARIES} ${EXTRA_LIBS} hidapi hidapi_parser m)

Expand Down

0 comments on commit 57c5dfe

Please sign in to comment.