virtual-input

0.0.2 • Public • Published

node-virtual-input

This nodejs lib lets you simulate keypresses, gamepad controls, joystick controls, mouse movement and clicks; all natively using uinput.

Prerequisite


This is only compatible with Linux OS with the uinput kernel module installed.

Installation


npm install --save virtual-input

Usage


const Input = require('virtual-input');

let opts = {};
let input = new Input(opts);

Methods


.connect(callback) Connects input device to device.

.disconnect(callback) Disconnects input device from device.

.sendEvent({type: <EVENTTYPE>, code: <EVENTCODE>, value: <VALUE>}) Sends an event.

type and code are numbers based on the event types and the event codes. Some of these types and codes are included in lib/uinput.js, if type and code are given strings, their value will be taken from there. (not all codes exist there).

Options


opts.ioctlArray You may supply an array of two array pairs of ioctl 'features'.

let input = new Input({ioctlArray: [
    ['UI_SET_KEYBIT', 'BTN_MIDDLE'],
    ['UI_SET_KEYBIT', 'BTN_EXTRA']
]});

Examples


There is rectangle.js in examples dir. If you want real code samples, then you can check out my sphero-as-joystick repo.

Forked and Worked on node-virtual-gamepads

Readme

Keywords

none

Package Sidebar

Install

npm i virtual-input

Weekly Downloads

1

Version

0.0.2

License

MIT

Last publish

Collaborators

  • omeryagmurlu