Skip to content

Commit 85a0022

Browse files
author
Morgan Brown
committed
1 parent 06b3c6a commit 85a0022

33 files changed

+5270
-6318
lines changed

libuiohook/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/.idea/
22
/.vs/
3+
/.vscode/
34
/build/
45
/dist/
6+
.DS_Store

libuiohook/CMakeLists.txt

Lines changed: 46 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
# You should have received a copy of the GNU Lesser General Public License
1616
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18-
cmake_minimum_required(VERSION 3.10)
18+
cmake_minimum_required(VERSION 3.19.5)
1919

20-
project(uiohook VERSION 1.2.0 LANGUAGES C)
20+
project(uiohook VERSION 1.3.0 LANGUAGES C)
2121

2222

2323
if (WIN32 OR WIN64)
@@ -28,13 +28,26 @@ else()
2828
set(UIOHOOK_SOURCE_DIR "x11")
2929
endif()
3030

31-
add_library(uiohook
32-
"src/logger.c"
33-
"src/${UIOHOOK_SOURCE_DIR}/input_helper.c"
34-
"src/${UIOHOOK_SOURCE_DIR}/input_hook.c"
35-
"src/${UIOHOOK_SOURCE_DIR}/post_event.c"
36-
"src/${UIOHOOK_SOURCE_DIR}/system_properties.c"
37-
)
31+
if (WIN32 OR WIN64)
32+
add_library(uiohook
33+
"src/logger.c"
34+
"src/${UIOHOOK_SOURCE_DIR}/dispatch_event.c"
35+
"src/${UIOHOOK_SOURCE_DIR}/input_helper.c"
36+
"src/${UIOHOOK_SOURCE_DIR}/input_hook.c"
37+
"src/${UIOHOOK_SOURCE_DIR}/post_event.c"
38+
"src/${UIOHOOK_SOURCE_DIR}/system_properties.c"
39+
"src/${UIOHOOK_SOURCE_DIR}/monitor_helper.c"
40+
)
41+
else()
42+
add_library(uiohook
43+
"src/logger.c"
44+
"src/${UIOHOOK_SOURCE_DIR}/dispatch_event.c"
45+
"src/${UIOHOOK_SOURCE_DIR}/input_helper.c"
46+
"src/${UIOHOOK_SOURCE_DIR}/input_hook.c"
47+
"src/${UIOHOOK_SOURCE_DIR}/post_event.c"
48+
"src/${UIOHOOK_SOURCE_DIR}/system_properties.c"
49+
)
50+
endif ()
3851

3952
set_target_properties(uiohook PROPERTIES
4053
C_STANDARD 99
@@ -130,6 +143,10 @@ if(ENABLE_TEST)
130143
target_link_libraries(uiohook_tests uiohook "${CMAKE_THREAD_LIBS_INIT}")
131144
endif()
132145

146+
option(USE_EPOCH_TIME "Use Unix epoch time for event timestamps (default: ON)" ON)
147+
if(USE_EPOCH_TIME)
148+
add_compile_definitions(uiohook PRIVATE USE_EPOCH_TIME)
149+
endif()
133150

134151
if(UNIX AND NOT APPLE)
135152
find_package(PkgConfig REQUIRED)
@@ -148,26 +165,6 @@ if(UNIX AND NOT APPLE)
148165
include(CheckIncludeFile)
149166
check_include_file(X11/extensions/record.h HAVE_RECORD_H "-include X11/Xlib.h")
150167

151-
option(USE_XKB_COMMON "X Keyboard Common Extension (default: ON)" ON)
152-
if(USE_XKB_COMMON)
153-
pkg_check_modules(XKB_COMMON REQUIRED xkbcommon-x11)
154-
add_compile_definitions(uiohook PRIVATE USE_XKB_COMMON)
155-
target_include_directories(uiohook PRIVATE "${XKB_COMMON_INCLUDE_DIRS}")
156-
target_link_libraries(uiohook "${XKB_COMMON_LDFLAGS}")
157-
158-
pkg_check_modules(X11_XCB REQUIRED x11-xcb)
159-
target_include_directories(uiohook PRIVATE "${X11_XCB_INCLUDE_DIRS}")
160-
target_link_libraries(uiohook "${X11_XCB_LDFLAGS}")
161-
endif()
162-
163-
option(USE_XKB_FILE "X Keyboard File Extension (default: ON)" ON)
164-
if(USE_XKB_FILE)
165-
pkg_check_modules(XKB_FILE REQUIRED xkbfile)
166-
add_compile_definitions(uiohook PRIVATE USE_XKB_FILE)
167-
target_include_directories(uiohook PRIVATE "${XKB_FILE_INCLUDE_DIRS}")
168-
target_link_libraries(uiohook "${XKB_FILE_LDFLAGS}")
169-
endif()
170-
171168
option(USE_XT "X Toolkit Extension (default: ON)" ON)
172169
if(USE_XT)
173170
pkg_check_modules(XT REQUIRED xt)
@@ -206,12 +203,6 @@ if(UNIX AND NOT APPLE)
206203
add_compile_definitions(uiohook PRIVATE USE_XRECORD_ASYNC)
207204
endif()
208205

209-
option(USE_XTEST "XTest API (default: ON)" ON)
210-
if(USE_XTEST)
211-
# XTest API is provided by Xtst
212-
add_compile_definitions(uiohook PRIVATE USE_XTEST)
213-
endif()
214-
215206
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
216207
option(USE_EVDEV "Generic Linux input driver (default: ON)" ON)
217208
if(USE_EVDEV)
@@ -220,14 +211,25 @@ if(UNIX AND NOT APPLE)
220211
endif()
221212
elseif(APPLE)
222213
set(CMAKE_MACOSX_RPATH 1)
223-
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.5")
224214

225-
find_package(Threads REQUIRED)
226-
target_link_libraries(uiohook "${CMAKE_THREAD_LIBS_INIT}")
227-
228-
find_library(CARBON Carbon REQUIRED)
229-
target_include_directories(uiohook PRIVATE "${CARBON}")
230-
target_link_libraries(uiohook "${CARBON}")
215+
option(MAC_CATALYST "Build for Mac Catalyst (default: OFF)" OFF)
216+
if(MAC_CATALYST)
217+
add_compile_definitions(uiohook PRIVATE MAC_CATALYST)
218+
find_library(CORE_FOUNDATION CoreFoundation REQUIRED)
219+
target_include_directories(uiohook PRIVATE "${CORE_FOUNDATION}")
220+
target_link_libraries(uiohook "${CORE_FOUNDATION}")
221+
find_library(CORE_GRAPHICS CoreGraphics REQUIRED)
222+
target_include_directories(uiohook PRIVATE "${CORE_GRAPHICS}")
223+
target_link_libraries(uiohook "${CORE_GRAPHICS}")
224+
else()
225+
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15")
226+
find_package(Threads REQUIRED)
227+
target_link_libraries(uiohook "${CMAKE_THREAD_LIBS_INIT}")
228+
229+
find_library(CARBON Carbon REQUIRED)
230+
target_include_directories(uiohook PRIVATE "${CARBON}")
231+
target_link_libraries(uiohook "${CARBON}")
232+
endif()
231233

232234
option(USE_APPLICATION_SERVICES "ApplicationServices framework (default: ON)" ON)
233235
if(USE_APPLICATION_SERVICES)
@@ -245,31 +247,13 @@ elseif(APPLE)
245247
target_link_libraries(uiohook "${IOKIT}")
246248
endif()
247249

248-
# FIXME Change USE_OBJC flag to USE_APPKIT
249-
#option(USE_APPKIT "AppKit framework (default: ON)" ON)
250-
option(USE_OBJC "Objective-C API (default: ON)" ON)
251-
if(USE_OBJC)
252-
# FIXME Drop USE_OBJC as it is included in AppKit
253-
find_library(OBJC objc REQUIRED)
254-
add_compile_definitions(USE_OBJC)
255-
target_include_directories(uiohook PRIVATE "${OBJC}")
256-
target_link_libraries(uiohook "${OBJC}")
257-
250+
option(USE_APPKIT "AppKit framework (default: ON)" ON)
251+
if(USE_APPKIT)
258252
find_library(APPKIT AppKit REQUIRED)
259253
add_compile_definitions(USE_APPKIT)
260254
target_include_directories(uiohook PRIVATE "${APPKIT}")
261255
target_link_libraries(uiohook "${APPKIT}")
262256
endif()
263-
264-
option(USE_CARBON_LEGACY "Legacy Carbon framework functionality (default: OFF)" OFF)
265-
if(USE_CARBON_LEGACY)
266-
message(DEPRECATION "Legacy Carbon functionality has been deprecated.")
267-
add_compile_definitions(USE_CARBON_LEGACY)
268-
269-
if(USE_CARBON_LEGACY AND CMAKE_SIZEOF_VOID_P EQUAL 8)
270-
message(WARNING "Legacy Carbon functionality should not be used with 64-bit targets.")
271-
endif()
272-
endif()
273257
elseif(WIN32)
274258
target_link_libraries(uiohook Advapi32)
275259
endif()

libuiohook/README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,18 @@ $ cmake --build . --parallel 2 --target install
3232
| __all__ | BUILD_DEMO:BOOL | demo applications | OFF |
3333
| | BUILD_SHARED_LIBS:BOOL | shared library | ON |
3434
| | ENABLE_TEST:BOOL | testing | OFF |
35+
| | USE_EPOCH_TIME:BOOL | unix epch event times | OFF |
3536
| __OSX__ | USE_APPLICATION_SERVICES:BOOL | framework | ON |
3637
| | USE_IOKIT:BOOL | framework | ON |
37-
| | USE_OBJC:BOOL | obj-c api | ON |
38-
| | USE_CARBON_LEGACY:BOOL | legacy framework | OFF |
38+
| | USE_APPKIT:BOOL | obj-c api | ON |
39+
| | MAC_CATALYST:BOOL | build for Mac Catalyst | ON |
3940
| __Win32__ | | | |
4041
| __Linux__ | USE_EVDEV:BOOL | generic input driver | ON |
4142
| __*nix__ | USE_XF86MISC:BOOL | xfree86-misc extension | OFF |
4243
| | USE_XINERAMA:BOOL | xinerama library | ON |
43-
| | USE_XKB_COMMON:BOOL | xkbcommon extension | ON |
44-
| | USE_XKB_FILE:BOOL | xkb-file extension | ON |
4544
| | USE_XRANDR:BOOL | xrandt extension | OFF |
4645
| | USE_XRECORD_ASYNC:BOOL | xrecord async api | OFF |
4746
| | USE_XT:BOOL | x toolkit extension | ON |
48-
| | USE_XTEST:BOOL | xtest extension | ON |
4947

5048
## Usage
5149
* [Hook Demo](demo/demo_hook.c)

0 commit comments

Comments
 (0)