Re: [w3c/gamepad] Move vibrationActuator to the main spec (PR #190)

@marcoscaceres commented on this pull request.



> @@ -153,6 +153,7 @@ <h2>
           readonly attribute GamepadMappingType mapping;
           readonly attribute FrozenArray&lt;double&gt; axes;
           readonly attribute FrozenArray&lt;GamepadButton&gt; buttons;
+          [SameObject] readonly attribute GamepadHapticActuator? vibrationActuator;

supporting null, seems a bit iffy to be honest (and kinda a pain to implement, because you need to know if you can play effects before you bind the object). 

My preference would be to make it non-nullable, as it's still an expectation that canPlayEffectType() can still return not-supported for everything. 

Also, the actual feature detection check is if it's `undefined` right now for browsers that don't implement this. 

Yes, there is risk of breakage for browsers, but developers still need to check (fake code for example):

```JS
// is supported at all
if (gamepad.vibrationActuator !== undefined) {
   // it's implemented, but can't play anything
    if (gamepad.vibrationActuator !== null) {
      // can it play the thing I need
      if (gamepad.vibrationActuator.canPlayEffectType(type)) {
      }
}
```

Which seems excessive. It should just be regular (which will work regardless):

```JS
if (gamepad.vibrationActuator?.canPlayEffectType(type)) {
   // play it...
}
```

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/gamepad/pull/190#discussion_r1407279246
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/gamepad/pull/190/review/1752140777@github.com>

Received on Tuesday, 28 November 2023 06:21:36 UTC