GamepadHapticActuator

فهرست فصل‌ها دانلود آرشیوناشر

MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونه‌کد

{{APIRef("Gamepad API")}}

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 {{domxref("Gamepad.hapticActuators")}} property.

Instance properties

  • {{domxref("GamepadHapticActuator.effects")}} {{ReadOnlyInline}} {{experimental_inline}}
  • : Returns an array of enumerated values representing the different haptic effects that the actuator supports.
  • {{domxref("GamepadHapticActuator.type")}} {{deprecated_inline}} {{ReadOnlyInline}} {{non-standard_inline}}
  • : Returns an enumerated value representing the type of the haptic hardware. This property is deprecated: use GamepadHapticActuator.effects to detect effect support.

Instance methods

  • {{domxref("GamepadHapticActuator.playEffect()")}}
  • : Causes the hardware to play a specific vibration effect.
  • {{domxref("GamepadHapticActuator.pulse()")}}
  • : Makes the hardware pulse at a certain intensity for a specified duration.
  • {{domxref("GamepadHapticActuator.reset()")}}
  • : Stops the hardware from playing an active vibration effect.

Examples

js
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

{{Specifications}}

Browser compatibility

{{Compat}}

See also