From 35d16e4fddc8d581ec090b196953cc634f67b7d5 Mon Sep 17 00:00:00 2001 From: Chris Mills Date: Thu, 27 Jun 2024 08:32:44 +0100 Subject: [PATCH 1/6] Gamepad trigger-rumble and associated updates --- files/en-us/web/api/gamepadhapticactuator/index.md | 4 +++- files/en-us/web/api/gamepadhapticactuator/type/index.md | 9 ++++++--- files/jsondata/GroupData.json | 7 ++++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/files/en-us/web/api/gamepadhapticactuator/index.md b/files/en-us/web/api/gamepadhapticactuator/index.md index a3b40c8b616ee17..d5f57d283301c80 100644 --- a/files/en-us/web/api/gamepadhapticactuator/index.md +++ b/files/en-us/web/api/gamepadhapticactuator/index.md @@ -14,7 +14,9 @@ This interface is accessible through the {{domxref("Gamepad.hapticActuators")}} ## Instance properties - {{domxref("GamepadHapticActuator.type")}} {{ReadOnlyInline}} - - : Returns an enum representing the type of the haptic hardware. + - : Returns an enumerated value representing the type of the haptic hardware. +- {{domxref("GamepadHapticActuator.effects")}} {{ReadOnlyInline}} + - : Returns an array of enumerated values representing the different haptic effects that the actuator supports. ## Instance methods diff --git a/files/en-us/web/api/gamepadhapticactuator/type/index.md b/files/en-us/web/api/gamepadhapticactuator/type/index.md index 2ee3e8226daefda..4f89c3e0a899da9 100644 --- a/files/en-us/web/api/gamepadhapticactuator/type/index.md +++ b/files/en-us/web/api/gamepadhapticactuator/type/index.md @@ -8,13 +8,16 @@ browser-compat: api.GamepadHapticActuator.type {{APIRef("Gamepad")}} -The **`type`** read-only property of the {{domxref("GamepadHapticActuator")}} interface returns an enum representing the type of the haptic hardware. +The **`type`** read-only property of the {{domxref("GamepadHapticActuator")}} interface returns an enumerated value representing the type of the haptic hardware. ## Value -An enum of type [`GamepadHapticActuatorType`](https://w3c.github.io/gamepad/extensions.html#gamepadhapticactuatortype-enum); currently available types are: +An enumerated value representing the haptic hardware type. Currently available types are: -- `vibration` — vibration hardware, which creates a rumbling effect. +- `dual-rumble` + - : vibration hardware, which creates a rumbling effect. +- `trigger-rumble` + - : vibration hardware, which creates a rumbling effect. ## Examples diff --git a/files/jsondata/GroupData.json b/files/jsondata/GroupData.json index 00819ddcc4004c0..71362d02cdf2deb 100644 --- a/files/jsondata/GroupData.json +++ b/files/jsondata/GroupData.json @@ -623,7 +623,12 @@ "/docs/Web/API/Gamepad_API/Using_the_Gamepad_API", "/docs/Games/Techniques/Controls_Gamepad_API" ], - "interfaces": ["Gamepad", "GamepadButton", "GamepadEvent"], + "interfaces": [ + "Gamepad", + "GamepadButton", + "GamepadEvent", + "GamepadHapticActuator" + ], "methods": ["Navigator.getGamepads()"], "properties": [], "events": ["Window: gamepadconnected", "Window: gamepaddisconnected"] From d3a13462ab0cd1908f3fa4fd96ab6e9b6f3dfed1 Mon Sep 17 00:00:00 2001 From: Chris Mills Date: Thu, 27 Jun 2024 12:43:35 +0100 Subject: [PATCH 2/6] Complete documentation updates --- .../gamepadhapticactuator/effects/index.md | 43 +++++++++++++++ .../web/api/gamepadhapticactuator/index.md | 12 ++--- .../gamepadhapticactuator/playeffect/index.md | 28 +++++----- .../api/gamepadhapticactuator/pulse/index.md | 2 +- .../api/gamepadhapticactuator/reset/index.md | 52 +++++++++++++++++++ .../api/gamepadhapticactuator/type/index.md | 17 +++--- 6 files changed, 129 insertions(+), 25 deletions(-) create mode 100644 files/en-us/web/api/gamepadhapticactuator/effects/index.md create mode 100644 files/en-us/web/api/gamepadhapticactuator/reset/index.md diff --git a/files/en-us/web/api/gamepadhapticactuator/effects/index.md b/files/en-us/web/api/gamepadhapticactuator/effects/index.md new file mode 100644 index 000000000000000..12efa1d24e05d1e --- /dev/null +++ b/files/en-us/web/api/gamepadhapticactuator/effects/index.md @@ -0,0 +1,43 @@ +--- +title: "GamepadHapticActuator: effects property" +short-title: effects +slug: Web/API/GamepadHapticActuator/effects +page-type: web-api-instance-property +browser-compat: api.GamepadHapticActuator.effects +--- + +{{APIRef("Gamepad API")}} + +The **`effects`** read-only property of the {{domxref("GamepadHapticActuator")}} interface returns an array of enumerated values representing the different haptic effects that the actuator supports. + +## Value + +An array representing the supported haptic effects. Possible included values are: + +- `"dual-rumble"` + - : A positional rumbling effect created by dual vibration motors in each handle of a controller, which can be vibrated independently. +- `"trigger-rumble"` + - : Localized rumbling effects on the surface of a controller's trigger buttons created by vibrational motors located in each button. These buttons most commonly take the form of spring-loaded triggers. + +> **Note:** If an effect is not listed that is known to be supported by the hardware, it may be that the browser does not support playing effects of that type. + +## Examples + +```js +const gamepad = navigator.getGamepads()[0]; + +// Logs "dual-rumble" or "trigger-rumble" +console.log(gamepad.hapticActuators[0].effects[0]); +``` + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} + +## See also + +- [Gamepad API](/en-US/docs/Web/API/Gamepad_API) diff --git a/files/en-us/web/api/gamepadhapticactuator/index.md b/files/en-us/web/api/gamepadhapticactuator/index.md index d5f57d283301c80..7d22fb76a89cada 100644 --- a/files/en-us/web/api/gamepadhapticactuator/index.md +++ b/files/en-us/web/api/gamepadhapticactuator/index.md @@ -13,19 +13,19 @@ This interface is accessible through the {{domxref("Gamepad.hapticActuators")}} ## Instance properties -- {{domxref("GamepadHapticActuator.type")}} {{ReadOnlyInline}} - - : Returns an enumerated value representing the type of the haptic hardware. - {{domxref("GamepadHapticActuator.effects")}} {{ReadOnlyInline}} - : Returns an array of enumerated values representing the different haptic effects that the actuator supports. +- {{domxref("GamepadHapticActuator.type")}} {{ReadOnlyInline}} + - : Returns an enumerated value representing the type of the haptic hardware. ## Instance methods +- {{domxref("GamepadHapticActuator.playEffect()")}} {{ReadOnlyInline}} + - : Causes the hardware to play a specific vibration effect. - {{domxref("GamepadHapticActuator.pulse()")}} {{ReadOnlyInline}} - - : Makes the hardware pulse at a certain intensity for a specified duration. - -- {{domxref("GamepadHapticActuator.playEffect()")}} {{ReadOnlyInline}} - - : Makes the hardware play a specific vibration pattern. +- {{domxref("GamepadHapticActuator.reset()")}} {{ReadOnlyInline}} + - : Stops the hardware from playing an active vibration effect. ## Examples diff --git a/files/en-us/web/api/gamepadhapticactuator/playeffect/index.md b/files/en-us/web/api/gamepadhapticactuator/playeffect/index.md index 0bd108dec1be672..1c7cd19563dbf9d 100644 --- a/files/en-us/web/api/gamepadhapticactuator/playeffect/index.md +++ b/files/en-us/web/api/gamepadhapticactuator/playeffect/index.md @@ -6,9 +6,9 @@ page-type: web-api-instance-method browser-compat: api.GamepadHapticActuator.playEffect --- -{{APIRef("Gamepad")}} +{{APIRef("Gamepad API")}} -The **`playEffect()`** method of the {{domxref("GamepadHapticActuator")}} interface makes the hardware play a specific vibration pattern. +The **`playEffect()`** method of the {{domxref("GamepadHapticActuator")}} interface causes the hardware to play a specific vibration effect. ## Syntax @@ -20,7 +20,7 @@ playEffect(type, params) - `type` - - : A string representing the desired effect. This can vary depending on the hardware type. Possible values are "dual-rumble" or "vibration". + - : A string representing the desired effect. Possible values are `"dual-rumble"` and `"trigger-rumble"`, and their effects can vary depending on the hardware type. See {{domxref("GamepadHapticActuator.effects")}} for further details of the effect types. - `params` @@ -28,20 +28,24 @@ playEffect(type, params) Expected values are: - - `duration` - - : The duration of the effect in milliseconds. - - `startDelay` - - : The delay in milliseconds before the effect is started. - - `strongMagnitude` - - : Rumble intensity of the low-frequency (strong) rumble motors, normalized to the range between 0.0 and 1.0. - - `weakMagnitude` - - : Rumble intensity of the high-frequency (weak) rumble motors, normalized to the range between 0.0 and 1.0. + - `duration` {{optional_inline}} + - : The duration of the effect in milliseconds. If omitted, `duration` defaults to `0`. + - `startDelay` {{optional_inline}} + - : The delay in milliseconds before the effect is started. If omitted, `startDelay` defaults to `0`. + - `strongMagnitude` {{optional_inline}} + - : The rumble intensity of the low-frequency (strong) rumble motors, normalized to the range between `0.0` and `1.0`. If omitted, `strongMagnitude` defaults to `0.0`. + - `weakMagnitude` {{optional_inline}} + - : The rumble intensity of the high-frequency (weak) rumble motors, normalized to the range between `0.0` and `1.0`. If omitted, `weakMagnitude` defaults to `0.0`. + - `leftTrigger` (relevant to `"trigger-rumble"` effects only) {{optional_inline}} + - : The rumble intensity of the bottom-left front trigger, normalized to the range between `0.0` and `1.0`. If omitted, `leftTrigger` defaults to `0.0`. + - `rightTrigger` (relevant to `"trigger-rumble"` effects only) {{optional_inline}} + - : The rumble intensity of the bottom-right front trigger, normalized to the range between `0.0` and `1.0`. If omitted, `rightTrigger` defaults to `0.0`. > **Note:** A new call to `playEffect()` overrides a previous ongoing call. ### Return value -A promise that resolves with `true` when the playEffect successfully completes. +A promise that resolves with `"complete"` when the effect successfully completes, or `"preempted"` if the current effect is stopped or replaced by another effect. ## Examples diff --git a/files/en-us/web/api/gamepadhapticactuator/pulse/index.md b/files/en-us/web/api/gamepadhapticactuator/pulse/index.md index 04a52b417672dd4..a479b68e74ca28e 100644 --- a/files/en-us/web/api/gamepadhapticactuator/pulse/index.md +++ b/files/en-us/web/api/gamepadhapticactuator/pulse/index.md @@ -6,7 +6,7 @@ page-type: web-api-instance-method browser-compat: api.GamepadHapticActuator.pulse --- -{{APIRef("Gamepad")}} +{{APIRef("Gamepad API")}} The **`pulse()`** method of the {{domxref("GamepadHapticActuator")}} interface makes the hardware pulse at a certain intensity for a specified duration. diff --git a/files/en-us/web/api/gamepadhapticactuator/reset/index.md b/files/en-us/web/api/gamepadhapticactuator/reset/index.md new file mode 100644 index 000000000000000..5083535309c20cd --- /dev/null +++ b/files/en-us/web/api/gamepadhapticactuator/reset/index.md @@ -0,0 +1,52 @@ +--- +title: "GamepadHapticActuator: reset() method" +short-title: reset() +slug: Web/API/GamepadHapticActuator/reset +page-type: web-api-instance-method +browser-compat: api.GamepadHapticActuator.reset +--- + +{{APIRef("Gamepad API")}} + +The **`reset()`** method of the {{domxref("GamepadHapticActuator")}} interface stops the hardware from playing an active vibration effect. + +## Syntax + +```js-nolint +reset() +``` + +### Parameters + +None. + +### Return value + +A promise that resolves with `"complete"` if the effect is successfully reset, or `"preempted"` if the effect was stopped or replaced by another effect. + +## Examples + +```js +const gamepad = navigator.getGamepads()[0]; + +gamepad.vibrationActuator.playEffect("dual-rumble", { + startDelay: 0, + duration: 200, + weakMagnitude: 1.0, + strongMagnitude: 1.0, +}); + +gamepad.vibrationActuator.reset(); +``` + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} + +## See also + +- [Gamepad API](/en-US/docs/Web/API/Gamepad_API) diff --git a/files/en-us/web/api/gamepadhapticactuator/type/index.md b/files/en-us/web/api/gamepadhapticactuator/type/index.md index 4f89c3e0a899da9..ff6a48ec77f7e83 100644 --- a/files/en-us/web/api/gamepadhapticactuator/type/index.md +++ b/files/en-us/web/api/gamepadhapticactuator/type/index.md @@ -6,7 +6,7 @@ page-type: web-api-instance-property browser-compat: api.GamepadHapticActuator.type --- -{{APIRef("Gamepad")}} +{{APIRef("Gamepad API")}} The **`type`** read-only property of the {{domxref("GamepadHapticActuator")}} interface returns an enumerated value representing the type of the haptic hardware. @@ -14,14 +14,19 @@ The **`type`** read-only property of the {{domxref("GamepadHapticActuator")}} in An enumerated value representing the haptic hardware type. Currently available types are: -- `dual-rumble` - - : vibration hardware, which creates a rumbling effect. -- `trigger-rumble` - - : vibration hardware, which creates a rumbling effect. +- `"vibration"` + - : Simple vibration hardware, which creates a rumbling effect. +- `"dual-rumble"` + - : A controller with a vibration motor in each handle. Each motor can be vibrated independently to create positional rumbling effects. ## Examples -TBC +```js +const gamepad = navigator.getGamepads()[0]; + +// Logs "vibration" or "dual-rumble" +console.log(gamepad.hapticActuators[0].type); +``` ## Specifications From fa06c5863e18a669a4936003992d7773a977dbb4 Mon Sep 17 00:00:00 2001 From: Chris Mills Date: Fri, 28 Jun 2024 07:45:00 +0100 Subject: [PATCH 3/6] mark type as deprecated --- files/en-us/web/api/gamepadhapticactuator/index.md | 4 ++-- files/en-us/web/api/gamepadhapticactuator/type/index.md | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/files/en-us/web/api/gamepadhapticactuator/index.md b/files/en-us/web/api/gamepadhapticactuator/index.md index 7d22fb76a89cada..9551ac98a1df921 100644 --- a/files/en-us/web/api/gamepadhapticactuator/index.md +++ b/files/en-us/web/api/gamepadhapticactuator/index.md @@ -15,8 +15,8 @@ This interface is accessible through the {{domxref("Gamepad.hapticActuators")}} - {{domxref("GamepadHapticActuator.effects")}} {{ReadOnlyInline}} - : Returns an array of enumerated values representing the different haptic effects that the actuator supports. -- {{domxref("GamepadHapticActuator.type")}} {{ReadOnlyInline}} - - : Returns an enumerated value representing the type of the haptic hardware. +- {{domxref("GamepadHapticActuator.type")}} {{deprecated_inline}} {{ReadOnlyInline}} + - : Returns an enumerated value representing the type of the haptic hardware. This property is deprecated: use `GamepadHapticActuator.effects` to detect effect support. ## Instance methods diff --git a/files/en-us/web/api/gamepadhapticactuator/type/index.md b/files/en-us/web/api/gamepadhapticactuator/type/index.md index ff6a48ec77f7e83..29a25e3e936317d 100644 --- a/files/en-us/web/api/gamepadhapticactuator/type/index.md +++ b/files/en-us/web/api/gamepadhapticactuator/type/index.md @@ -3,13 +3,17 @@ title: "GamepadHapticActuator: type property" short-title: type slug: Web/API/GamepadHapticActuator/type page-type: web-api-instance-property +status: + - deprecated browser-compat: api.GamepadHapticActuator.type --- -{{APIRef("Gamepad API")}} +{{APIRef("Gamepad API")}}{{deprecated_header}} The **`type`** read-only property of the {{domxref("GamepadHapticActuator")}} interface returns an enumerated value representing the type of the haptic hardware. +This property is deprecated: use {{domxref("GamepadHapticActuator.effects")}} to detect effect support. + ## Value An enumerated value representing the haptic hardware type. Currently available types are: From 7cbb46ed6e0d65a4aadfa43b19562c9352bb406a Mon Sep 17 00:00:00 2001 From: Chris Mills Date: Mon, 8 Jul 2024 10:53:03 +0100 Subject: [PATCH 4/6] Fixes for wbamberg comments --- .../gamepadhapticactuator/playeffect/index.md | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/files/en-us/web/api/gamepadhapticactuator/playeffect/index.md b/files/en-us/web/api/gamepadhapticactuator/playeffect/index.md index 1c7cd19563dbf9d..ace55b9525a6411 100644 --- a/files/en-us/web/api/gamepadhapticactuator/playeffect/index.md +++ b/files/en-us/web/api/gamepadhapticactuator/playeffect/index.md @@ -29,17 +29,23 @@ playEffect(type, params) Expected values are: - `duration` {{optional_inline}} - - : The duration of the effect in milliseconds. If omitted, `duration` defaults to `0`. + - : The duration of the effect in milliseconds. + Defaults to `0`. - `startDelay` {{optional_inline}} - - : The delay in milliseconds before the effect is started. If omitted, `startDelay` defaults to `0`. + - : The delay in milliseconds before the effect is started. + Defaults to `0`. - `strongMagnitude` {{optional_inline}} - - : The rumble intensity of the low-frequency (strong) rumble motors, normalized to the range between `0.0` and `1.0`. If omitted, `strongMagnitude` defaults to `0.0`. + - : The rumble intensity of the low-frequency (strong) rumble motors, normalized to the range between `0.0` and `1.0`. + Defaults to `0.0`. - `weakMagnitude` {{optional_inline}} - - : The rumble intensity of the high-frequency (weak) rumble motors, normalized to the range between `0.0` and `1.0`. If omitted, `weakMagnitude` defaults to `0.0`. + - : The rumble intensity of the high-frequency (weak) rumble motors, normalized to the range between `0.0` and `1.0`. + Defaults to `0.0`. - `leftTrigger` (relevant to `"trigger-rumble"` effects only) {{optional_inline}} - - : The rumble intensity of the bottom-left front trigger, normalized to the range between `0.0` and `1.0`. If omitted, `leftTrigger` defaults to `0.0`. + - : The rumble intensity of the bottom-left front trigger, normalized to the range between `0.0` and `1.0`. + Defaults to `0.0`. - `rightTrigger` (relevant to `"trigger-rumble"` effects only) {{optional_inline}} - - : The rumble intensity of the bottom-right front trigger, normalized to the range between `0.0` and `1.0`. If omitted, `rightTrigger` defaults to `0.0`. + - : The rumble intensity of the bottom-right front trigger, normalized to the range between `0.0` and `1.0`. + Defaults to `0.0`. > **Note:** A new call to `playEffect()` overrides a previous ongoing call. From d87068fe9cd104d93323e00d97786a839d8d9d67 Mon Sep 17 00:00:00 2001 From: Chris Mills Date: Mon, 15 Jul 2024 15:36:10 +0100 Subject: [PATCH 5/6] Improve examples as suggested, add exceptions --- .../gamepadhapticactuator/playeffect/index.md | 26 ++++++++++++---- .../api/gamepadhapticactuator/reset/index.md | 30 ++++++++++++------- 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/files/en-us/web/api/gamepadhapticactuator/playeffect/index.md b/files/en-us/web/api/gamepadhapticactuator/playeffect/index.md index ace55b9525a6411..b9889c48ca1b885 100644 --- a/files/en-us/web/api/gamepadhapticactuator/playeffect/index.md +++ b/files/en-us/web/api/gamepadhapticactuator/playeffect/index.md @@ -53,17 +53,31 @@ playEffect(type, params) A promise that resolves with `"complete"` when the effect successfully completes, or `"preempted"` if the current effect is stopped or replaced by another effect. +The promise may reject with the following exception types: + +- `InvalidStateError` {{domxref("DOMException")}} + - : The current document is not active or hidden. +- `NotSupportedError` {{domxref("DOMException")}} + - : The requested `type` is not supported by the current gamepad's actuator. +- `TypeError` {{domxref("DOMException")}} + - : The requested `type` is not a valid effect type. + ## Examples ```js const gamepad = navigator.getGamepads()[0]; -gamepad.vibrationActuator.playEffect("dual-rumble", { - startDelay: 0, - duration: 200, - weakMagnitude: 1.0, - strongMagnitude: 1.0, -}); +async function playEffect() { + const result = await gamepad.vibrationActuator.playEffect("dual-rumble", { + startDelay: 0, + duration: 200, + weakMagnitude: 1.0, + strongMagnitude: 1.0, + }); + + // Should log "complete" if effect successfully runs + console.log(result); +} ``` ## Specifications diff --git a/files/en-us/web/api/gamepadhapticactuator/reset/index.md b/files/en-us/web/api/gamepadhapticactuator/reset/index.md index 5083535309c20cd..09b32e31e9de616 100644 --- a/files/en-us/web/api/gamepadhapticactuator/reset/index.md +++ b/files/en-us/web/api/gamepadhapticactuator/reset/index.md @@ -24,19 +24,29 @@ None. A promise that resolves with `"complete"` if the effect is successfully reset, or `"preempted"` if the effect was stopped or replaced by another effect. -## Examples +The promise may reject with the following exception types: -```js -const gamepad = navigator.getGamepads()[0]; +- `InvalidStateError` {{domxref("DOMException")}} + - : Promise rejects with `InvalidStateError` if the current document is not active or hidden. -gamepad.vibrationActuator.playEffect("dual-rumble", { - startDelay: 0, - duration: 200, - weakMagnitude: 1.0, - strongMagnitude: 1.0, -}); +## Examples -gamepad.vibrationActuator.reset(); +```js +async function playEffect() { + const result = await gamepad.vibrationActuator.playEffect("dual-rumble", { + startDelay: 0, + duration: 200, + weakMagnitude: 1.0, + strongMagnitude: 1.0, + }); + + setTimeout(() => { + gamepad.vibrationActuator.reset(); + }, 150); + + // Should log "preempted" because reset() was called before the end of the effect + console.log(result); +} ``` ## Specifications From 61d560f155afcdafd604368a66fce8180b9c8715 Mon Sep 17 00:00:00 2001 From: Chris Mills Date: Wed, 17 Jul 2024 11:50:29 +0100 Subject: [PATCH 6/6] further improvements to code examples --- .../gamepadhapticactuator/playeffect/index.md | 12 +++++----- .../api/gamepadhapticactuator/reset/index.md | 22 +++++++++---------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/files/en-us/web/api/gamepadhapticactuator/playeffect/index.md b/files/en-us/web/api/gamepadhapticactuator/playeffect/index.md index b9889c48ca1b885..e07299e94b5a3ea 100644 --- a/files/en-us/web/api/gamepadhapticactuator/playeffect/index.md +++ b/files/en-us/web/api/gamepadhapticactuator/playeffect/index.md @@ -67,17 +67,15 @@ The promise may reject with the following exception types: ```js const gamepad = navigator.getGamepads()[0]; -async function playEffect() { - const result = await gamepad.vibrationActuator.playEffect("dual-rumble", { +gamepad.vibrationActuator + .playEffect("dual-rumble", { startDelay: 0, duration: 200, weakMagnitude: 1.0, strongMagnitude: 1.0, - }); - - // Should log "complete" if effect successfully runs - console.log(result); -} + }) + .then((result) => console.log(result)); +// Should log "complete" if effect successfully runs ``` ## Specifications diff --git a/files/en-us/web/api/gamepadhapticactuator/reset/index.md b/files/en-us/web/api/gamepadhapticactuator/reset/index.md index 09b32e31e9de616..edb24c56c0f40a6 100644 --- a/files/en-us/web/api/gamepadhapticactuator/reset/index.md +++ b/files/en-us/web/api/gamepadhapticactuator/reset/index.md @@ -32,21 +32,21 @@ The promise may reject with the following exception types: ## Examples ```js -async function playEffect() { - const result = await gamepad.vibrationActuator.playEffect("dual-rumble", { +const gamepad = navigator.getGamepads()[0]; + +setTimeout(() => { + gamepad.vibrationActuator.reset(); +}, 150); + +gamepad.vibrationActuator + .playEffect("dual-rumble", { startDelay: 0, duration: 200, weakMagnitude: 1.0, strongMagnitude: 1.0, - }); - - setTimeout(() => { - gamepad.vibrationActuator.reset(); - }, 150); - - // Should log "preempted" because reset() was called before the end of the effect - console.log(result); -} + }) + .then((result) => console.log(result)); +// Should log "preempted" because reset() will run before the effect ends ``` ## Specifications