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

[Extensions] make pulse() more like navigator.vibrate #66

Closed
GrosSacASac opened this issue Nov 28, 2017 · 2 comments
Closed

[Extensions] make pulse() more like navigator.vibrate #66

GrosSacASac opened this issue Nov 28, 2017 · 2 comments
Labels

Comments

@GrosSacASac
Copy link

It would be nice to have pulse be like navigator.vibrate or to have something similar

navigator.vibrate(100) // simple value for duration
navigator.vibrate([100,500, 100]) // array for duration, pause duration patterns

Thoughts ?

@nondebug
Copy link
Collaborator

I think this is insufficient for the types of vibration effects that are common on gamepads. For instance, most modern gamepads support vibrating at varying intensity levels rather than simple on/off durations as used by navigator.vibrate.

I've proposed an alternate extension for vibration effects, please take a look:

#19 (comment)

It's used like this:

let pads = navigator.getGamepads();
pads[0].vibrationActuator.playEffect("dual-rumble", {
    startDelay: 0,
    duration: 1000,
    weakMagnitude: 0.5,
    strongMagnitude: 0.5
});

playEffect returns a Promise that resolves once the effect playback is complete. You can take advantage of this to simulate the on/off durations used by navigator.vibrate:

let startEffect = { duration: 100, weakMagnitude: 1.0 };
let continueEffect = { startDelay: 500, duration: 100, weakMagnitude: 1.0 };
pads[0].vibrationActuator.playEffect("dual-rumble", startEffect).then(() => {
    pads[0].vibrationActuator.playEffect("dual-rumble", continueEffect)
});

@sgraham sgraham added the v2 label Feb 14, 2018
@GrosSacASac
Copy link
Author

closing to continue discussion github.com//issues/19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants