How to use the buttplug.SingleMotorVibrateCmd function in buttplug

To help you get started, we’ve selected a few buttplug examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github metafetish / syncydink / tests / haptics-tests.ts View on Github external
it("Should zip multiple command arrays correctly", async () => {
    const fleshlightMap = new Map();
    const fleshlightCommands = [new FleshlightLaunchFW12Cmd(10, 20),
                                new FleshlightLaunchFW12Cmd(20, 30),
                                new FleshlightLaunchFW12Cmd(30, 40)];
    fleshlightMap.set(1, [fleshlightCommands[0]]);
    fleshlightMap.set(3, [fleshlightCommands[1]]);
    fleshlightMap.set(5, [fleshlightCommands[2]]);
    fleshlightMap.set(10, [fleshlightCommands[0]]);
    const vibrateMap = new Map();
    const vibrateCommands = [new SingleMotorVibrateCmd(10),
                             new SingleMotorVibrateCmd(20),
                             new SingleMotorVibrateCmd(30)];
    vibrateMap.set(1, [vibrateCommands[0]]);
    vibrateMap.set(2, [vibrateCommands[1]]);
    vibrateMap.set(4, [vibrateCommands[2]]);
    // Map with no messages
    const emptyMap = new Map();
    const commandArray = HapticCommandToButtplugMessage.ZipCommandMaps([fleshlightMap, vibrateMap, emptyMap]);
    const expectedCommandArray = new Map();
    expectedCommandArray.set(1, [fleshlightCommands[0], vibrateCommands[0]]);
    expectedCommandArray.set(2, [vibrateCommands[1]]);
    expectedCommandArray.set(3, [fleshlightCommands[1]]);
    expectedCommandArray.set(4, [vibrateCommands[2]]);
    expectedCommandArray.set(5, [fleshlightCommands[2]]);
    expectedCommandArray.set(10, [fleshlightCommands[0]]);
    expect(commandArray).to.deep.equal(expectedCommandArray);
    expect(Array.from(commandArray.keys())).to.deep.equal([1, 2, 3, 4, 5, 10]);
github metafetish / syncydink / tests / haptics-tests.ts View on Github external
it("Should zip multiple command arrays correctly", async () => {
    const fleshlightMap = new Map();
    const fleshlightCommands = [new FleshlightLaunchFW12Cmd(10, 20),
                                new FleshlightLaunchFW12Cmd(20, 30),
                                new FleshlightLaunchFW12Cmd(30, 40)];
    fleshlightMap.set(1, [fleshlightCommands[0]]);
    fleshlightMap.set(3, [fleshlightCommands[1]]);
    fleshlightMap.set(5, [fleshlightCommands[2]]);
    fleshlightMap.set(10, [fleshlightCommands[0]]);
    const vibrateMap = new Map();
    const vibrateCommands = [new SingleMotorVibrateCmd(10),
                             new SingleMotorVibrateCmd(20),
                             new SingleMotorVibrateCmd(30)];
    vibrateMap.set(1, [vibrateCommands[0]]);
    vibrateMap.set(2, [vibrateCommands[1]]);
    vibrateMap.set(4, [vibrateCommands[2]]);
    // Map with no messages
    const emptyMap = new Map();
    const commandArray = HapticCommandToButtplugMessage.ZipCommandMaps([fleshlightMap, vibrateMap, emptyMap]);
    const expectedCommandArray = new Map();
    expectedCommandArray.set(1, [fleshlightCommands[0], vibrateCommands[0]]);
    expectedCommandArray.set(2, [vibrateCommands[1]]);
    expectedCommandArray.set(3, [fleshlightCommands[1]]);
    expectedCommandArray.set(4, [vibrateCommands[2]]);
    expectedCommandArray.set(5, [fleshlightCommands[2]]);
    expectedCommandArray.set(10, [fleshlightCommands[0]]);
    expect(commandArray).to.deep.equal(expectedCommandArray);
github metafetish / syncydink / tests / haptics-tests.ts View on Github external
it("Should zip multiple command arrays correctly", async () => {
    const fleshlightMap = new Map();
    const fleshlightCommands = [new FleshlightLaunchFW12Cmd(10, 20),
                                new FleshlightLaunchFW12Cmd(20, 30),
                                new FleshlightLaunchFW12Cmd(30, 40)];
    fleshlightMap.set(1, [fleshlightCommands[0]]);
    fleshlightMap.set(3, [fleshlightCommands[1]]);
    fleshlightMap.set(5, [fleshlightCommands[2]]);
    fleshlightMap.set(10, [fleshlightCommands[0]]);
    const vibrateMap = new Map();
    const vibrateCommands = [new SingleMotorVibrateCmd(10),
                             new SingleMotorVibrateCmd(20),
                             new SingleMotorVibrateCmd(30)];
    vibrateMap.set(1, [vibrateCommands[0]]);
    vibrateMap.set(2, [vibrateCommands[1]]);
    vibrateMap.set(4, [vibrateCommands[2]]);
    // Map with no messages
    const emptyMap = new Map();
    const commandArray = HapticCommandToButtplugMessage.ZipCommandMaps([fleshlightMap, vibrateMap, emptyMap]);
    const expectedCommandArray = new Map();
    expectedCommandArray.set(1, [fleshlightCommands[0], vibrateCommands[0]]);
    expectedCommandArray.set(2, [vibrateCommands[1]]);
    expectedCommandArray.set(3, [fleshlightCommands[1]]);
    expectedCommandArray.set(4, [vibrateCommands[2]]);
    expectedCommandArray.set(5, [fleshlightCommands[2]]);
    expectedCommandArray.set(10, [fleshlightCommands[0]]);
    expect(commandArray).to.deep.equal(expectedCommandArray);
    expect(Array.from(commandArray.keys())).to.deep.equal([1, 2, 3, 4, 5, 10]);
  });
github metafetish / syncydink / src / utils / HapticsToButtplug.ts View on Github external
for (const aCommand of aCommands) {
      if (lastTime < 0) {
        lastTime = aCommand.Time;
        lastPosition = aCommand.Position;
        continue;
      }
      currentTime = aCommand.Time;
      currentPosition = aCommand.Position;

      timeDelta = currentTime - lastTime;
      // Set a maximum time delta, otherwise we'll have ramps that can last
      // multiple minutes.
      if (timeDelta > 5000) {
        timeDelta = 5000;
        commands.set(lastTime + timeDelta + 1, [new SingleMotorVibrateCmd(0)]);
      }

      timeSteps = Math.floor(timeDelta / density);
      posStep = ((currentPosition - lastPosition) / 100) / timeSteps;
      step = 0;
      while (lastTime + (step * density) < currentTime) {
        commands.set(lastTime + (step * density),
                     [new SingleMotorVibrateCmd((lastPosition * 0.01) + (posStep * step))]);
        step += 1;
      }
      lastTime = currentTime;
      lastPosition = currentPosition;
    }
    // Make sure we stop the vibrator at the end
    commands.set(lastTime + 100, [new SingleMotorVibrateCmd(0)]);
    return commands;
github metafetish / syncydink / src / utils / HapticsToButtplug.ts View on Github external
currentPosition = aCommand.Position;

      timeDelta = currentTime - lastTime;
      // Set a maximum time delta, otherwise we'll have ramps that can last
      // multiple minutes.
      if (timeDelta > 5000) {
        timeDelta = 5000;
        commands.set(lastTime + timeDelta + 1, [new SingleMotorVibrateCmd(0)]);
      }

      timeSteps = Math.floor(timeDelta / density);
      posStep = ((currentPosition - lastPosition) / 100) / timeSteps;
      step = 0;
      while (lastTime + (step * density) < currentTime) {
        commands.set(lastTime + (step * density),
                     [new SingleMotorVibrateCmd((lastPosition * 0.01) + (posStep * step))]);
        step += 1;
      }
      lastTime = currentTime;
      lastPosition = currentPosition;
    }
    // Make sure we stop the vibrator at the end
    commands.set(lastTime + 100, [new SingleMotorVibrateCmd(0)]);
    return commands;
  }
github metafetish / syncydink / src / utils / HapticsToButtplug.ts View on Github external
timeDelta = currentTime - lastTime;

      // Set a maximum time delta, otherwise we'll have ramps that can last
      // multiple minutes.
      if (timeDelta > 5000) {
        timeDelta = 5000;
        commands.set(lastTime + timeDelta + 1, [new SingleMotorVibrateCmd(0)]);
      }

      timeSteps = Math.floor(timeDelta / density);
      posStep = ((currentPosition - lastPosition) / 100) / timeSteps;
      step = 0;
      while (lastTime + (step * density) < currentTime) {
        commands.set(lastTime + (step * density),
                     [new SingleMotorVibrateCmd((lastPosition * 0.01) + (posStep * step))]);
        step += 1;
      }
      lastTime = currentTime;
      lastPosition = currentPosition;
    }
    // Make sure we stop the vibrator at the end
    commands.set(lastTime + 100, [new SingleMotorVibrateCmd(0)]);
    return commands;
  }
}
github metafetish / syncydink / src / utils / HapticsToButtplug.ts View on Github external
commands.set(lastTime + timeDelta + 1, [new SingleMotorVibrateCmd(0)]);
      }

      timeSteps = Math.floor(timeDelta / density);
      posStep = ((currentPosition - lastPosition) / 100) / timeSteps;
      step = 0;
      while (lastTime + (step * density) < currentTime) {
        commands.set(lastTime + (step * density),
                     [new SingleMotorVibrateCmd((lastPosition * 0.01) + (posStep * step))]);
        step += 1;
      }
      lastTime = currentTime;
      lastPosition = currentPosition;
    }
    // Make sure we stop the vibrator at the end
    commands.set(lastTime + 100, [new SingleMotorVibrateCmd(0)]);
    return commands;
  }
}