-
Notifications
You must be signed in to change notification settings - Fork 1
Controller Events
Event | Fires when… |
---|---|
gc.controller.found |
…a controller is connected or turned on. |
gc.controller.lost |
…a controller is no longer visible to the browser. |
The found event fires after a gamepad is connected and has been initialized. Depending on your browser this may happen as soon as you plug in or connect your gamepad, or you may have to press a button on the gamepad to "wake" it before it becomes visible.
This event passes the following to the detail
property of the Event
object:
-
controller
: The Controller instance. -
id
: The controller id. -
index
: The controller index. -
timestamp
: When the controller was initialized, in Unix time.
window.addEventListener('gc.controller.found', function(event) {
console.log(event.detail);
}, false);
>> Object {
>> controller: Controller, // a reference to this instance of Controller
>> index: 0,
>> time: 427075200,
>> id: "Wireless Controller (STANDARD GAMEPAD Vendor: 054c Product: 05c4)"
>> }
When the lost event fires it either means the gamepad has been physically or otherwise disconnected, or it has lost power.
This event passes the following to the detail
property of the Event
object:
-
id
: The controller id. -
timestamp
: When the gamepad was disconnected, in Unix time.
window.addEventListener('gc.controller.lost', function(event {
console.log(event.detail);
}, false);
>> Object {
>> index: 0,
>> time: 498441600
>> }
The MIT License (MIT)
Copyright © 2022 Jack Carey
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