import Gamepad from '@mobilizing/library/js/Mobilizing/input/Gamepad.js'
Gamepad
Extends:
Constructor Summary
Public Constructor | ||
public | constructor(params: Object) 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
Method Summary
Public Methods | ||
public | gamepadConnectedHandler(event: Event) Gamepad connection handler | |
public | gamepadDisconnectedHandler(event: Event) Gamepad disconnection handler | |
public | getAllAxes(index: *): Array Method to get a gamepad joysticks axes values | |
public | getAllButtons(index: Number): Object Method to get all the buttons of this gamepad | |
public | Method to get a specific axes's deltas | |
public | Method to get a specific button's state | |
public | getGamePadFromIndex(index: *): * | |
public | off() | |
public | on() | |
public | setup() |
Private Methods | ||
private | Updates the gamepads state, according to the API |
Inherited Summary
From class Component | ||
public | ||
public | context: * | |
public | events: * | |
public | id: * | |
public | name: * | |
private | _nexts: *[] | |
private | ||
public | byPass() | |
public | 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() preLoad the component This empty method is usually overriden to perform preLoad 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 | prepare() prepare the component This empty method is usually overriden to perform preparation actions for the component, from external process as a server. | |
public | setup() 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() 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#constructorParams:
Name | Type | Attribute | Description |
params | Object |
Public Methods
public gamepadConnectedHandler(event: Event) source
Gamepad connection handler
Params:
Name | Type | Attribute | Description |
event | Event |
public gamepadDisconnectedHandler(event: Event) source
Gamepad disconnection handler
Params:
Name | Type | Attribute | Description |
event | Event |
public getAllAxes(index: *): Array source
Method to get a gamepad joysticks axes values
Params:
Name | Type | Attribute | Description |
index | * | the gamapad's index to get axes from. |
Return:
Array | the axes array according to the capacities of the gamepad |
public getAllButtons(index: Number): Object source
Method to get all the buttons of this gamepad
Params:
Name | Type | Attribute | Description |
index | Number |
Return:
Object | all buttons object in their original format |
public getAxes(axeIndex: Number, gamepadIndex: Number): * source
Method to get a specific axes's deltas
Return:
* |
public getButton(buttonIndex: Number, gamepadIndex: Number): * source
Method to get a specific button's state
Return:
* |
public on() source
Activate the component A call to this method calls the setup method if it has not been run yet
Override:
Component#onpublic 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#setupPrivate Methods
private updateGamePads() source
Updates the gamepads state, according to the API