File tree 2 files changed +47
-0
lines changed
2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -272,6 +272,22 @@ message(STATUS "LibXml2: ${LIBXML2_VERSION_STRING}")
272
272
include_directories (${LIBXML2_INCLUDE_DIR} )
273
273
list (APPEND COMMON_LIBRARIES ${LIBXML2_LIBRARIES} )
274
274
275
+ option (ENABLE_HIDAPI "Enable support for HIDAPI input driver." ON )
276
+ if (ENABLE_HIDAPI)
277
+ find_package (HidAPI 0.10 QUIET )
278
+ if (HIDAPI_FOUND)
279
+ message (STATUS "HidAPI: ${HIDAPI_VERSION_STRING} " )
280
+ set (INPUT_DRIVER_HIDAPI_SOURCES src/input /HidApiInputDriver.cc)
281
+ include_directories (${HIDAPI_INCLUDE_DIR} )
282
+ list (APPEND COMMON_LIBRARIES ${HIDAPI_LIBRARY} )
283
+ add_definitions (-DENABLE_HIDAPI)
284
+ else ()
285
+ message (STATUS "HIDAPI: disabled" )
286
+ endif ()
287
+ else ()
288
+ message (STATUS "HIDAPI: disabled per user request" )
289
+ endif ()
290
+
275
291
option (ENABLE_CAIRO "Enable support for cairo vector graphics library." ON )
276
292
if (ENABLE_CAIRO)
277
293
find_package (Cairo 1.14 QUIET )
@@ -632,6 +648,7 @@ endif()
632
648
633
649
set (INPUT_DRIVER_SOURCES
634
650
${PLATFORM_INPUT_DRIVER_SOURCES}
651
+ ${INPUT_DRIVER_HIDAPI_SOURCES}
635
652
${INPUT_DRIVER_DBUS_SOURCES} )
636
653
637
654
set (GUI_SOURCES
Original file line number Diff line number Diff line change
1
+ find_package (PkgConfig QUIET )
2
+ PKG_CHECK_MODULES(PC_HIDAPI QUIET hidapi-libusb)
3
+
4
+ find_path (HIDAPI_INCLUDE_DIR NAMES hidapi.h
5
+ HINTS
6
+ ${PC_HIDAPI_INCLUDEDIR}
7
+ ${PC_HIDAPI_INCLUDE_DIRS} )
8
+
9
+ find_library (HIDAPI_LIBRARY NAMES hidapi-libusb
10
+ HINTS
11
+ ${PC_HIDAPI_LIBDIR}
12
+ ${PC_HIDAPI_LIBRARY_DIRS} )
13
+
14
+ if (HIDAPI_INCLUDE_DIR AND EXISTS "${HIDAPI_INCLUDE_DIR} /hidapi.h" )
15
+ file (STRINGS "${HIDAPI_INCLUDE_DIR} /hidapi.h" hidapi_version_major
16
+ REGEX "^#define[\t ]+HID_API_VERSION_MAJOR[\t ]+[0-9]+" )
17
+ file (STRINGS "${HIDAPI_INCLUDE_DIR} /hidapi.h" hidapi_version_minor
18
+ REGEX "^#define[\t ]+HID_API_VERSION_MINOR[\t ]+[0-9]+" )
19
+ file (STRINGS "${HIDAPI_INCLUDE_DIR} /hidapi.h" hidapi_version_patch
20
+ REGEX "^#define[\t ]+HID_API_VERSION_PATCH[\t ]+[0-9]+" )
21
+ string (REGEX REPLACE "[^0-9.]" "" HIDAPI_VERSION_STRING "${hidapi_version_major} .${hidapi_version_minor} .${hidapi_version_patch} " )
22
+ unset (hidapi_version_major)
23
+ unset (hidapi_version_minor)
24
+ unset (hidapi_version_patch)
25
+ endif ()
26
+
27
+ include (FindPackageHandleStandardArgs)
28
+ find_package_handle_standard_args(HidAPI REQUIRED_VARS HIDAPI_LIBRARY HIDAPI_INCLUDE_DIR)
29
+
30
+ mark_as_advanced (HIDAPI_INCLUDE_DIR HIDAPI_LIBRARY)
You can’t perform that action at this time.
0 commit comments