w3c / gamepad

Gamepad
https://w3c.github.io/gamepad/
Other
139 stars 49 forks source link

Xbox One impulse trigger effects #138

Closed nondebug closed 3 months ago

nondebug commented 3 years ago

The haptic vibration proposal (https://github.com/w3c/gamepad/pull/68) only defines the typical "dual-rumble" style rumble effect with strong/weak ERM actuators. Xbox One controllers additionally have Impulse Triggers: haptic actuators that can be used to create effects localized to a particular trigger. To support these let's add new actuator types, for instance:

    enum GamepadHapticActuatorType {    
      "dual-rumble",
      "impulse-trigger-left",  // NEW
      "impulse-trigger-right",  // NEW
    };

Xbox One impulse triggers can be controlled on Windows 10 using the Windows.Gaming.Input API.

marcoscaceres commented 3 years ago

Seems pretty straight forward to add. As I'm new to the actuator discussion, what's that envisioned API shape for activating an actuator look like? Is it something like gamepad.something("impulse-trigger-left", 0.4) ?

nondebug commented 3 years ago

The activation method could be the same as for dual-rumble effects but with a different set of parameters.

// 1 second dual-rumble effect (100% strong, 50% weak)
navigator.getGamepads()[0].vibrationActuator.playEffect("dual-rumble", {
    strongMagnitude: 1.0,
    weakMagnitude: 0.5,
    duration: 1000
});

// 1 second impulse trigger effect, left trigger (40% magnitude)
navigator.getGamepads()[0].vibrationActuator.playEffect("impulse-trigger-left", {
    magnitude: 0.4,
    duration: 1000
});

It might make sense to also have a combined impulse-trigger effect to make it easier to send effects to both triggers at the same time.

// 1 second impulse trigger effect, both triggers (10% left, 20% right)
navigator.getGamepads()[0].vibrationActuator.playEffect("impulse-trigger", {
    leftMagnitude: 0.1,
    rightMagnitude: 0.2,
    duration: 1000
});

The vibrationActuator object should also support querying its capabilities so applications can determine if impulse trigger effects are supported.

-> navigator.getGamepads()[0].vibrationActuator.effects
<- [ "dual-rumble", "impulse-trigger", "impulse-trigger-left", "impulse-trigger-right" ]
marcoscaceres commented 3 years ago

Ok cool, thanks for the explanation. Makes sense :D

mrmcpowned commented 3 years ago

@nondebug I believe you wrote this proposal as well which would be good to have handy here for reference as well

gabrielsanbrito commented 2 years ago

Hi! We have written a proposal for this extension. What do you think?

DJm00n commented 2 years ago

@gabrielsanbrito gamepad trigger vibration is also feature (among others) of Sony DualSense controller (PS5 one) - and could be implemented with it too.