Description

Can play with the gamepad

Example

In method "ready" of the scene :

var canvas = CE.defines("canvas_id").
extend(Input).
ready(function() {
    canvas.Scene.call("MyScene");
});

canvas.Scene.new({
    name: "MyScene",
    ready: function(stage) {
        this.gamepad = canvas.Input.Gamepad.init(function() {
          console.log("Gamepad connected");
        }, function() {
          console.log("Gamepad disconnected");
        });

        this.gamepad.addListener("faceButton0", function() {
           console.log("key A down");
        }, function() {
           console.log("key A up");
        });
    },
    render: function(stage) {
        this.gamepad.update();
    }
});

Methods

init

Initialize the gamepad

addListener

Adds a listener when a button is pressed or released

addListener

Execute a function already defined on the keyboard

update

Updates the inputs of the gamepad

Discussion