Class: Gamepad

Gamepad()

Handle gamepad input.
Assumes Standard Gamepad Layout, as described at https://w3c.github.io/gamepad/#dfn-standard-gamepad

Constructor

new Gamepad()

Initialize required variables and set up listeners.
Source:

Methods

buttonPressed(buttonName) → {boolean}

Check if a button was just pressed; only true for a single frame after button is pressed.
Parameters:
Name Type Description
buttonName string the name of the button to check
Source:
Returns:
true if the button was just pressed
Type
boolean

buttonPressing(buttonName) → {boolean}

Check if a button is currently down; true for the duration between button pressed and button released.
Parameters:
Name Type Description
buttonName string the name of the button to check
Source:
Returns:
true if the button is currently down
Type
boolean

buttonReleased(buttonName) → {boolean}

Check if a button was just pressed; only true for a single frame after button is released.
Parameters:
Name Type Description
buttonName string the name of the button to check
Source:
Returns:
true if the button was just released
Type
boolean

getAxisValue(axisName) → {number}

Get value representing position of axis, from lowest value (-1) to highest value (+1).
Parameters:
Name Type Description
axisName string the name of the axis to check
Source:
Returns:
value of axis
Type
number

getJoystickVector(joystickNumber) → {Vector}

Get a Vector containing both axis values of a joystick.
(May be useful to simplify calculating length and angle of joystick position.)
Parameters:
Name Type Description
joystickNumber number left joystick = 1, right joystick = 2
Source:
Returns:
vector containing both axis values of specified joystick
Type
Vector

update()

Update button state data.
This method should be called once per frame by the Game class.
Source: