-
Notifications
You must be signed in to change notification settings - Fork 15
Home
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:
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.
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"
.
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.
→ Setup
→ Buttons & Analog Sticks
→ Controller Layouts
→ Configuring Settings
→ Event Model
→ The Controller Object
→ Controller Instances
→ Controller Settings
→ Grunt Tasks
→ Registering Settings
→ Creating Layout Maps
The MIT License (MIT)
Copyright © 2016 Samir Zahran
Setup
Buttons & Analog Sticks
Controller Layouts
Configuring Settings
Controller Events
Button Events
Analog Stick Events
Controller.supported
Controller.controllers
Controller.controllerCount
Controller.search()
Controller.getController()
Controller.watchAll()
Controller.unwatchAll()
.connectedTimestamp
.id
.index
.inputs
.layoutInfo
.name
.watch()
.unwatch()
Settings Objects
List of Settings
settings.list()
settings.clear()
settings.update()
→ Grunt Tasks
→ Registering Settings
→ Creating Layout Maps