npm.io
1.0.0 • Published 3 years ago

gamepad-library

Licence
MIT
Version
1.0.0
Deps
0
Size
9 kB
Vulns
0
Weekly
0

Gamepad Library

A suite of Gamepads for use in browser-based applications (for ex. games).

Supported Devices

  • XInput-compliant controllers (ex. Xbox 360)
  • Create a PR to add more!

Usage example in applications

const { XInput } = require("gamepad-library");

const inputMethod = new XInput();

// in some sort of polling loop

const pad = navigator.getGamepads()[0];
// assuming it is indeed a XInput

const buttons = inputMethod.getPressedButtons(pad);

// check if B button is pressed

if (buttons.includes("B")) {
  // hadoken
}

Keywords