Re: [w3c/gamepad] Vibrate feature for Gamepad (#19)

@razvanphp I think this is not easily doable, but patches are welcome and I think this would be a good addition to the API.

Note that Microsoft is now interested in developing a new [HapticsDevice API](https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/main/HapticsDevice/explainer.md) which I think would be the best path forward to support advanced haptics for racing wheels. We can still support wheel vibration through vibrationActuator but HapticsDevice could enable support for more advanced haptic effects. Please take a look at the explainer and consider reaching out to @bmathwig to discuss how racing wheels would be supported.

I purchased a Logitech G29 to investigate adding support for racing wheels and found that it did not have a dedicated vibration actuator. Instead, applications can rapidly turn the wheel actuator back and forth to emulate a rumble effect.

I don't know how we can do this safely without vendor support. If we're sending commands to control wheel haptics we need to be very careful not to send commands that would cause the wheel to rotate with dangerous force. The difference between a "dangerous" haptics command and a "safe" rumble command is subtle enough that I'm not confident we can write a simple test to guarantee we are always operating safely. It needs to be fail-safe so that if the browser exits unexpectedly the device is always released in a safe state. I would rather rely on vendor documentation or drivers to ensure we are operating within safe parameters.

The first step is to **create an application demonstrating how to simulate a dual-rumble vibration effect on a specific Logitech or Thrustmaster device**. dual-rumble has two vibration channels that rumble at different (unspecified) frequencies, a lower-frequency "strong" channel and a higher-frequency "weak" channel. Ideally we would generate an effect that scales two oscillators and adds them together to represent the "strong" and "weak" actuators. I'm not sure whether wheel actuators are good enough to simulate that sort of combined effect. If that's not achievable then we could simply use max(strong,weak) to scale a single oscillator.

On Windows, I suspect we can support racing wheel haptics through [Windows.Gaming.Input.ForceFeedback](https://docs.microsoft.com/en-us/uwp/api/windows.gaming.input.forcefeedback) and this might be a good option for developing the demo app. As an alternative, we have an [ongoing effort](https://crbug.com/1098876) to add a new Windows data fetcher that consumes inputs from the Windows.Gaming.Input API instead of XInput: [WgiDataFetcherWin](https://source.chromium.org/chromium/chromium/src/+/main:device/gamepad/wgi_data_fetcher_win.h). Support for dual-rumble was [recently added](https://crrev.com/c/3347270). It might be easier to add experimental racing wheel support to WgiDataFetcherWin than to develop a standalone demo. If you're interested in going that route, let's coordinate on the [bug](https://crbug.com/1098876).

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/gamepad/issues/19#issuecomment-1027260690
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/gamepad/issues/19/1027260690@github.com>

Received on Tuesday, 1 February 2022 20:32:38 UTC