npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

uinput2

v1.0.2

Published

Linux uinput module

Downloads

15

Readme

node-uinput

Linux uinput nodejs wrapper

Installation

npm install uinput

Example

const UInput = require('uinput2');

const SETUP_OPTIONS = {
    UI_SET_EVBIT:  [
        UInput.EV_KEY,
        UInput.EV_SYN,
        UInput.EV_REL,
    ],
    UI_SET_RELBIT: [
        UInput.REL_X,
        UInput.REL_Y,
        UInput.REL_WHEEL,
        UInput.REL_HWHEEL,
    ],
    UI_SET_KEYBIT: [
        UInput.BTN_LEFT,
        UInput.BTN_RIGHT,
        UInput.BTN_MIDDLE,
        UInput.BTN_SIDE,
        UInput.BTN_EXTRA,
    ],
};

const CREATE_OPTIONS = {
    name: 'Wine Launcher Mouse Emulation',
    id:   {
        busType: UInput.BUS_USB,
        vendor:  0x0,
        product: 0x0,
        version: 1
    },
};

export default class UInputMouse {
    static map = {
        left:   UInput.BTN_LEFT,
        right:  UInput.BTN_RIGHT,
        middle: UInput.BTN_MIDDLE,
    };
    runtime = Promise.resolve();
    delay = 2;
    device;

    async createDevice() {
        if (undefined !== this.device) {
            return this.device;
        }

        this.device = await UInput.setup(SETUP_OPTIONS);
        this.device.create(CREATE_OPTIONS);

        return this.device;
    }

    async sleep(time) {
        return new Promise((resolve) => setTimeout(resolve, time));
    }

    /**
     * @param {number} x
     * @param {number} y
     */
    moveMouse(x, y) {
        this.createDevice().then(device => {
            this.runtime = this.runtime
                .then(() => device.sendEvent(UInput.EV_REL, UInput.REL_X, x, false))
                .then(() => device.sendEvent(UInput.EV_REL, UInput.REL_Y, y, true))
                .then(() => this.sleep(this.delay));
        });
    }


    /**
     * @param {string} key [left, right, middle]
     * @param {boolean} pressed
     */
    keyToggle(key, pressed) {
        if (undefined === UInputMouse.map[key]) {
            return;
        }

        this.createDevice().then(device => {
            this.runtime = this.runtime
                .then(() => device.keyEvent(UInputMouse.map[key], pressed))
                .then(() => this.sleep(this.delay));
        });
    }
}

const device = new UInputMouse();

device.moveMouse(0, 100);
device.keyToggle('right', true);
device.keyToggle('right', false);

API

async UInput.setup(options)

  • options Object
    • event_type where event_type can be EV_KEY, EV_ABS, EV_REL, etc. and it's an Array with the different events we want the uinput device to handle
  • Returns a UInputClass on success

It configures the uinput device we are about to create.

async UInputClass.create(options)

  • options Object. See uinput_user_dev definition in linux/uinput.h
    • name String with the name of the device
    • id Object
      • busType Number
      • vendor Number
      • product Number
      • version Number
    • ffEffectsMax Number
    • absMax Array of Numbers of size: UInput.ABS_CNT
    • absMin Array of Numbers of size: UInput.ABS_CNT
    • absFuzz Array of Numbers of size: UInput.ABS_CNT
    • absFlat Array of Numbers of size: UInput.ABS_CNT

It creates the uinput device.

async UInputClass.sendEvent(type, code, value, syn)

  • type Number
  • code Number
  • value Number
  • syn Boolean

It sends an event to the uinput device.

async UInputClass.keyEvent(code, press)

  • code Number
  • press Boolean

Wrapper over send_event to simulate key presses and mouse clicks.

async UInputClass.emitCombo(code)

  • code Array with any combination of keys

It sends an event to the uinput device with the combination keys generated.