Repository

Gamepad

Extends:

Component → Gamepad

Constructor Summary

Public Constructor
public

Gamepad class is a simple layer on top of the official Gamepad API : https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API

Member Summary

Public Members
public

True is the Gamepad API is supported

public
public

Method Summary

Public Methods
public

Gamepad connection handler

public

Gamepad disconnection handler

public

getAllAxes(index: *): Object

Method to get a gamepad joysticks axes values

public

Method to get all the buttons of this gamepad

public

getAxes(axeIndex: Number, gamepadIndex: Number): *

Method to get a specific axes's deltas

public

getButton(buttonIndex: Number, gamepadIndex: Number): *

Method to get a specific button's state

public

off()

public

on()

public
Private Methods
private

Updates the gamepads state, according to the API

Inherited Summary

From class Component
public
public
public

events: *

public

id: *

public

name: *

private

_nexts: *[]

private
public
public

chain(component: Component)

Adds a component to this chained component array

public

Returns the array of attached children components

public

off()

Deactivate the component

public

on()

Activate the component A call to this method calls the setup method if it has not been run yet

public

Run code after the update of all components is run This empty method is usually overriden to perform post-update actions for the component It is called periodically by an internal Mobilizing mechanism

public

preLoad the component This empty method is usually overriden to perform setup actions for the component.

public

Run code before the update of all components is run This empty method is usually overriden to perform pre-update actions for the component It is called once per component by an internal Mobilizing mechanism

public

Set's up the component This empty method is usually overriden to perform setup actions for the component This is where all the initialization (such as adding event listeners)should be done It is called automatically by an internal Mobilizing mechanism and should thus not be called directly

public

Update the component This empty method is usually overriden to perform update actions for the component It is called periodically by an internal Mobilizing mechanism

Public Constructors

public constructor(params: Object) source

Gamepad class is a simple layer on top of the official Gamepad API : https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API

Override:

Component#constructor

Params:

NameTypeAttributeDescription
paramsObject

Public Members

public available: Boolean source

True is the Gamepad API is supported

public currentGamepadIndex: * source

public gamepads: {} source

Public Methods

public gamepadConnectedHandler(event: Event) source

Gamepad connection handler

Params:

NameTypeAttributeDescription
eventEvent

public gamepadDisconnectedHandler(event: Event) source

Gamepad disconnection handler

Params:

NameTypeAttributeDescription
eventEvent

public getAllAxes(index: *): Object source

Method to get a gamepad joysticks axes values

Params:

NameTypeAttributeDescription
index*

the gamapad's index to get axes from.

Return:

Object

the axes as {0 : {x,y}, 1 : {x,y}, ...} according to the capacities of the gamepad

public getAllButtons(index: Number): Object source

Method to get all the buttons of this gamepad

Params:

NameTypeAttributeDescription
indexNumber

Return:

Object

all buttons object in their original format

public getAxes(axeIndex: Number, gamepadIndex: Number): * source

Method to get a specific axes's deltas

Params:

NameTypeAttributeDescription
axeIndexNumber
gamepadIndexNumber

Return:

*

public getButton(buttonIndex: Number, gamepadIndex: Number): * source

Method to get a specific button's state

Params:

NameTypeAttributeDescription
buttonIndexNumber
gamepadIndexNumber

Return:

*

public off() source

Deactivate the component

Override:

Component#off

public on() source

Activate the component A call to this method calls the setup method if it has not been run yet

Override:

Component#on

public setup() source

Set's up the component This empty method is usually overriden to perform setup actions for the component This is where all the initialization (such as adding event listeners)should be done It is called automatically by an internal Mobilizing mechanism and should thus not be called directly

Override:

Component#setup

Private Methods

private updateGamePads() source

Updates the gamepads state, according to the API