API Reference

Class List

pc.GamePads

Input handler for accessing GamePad input.

Summary

Methods

getAxis

Get the value of one of the analogue axes of the pad.

isPressed

Returns true if the button on the pad requested is pressed.

poll

Poll for the latest data from the gamepad API.

update

Update the current and previous state of the gamepads.

wasPressed

Returns true if the button was pressed since the last frame.

Details

Constructor

GamePads()

Methods

getAxis(index, axes)

Get the value of one of the analogue axes of the pad.

Parameters

indexnumber

The index of the pad to check, use constants pc.PAD_1, pc.PAD_2, etc.

axesnumber

The axes to get the value of, use constants pc.PAD_L_STICK_X, etc.

Returns

number

The value of the axis between -1 and 1.

isPressed(index, button)

Returns true if the button on the pad requested is pressed.

Parameters

indexnumber

The index of the pad to check, use constants pc.PAD_1, pc.PAD_2, etc.

buttonnumber

The button to test, use constants pc.PAD_FACE_1, etc.

Returns

boolean

True if the button is pressed.

poll()

Poll for the latest data from the gamepad API.

var gamepads = new pc.GamePads();
var pads = gamepads.poll();

Returns

object[]

An array of gamepads and mappings for the model of gamepad that is attached.

update()

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

wasPressed(index, button)

Returns true if the button was pressed since the last frame.

Parameters

indexnumber

The index of the pad to check, use constants pc.PAD_1, pc.PAD_2, etc.

buttonnumber

The button to test, use constants pc.PAD_FACE_1, etc.

Returns

boolean

True if the button was pressed since the last frame.