Add initial files

This commit is contained in:
Luis Blanco 2023-11-28 20:46:16 +04:00
parent 14b81c850d
commit 65bbfd81cc
26 changed files with 2588 additions and 1 deletions

78
.eslintrc.json Normal file
View File

@ -0,0 +1,78 @@
{
"extends": [
"eslint:recommended",
"plugin:node/recommended"
],
"parserOptions": {
"ecmaVersion": 2022
},
"env": {
"node": true,
"es6": true
},
"rules": {
"arrow-parens": ["error", "always"],
"no-trailing-spaces": [
"error",
{
"skipBlankLines": true
}
],
"indent": [
"error",
"tab",
{
"SwitchCase": 1
}
],
"operator-linebreak": [
"error",
"after",
{
"overrides": {
"?": "before",
":": "before"
}
}
],
"max-len": ["error", 110],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
],
"no-multiple-empty-lines": ["error", { "max": 3, "maxEOF": 1, "maxBOF": 1 }],
"keyword-spacing": ["error", { "before": true, "after": true }],
"space-before-blocks": ["error"],
"space-before-function-paren": ["error", {"anonymous": "always", "named": "never", "asyncArrow": "always"}],
"camelcase": ["error"],
"no-tabs": [0],
"global-require": [0],
"no-underscore-dangle": [0],
"no-plusplus": [0],
"no-shadow": [0],
"node/no-unpublished-require": [0],
"no-process-exit": [0],
"linebreak-style": [0],
"node/no-missing-require": [0],
"no-console": [0],
"node/no-unsupported-features/es-builtins": [
"error",
{ "version": ">=18.16.0" }
],
"node/no-unsupported-features/node-builtins": [
"error",
{ "version": ">=18.16.0" }
],
"func-names": [
"error",
"never",
{
"generators": "never"
}
]
}
}

107
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,107 @@
name: Build Binaries
defaults:
run:
shell: bash
on:
workflow_dispatch
jobs:
create_release:
name: Create Release
if: contains('["raub"]', github.actor)
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Fetch Repository
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18.16.0
cache: 'npm'
- name: Get Package Version
id: package-version
run: node -p "'version='+require('./package').version" >> $GITHUB_OUTPUT
- name: Create Draft Release
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
draft: true
tag_name: ${{ steps.package-version.outputs.version }}
name: Release ${{ steps.package-version.outputs.version }}
body: Binaries at ${{ github.sha }}
build:
name: Build
strategy:
matrix:
os: [ubuntu-20.04, windows-2022, macos-11, [self-hosted, linux, ARM64]]
runs-on: ${{ matrix.os }}
steps:
- name: Fetch Repository
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18.16.0
cache: 'npm'
- name: Install Modules
run: npm ci --ignore-scripts
- name: Add msbuild to PATH
if: matrix.os == 'windows-2022'
uses: microsoft/setup-msbuild@v1.1
with:
msbuild-architecture: x64
- name: Build Pre Step
run: chmod +x src/extract.sh && src/extract.sh
- name: Build Unix
if: matrix.os != 'windows-2022'
run: node src/build-unix
- name: Build Windows
if: matrix.os == 'windows-2022'
run: src/windows.sh
- name: Build Post Step
run: node src/build-post
- name: Get Package Version
id: package-version
shell: bash
run: node -p "'version='+require('./package').version" >> $GITHUB_OUTPUT
- name: Pack Files
id: pack-files
run: node -e "require('addon-tools-raub').actionPack()" >> $GITHUB_OUTPUT
- name: Store Binaries
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
draft: true
tag_name: ${{ steps.package-version.outputs.version }}
name: Release ${{ steps.package-version.outputs.version }}
files: ${{ steps.pack-files.outputs.pack }}

36
.github/workflows/eslint.yml vendored Normal file
View File

@ -0,0 +1,36 @@
name: ESLint
defaults:
run:
shell: bash
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
eslint:
name: ESLint
runs-on: ubuntu-20.04
steps:
- name: Fetch Repository
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18.16.0
cache: 'npm'
- name: Install Modules
run: npm ci --ignore-scripts
- name: Run ESLint
run: npm run eslint

46
.github/workflows/publish.yml vendored Normal file
View File

@ -0,0 +1,46 @@
name: Publish to NPM
defaults:
run:
shell: bash
on:
workflow_dispatch
jobs:
Publish:
if: contains('["raub"]', github.actor)
runs-on: ubuntu-latest
steps:
- name: Fetch Repository
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18.16.0
cache: 'npm'
- name: Get Package Version
id: package-version
run: node -p "'version='+require('./package').version" >> $GITHUB_OUTPUT
- name: Publish
run: |
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
npm publish --ignore-scripts
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
draft: true
tag_name: ${{ steps.package-version.outputs.version }}
name: Release ${{ steps.package-version.outputs.version }}

40
.github/workflows/test.yml vendored Normal file
View File

@ -0,0 +1,40 @@
name: Test
defaults:
run:
shell: bash
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
unit-tests:
name: Unit Tests
strategy:
matrix:
os: [ubuntu-20.04, windows-2022, macos-11, [self-hosted, linux, ARM64]]
runs-on: ${{ matrix.os }}
steps:
- name: Fetch Repository
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18.16.0
cache: 'npm'
- name: Install Modules
run: npm ci --ignore-scripts
- name: Run Unit Tests
run: npm test

12
.gitignore vendored Normal file
View File

@ -0,0 +1,12 @@
.cproject
.idea
.lock-wscript
.DS_Store
.project
.vscode
.eslintrc
node_modules/
bin-*/
src/build/
src/libuiohook/
*.log

164
LIBUIOHOOK_LGPL.md Normal file
View File

@ -0,0 +1,164 @@
GNU Lesser General Public License
=================================
Version 3, 29 June 2007
Copyright &copy; 2007 Free Software Foundation, Inc. &lt;<http://fsf.org/>&gt;
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
### 0. Additional Definitions.
As used herein, &ldquo;this License&rdquo; refers to version 3 of the GNU Lesser
General Public License, and the &ldquo;GNU GPL&rdquo; refers to version 3 of the GNU
General Public License.
&ldquo;The Library&rdquo; refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An &ldquo;Application&rdquo; is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A &ldquo;Combined Work&rdquo; is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the &ldquo;Linked
Version&rdquo;.
The &ldquo;Minimal Corresponding Source&rdquo; for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The &ldquo;Corresponding Application Code&rdquo; for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
### 1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
### 2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
* a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
* b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
### 3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
* a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
* b) Accompany the object code with a copy of the GNU GPL and this license
document.
### 4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
* a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
* b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
* c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
* d) Do one of the following:
- 0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
- 1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
* e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
### 5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
* a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
* b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
### 6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License &ldquo;or any later version&rdquo;
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 Luis Blanco
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1 +1,33 @@
# deps-uiohook-raub
# Lib Binaries
This is a part of [Node3D](https://github.com/raub) project.
[![NPM](https://badge.fury.io/js/deps-uiohook-raub.svg)](https://badge.fury.io/js/deps-uiohook-raub)
[![ESLint](https://github.com/raub/deps-uiohook-raub/actions/workflows/eslint.yml/badge.svg)](https://github.com/raub/deps-uiohook-raub/actions/workflows/eslint.yml)
[![Test](https://github.com/raub/deps-uiohook-raub/actions/workflows/test.yml/badge.svg)](https://github.com/raub/deps-uiohook-raub/actions/workflows/test.yml)
```console
npm i -s deps-uiohook-raub
```
This dependency package is distributing **Bullet Physics**
binaries through **NPM** for **Node.js** addons.
* Platforms (x64): Windows x64, Linux x64, OSX x64, Linux Aarch64.
* Library: Bullet physics, see list below.
* Linking: static lib-type.
See the official
[Bullet3 manual](https://github.com/bulletphysics/bullet3/blob/master/docs/Bullet_User_Manual.pdf)
and [examples](https://github.com/bulletphysics/bullet3/tree/master/examples).
See [uiohook-raub](https://github.com/raub/uiohook-raub/tree/master/src) for
how the libraries may be used in a Node.js addon.
## Legal Notice
This software uses [libUIOHook](https://github.com/kwhat/libuiohook) under LGPL3 license.
A copy of libUIOHook license is [included](/LIBUIOHOOK_LGPL.md),
and can also be found at the
[official repository](https://github.com/kwhat/libuiohook/blob/1.2/COPYING.LESSER.md).

457
include/uiohook.h Normal file
View File

@ -0,0 +1,457 @@
/* libUIOHook: Cross-platform keyboard and mouse hooking from userland.
* Copyright (C) 2006-2022 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/>.
*/
#ifndef __UIOHOOK_H
#define __UIOHOOK_H
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
/* Begin Error Codes */
#define UIOHOOK_SUCCESS 0x00
#define UIOHOOK_FAILURE 0x01
// System level errors.
#define UIOHOOK_ERROR_OUT_OF_MEMORY 0x02
// Unix specific errors.
#define UIOHOOK_ERROR_X_OPEN_DISPLAY 0x20
#define UIOHOOK_ERROR_X_RECORD_NOT_FOUND 0x21
#define UIOHOOK_ERROR_X_RECORD_ALLOC_RANGE 0x22
#define UIOHOOK_ERROR_X_RECORD_CREATE_CONTEXT 0x23
#define UIOHOOK_ERROR_X_RECORD_ENABLE_CONTEXT 0x24
#define UIOHOOK_ERROR_X_RECORD_GET_CONTEXT 0x25
// Windows specific errors.
#define UIOHOOK_ERROR_SET_WINDOWS_HOOK_EX 0x30
#define UIOHOOK_ERROR_GET_MODULE_HANDLE 0x31
// Darwin specific errors.
#define UIOHOOK_ERROR_AXAPI_DISABLED 0x40
#define UIOHOOK_ERROR_CREATE_EVENT_PORT 0x41
#define UIOHOOK_ERROR_CREATE_RUN_LOOP_SOURCE 0x42
#define UIOHOOK_ERROR_GET_RUNLOOP 0x43
#define UIOHOOK_ERROR_CREATE_OBSERVER 0x44
/* End Error Codes */
/* Begin Log Levels and Function Prototype */
typedef enum _log_level {
LOG_LEVEL_DEBUG = 1,
LOG_LEVEL_INFO,
LOG_LEVEL_WARN,
LOG_LEVEL_ERROR
} log_level;
// Logger callback function prototype.
typedef bool (*logger_t)(unsigned int, const char *, ...);
/* End Log Levels and Function Prototype */
/* Begin Virtual Event Types and Data Structures */
typedef enum _event_type {
EVENT_HOOK_ENABLED = 1,
EVENT_HOOK_DISABLED,
EVENT_KEY_TYPED,
EVENT_KEY_PRESSED,
EVENT_KEY_RELEASED,
EVENT_MOUSE_CLICKED,
EVENT_MOUSE_PRESSED,
EVENT_MOUSE_RELEASED,
EVENT_MOUSE_MOVED,
EVENT_MOUSE_DRAGGED,
EVENT_MOUSE_WHEEL
} event_type;
typedef struct _screen_data {
uint8_t number;
int16_t x;
int16_t y;
uint16_t width;
uint16_t height;
} screen_data;
typedef struct _keyboard_event_data {
uint16_t keycode;
uint16_t rawcode;
uint16_t keychar;
} keyboard_event_data,
key_pressed_event_data,
key_released_event_data,
key_typed_event_data;
typedef struct _mouse_event_data {
uint16_t button;
uint16_t clicks;
int16_t x;
int16_t y;
} mouse_event_data,
mouse_pressed_event_data,
mouse_released_event_data,
mouse_clicked_event_data;
typedef struct _mouse_wheel_event_data {
uint16_t clicks;
int16_t x;
int16_t y;
uint8_t type;
uint16_t amount;
int16_t rotation;
uint8_t direction;
} mouse_wheel_event_data;
typedef struct _uiohook_event {
event_type type;
uint64_t time;
uint16_t mask;
uint16_t reserved;
union {
keyboard_event_data keyboard;
mouse_event_data mouse;
mouse_wheel_event_data wheel;
} data;
} uiohook_event;
typedef void (*dispatcher_t)(uiohook_event *const);
/* End Virtual Event Types and Data Structures */
/* Begin Virtual Key Codes */
#define VC_ESCAPE 0x0001
// Begin Function Keys
#define VC_F1 0x003B
#define VC_F2 0x003C
#define VC_F3 0x003D
#define VC_F4 0x003E
#define VC_F5 0x003F
#define VC_F6 0x0040
#define VC_F7 0x0041
#define VC_F8 0x0042
#define VC_F9 0x0043
#define VC_F10 0x0044
#define VC_F11 0x0057
#define VC_F12 0x0058
#define VC_F13 0x005B
#define VC_F14 0x005C
#define VC_F15 0x005D
#define VC_F16 0x0063
#define VC_F17 0x0064
#define VC_F18 0x0065
#define VC_F19 0x0066
#define VC_F20 0x0067
#define VC_F21 0x0068
#define VC_F22 0x0069
#define VC_F23 0x006A
#define VC_F24 0x006B
// End Function Keys
// Begin Alphanumeric Zone
#define VC_BACKQUOTE 0x0029
#define VC_1 0x0002
#define VC_2 0x0003
#define VC_3 0x0004
#define VC_4 0x0005
#define VC_5 0x0006
#define VC_6 0x0007
#define VC_7 0x0008
#define VC_8 0x0009
#define VC_9 0x000A
#define VC_0 0x000B
#define VC_MINUS 0x000C // '-'
#define VC_EQUALS 0x000D // '='
#define VC_BACKSPACE 0x000E
#define VC_TAB 0x000F
#define VC_CAPS_LOCK 0x003A
#define VC_A 0x001E
#define VC_B 0x0030
#define VC_C 0x002E
#define VC_D 0x0020
#define VC_E 0x0012
#define VC_F 0x0021
#define VC_G 0x0022
#define VC_H 0x0023
#define VC_I 0x0017
#define VC_J 0x0024
#define VC_K 0x0025
#define VC_L 0x0026
#define VC_M 0x0032
#define VC_N 0x0031
#define VC_O 0x0018
#define VC_P 0x0019
#define VC_Q 0x0010
#define VC_R 0x0013
#define VC_S 0x001F
#define VC_T 0x0014
#define VC_U 0x0016
#define VC_V 0x002F
#define VC_W 0x0011
#define VC_X 0x002D
#define VC_Y 0x0015
#define VC_Z 0x002C
#define VC_OPEN_BRACKET 0x001A // '['
#define VC_CLOSE_BRACKET 0x001B // ']'
#define VC_BACK_SLASH 0x002B // '\'
#define VC_SEMICOLON 0x0027 // ';'
#define VC_QUOTE 0x0028
#define VC_ENTER 0x001C
#define VC_COMMA 0x0033 // ','
#define VC_PERIOD 0x0034 // '.'
#define VC_SLASH 0x0035 // '/'
#define VC_SPACE 0x0039
// End Alphanumeric Zone
#define VC_PRINTSCREEN 0x0E37
#define VC_SCROLL_LOCK 0x0046
#define VC_PAUSE 0x0E45
#define VC_LESSER_GREATER 0x0E46 // '<', '>', '|' on qwertz layout
// Begin Edit Key Zone
#define VC_INSERT 0x0E52
#define VC_DELETE 0x0E53
#define VC_HOME 0x0E47
#define VC_END 0x0E4F
#define VC_PAGE_UP 0x0E49
#define VC_PAGE_DOWN 0x0E51
// End Edit Key Zone
// Begin Cursor Key Zone
#define VC_UP 0xE048
#define VC_LEFT 0xE04B
#define VC_CLEAR 0xE04C
#define VC_RIGHT 0xE04D
#define VC_DOWN 0xE050
// End Cursor Key Zone
// Begin Numeric Zone
#define VC_NUM_LOCK 0x0045
#define VC_KP_DIVIDE 0x0E35
#define VC_KP_MULTIPLY 0x0037
#define VC_KP_SUBTRACT 0x004A
#define VC_KP_EQUALS 0x0E0D
#define VC_KP_ADD 0x004E
#define VC_KP_ENTER 0x0E1C
#define VC_KP_SEPARATOR 0x0053
#define VC_KP_1 0x004F
#define VC_KP_2 0x0050
#define VC_KP_3 0x0051
#define VC_KP_4 0x004B
#define VC_KP_5 0x004C
#define VC_KP_6 0x004D
#define VC_KP_7 0x0047
#define VC_KP_8 0x0048
#define VC_KP_9 0x0049
#define VC_KP_0 0x0052
#define VC_KP_END 0xEE00 | VC_KP_1
#define VC_KP_DOWN 0xEE00 | VC_KP_2
#define VC_KP_PAGE_DOWN 0xEE00 | VC_KP_3
#define VC_KP_LEFT 0xEE00 | VC_KP_4
#define VC_KP_CLEAR 0xEE00 | VC_KP_5
#define VC_KP_RIGHT 0xEE00 | VC_KP_6
#define VC_KP_HOME 0xEE00 | VC_KP_7
#define VC_KP_UP 0xEE00 | VC_KP_8
#define VC_KP_PAGE_UP 0xEE00 | VC_KP_9
#define VC_KP_INSERT 0xEE00 | VC_KP_0
#define VC_KP_DELETE 0xEE00 | VC_KP_SEPARATOR
// End Numeric Zone
// Begin Modifier and Control Keys
#define VC_SHIFT_L 0x002A
#define VC_SHIFT_R 0x0036
#define VC_CONTROL_L 0x001D
#define VC_CONTROL_R 0x0E1D
#define VC_ALT_L 0x0038 // Option or Alt Key
#define VC_ALT_R 0x0E38 // Option or Alt Key
#define VC_META_L 0x0E5B // Windows or Command Key
#define VC_META_R 0x0E5C // Windows or Command Key
#define VC_CONTEXT_MENU 0x0E5D
// End Modifier and Control Keys
// Begin Media Control Keys
#define VC_POWER 0xE05E
#define VC_SLEEP 0xE05F
#define VC_WAKE 0xE063
#define VC_MEDIA_PLAY 0xE022
#define VC_MEDIA_STOP 0xE024
#define VC_MEDIA_PREVIOUS 0xE010
#define VC_MEDIA_NEXT 0xE019
#define VC_MEDIA_SELECT 0xE06D
#define VC_MEDIA_EJECT 0xE02C
#define VC_VOLUME_MUTE 0xE020
#define VC_VOLUME_UP 0xE030
#define VC_VOLUME_DOWN 0xE02E
#define VC_APP_MAIL 0xE06C
#define VC_APP_CALCULATOR 0xE021
#define VC_APP_MUSIC 0xE03C
#define VC_APP_PICTURES 0xE064
#define VC_BROWSER_SEARCH 0xE065
#define VC_BROWSER_HOME 0xE032
#define VC_BROWSER_BACK 0xE06A
#define VC_BROWSER_FORWARD 0xE069
#define VC_BROWSER_STOP 0xE068
#define VC_BROWSER_REFRESH 0xE067
#define VC_BROWSER_FAVORITES 0xE066
// End Media Control Keys
// Begin Japanese Language Keys
#define VC_KATAKANA 0x0070
#define VC_UNDERSCORE 0x0073
#define VC_FURIGANA 0x0077
#define VC_KANJI 0x0079
#define VC_HIRAGANA 0x007B
#define VC_YEN 0x007D
#define VC_KP_COMMA 0x007E
// End Japanese Language Keys
// Begin Sun keyboards
#define VC_SUN_HELP 0xFF75
#define VC_SUN_STOP 0xFF78
#define VC_SUN_PROPS 0xFF76
#define VC_SUN_FRONT 0xFF77
#define VC_SUN_OPEN 0xFF74
#define VC_SUN_FIND 0xFF7E
#define VC_SUN_AGAIN 0xFF79
#define VC_SUN_UNDO 0xFF7A
#define VC_SUN_COPY 0xFF7C
#define VC_SUN_INSERT 0xFF7D
#define VC_SUN_CUT 0xFF7B
// End Sun keyboards
#define VC_UNDEFINED 0x0000 // KeyCode Unknown
#define CHAR_UNDEFINED 0xFFFF // CharCode Unknown
/* End Virtual Key Codes */
/* Begin Virtual Modifier Masks */
#define MASK_SHIFT_L 1 << 0
#define MASK_CTRL_L 1 << 1
#define MASK_META_L 1 << 2
#define MASK_ALT_L 1 << 3
#define MASK_SHIFT_R 1 << 4
#define MASK_CTRL_R 1 << 5
#define MASK_META_R 1 << 6
#define MASK_ALT_R 1 << 7
#define MASK_SHIFT MASK_SHIFT_L | MASK_SHIFT_R
#define MASK_CTRL MASK_CTRL_L | MASK_CTRL_R
#define MASK_META MASK_META_L | MASK_META_R
#define MASK_ALT MASK_ALT_L | MASK_ALT_R
#define MASK_BUTTON1 1 << 8
#define MASK_BUTTON2 1 << 9
#define MASK_BUTTON3 1 << 10
#define MASK_BUTTON4 1 << 11
#define MASK_BUTTON5 1 << 12
#define MASK_NUM_LOCK 1 << 13
#define MASK_CAPS_LOCK 1 << 14
#define MASK_SCROLL_LOCK 1 << 15
/* End Virtual Modifier Masks */
/* Begin Virtual Mouse Buttons */
#define MOUSE_NOBUTTON 0 // Any Button
#define MOUSE_BUTTON1 1 // Left Button
#define MOUSE_BUTTON2 2 // Right Button
#define MOUSE_BUTTON3 3 // Middle Button
#define MOUSE_BUTTON4 4 // Extra Mouse Button
#define MOUSE_BUTTON5 5 // Extra Mouse Button
#define WHEEL_UNIT_SCROLL 1
#define WHEEL_BLOCK_SCROLL 2
#define WHEEL_VERTICAL_DIRECTION 3
#define WHEEL_HORIZONTAL_DIRECTION 4
/* End Virtual Mouse Buttons */
#ifdef _WIN32
#define UIOHOOK_API __declspec(dllexport)
#else
#define UIOHOOK_API
#endif
#ifdef __cplusplus
extern "C" {
#endif
// Set the logger callback functions.
UIOHOOK_API void hook_set_logger_proc(logger_t logger_proc);
// Send a virtual event back to the system.
UIOHOOK_API void hook_post_event(uiohook_event * const event);
// Set the event callback function.
UIOHOOK_API void hook_set_dispatch_proc(dispatcher_t dispatch_proc);
// Insert the event hook.
UIOHOOK_API int hook_run();
// Withdraw the event hook.
UIOHOOK_API int hook_stop();
// Retrieves an array of screen data for each available monitor.
UIOHOOK_API screen_data* hook_create_screen_info(unsigned char *count);
// Retrieves the keyboard auto repeat rate.
UIOHOOK_API long int hook_get_auto_repeat_rate();
// Retrieves the keyboard auto repeat delay.
UIOHOOK_API long int hook_get_auto_repeat_delay();
// Retrieves the mouse acceleration multiplier.
UIOHOOK_API long int hook_get_pointer_acceleration_multiplier();
// Retrieves the mouse acceleration threshold.
UIOHOOK_API long int hook_get_pointer_acceleration_threshold();
// Retrieves the mouse sensitivity.
UIOHOOK_API long int hook_get_pointer_sensitivity();
// Retrieves the double/triple click interval.
UIOHOOK_API long int hook_get_multi_click_time();
#ifdef __cplusplus
}
#endif
#endif

15
index.d.ts vendored Normal file
View File

@ -0,0 +1,15 @@
declare module "deps-uiohook-raub" {
/**
* Path to binaries
*
* Platform binary directory absolute path
*/
export const bin: string;
/**
* Path to includes
*
* Include directory for this module
*/
export const include: string;
}

3
index.js Normal file
View File

@ -0,0 +1,3 @@
'use strict';
module.exports = require('addon-tools-raub').getPaths(__dirname);

8
install.js Normal file
View File

@ -0,0 +1,8 @@
'use strict';
const { install } = require('addon-tools-raub');
const prefix = 'https://github.com/node-3d/deps-uiohook-raub/releases/download';
const tag = '0.0.1';
install(`${prefix}/${tag}`);

1334
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

54
package.json Normal file
View File

@ -0,0 +1,54 @@
{
"author": "Luis Blanco <luisblanco1337@gmail.com>",
"name": "deps-uiohook-raub",
"version": "0.0.1",
"description": "Binaries and headers for libUIOHook-dependent compilation",
"license": "MIT",
"main": "index.js",
"keywords": [
"dependency",
"libuiohook",
"uiohook",
"binary",
"library",
"headers",
"lib",
"c++",
"addon",
"bindings",
"native",
"gyp"
],
"files": [
"include",
"index.js",
"install.d.ts",
"install.js",
"LIBUIOHOOK_LGPL.md",
"LICENSE",
"package.json",
"README.md"
],
"scripts": {
"postinstall": "node install",
"eslint": "eslint .",
"test": "node --test"
},
"engines": {
"node": ">=18.16.0",
"npm": ">=9.5.1"
},
"repository": {
"type": "git",
"url": "https://github.com/node-3d/deps-uiohook-raub.git"
},
"dependencies": {
"addon-tools-raub": "^7.3.0"
},
"devDependencies": {
"eslint-plugin-node": "^11.1.0",
"eslint": "^8.51.0",
"node-addon-api": "^7.0.0",
"typescript": "^5.2.2"
}
}

1
src/aarch64.sh Normal file
View File

@ -0,0 +1 @@
chmod +x src/linux-common.sh && src/linux-common.sh

28
src/build-post.js Normal file
View File

@ -0,0 +1,28 @@
'use strict';
const path = require('node:path');
const {
getBin, ensuredir, copyall,
} = require('addon-tools-raub');
const bin = getBin();
const binPath = path.resolve(bin);
const fail = (error) => {
console.error(error);
process.exit(-1);
};
(async () => {
try {
await ensuredir(binPath);
await copyall(path.resolve('src/build'), binPath);
} catch (error) {
fail(error);
}
})();

66
src/build-unix.js Normal file
View File

@ -0,0 +1,66 @@
'use strict';
const util = require('node:util');
const exec = util.promisify(require('node:child_process').exec);
const {
getPlatform,
} = require('addon-tools-raub');
const platform = getPlatform();
const getScriptForLib = () => `src/${platform}.sh`;
const fail = (error) => {
console.error(error);
process.exit(-1);
};
const updateSystem = async () => {
try {
if (!['linux', 'aarch64'].includes(platform)) {
return;
}
console.log('Updating System');
const { stderr } = await exec(`sh src/update-${platform}.sh`);
if (stderr) {
console.error(stderr);
}
console.log('-------------------');
} catch (error) {
fail(error);
}
};
const buildLib = async () => {
try {
console.log('Bullet Build Started');
const { stderr, stdout } = await exec(`sh ${getScriptForLib()}`);
if (stdout) {
console.error(stdout);
}
if (stderr) {
console.error(stderr);
}
console.log('Bullet Build Finished');
console.log('-------------------');
} catch (error) {
fail(error);
}
};
(async () => {
try {
await updateSystem();
await buildLib();
} catch (error) {
fail(error);
}
})();

12
src/extract.sh Normal file
View File

@ -0,0 +1,12 @@
(
cd src
rm -rf build
mkdir -p build
rm -rf libuiohook
git clone --depth 1 -b 1.2.2 https://github.com/kwhat/libuiohook.git
mkdir -p libuiohook/installed
mkdir -p libuiohook/build
)

16
src/linux-common.sh Normal file
View File

@ -0,0 +1,16 @@
(
cd src/libuiohook/build
cmake -A x64 \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_DEMO=OFF \
-DCMAKE_INSTALL_PREFIX=../installed \
-S ..
cmake --build . --config Release
# Use install to fetch INCLUDES
cmake --install . --config Release
)
cp src/libuiohook/installed/lib/uiohook.a src/build/uiohook.a

1
src/linux.sh Normal file
View File

@ -0,0 +1 @@
chmod +x src/linux-common.sh && src/linux-common.sh

16
src/osx.sh Normal file
View File

@ -0,0 +1,16 @@
(
cd src/libuiohook/build
cmake -A x64 \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_DEMO=OFF \
-DCMAKE_INSTALL_PREFIX=../installed \
-S ..
cmake --build . --config Release
# Use install to fetch INCLUDES
cmake --install . --config Release
)
cp src/libuiohook/installed/lib/uiohook.a src/build/uiohook.a

2
src/update-aarch64.sh Normal file
View File

@ -0,0 +1,2 @@
sudo yum -y update
sudo yum -y install cmake

1
src/update-linux.sh Normal file
View File

@ -0,0 +1 @@
sudo apt-get update -qq

16
src/windows.sh Normal file
View File

@ -0,0 +1,16 @@
(
cd src/libuiohook/build
cmake -A x64 \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_DEMO=OFF \
-DCMAKE_INSTALL_PREFIX=../installed \
-S ..
cmake --build . --config Release
# Use install to fetch INCLUDES
cmake --install . --config Release
)
cp src/libuiohook/installed/lib/uiohook.lib src/build/uiohook.lib

21
test/index.test.js Normal file
View File

@ -0,0 +1,21 @@
'use strict';
const assert = require('node:assert').strict;
const { describe, it } = require('node:test');
const deps = require('..');
describe('Paths', () => {
it('exports an object', () => {
assert.strictEqual(typeof deps, 'object');
});
it('exports "bin" string', () => {
assert.strictEqual(typeof deps.bin, 'string');
});
it('exports "include" string', () => {
assert.strictEqual(typeof deps.include, 'string');
});
});