Skip to content

Commit

Permalink
+ Fix cross compilation for linux x64
Browse files Browse the repository at this point in the history
+ Update typings
+ Cleanup repository
  • Loading branch information
wilix-lead committed Feb 15, 2018
1 parent eade978 commit 959de2b
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ build
prebuilds
builds
*.DS_Store
electron-example/.DS_Store
examples/electron-example/.DS_Store

2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CMakeFiles/
libuiohook/
build/
electron-example
examples/electron-example
prebuilds/
builds/
.env
Expand Down
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ matrix:
include:
- os: linux
env: ARCH=x32
- os: linux
env: ARCH=x64
- os: osx

node_js:
Expand Down
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ If you like this module or are interested in updates, follow me on Twitter [http
Already tested in:
- Ubuntu 16.04 / 17
- macOS High Sierra 10.13.2 and older
- Windows (NOT TESTED YET)
- Windows x32/x64

## Installation
This module use native library libuiohook and require some installed packages.
I really hope find way for use build systems for online build or download prebuild packages.

`npm install iohook --save`
`npm install iohook --save`
_PS: TypeScript types already included_

### Electron users [optional]
Before install this module, you need specify build runtime.
Expand Down Expand Up @@ -81,6 +82,11 @@ All what you need install os dependencies and start compilation:
- `cd node_modules/iohook`
- `npm run build`

### Windows
Install: msys2 with autotools, pkg-config, libtool, gcc, clang, glib, C++ Build Tools, cmake
- `cd node_modules/iohook`
- `npm run build`

## Usage
Module is pretty simple for use. There is example:

Expand Down Expand Up @@ -140,7 +146,7 @@ Calls when user press a key. Event contain next object:

### keyup
Calls when user release a key. Event contain next object:
`{keychar: 'f', keycode: 19, rawcode: 15, type: 'keup'}`
`{keychar: 'f', keycode: 19, rawcode: 15, type: 'keyup'}`

### mouseclick
Calls when user click mouse button. Event contain next object:
Expand Down Expand Up @@ -175,3 +181,4 @@ but I still can't find a problem. Will be happy if somebody helps with it.
Thanks for [libuiohook](https://github.com/kwhat/libuiohook) project!
Thank you [ayoubserti](https://github.com/ayoubserti) for first iohook prototype
Thank you [vespakoen](https://github.com/vespakoen) for prebuild system implementation
Thank you [matthewshirley](https://github.com/matthewshirley) for fixing prebuild for Windows
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const {app} = require('electron');
const ioHook = require('../index');
const ioHook = require('../../index');

function eventHandler(event) {
console.log(event);
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion example.js → examples/example.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const ioHook = require('./index.js');
const ioHook = require('../index.js');

ioHook.on("mousedown",function(msg){console.log(msg);});

Expand Down
58 changes: 56 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,67 @@
import { EventEmitter } from 'events'

declare class IOHook extends EventEmitter {
/**
* Native module for hooking keyboard and mouse events
*/
declare class IOHook extends EventEmitter<IOHookEvent> {
/**
* Start hooking engine. Call it when you ready to receive events
* @param {boolean} enableLogger If true, module will publish debug information to stdout
*/
start(enableLogger: boolean): void

/**
* Stop rising keyboard/mouse events
*/
stop(): void

/**
* Manual native code load. Call this function only if unload called before
*/
load(): void

/**
* Unload native code and free memory and system hooks
*/
unload(): void

/**
* Enable/Disable stdout debug
* @param {boolean} mode
*/
setDebug(mode: boolean): void

/**
* Register global shortcut. When all keys in keys array pressed, callback will be called
* @param {Array<string|number>} keys Array of keycodes
* @param {Function} callback Callback for call when shortcut pressed
* @return {number} ShortcutId for unregister
*/
registerShortcut(keys, callback): number

/**
* Unregister shortcut by ShortcutId
* @param shortcutId
*/
unregisterShortcut(shortcutId): void

/**
* Unregister all shortcuts
*/
unregisterAllShortcuts(): void
}

declare interface IOHookEvent {
type: string
keychar?: number
keycode?: number
rawcode?: number
button?: number
clicks?: number
x?: number
y?: number
}

declare const iohook: IOHook
declare const iohook: IOHook;

export = iohook
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iohook",
"version": "0.1.11",
"version": "0.1.12",
"description": "Node.js global keyboard and mouse hook",
"main": "index.js",
"types": "index.d.ts",
Expand Down
22 changes: 0 additions & 22 deletions support.js

This file was deleted.

0 comments on commit 959de2b

Please sign in to comment.