Re: Generic Sensor API and Gamepad API?

Hi Vincent, All,

> On 01 Nov 2016, at 22:06, Vincent Scheib <scheib@google.com> wrote:
> 
> I'm curious for an early feasibility check of using the Generic Sensor API to support Gamepads.
> 
> I have mixed initial instincts, given that Gamepads are fairly specialized HIDs with a cluster of sensors that are appropriate to manage in a first class way. However, those working on the Generic Sensor API may have reasonable arguments for how this may come together nicely after all.

Thanks for bringing this up. This would be an interesting area to experiment on. I cc'd Alexander, Mikhail, and Riju who edit Generic Sensor API-based Accelerometer, Gyroscope, Magnetometer with me, and Tobie who's editing the Generic Sensor API, the spec for the abstract base class. Generally speaking, reusing Generic Sensor API where it makes sense is a good idea.

For pointers to these specs, see https://www.w3.org/2009/dap/#sensors

Vincent - to continue this discussion and make sure we loop in all interested folks, I'd suggest you open an issue at https://github.com/w3c/sensors/issues, perhaps cross-link it to an appropriate issue at https://github.com/w3c/gamepad/issues (if any).

Some initial thoughts below:

The Gamepad API (https://w3c.github.io/gamepad/) has proposed extensions (https://w3c.github.io/gamepad/extensions.html) purpose-built for WebVR use cases. Brandon has specced and implemented the extensions in Chromium (in the experimental Chromium WebVR build behind the enable-gamepad-extensions flag).

The GamepadPose interface (https://w3c.github.io/gamepad/extensions.html#gamepadpose-interface) in the extension spec is currently reusing the VRPose (https://w3c.github.io/webvr/#interface-vrpose) definitions from the WebVR API. The Float32Array type is used for position, linearVelocity, linearAcceleration et al. to make it a good fit for passing data to WebGL (same rationale as for the WebVR API).

In order to use the Generic Sensor API for Gamepad API, these attributes could instead expose an instance of Generic Sensor API-based Accelerometer (https://w3c.github.io/accelerometer/#accelerometer-interface) or Gyroscope (https://w3c.github.io/gyroscope/#gyroscope-interface). We could perhaps expose their sensor data also in Float32Array type in future versions of the specs given good use cases (making data passing to WebGL easier and more performant sounds like a good use case).

On a related note, in https://github.com/w3c/webvr/issues/134 there's a similar discussion whether DOMMatrix should be used in the WebVR API instead of Float32Arrays for matrices.

Thanks,

-Anssi

Received on Wednesday, 2 November 2016 13:44:57 UTC