Shaku

Shaku JS

Back To Table of Content

Gamepad

Classes

Gamepad

Gamepad data object. This object represents a snapshot of a gamepad state, it does not update automatically.

FourButtonsCluster

Buttons cluster container - 4 buttons.

ThreeButtonsCluster

Buttons cluster container - 3 buttons.

FrontButtons

Front buttons.

Functions

_gamepadButtonPressed()

Get if a gamepad button is currently pressed.

Gamepad

Gamepad data object. This object represents a snapshot of a gamepad state, it does not update automatically.

Kind: global class

new Gamepad(gp)

Create gamepad state object.

Param Type Description
gp \* Browser gamepad state object.

gamepad.id : String

Gamepad Id.

Kind: instance property of Gamepad

gamepad.axis1 : Vector2

Gamepad first axis value.

Kind: instance property of Gamepad

gamepad.axis2 : Vector2

Gamepad second axis value.

Kind: instance property of Gamepad

gamepad.mapping : String

Mapping type.

Kind: instance property of Gamepad

gamepad.isMapped : Boolean

True if the gamepad is of a known type and we have extra mapped attributes. False if unknown / not supported.

Kind: instance property of Gamepad

gamepad.leftStick : Vector2

Gamepad left stick. Only available with “standard” mapping.

Kind: instance property of Gamepad

gamepad.rightStick : Vector2

Gamepad right stick. Only available with “standard” mapping.

Kind: instance property of Gamepad

gamepad.leftStickPressed : Boolean

Gamepad left stick is pressed. Only available with “standard” mapping.

Kind: instance property of Gamepad

gamepad.leftStickPressed : Boolean

Gamepad right stick is pressed. Only available with “standard” mapping.

Kind: instance property of Gamepad

gamepad.rightButtons : FourButtonsCluster

Right cluster button states.

Kind: instance property of Gamepad

gamepad.leftButtons : FourButtonsCluster

Left cluster button states.

Kind: instance property of Gamepad

gamepad.leftButtons : FourButtonsCluster

Center cluster button states.

Kind: instance property of Gamepad

gamepad.frontButtons : FrontButtons

Front buttons states.

Kind: instance property of Gamepad

gamepad.isMapped : Boolean

True if the gamepad is of a known type and we have extra mapped attributes. False if unknown.

Kind: instance property of Gamepad

gamepad.buttonsCount ⇒ Number

Get buttons count.

Kind: instance property of Gamepad
Returns: Number - Buttons count.

gamepad.button(index) ⇒ Boolean

Get button state (if pressed down) by index.

Kind: instance method of Gamepad
Returns: Boolean - True if pressed, false otherwise.

Param Type Description
index Number Button index to check.

FourButtonsCluster

Buttons cluster container - 4 buttons.

Kind: global class

new FourButtonsCluster(bottom, right, left, top)

Create the cluster states.

Param Type Description
bottom Boolean Bottom button state.
right Boolean Right button state.
left Boolean Left button state.
top Boolean Top button state.

ThreeButtonsCluster

Buttons cluster container - 3 buttons.

Kind: global class

new ThreeButtonsCluster(left, right, center)

Create the cluster states.

Param Type Description
left Boolean Left button state.
right Boolean Right button state.
center Boolean Center button state.

FrontButtons

Front buttons.

Kind: global class

new FrontButtons()

Create the cluster states.

_gamepadButtonPressed()

Get if a gamepad button is currently pressed.

Kind: global function
Prviate: