forked from scratchfoundation/scratch-gui
-
Notifications
You must be signed in to change notification settings - Fork 258
Closed
Description
Just a "dangerous" addon that you can turn on to disable the vibration features of some TurboWarp extensions.
The easiest way to do this would probably be to provide a canVibrate function which returns false when this addon is enabled and true otherwise.
Changes in extension code
rumble({ s, w, t, i }) {
const gamepads = getGamepads(i);
for (const { realGamepad } of gamepads) {
- if (realGamepad.vibrationActuator) {
+ if (Scratch.canVibrate() && realGamepad.vibrationActuator) {
realGamepad.vibrationActuator.playEffect("dual-rumble", {
startDelay: 0,
duration: t * 1000,
weakMagnitude: w,
strongMagnitude: s,
});
}
}
} start(args) {
- if (navigator.vibrate) {
+ if (Scratch.canVibrate() && navigator.vibrate) {
navigator.vibrate(Scratch.Cast.toNumber(args.SECONDS) * 1000);
}
}
startPattern(args) {
- if (navigator.vibrate) {
+ if (Scratch.canVibrate() && navigator.vibrate) {
const pattern = Scratch.Cast.toString(args.PATTERN)
.match(/[\w\-.]+/g) // Make into array
?.map((val) => Scratch.Cast.toNumber(val) * 1000); // Convert to numbers in milliseconds
if (pattern) {
navigator.vibrate(pattern);
}
}
}Metadata
Metadata
Assignees
Labels
No labels