GamepadHapticActuator
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
The GamepadHapticActuator interface of the Gamepad API represents hardware in the controller designed to provide haptic feedback to the user (if available), most commonly vibration hardware.
This interface is accessible through the Gamepad.hapticActuators property.
Instance properties
GamepadHapticActuator.effectsRead only-
Returns an array of enumerated values representing the different haptic effects that the actuator supports.
GamepadHapticActuator.typeRead only-
Returns an enumerated value representing the type of the haptic hardware. This property is deprecated: use
GamepadHapticActuator.effectsto detect effect support.
Instance methods
GamepadHapticActuator.playEffect()Read only-
Causes the hardware to play a specific vibration effect.
GamepadHapticActuator.pulse()Read only-
Makes the hardware pulse at a certain intensity for a specified duration.
GamepadHapticActuator.reset()Read only-
Stops the hardware from playing an active vibration effect.
Examples
const gamepad = navigator.getGamepads()[0];
gamepad.hapticActuators[0].pulse(1.0, 200);
gamepad.vibrationActuator.playEffect("dual-rumble", {
startDelay: 0,
duration: 200,
weakMagnitude: 1.0,
strongMagnitude: 1.0,
});
Specifications
| Specification |
|---|
| Gamepad # gamepadhapticactuator-interface |
Browser compatibility
| desktop | mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
GamepadHapticActuator
|
|
|
|
|
|
|
|
|
|
|
|
|
canPlayEffectType
|
|
|
|
|
|
|
|
|
|
|
|
|
effects
|
|
|
|
|
|
|
|
|
|
|
|
|
trigger-rumble effect type
|
|
|
|
|
|
|
|
|
|
|
|
|
playEffect
|
|
|
|
|
|
|
|
|
|
|
|
|
params.leftTrigger parameter
|
|
|
|
|
|
|
|
|
|
|
|
|
params.rightTrigger parameter
|
|
|
|
|
|
|
|
|
|
|
|
|
trigger-rumble effect type
|
|
|
|
|
|
|
|
|
|
|
|
|
pulse
|
|
|
|
|
|
|
|
|
|
|
|
|
reset
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Secure context required
|
|
|
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
|
|
|
|
|
|
|
|
|
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- Experimental. Expect behavior to change in the future.
- Non-standard. Check cross-browser support before using.
- Deprecated. Not for use in new websites.
- User must explicitly enable this feature.