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
| 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. |
Returns
numberThe value of the axis between -1 and 1.
isPressed(index, button)
Returns true if the button on the pad requested is pressed.
Parameters
| 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. |
Returns
booleanTrue 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
| 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. |
Returns
booleanTrue if the button was pressed since the last frame.