Skip to content

"Disable vibration" addon #1120

@DNin01

Description

@DNin01

Just a "dangerous" addon that you can turn on to disable the vibration features of some TurboWarp extensions.

Dangerous addons, remove feedback button, disable cloud variables, disable vibration, disable compiler in editor, and running block border pictured

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);
      }
    }
  }

@GarboMuffin

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions