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

js-gamepad-overlay

v0.8.0

Published

js/html overlay for gamepad inputs

Downloads

22

Readme

js-gamepad-overlay

HTML5 gamepad overlay which aims to adapt the main functionality of the HTML5 gamepad api. Supports mouse and touch input.

This library does implement styling on a very low level. Every element is completely customizable.

features

  • Gamepad buttons that are visible on the screen.
  • Gamepad sticks that are visible on the screen.
  • HTML5Gamepad Interface through toHTML5GamepadAPI()

getting started

<div id="gamepadContainer"></div>
import GamepadOverlay from "js-gamepad-overlay";

const gamepadOverlay = new GamepadOverlay({
    domHook: document.getElementById("gamepadContainer")
})

api

createNewButton()

Creates a new button.

#####parameters

  • code – required – id of the button
  • width – optional – defaults to 0 – width of the button
  • height – optional – defaults to 0 – height of the button
  • styles – optional – defaults to {} – css style object
  • text – optional – defaults to "" – visible text on the button
  • onPress – optional defaults to () => null – callback when the button is pressed
  • onRelease – optional defaults to () => null – callback when the button is released

createNewStick()

Creates a new stick with 2 axes.

#####parameters

  • code – required – id of the stick
  • radius – optional – defaults to 0 – radius of the stick
  • styles – optional – defaults to {} – css style object of the stick
  • snapBackDelay – optional – defaults to 0 – the delay of the stickButton to snap back after releasing it
  • stickButtonScale – optional – defaults to 0.5 – size of the stickButton relative to the stick container
  • stickButtonStyles – optional – defaults to {} – css style of the stick button
  • onMove – optional defaults to () => null – callback when the stick is moved
  • onMoveEnd – optional defaults to () => null – callback when the stick is released

toHTML5GamepadAPI()

Returns an object similar to the HTML5GamepadAPI.

Gamepad

####Objectstructure

{
    axes: {...}
    sticks: {...}
    buttons: {...}
}

Gamepad.sticks

{
    codeStick0:{
        code: "codeStick0"
        axes: {...},
        ui: DOMElement,
        buttonUi: DOMElement
    },
    ...
}

Gamepad.axes

{
    codeStick0-0: AxesValue,
    codeStick0-1: AxesValue,
    ...
}

Gamepad.buttons

{
    buttonCode0: {
        code: "buttonCode0",
        ui: DOMElement,
        pressed: Boolean
    },
    ...
}

Example

import GamepadOverlay from "js-gamepad-overlay";
// const GamepadOverlay = require("js-gamepad-overlay").default;

const gamepadOverlay = new GamepadOverlay({domHook: document.querySelector("body")});

gamepadOverlay.createNewButton({
    code: 0,
    width: 50,
    height: 50,
    styles:{
        position: "absolute",
        left: "300px",
        bottom: "100px",
        borderRadius: "50%",
        backgroundColor: "transparent",
        border: "2px solid grey",
        fontSize: "20px",
        fontWeight: "bold"
    },
    text: "A",
    onPress: (button) => {button.ui.style.backgroundColor = "gray";},
    onRelease: (button) => {button.ui.style.backgroundColor = "transparent";}
});

gamepadOverlay.createNewStick({
    code: 0,
    radius: 50,
    styles: {
        position: "absolute",
        bottom: "100px",
        left: "100px",
        border: "2px solid grey",
    },
    stickButtonStyles: {
        border: "2px solid grey"
    },
    onMove: (stick) => {stick.buttonUi.style.transition = "0s ease";},
    onMoveEnd: (stick) => {stick.buttonUi.style.transition = "0.15s ease";}
});

console.log(gamepadOverlay.axes);
console.log(gamepadOverlay.sticks);
console.log(gamepadOverlay.buttons);
console.log(gamepadOverlay.toHTML5GamepadAPI());