-
Notifications
You must be signed in to change notification settings - Fork 22.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gamepad trigger-rumble and associated updates #34442
Changes from 3 commits
35d16e4
d3a1346
fa06c58
7cbb46e
fd1eaa3
7890ac7
d87068f
61d560f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if you want to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @tomayac! I wasn't 100% sure what you meant, but I've tried to update both pages as suggested. Let me know what you think! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've swapped the order as you suggested, and converted both examples to use |
||
``` | ||
|
||
## Specifications | ||
|
||
{{Specifications}} | ||
|
||
## Browser compatibility | ||
|
||
{{Compat}} | ||
|
||
## See also | ||
|
||
- [Gamepad API](/en-US/docs/Web/API/Gamepad_API) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,22 +3,34 @@ title: "GamepadHapticActuator: type property" | |
short-title: type | ||
slug: Web/API/GamepadHapticActuator/type | ||
page-type: web-api-instance-property | ||
status: | ||
- deprecated | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These days the source of truth for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, good call. I've just done that. |
||
browser-compat: api.GamepadHapticActuator.type | ||
--- | ||
|
||
{{APIRef("Gamepad")}} | ||
{{APIRef("Gamepad API")}}{{deprecated_header}} | ||
|
||
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. | ||
|
||
This property is deprecated: use {{domxref("GamepadHapticActuator.effects")}} to detect effect support. | ||
|
||
## 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. | ||
- `"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 | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
highly subjective, but I think this is overly repetitive, and in this situation I just say:
I wish we had a consistent way to write default values for optional items.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, mine is wordier, but it is also a bit more intuitive. Saying that, I don't think it really adds much, so I've updated it to your suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is, and if this were the only place we document a default I would prefer it. But there are (obviously) thousands of places we document defaults, and if every one says "If omitted,
thing
defaults tovalue
" then it is very repetitive: "if omitted" essentially repeats the definition of "default" every time. IMO MDN really misses a structured consistent way to represent "default", that's not just in prose at all.