How to use buttplug - 10 common examples

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 / 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();
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]]);
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]);
github buttplugio / buttplug-js / packages / buttplug-server-cli / src / local.ts View on Github external
async function main() {
  process.on("unhandledRejection", (reason, p) => {
    console.log("Unhandled Rejection at: Promise", p, "reason:", reason);
    // application specific logging, throwing an error, or other logic here
  });

  commander
    .version("0.0.1-alpha")
    .parse(process.argv);
  let res;
  const p = new Promise((resolve, reject) => { res = resolve });
  const bs = new ButtplugServer();
  bs.AddDeviceManager(new ButtplugNodeBluetoothLEDeviceManager());
  const localConnector = new ButtplugEmbeddedServerConnector();
  localConnector.Server = bs;
  const bc = new ButtplugClient("Buttplug Local Client");
  await bc.Connect(localConnector);
  bc.on("deviceadded", (d) => {
    console.log(`Device Found: ${d.Name}`);
    res();
  });
  console.log("starting scan");
  await bc.StartScanning();
  console.log("scanning");
  await p;
  console.log("Found a device, exiting.")
  await bc.Disconnect();
  process.exit();
}
github buttplugio / buttplug-js / packages / buttplug-server-cli / src / local.ts View on Github external
async function main() {
  process.on("unhandledRejection", (reason, p) => {
    console.log("Unhandled Rejection at: Promise", p, "reason:", reason);
    // application specific logging, throwing an error, or other logic here
  });

  commander
    .version("0.0.1-alpha")
    .parse(process.argv);
  let res;
  const p = new Promise((resolve, reject) => { res = resolve });
  const bs = new ButtplugServer();
  bs.AddDeviceManager(new ButtplugNodeBluetoothLEDeviceManager());
  const localConnector = new ButtplugEmbeddedServerConnector();
  localConnector.Server = bs;
  const bc = new ButtplugClient("Buttplug Local Client");
  await bc.Connect(localConnector);
  bc.on("deviceadded", (d) => {
    console.log(`Device Found: ${d.Name}`);
    res();
  });
  console.log("starting scan");
  await bc.StartScanning();
  console.log("scanning");
  await p;
  console.log("Found a device, exiting.")
  await bc.Disconnect();
  process.exit();
}
github buttplugio / buttplug-js / packages / buttplug-server-cli / src / local.ts View on Github external
async function main() {
  process.on("unhandledRejection", (reason, p) => {
    console.log("Unhandled Rejection at: Promise", p, "reason:", reason);
    // application specific logging, throwing an error, or other logic here
  });

  commander
    .version("0.0.1-alpha")
    .parse(process.argv);
  let res;
  const p = new Promise((resolve, reject) => { res = resolve });
  const bs = new ButtplugServer();
  bs.AddDeviceManager(new ButtplugNodeBluetoothLEDeviceManager());
  const localConnector = new ButtplugEmbeddedServerConnector();
  localConnector.Server = bs;
  const bc = new ButtplugClient("Buttplug Local Client");
  await bc.Connect(localConnector);
  bc.on("deviceadded", (d) => {
    console.log(`Device Found: ${d.Name}`);
    res();
  });
  console.log("starting scan");
  await bc.StartScanning();
  console.log("scanning");
  await p;
  console.log("Found a device, exiting.")
  await bc.Disconnect();
  process.exit();
github buttplugio / buttplug-js / packages / buttplug-node-bluetoothle-manager / src / ButtplugNodeBluetoothLEDevice.ts View on Github external
continue;
      }
      // If no characteristics are present in the DeviceInfo block, we assume that
      // we're connecting to a simple rx/tx service, and can query to figure out
      // characteristics. Assume that the characteristics have tx/rx references.
      const characteristics = await discoverCharsAsync([]);
      for (const char of characteristics) {
        if (char.properties.indexOf("write") !== -1 ||
            char.properties.indexOf("writeWithoutResponse") !== -1 ||
            char.properties.indexOf("reliableWrite") !== -1) {
          this._characteristics.set(Endpoints.Tx, char);
        } else if (char.properties.indexOf("read") !== -1 ||
                   char.properties.indexOf("broadcast") !== -1 ||
                   char.properties.indexOf("notify") !== -1 ||
                   char.properties.indexOf("indicate") !== -1) {
          this._characteristics.set(Endpoints.Rx, char);
        }
      }
    }
    if (this._characteristics.size === 0) {
      const err = `No characteristics found for device ${this.Name}, cannot communicate with device.`;
      throw new ButtplugDeviceException(err);
    }
    this._device.once("disconnect", () => {
      this.emit("deviceremoved");
    });
  }