Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 45 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ cmake_minimum_required(VERSION 3.10)
project(uiohook VERSION 1.3.0 LANGUAGES C)


if (WIN32 OR WIN64)
if(WIN32 OR WIN64)
set(UIOHOOK_SOURCE_DIR "windows")
elseif (APPLE)
elseif(APPLE)
set(UIOHOOK_SOURCE_DIR "darwin")
else()
set(UIOHOOK_SOURCE_DIR "x11")
set(UIOHOOK_SOURCE_DIR "evdev")
endif()

add_library(uiohook
Expand Down Expand Up @@ -71,8 +71,8 @@ export(TARGETS uiohook FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.
install(EXPORT ${PROJECT_NAME}-config DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})


if (BUILD_DEMO)
if (NOT BUILD_SHARED_LIBS)
if(BUILD_DEMO)
if(NOT BUILD_SHARED_LIBS)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
endif()
Expand Down Expand Up @@ -111,7 +111,7 @@ if (BUILD_DEMO)
add_compile_definitions(all_demos PRIVATE inline=__inline)
add_compile_definitions(all_demos PRIVATE _CRT_SECURE_NO_WARNINGS)

if (MSVC_VERSION LESS "1900")
if(MSVC_VERSION LESS "1900")
add_compile_definitions(all_demos PRIVATE snprintf=_snprintf)
endif()
endif()
Expand Down Expand Up @@ -139,6 +139,36 @@ endif()
if(UNIX AND NOT APPLE)
find_package(PkgConfig REQUIRED)

pkg_check_modules(EVDEV REQUIRED libevdev)
target_include_directories(uiohook PRIVATE "${EVDEV_INCLUDE_DIRS}")
target_link_libraries(uiohook "${EVDEV_LDFLAGS}")

pkg_check_modules(UDEV REQUIRED libudev)
target_include_directories(uiohook PRIVATE "${UDEV_INCLUDE_DIRS}")
target_link_libraries(uiohook "${UDEV_LDFLAGS}")

#pkg_check_modules(XCB REQUIRED xcb)
#target_include_directories(uiohook PRIVATE "${XCB_INCLUDE_DIRS}")
#target_link_libraries(uiohook "${XCB_LDFLAGS}")

pkg_check_modules(XCB_X11 REQUIRED x11-xcb)
target_include_directories(uiohook PRIVATE "${XCB_X11_INCLUDE_DIRS}")
target_link_libraries(uiohook "${XCB_X11_LDFLAGS}")

pkg_check_modules(XKB REQUIRED xkbcommon)
target_include_directories(uiohook PRIVATE "${XKB_INCLUDE_DIRS}")
target_link_libraries(uiohook "${XKB_LDFLAGS}")

pkg_check_modules(XKB_X11 REQUIRED xkbcommon-x11)
target_include_directories(uiohook PRIVATE "${XKB_X11_INCLUDE_DIRS}")
target_link_libraries(uiohook "${XKB_X11_LDFLAGS}")

# FIXME Check for header X11/extensions/XKB.h
include(CheckIncludeFile)
check_include_file(X11/extensions/XKB.h HAVE_XKB_H)



pkg_check_modules(X11 REQUIRED x11)
target_include_directories(uiohook PRIVATE "${X11_INCLUDE_DIRS}")
target_link_libraries(uiohook "${X11_LDFLAGS}")
Expand All @@ -147,11 +177,18 @@ if(UNIX AND NOT APPLE)
target_include_directories(uiohook PRIVATE "${XTST_INCLUDE_DIRS}")
target_link_libraries(uiohook "${XTST_LDFLAGS}")

pkg_check_modules(XINPUT REQUIRED xi)
target_include_directories(uiohook PRIVATE "${XINPUT_INCLUDE_DIRS}")
target_link_libraries(uiohook "${XINPUT_LDFLAGS}")



include(CMakePrintHelpers)
cmake_print_variables(EVDEV_INCLUDE_DIRS)

include(CheckLibraryExists)
check_library_exists(Xtst XRecordQueryVersion "" HAVE_XRECORD)

include(CheckIncludeFile)
check_include_file(X11/extensions/record.h HAVE_RECORD_H "-include X11/Xlib.h")

option(USE_XT "X Toolkit Extension (default: ON)" ON)
if(USE_XT)
Expand Down
3 changes: 1 addition & 2 deletions demo/demo_hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@
#include <inttypes.h>
#include <locale.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <uiohook.h>


static void logger_proc(unsigned int level, void *user_data, const char *format, va_list args) {
switch (level) {
default:
case LOG_LEVEL_INFO:
vfprintf(stdout, format, args);
break;
Expand Down
2 changes: 2 additions & 0 deletions include/uiohook.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
#define UIOHOOK_ERROR_X_RECORD_ENABLE_CONTEXT 0x24
#define UIOHOOK_ERROR_X_RECORD_GET_CONTEXT 0x25

#define UIOHOOK_ERROR_EPOLL_CREATE 0x26

// Windows specific errors.
#define UIOHOOK_ERROR_SET_WINDOWS_HOOK_EX 0x30
#define UIOHOOK_ERROR_GET_MODULE_HANDLE 0x31
Expand Down
Loading
Loading