@mukea/uiohook-napi 1.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +77 -0
- package/binding.gyp +85 -0
- package/dist/index.d.ts +194 -0
- package/dist/index.js +206 -0
- package/dist/index.js.map +1 -0
- package/dist/prebuild-test-noop.d.ts +0 -0
- package/dist/prebuild-test-noop.js +3 -0
- package/dist/prebuild-test-noop.js.map +1 -0
- package/libuiohook/include/uiohook.h +457 -0
- package/libuiohook/src/darwin/input_helper.c +535 -0
- package/libuiohook/src/darwin/input_helper.h +203 -0
- package/libuiohook/src/darwin/input_hook.c +1436 -0
- package/libuiohook/src/darwin/post_event.c +303 -0
- package/libuiohook/src/darwin/system_properties.c +479 -0
- package/libuiohook/src/logger.c +40 -0
- package/libuiohook/src/logger.h +32 -0
- package/libuiohook/src/windows/input_helper.c +913 -0
- package/libuiohook/src/windows/input_helper.h +146 -0
- package/libuiohook/src/windows/input_hook.c +722 -0
- package/libuiohook/src/windows/post_event.c +248 -0
- package/libuiohook/src/windows/system_properties.c +231 -0
- package/libuiohook/src/x11/input_helper.c +1846 -0
- package/libuiohook/src/x11/input_helper.h +108 -0
- package/libuiohook/src/x11/input_hook.c +1116 -0
- package/libuiohook/src/x11/post_event.c +427 -0
- package/libuiohook/src/x11/system_properties.c +494 -0
- package/package.json +60 -0
- package/prebuilds/darwin/darwin-arm64/@mukea+uiohook-napi.node +0 -0
- package/prebuilds/darwin/darwin-x64/@mukea+uiohook-napi.node +0 -0
- package/prebuilds/linux/linux-arm64/@mukea+uiohook-napi.node +0 -0
- package/prebuilds/linux/linux-x64/@mukea+uiohook-napi.node +0 -0
- package/prebuilds/windows/win32-x64/@mukea+uiohook-napi.node +0 -0
- package/src/lib/addon.c +337 -0
- package/src/lib/napi_helpers.c +51 -0
- package/src/lib/napi_helpers.h +53 -0
- package/src/lib/uiohook_worker.c +200 -0
- package/src/lib/uiohook_worker.h +12 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/* libUIOHook: Cross-platform keyboard and mouse hooking from userland.
|
|
2
|
+
* Copyright (C) 2006-2023 Alexander Barker. All Rights Reserved.
|
|
3
|
+
* https://github.com/kwhat/libuiohook/
|
|
4
|
+
*
|
|
5
|
+
* libUIOHook is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU Lesser General Public License as published
|
|
7
|
+
* by the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
* (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* libUIOHook is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
16
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
// Reference: http://boredzo.org/blog/wp-content/uploads/2007/05/imtx-virtual-keycodes.png
|
|
20
|
+
// Reference: https://svn.blender.org/svnroot/bf-blender/branches/render25/intern/ghost/intern/GHOST_SystemCocoa.mm
|
|
21
|
+
// Reference: http://www.mactech.com/macintosh-c/chap02-1.html
|
|
22
|
+
|
|
23
|
+
#ifndef _included_input_helper
|
|
24
|
+
#define _included_input_helper
|
|
25
|
+
|
|
26
|
+
#include <ApplicationServices/ApplicationServices.h>
|
|
27
|
+
#include <Carbon/Carbon.h> // For HIToolbox kVK_ key codes and TIS functions.
|
|
28
|
+
|
|
29
|
+
#ifdef USE_IOKIT
|
|
30
|
+
#include <IOKit/hidsystem/ev_keymap.h>
|
|
31
|
+
#endif
|
|
32
|
+
#include <stdbool.h>
|
|
33
|
+
|
|
34
|
+
#ifndef USE_IOKIT
|
|
35
|
+
// Some of the system key codes that maybe missing from IOKit. They appear to have shown up over the years.
|
|
36
|
+
|
|
37
|
+
#ifndef NX_NOSPECIALKEY
|
|
38
|
+
#define NX_NOSPECIALKEY 0xFFFF
|
|
39
|
+
#endif
|
|
40
|
+
|
|
41
|
+
#ifndef NX_KEYTYPE_SOUND_UP
|
|
42
|
+
#define NX_KEYTYPE_SOUND_UP 0x00
|
|
43
|
+
#endif
|
|
44
|
+
|
|
45
|
+
#ifndef NX_KEYTYPE_SOUND_DOWN
|
|
46
|
+
#define NX_KEYTYPE_SOUND_DOWN 0x01
|
|
47
|
+
#endif
|
|
48
|
+
|
|
49
|
+
#ifndef NX_KEYTYPE_BRIGHTNESS_UP
|
|
50
|
+
#define NX_KEYTYPE_BRIGHTNESS_UP 0x02
|
|
51
|
+
#endif
|
|
52
|
+
|
|
53
|
+
#ifndef NX_KEYTYPE_BRIGHTNESS_DOWN
|
|
54
|
+
#define NX_KEYTYPE_BRIGHTNESS_DOWN 0x03
|
|
55
|
+
#endif
|
|
56
|
+
|
|
57
|
+
#ifndef NX_KEYTYPE_CAPS_LOCK
|
|
58
|
+
#define NX_KEYTYPE_CAPS_LOCK 0x04
|
|
59
|
+
#endif
|
|
60
|
+
|
|
61
|
+
#ifndef NX_KEYTYPE_HELP
|
|
62
|
+
#define NX_KEYTYPE_HELP 0x05
|
|
63
|
+
#endif
|
|
64
|
+
|
|
65
|
+
#ifndef NX_POWER_KEY
|
|
66
|
+
#define NX_POWER_KEY 0x06
|
|
67
|
+
#endif
|
|
68
|
+
|
|
69
|
+
#ifndef NX_KEYTYPE_MUTE
|
|
70
|
+
#define NX_KEYTYPE_MUTE 0x07
|
|
71
|
+
#endif
|
|
72
|
+
|
|
73
|
+
#ifndef NX_UP_ARROW_KEY
|
|
74
|
+
#define NX_UP_ARROW_KEY 0x0B
|
|
75
|
+
#endif
|
|
76
|
+
|
|
77
|
+
#ifndef NX_DOWN_ARROW_KEY
|
|
78
|
+
#define NX_DOWN_ARROW_KEY 0x09
|
|
79
|
+
#endif
|
|
80
|
+
|
|
81
|
+
#ifndef NX_KEYTYPE_NUM_LOCK
|
|
82
|
+
#define NX_KEYTYPE_NUM_LOCK 0x0A
|
|
83
|
+
#endif
|
|
84
|
+
|
|
85
|
+
#ifndef NX_KEYTYPE_CONTRAST_UP
|
|
86
|
+
#define NX_KEYTYPE_CONTRAST_UP 0x0B
|
|
87
|
+
#endif
|
|
88
|
+
|
|
89
|
+
#ifndef NX_KEYTYPE_CONTRAST_DOWN
|
|
90
|
+
#define NX_KEYTYPE_CONTRAST_DOWN 0x0C
|
|
91
|
+
#endif
|
|
92
|
+
|
|
93
|
+
#ifndef NX_KEYTYPE_LAUNCH_PANEL
|
|
94
|
+
#define NX_KEYTYPE_LAUNCH_PANEL 0x0D
|
|
95
|
+
#endif
|
|
96
|
+
|
|
97
|
+
#ifndef NX_KEYTYPE_EJECT
|
|
98
|
+
#define NX_KEYTYPE_EJECT 0x0E
|
|
99
|
+
#endif
|
|
100
|
+
|
|
101
|
+
#ifndef NX_KEYTYPE_VIDMIRROR
|
|
102
|
+
#define NX_KEYTYPE_VIDMIRROR 0x0F
|
|
103
|
+
#endif
|
|
104
|
+
|
|
105
|
+
#ifndef NX_KEYTYPE_PLAY
|
|
106
|
+
#define NX_KEYTYPE_PLAY 0x10
|
|
107
|
+
#endif
|
|
108
|
+
|
|
109
|
+
#ifndef NX_KEYTYPE_NEXT
|
|
110
|
+
#define NX_KEYTYPE_NEXT 0x11
|
|
111
|
+
#endif
|
|
112
|
+
|
|
113
|
+
#ifndef NX_KEYTYPE_PREVIOUS
|
|
114
|
+
#define NX_KEYTYPE_PREVIOUS 0x12
|
|
115
|
+
#endif
|
|
116
|
+
|
|
117
|
+
#ifndef NX_KEYTYPE_FAST
|
|
118
|
+
#define NX_KEYTYPE_FAST 0x13
|
|
119
|
+
#endif
|
|
120
|
+
|
|
121
|
+
#ifndef NX_KEYTYPE_REWIND
|
|
122
|
+
#define NX_KEYTYPE_REWIND 0x14
|
|
123
|
+
#endif
|
|
124
|
+
|
|
125
|
+
#ifndef NX_KEYTYPE_ILLUMINATION_UP
|
|
126
|
+
#define NX_KEYTYPE_ILLUMINATION_UP 0x15
|
|
127
|
+
#endif
|
|
128
|
+
|
|
129
|
+
#ifndef NX_KEYTYPE_ILLUMINATION_DOWN
|
|
130
|
+
#define NX_KEYTYPE_ILLUMINATION_DOWN 0x16
|
|
131
|
+
#endif
|
|
132
|
+
|
|
133
|
+
#ifndef NX_KEYTYPE_ILLUMINATION_TOGGLE
|
|
134
|
+
#define NX_KEYTYPE_ILLUMINATION_TOGGLE 0x17
|
|
135
|
+
#endif
|
|
136
|
+
|
|
137
|
+
#ifndef NX_NUMSPECIALKEYS
|
|
138
|
+
#define NX_NUMSPECIALKEYS 0x18 /* Maximum number of special keys */
|
|
139
|
+
#endif
|
|
140
|
+
|
|
141
|
+
#endif
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
// These virtual key codes do not appear to be defined by Apple.
|
|
145
|
+
#define kVK_NX_Power 0xE0 | NX_POWER_KEY /* 0xE6 */
|
|
146
|
+
#define kVK_NX_Eject 0xE0 | NX_KEYTYPE_EJECT /* 0xEE */
|
|
147
|
+
|
|
148
|
+
#define kVK_MEDIA_Play 0xE0 | NX_KEYTYPE_PLAY /* 0xF0 */
|
|
149
|
+
#define kVK_MEDIA_Next 0xE0 | NX_KEYTYPE_NEXT /* 0xF1 */
|
|
150
|
+
#define kVK_MEDIA_Previous 0xE0 | NX_KEYTYPE_PREVIOUS /* 0xF2 */
|
|
151
|
+
|
|
152
|
+
#define kVK_RightCommand 0x36
|
|
153
|
+
#define kVK_ContextMenu 0x6E // AKA kMenuPowerGlyph
|
|
154
|
+
#define kVK_Undefined 0xFF
|
|
155
|
+
|
|
156
|
+
// These button codes do not appear to be defined by Apple.
|
|
157
|
+
#define kVK_LBUTTON kCGMouseButtonLeft
|
|
158
|
+
#define kVK_RBUTTON kCGMouseButtonRight
|
|
159
|
+
#define kVK_MBUTTON kCGMouseButtonCenter
|
|
160
|
+
#define kVK_XBUTTON1 3
|
|
161
|
+
#define kVK_XBUTTON2 4
|
|
162
|
+
|
|
163
|
+
// These button masks do not appear to be defined by Apple.
|
|
164
|
+
#define kCGEventFlagMaskButtonLeft 1 << 0
|
|
165
|
+
#define kCGEventFlagMaskButtonRight 1 << 1
|
|
166
|
+
#define kCGEventFlagMaskButtonCenter 1 << 2
|
|
167
|
+
#define kCGEventFlagMaskXButton1 1 << 3
|
|
168
|
+
#define kCGEventFlagMaskXButton2 1 << 4
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
/* Check for access to Apples accessibility API.
|
|
172
|
+
*/
|
|
173
|
+
extern bool is_accessibility_enabled();
|
|
174
|
+
|
|
175
|
+
/* Converts an OSX key code and event mask to the appropriate Unicode character
|
|
176
|
+
* representation.
|
|
177
|
+
*/
|
|
178
|
+
extern UniCharCount keycode_to_unicode(CGEventRef event_ref, UniChar *buffer, UniCharCount size);
|
|
179
|
+
|
|
180
|
+
/* Converts an OSX keycode to the appropriate UIOHook scancode constant.
|
|
181
|
+
*/
|
|
182
|
+
extern uint16_t keycode_to_scancode(UInt64 keycode);
|
|
183
|
+
|
|
184
|
+
/* Converts a UIOHook scancode constant to the appropriate OSX keycode.
|
|
185
|
+
*/
|
|
186
|
+
extern UInt64 scancode_to_keycode(uint16_t keycode);
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
/* Initialize items required for KeyCodeToKeySym() and KeySymToUnicode()
|
|
190
|
+
* functionality. This method is called by OnLibraryLoad() and may need to be
|
|
191
|
+
* called in combination with UnloadInputHelper() if the native keyboard layout
|
|
192
|
+
* is changed.
|
|
193
|
+
*/
|
|
194
|
+
extern void load_input_helper();
|
|
195
|
+
|
|
196
|
+
/* De-initialize items required for KeyCodeToKeySym() and KeySymToUnicode()
|
|
197
|
+
* functionality. This method is called by OnLibraryUnload() and may need to be
|
|
198
|
+
* called in combination with LoadInputHelper() if the native keyboard layout
|
|
199
|
+
* is changed.
|
|
200
|
+
*/
|
|
201
|
+
extern void unload_input_helper();
|
|
202
|
+
|
|
203
|
+
#endif
|