jsgamepad
v0.1.0
Published
W3C Gamepad API Simplified & Implementation fixes
Downloads
15
Maintainers
Readme
jsGamepad
W3C Gamepad API Simplified & Implementation fixes
Specification
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