forked from kwhat/libuiohook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo_properties.c
115 lines (100 loc) · 4.04 KB
/
demo_properties.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/* libUIOHook: Cross-platform keyboard and mouse hooking from userland.
* Copyright (C) 2006-2023 Alexander Barker. All Rights Reserved.
* https://github.com/kwhat/libuiohook/
*
* libUIOHook is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* libUIOHook is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <uiohook.h>
static bool logger_proc(unsigned int level, const char *format, ...) {
bool status = false;
va_list args;
switch (level) {
case LOG_LEVEL_INFO:
va_start(args, format);
status = vfprintf(stdout, format, args) >= 0;
va_end(args);
break;
case LOG_LEVEL_WARN:
case LOG_LEVEL_ERROR:
va_start(args, format);
status = vfprintf(stderr, format, args) >= 0;
va_end(args);
break;
}
return status;
}
int main() {
// Disable the logger.
hook_set_logger_proc(&logger_proc);
// Retrieves current monitor layout and size.
unsigned char count;
screen_data* monitors = hook_create_screen_info(&count);
logger_proc(LOG_LEVEL_INFO, "Monitors Found:\t%u\n", count);
for (int i = 0; i < count; i++) {
logger_proc(LOG_LEVEL_INFO, "\t%3u) %4u x %-4u (%5d, %-5d)\n",
monitors[i].number,
monitors[i].width, monitors[i].height,
monitors[i].x, monitors[i].y);
}
logger_proc(LOG_LEVEL_INFO, "\n");
// Retrieves the keyboard auto repeat rate.
long int repeat_rate = hook_get_auto_repeat_rate();
if (repeat_rate >= 0) {
logger_proc(LOG_LEVEL_INFO, "Auto Repeat Rate:\t%ld\n", repeat_rate);
} else {
logger_proc(LOG_LEVEL_WARN, "Failed to acquire keyboard auto repeat rate!\n");
}
// Retrieves the keyboard auto repeat delay.
long int repeat_delay = hook_get_auto_repeat_delay();
if (repeat_delay >= 0) {
logger_proc(LOG_LEVEL_INFO, "Auto Repeat Delay:\t%ld\n", repeat_delay);
} else {
logger_proc(LOG_LEVEL_WARN, "Failed to acquire keyboard auto repeat delay!\n");
}
// Retrieves the mouse acceleration multiplier.
long int acceleration_multiplier = hook_get_pointer_acceleration_multiplier();
if (acceleration_multiplier >= 0) {
logger_proc(LOG_LEVEL_INFO, "Mouse Acceleration Multiplier:\t%ld\n", acceleration_multiplier);
} else {
logger_proc(LOG_LEVEL_WARN, "Failed to acquire mouse acceleration multiplier!\n");
}
// Retrieves the mouse acceleration threshold.
long int acceleration_threshold = hook_get_pointer_acceleration_threshold();
if (acceleration_threshold >= 0) {
logger_proc(LOG_LEVEL_INFO, "Mouse Acceleration Threshold:\t%ld\n", acceleration_threshold);
} else {
logger_proc(LOG_LEVEL_WARN, "Failed to acquire mouse acceleration threshold!\n");
}
// Retrieves the mouse sensitivity.
long int sensitivity = hook_get_pointer_sensitivity();
if (sensitivity >= 0) {
logger_proc(LOG_LEVEL_INFO, "Mouse Sensitivity:\t%ld\n", sensitivity);
} else {
logger_proc(LOG_LEVEL_WARN, "Failed to acquire mouse sensitivity value!\n");
}
// Retrieves the double/triple click interval.
long int click_time = hook_get_multi_click_time();
if (click_time >= 0) {
logger_proc(LOG_LEVEL_INFO, "Multi-Click Time:\t%ld\n", click_time);
} else {
logger_proc(LOG_LEVEL_WARN, "Failed to acquire mouse multi-click time!\n");
}
return EXIT_SUCCESS;
}