diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..052fd29 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "src/logid/hidpp"] + path = src/logid/hidpp + url = https://github.com/PixlOne/hidpp.git + branch = master diff --git a/README.md b/README.md index 8c4e1b5..29a4a98 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ You may also refer to logid.example.cfg for an example. ## Building -This project requires a C++14 compiler, cmake, libevdev, libconfig, and [my fork of libhidpp](https://github.com/PixlOne/hidpp) +This project requires a C++14 compiler, cmake, libevdev, libudev, and libconfig To build this project, run: @@ -34,4 +34,4 @@ To install, run `sudo make install` after building. You can set the daemon to st | K350 | Untested | | M325c | Untested | -I own the MX Master, T400, K400r, K350, and M325c. Feel free to add to this list if you can test any additional devices. \ No newline at end of file +I own the MX Master, T400, K400r, K350, and M325c. Feel free to add to this list if you can test any additional devices. diff --git a/src/logid/CMakeLists.txt b/src/logid/CMakeLists.txt index 103efe9..6a2b52f 100644 --- a/src/logid/CMakeLists.txt +++ b/src/logid/CMakeLists.txt @@ -37,6 +37,39 @@ find_library(EVDEV_LIBRARY include_directories(${HIDPP_INCLUDE_DIR}/hidpp ${EVDEV_INCLUDE_DIR}) + +if((NOT HIDPP_INCLUDE_DIR) OR (NOT EXISTS ${HIDPP_INCLUDE_DIR}) OR (NOT HIDPP_LIBRARY) OR FORCE_BUILD_HIDPP) + message("Could not find libhidpp include dir, getting submodule") + + execute_process(COMMAND git submodule update --init -- hidpp + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + + if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + set(DEFAULT_HID_BACKEND "linux") + elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows") + set(DEFAULT_HID_BACKEND "windows") + else() + message(WARNING "System is not supported") + endif() + + set(HID_BACKEND "${DEFAULT_HID_BACKEND}" CACHE STRING "Backend used for accessing HID devices") + set_property(CACHE HID_BACKEND PROPERTY STRINGS linux windows) + + if("${HID_BACKEND}" STREQUAL "linux") + pkg_check_modules(LIBUDEV libudev REQUIRED) + elseif("${HID_BACKEND}" STREQUAL "windows") + add_definitions(-DUNICODE -D_UNICODE) + add_definitions(-D_WIN32_WINNT=0x0600) # Use vista or later + else() + message(FATAL_ERROR "HID_BACKEND is invalid.") + endif() + + add_subdirectory(hidpp/src/libhidpp) + + set(HIDPP_INCLUDE_DIR "hidpp/src/libhidpp/") + set(HIDPP_LIBRARY hidpp) +endif() + target_link_libraries(logid ${CMAKE_THREAD_LIBS_INIT} ${EVDEV_LIBRARY} config++ ${HIDPP_LIBRARY}) install(TARGETS logid DESTINATION bin) diff --git a/src/logid/hidpp b/src/logid/hidpp new file mode 160000 index 0000000..d124f4e --- /dev/null +++ b/src/logid/hidpp @@ -0,0 +1 @@ +Subproject commit d124f4ecf99ba73a3a190c8a60015d9916b25dc0