Skip to content
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

Appropriate way to contribute a web API interface that is changing (Gamepad hapticActuators -> vibrationActuator) #4089

Open
brettchalupa opened this issue Aug 22, 2024 · 3 comments

Comments

@brettchalupa
Copy link

brettchalupa commented Aug 22, 2024

Summary

The Gamepad specification is in draft for for how force feedback (a.k.a. rumble, a.k.a. vibration) works. The specification within web-sys for hapticActuators is in Editor's Draft as of 09 August 2024 to change to:

[Exposed=Window]
interface Gamepad {
  readonly attribute DOMString id;
  readonly attribute long index;
  readonly attribute boolean connected;
  readonly attribute DOMHighResTimeStamp timestamp;
  readonly attribute GamepadMappingType mapping;
  readonly attribute FrozenArray<double> axes;
  readonly attribute FrozenArray<GamepadButton> buttons;
  [SameObject] readonly attribute GamepadHapticActuator vibrationActuator;
};

Notice the last line:

[SameObject] readonly attribute GamepadHapticActuator vibrationActuator;

hapticActuators has changed to vibrationActuator, and then the API for what that attribute is, a GamepadHapticActuator, has a new API:

[Exposed=Window]
interface GamepadHapticActuator {
  [SameObject] readonly attribute FrozenArray<GamepadHapticEffectType> effects;
  Promise<GamepadHapticsResult> playEffect(
      GamepadHapticEffectType type,
      optional GamepadEffectParameters params = {}
  );
  Promise<GamepadHapticsResult> reset();
};

This definition differs from what's currently enabled in GamepadHapticActuator.webidl

So my question is this: how does one go about contributing a change to an existing specification in this scenario? Would we add the new ones side-by-side with the existing? Or something else?

Additional Details

  • the Gamepad hapticActuators API is only supported in Firefox (MDN) and is marked as experimental; it does not work from my testing
  • the Gamepad vibrationActuator api is supported in Chrome, Edge, Opera, and Safari (MDN) and functions from my testing
  • hapticActuators appears to be part of an older specification extension
  • I couldn't find the WebIDL file that specifies the whole specification for Gamepad, but I think we can piece it together from https://w3c.github.io/gamepad/

Because many browsers do support the vibrationActuator property and it's in the Gamepad spec draft, it seems like it's the future standard; it'd be awesome is web-sys supported it for implementing rumble for controllers in WASM; that's the core motivation for this addition/change.

I'm happy to do the work to contribute this, but I figure since it's something changing, I should open an issue to start the conversation and get guidance. Thank you!

@daxpedda
Copy link
Collaborator

This API should probably not have been made stable in the first place, but fortunately none of these new additions require a breaking change to the already existing API.

Generally speaking we follow the spec no matter the browser support, but non-stable specifications should never override stable ones.

In this case adding all this new API unstably shouldn't be an issue and we can go ahead and deprecate the old API.

Let me know if you have any issues accomplishing any of this.

@brettchalupa
Copy link
Author

@daxpedda thanks for the guidance, makes sense! I'll dig into adding the new API. Is there any reference/guidance for how to deprecate the old API?

@daxpedda
Copy link
Collaborator

To deprecate an API you just slap the [RustDeprecated] attribute on it.

brettchalupa added a commit to brettchalupa/wasm-bindgen that referenced this issue Aug 29, 2024
The API that currently exists in the repo has been deprecated and the
new API has been added.

This allows gamepads to be rumbled

Spec: https://w3c.github.io/gamepad/

More details: rustwasm#4089
brettchalupa added a commit to brettchalupa/wasm-bindgen that referenced this issue Aug 29, 2024
The API that currently exists in the repo has been deprecated and the
new API has been added.

This allows gamepads to be rumbled

Spec: https://w3c.github.io/gamepad/

More details: rustwasm#4089
brettchalupa added a commit to brettchalupa/wasm-bindgen that referenced this issue Sep 13, 2024
The API that currently exists in the repo has been deprecated and the
new API has been added.

This allows gamepads to be rumbled

Spec: https://w3c.github.io/gamepad/

More details: rustwasm#4089
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants