@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.
Files changed (38) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +77 -0
  3. package/binding.gyp +85 -0
  4. package/dist/index.d.ts +194 -0
  5. package/dist/index.js +206 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/prebuild-test-noop.d.ts +0 -0
  8. package/dist/prebuild-test-noop.js +3 -0
  9. package/dist/prebuild-test-noop.js.map +1 -0
  10. package/libuiohook/include/uiohook.h +457 -0
  11. package/libuiohook/src/darwin/input_helper.c +535 -0
  12. package/libuiohook/src/darwin/input_helper.h +203 -0
  13. package/libuiohook/src/darwin/input_hook.c +1436 -0
  14. package/libuiohook/src/darwin/post_event.c +303 -0
  15. package/libuiohook/src/darwin/system_properties.c +479 -0
  16. package/libuiohook/src/logger.c +40 -0
  17. package/libuiohook/src/logger.h +32 -0
  18. package/libuiohook/src/windows/input_helper.c +913 -0
  19. package/libuiohook/src/windows/input_helper.h +146 -0
  20. package/libuiohook/src/windows/input_hook.c +722 -0
  21. package/libuiohook/src/windows/post_event.c +248 -0
  22. package/libuiohook/src/windows/system_properties.c +231 -0
  23. package/libuiohook/src/x11/input_helper.c +1846 -0
  24. package/libuiohook/src/x11/input_helper.h +108 -0
  25. package/libuiohook/src/x11/input_hook.c +1116 -0
  26. package/libuiohook/src/x11/post_event.c +427 -0
  27. package/libuiohook/src/x11/system_properties.c +494 -0
  28. package/package.json +60 -0
  29. package/prebuilds/darwin/darwin-arm64/@mukea+uiohook-napi.node +0 -0
  30. package/prebuilds/darwin/darwin-x64/@mukea+uiohook-napi.node +0 -0
  31. package/prebuilds/linux/linux-arm64/@mukea+uiohook-napi.node +0 -0
  32. package/prebuilds/linux/linux-x64/@mukea+uiohook-napi.node +0 -0
  33. package/prebuilds/windows/win32-x64/@mukea+uiohook-napi.node +0 -0
  34. package/src/lib/addon.c +337 -0
  35. package/src/lib/napi_helpers.c +51 -0
  36. package/src/lib/napi_helpers.h +53 -0
  37. package/src/lib/uiohook_worker.c +200 -0
  38. package/src/lib/uiohook_worker.h +12 -0
@@ -0,0 +1,108 @@
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
+ #ifndef _included_input_helper
20
+ #define _included_input_helper
21
+
22
+ #include <stdint.h>
23
+ #include <X11/Xlib.h>
24
+
25
+ #ifdef USE_XKB_COMMON
26
+ #include <X11/Xlib-xcb.h>
27
+ #include <xkbcommon/xkbcommon.h>
28
+ #include <xkbcommon/xkbcommon-x11.h>
29
+ #endif
30
+
31
+
32
+ // Virtual button codes that are not defined by X11.
33
+ #define Button1 1
34
+ #define Button2 2
35
+ #define Button3 3
36
+ #define WheelUp 4
37
+ #define WheelDown 5
38
+ #define WheelLeft 6
39
+ #define WheelRight 7
40
+ #define XButton1 8
41
+ #define XButton2 9
42
+
43
+ // Helper display used by input helper, properties and post event.
44
+ extern Display *helper_disp;
45
+
46
+ /* Converts a X11 key symbol to a single Unicode character. No direct X11
47
+ * functionality exists to provide this information.
48
+ */
49
+ extern size_t keysym_to_unicode(KeySym keysym, uint16_t *buffer, size_t size);
50
+
51
+ /* Convert a single Unicode character to a X11 key symbol. This function
52
+ * provides a better translation than XStringToKeysym() for Unicode characters.
53
+ */
54
+ extern KeySym unicode_to_keysym(uint16_t unicode);
55
+
56
+ /* Converts a X11 key code to the appropriate keyboard scan code.
57
+ */
58
+ extern uint16_t keycode_to_scancode(KeyCode keycode);
59
+
60
+ /* Converts a keyboard scan code to the appropriate X11 key code.
61
+ */
62
+ extern KeyCode scancode_to_keycode(uint16_t scancode);
63
+
64
+
65
+ #ifdef USE_XKB_COMMON
66
+
67
+ /* Converts a X11 key code to a Unicode character sequence. libXKBCommon support
68
+ * is required for this method.
69
+ */
70
+ extern size_t keycode_to_unicode(struct xkb_state* state, KeyCode keycode, uint16_t *buffer, size_t size);
71
+
72
+ /* Create a xkb_state structure and return a pointer to it.
73
+ */
74
+ extern struct xkb_state * create_xkb_state(struct xkb_context *context, xcb_connection_t *connection);
75
+
76
+ /* Release xkb_state structure created by create_xkb_state().
77
+ */
78
+ extern void destroy_xkb_state(struct xkb_state* state);
79
+
80
+ #else
81
+
82
+ /* Converts a X11 key code and event mask to the appropriate X11 key symbol.
83
+ * This functions in much the same way as XKeycodeToKeysym() but allows for a
84
+ * faster and more flexible lookup.
85
+ */
86
+ extern KeySym keycode_to_keysym(KeyCode keycode, unsigned int modifier_mask);
87
+
88
+ #endif
89
+
90
+ /* Lookup a X11 buttons possible remapping and return that value.
91
+ */
92
+ extern unsigned int button_map_lookup(unsigned int button);
93
+
94
+ /* Initialize items required for KeyCodeToKeySym() and KeySymToUnicode()
95
+ * functionality. This method is called by OnLibraryLoad() and may need to be
96
+ * called in combination with UnloadInputHelper() if the native keyboard layout
97
+ * is changed.
98
+ */
99
+ extern void load_input_helper();
100
+
101
+ /* De-initialize items required for KeyCodeToKeySym() and KeySymToUnicode()
102
+ * functionality. This method is called by OnLibraryUnload() and may need to be
103
+ * called in combination with LoadInputHelper() if the native keyboard layout
104
+ * is changed.
105
+ */
106
+ extern void unload_input_helper();
107
+
108
+ #endif