Skip to content

Controller.search()

Samir Zahran edited this page May 18, 2017 · 4 revisions

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.

Arguments

Controller.search([options])

Argument Type Description
options Associative Array Optional: An array of options.

Example

Controller.search();
// New controllers will fire gc.controller.found events

Search Options

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.

Examples

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"
Clone this wiki locally