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 🙏

© 2026 – Pkg Stats / Ryan Hefner

gamepad-io

v0.3.2

Published

Node.js library for gamepad support using node-hid

Readme

gamepad-io

npm version License: MIT Node.js Version

Node.js library for gamepad support using node-hid. Provides event-driven API for button presses, stick movements, and key combinations.

Installation

npm install gamepad-io

Important: This library requires native HID access. On Linux, you may need to configure udev rules. On macOS and Windows, additional setup might be required for non-standard gamepads.

Quick Start

import { Gamepad, GamepadEvent, GamepadButton } from 'gamepad-io';
import { config } from 'gamepad-io/src/gamepads/8bitdopro2.json';

// Create gamepad instance
const gamepad = new Gamepad(config);

// Listen for button events
gamepad.on(GamepadEvent.DOWN, (buttonName) => {
    console.log(`Button ${buttonName} pressed`);
});

gamepad.on(GamepadEvent.UP, (buttonName) => {
    console.log(`Button ${buttonName} released`);
});

// Start listening
gamepad.start();

Built-in Configurations

The library provides predefined gamepad configurations for supported controllers. These configurations are available via the gamepadConfigs export.

import { Gamepad, GamepadEvent } from 'gamepad-io';
import { gamepadConfigs } from 'gamepad-io';

// Use the 8BitDo Pro 2 configuration
const gamepad = new Gamepad(gamepadConfigs.eightBitDoPro2);

// Listen for button events
gamepad.on(GamepadEvent.DOWN, (buttonName) => {
    console.log(`Button ${buttonName} pressed`);
});

gamepad.start();

Currently Supported Gamepads

  • 8BitDo Pro 2 (gamepadConfigs.eightBitDoPro2) - Vendor ID: 0x2dc8, Product ID: 0x6006
  • Logitech F310 (gamepadConfigs.logitechF310) - Vendor ID: 0x046d, Product ID: 0xc216
  • Logitech F710 (gamepadConfigs.logitechF710) - Vendor ID: 0x046d, Product ID: 0xc219

To add support for other gamepads, create a custom JSON configuration file following the existing structure and use it with the Gamepad constructor.

Gamepad Configuration Helper

For easier gamepad configuration creation, use the standalone gamepad‑io‑helper tool. It provides a GUI for mapping buttons, axes, and combinations, and generates JSON configurations compatible with gamepad‑io.

Usage Examples

Tracking Button States

import { Gamepad, GamepadEvent, GamepadButton } from 'gamepad-io';
import config from './path-to-your-config.json';

const gamepad = new Gamepad(config);

// Check if a button is currently pressed
if (gamepad.isPressed(GamepadButton.A)) {
    console.log('A button is pressed');
}

// Handle specific button events
gamepad.on(GamepadEvent.DOWN, (buttonName) => {
    switch (buttonName) {
        case GamepadButton.A:
            console.log('Jump!');
            break;
        case GamepadButton.B:
            console.log('Attack!');
            break;
    }
});

gamepad.start();

Working with Sticks (Joysticks)

import { Gamepad, GamepadEvent } from 'gamepad-io';
import config from './path-to-your-config.json';

const gamepad = new Gamepad(config);

// Listen for stick movements
gamepad.on(GamepadEvent.MOVE, (stickName, position) => {
    console.log(`Stick ${stickName} moved: x=${position.x}, y=${position.y}`);

    // Example: dead zone handling
    const deadZone = 0.1;
    if (Math.abs(position.x) > deadZone || Math.abs(position.y) > deadZone) {
        console.log(`Active movement detected`);
    }
});

gamepad.start();

Key Combinations

import { Gamepad, GamepadEvent, GamepadButton } from 'gamepad-io';
import config from './path-to-your-config.json';

const gamepad = new Gamepad(config);

// Register combination
gamepad.registerCombination('SPECIAL_ATTACK', [GamepadButton.A, GamepadButton.B, GamepadButton.X]);

// Listen for combination events
gamepad.on(GamepadEvent.COMBO_DOWN, (comboName) => {
    console.log(`${comboName} activated!`);
});

gamepad.on(GamepadEvent.COMBO_UP, (comboName) => {
    console.log(`${comboName} deactivated`);
});

// Check combination state
if (gamepad.isCombinationPressed('SPECIAL_ATTACK')) {
    console.log('Special attack is ready!');
}

gamepad.start();

Debug Mode

The library includes a debug utility that logs all gamepad events:

import { debug } from 'gamepad-io/debug';
import config from './path-to-your-config.json';

// Start debug mode
debug(config);

Or via npm script:

npm run debug

Development

Building

npm run build

Testing

npm test

Linting

npm run lint
npm run lint:fix  # Auto-fix lint issues

Watch Mode (Development)

npm run dev

License

MIT © 2026 ys.kalyakin