Skip to content
Samir Zahran edited this page May 18, 2017 · 2 revisions

Controller.js is built to handle the busy-work associated with using the Gamepad API make it easier to use for non-gaming purposes. It has three main features:


An event-driven interface

Controller.js fires DOM events on controller state and input changes. It keeps track of each input's changes over time and reports them similarly to mouse and keyboard events.

Each event provides a packet of information about the event fired, such as coordinates and angle for analog stick events.


Standardized input names

A challenge of working with gamepads is the number and variety of devices that exist in the market. Some will have more inputs than a "normal" gamepad, and some will have fewer. The Gamepad API allows for an arbitrary number of buttons and axes but it doesn't privide a way to tell what each of those inputs actually is. buttons[0] might be a D-pad input on one gamepad, but a trigger on another.

Controller.js alleviates this issue by mapping raw inputs against a set of known layouts and giving each input a unique, descriptive name, i.e. "DPAD_UP", "LEFT_SHOULDER", "RIGHT_ANALOG_STICK".


Useful features and settings

Controller.js provides a set of functions for common tasks and configurable options for each gamepad. It handles the process of discovering gamepads, mapping their inputs and listening for and pausing events from those gamepads. It also provides settings to do things like change button sensitivity or map analog stick movements to the D-pad.

Getting Started

Buttons & Analog Sticks
Controller Layouts
Configuring Settings

Explore The API

Event Model
The Controller Object
Controller Instances
Controller Settings

Contributing (in progress)

Grunt Tasks
Registering Settings
Creating Layout Maps

You can’t perform that action at this time.