Class: GamePads

pc.GamePads

Input handler for accessing GamePad input.

Constructor

new GamePads()

Source:

Methods

getAxis(index, axes) → {Number}

Get the value of one of the analogue axes of the pad
Parameters:
Name Type Description
index Number The index of the pad to check, use constants pc.PAD_1, pc.PAD_2, etc
axes Number The axes to get the value of, use constants pc.PAD_L_STICK_X, etc
Source:
Returns:
The value of the axis between -1 and 1.
Type
Number

isPressed(index, button) → {Boolean}

Returns true if the button on the pad requested is pressed
Parameters:
Name Type Description
index Number The index of the pad to check, use constants pc.PAD_1, pc.PAD_2, etc
button Number The button to test, use constants pc.PAD_FACE_1, etc
Source:
Returns:
True if the button is pressed
Type
Boolean

poll() → {Array.<Object>}

Poll for the latest data from the gamepad API.
Source:
Returns:
An array of gamepads and mappings for the model of gamepad that is attached
Type
Array.<Object>
Example
var gamepads = new pc.GamePads();
  var pads = gamepads.poll();
  // pads[0] = { map: <map>, pad: <pad> }

update()

Update the current and previous state of the gamepads. This must be called every frame for wasPressed() to work
Source:

wasPressed(index, button) → {Boolean}

Returns true if the button was pressed since the last frame
Parameters:
Name Type Description
index Number The index of the pad to check, use constants pc.PAD_1, pc.PAD_2, etc
button Number The button to test, use constants pc.PAD_FACE_1, etc
Source:
Returns:
True if the button was pressed since the last frame
Type
Boolean