The list of current gamepads.
Whether gamepads are supported by this device.
Fire an event, all additional arguments are passed on to the event listener.
Name of event to fire.
Optional
arg1: anyFirst argument that is passed to the event handler.
Optional
arg2: anySecond argument that is passed to the event handler.
Optional
arg3: anyThird argument that is passed to the event handler.
Optional
arg4: anyFourth argument that is passed to the event handler.
Optional
arg5: anyFifth argument that is passed to the event handler.
Optional
arg6: anySixth argument that is passed to the event handler.
Optional
arg7: anySeventh argument that is passed to the event handler.
Optional
arg8: anyEighth argument that is passed to the event handler.
Self for chaining.
Get the value of one of the analog axes of the pad.
The axis to get the value of, use constants PAD_L_STICK_X, etc.
The value of the axis between -1 and 1.
Returns true if the button on the pad requested is pressed.
The button to test, use constants PAD_FACE_1, etc.
True if the button is pressed.
Detach an event handler from an event. If callback is not provided then all callbacks are unbound from the event, if scope is not provided then all events with the callback will be unbound.
Optional
name: stringName of the event to unbind.
Optional
callback: HandleEventCallbackFunction to be unbound.
Optional
scope: objectScope that was used as the this when the event is fired.
Self for chaining.
const handler = function () {
};
obj.on('test', handler);
obj.off(); // Removes all events
obj.off('test'); // Removes all events called 'test'
obj.off('test', handler); // Removes all handler functions, called 'test'
obj.off('test', handler, this); // Removes all handler functions, called 'test' with scope this
Attach an event handler to an event.
Name of the event to bind the callback to.
Function that is called when event is fired. Note the callback is limited to 8 arguments.
Optional
scope: object = ...Object to use as 'this' when the event is fired, defaults to current this.
Can be used for removing event in the future.
Attach an event handler to an event. This handler will be removed after being fired once.
Name of the event to bind the callback to.
Function that is called when event is fired. Note the callback is limited to 8 arguments.
Optional
scope: object = ...Object to use as 'this' when the event is fired, defaults to current this.
Poll for the latest data from the gamepad API.
Optional
pads: GamePad[] = []An optional array used to receive the gamepads mapping. This array will be returned by this function.
An array of gamepads and mappings for the model of gamepad that is attached.
Make the gamepad vibrate.
Intensity for the vibration in the range 0 to 1.
Duration for the vibration in milliseconds.
Optional
options: { startDelay?: number; strongMagnitude?: number; weakMagnitude?: number }Options for special vibration pattern.
Optional
startDelay?: numberDelay before the pattern starts, in milliseconds. Defaults to 0.
Optional
strongMagnitude?: numberIntensity for strong actuators in the range 0 to 1. Defaults to intensity.
Optional
weakMagnitude?: numberIntensity for weak actuators in the range 0 to 1. Defaults to intensity.
Return a Promise resulting in true if the pulse was successfully completed.
Make all gamepads vibrate.
Intensity for the vibration in the range 0 to 1.
Duration for the vibration in milliseconds.
Optional
options: { startDelay?: number; strongMagnitude?: number; weakMagnitude?: number }Options for special vibration pattern.
Optional
startDelay?: numberDelay before the pattern starts, in milliseconds. Defaults to 0.
Optional
strongMagnitude?: numberIntensity for strong actuators in the range 0 to 1. Defaults to intensity.
Optional
weakMagnitude?: numberIntensity for weak actuators in the range 0 to 1. Defaults to intensity.
Return a Promise resulting in an array of booleans defining if the pulse was successfully completed for every gamepads.
Returns true if the button was pressed since the last frame.
The button to test, use constants PAD_FACE_1, etc.
True if the button was pressed since the last frame.
Returns true if the button was released since the last frame.
The button to test, use constants PAD_FACE_1, etc.
True if the button was released since the last frame.
Static
EVENT_Fired when a gamepad is connected. The handler is passed the GamePad object that was connected.
Static
EVENT_Fired when a gamepad is disconnected. The handler is passed the GamePad object that was disconnected.
Input handler for accessing GamePad input.