jsgamepad

0.1.0 • Public • Published

jsGamepad

NPM Version NPM Downloads License

W3C Gamepad API Simplified & Implementation fixes

Demo

Specification

Gamepad API, W3C

Fixes

This lib fixes a bug in Chrome, where the connected event will be emitted instead of the disconnected event.

Usage

I suggest you to use jspm as your package manager.

import gamepad from "jsgamepad";
 
gamepad.on("connected", (gamepad) => {
  console.log("connected " + gamepad.index);
}).on("disconnected", (gamepad) => {
  console.log("disconnected " + gamepad.index);
}).on("buttonPressed", ({ button, buttonIndex, gamepad }) => {
  console.log("pressed " + buttonIndex);
}).on("buttonReleased", ({ button, buttonIndex, gamepad }) => {
  console.log("released " + buttonIndex);
});
 
// start loop for buttons and axes detection
gamepad.watch();

Directly in a browser

Please checkout the index-dist.html file for direct usage in a browser.

TODO

  • API

License

MIT

Dependents (0)

Package Sidebar

Install

npm i jsgamepad

Weekly Downloads

1

Version

0.1.0

License

MIT

Last publish

Collaborators

  • ardean