-
Notifications
You must be signed in to change notification settings - Fork 15
Controller.search()
Listens for new controllers.
The Controller.search()
method begins polling for new gamepads. As they are connected, they will each dispatch a gc.controller.found event to the window
object of the DOM.
Argument | Type | Description |
---|---|---|
options |
Associative Array |
Optional: An array of options. |
Controller.search();
// New controllers will fire gc.controller.found events
Option | Type | Description |
---|---|---|
unsupportedCallback |
Function |
A function to call if Controller.js is not supported in the user's browser. |
settings |
Object |
A list of key/value pairs representing controller setting and their values. |
Controller.search({ unsupportedCallback: fallback });
function fallback() {
window.alert("Your browser does not support gamepads.");
}
Controller.search({
settings: {
useAnalogAsDpad: "both"
}
});
var controller = Controller.getController(0);
console.log(controller.settings.useAnalogAsDpad);
>> "both"
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