public async Task Set(ButtplugClientDevice device, IntermediateCommandInformation information) { if (_client == null) { return; } if (device.AllowedMessages.ContainsKey(nameof(SingleMotorVibrateCmd))) { double speedFrom = CommandConverter.LaunchToVibrator(information.DeviceInformation.PositionFromOriginal); double speedTo = CommandConverter.LaunchToVibrator(information.DeviceInformation.PositionToOriginal); double speed = speedFrom * (1 - information.Progress) + speedTo * information.Progress * information.DeviceInformation.SpeedMultiplier; speed = information.DeviceInformation.TransformSpeed(speed); try { await _clientLock.WaitAsync(); ButtplugMessage response = await _client.SendDeviceMessage(device, new SingleMotorVibrateCmd(device.Index, speed)); await CheckResponse(response); } finally { _clientLock.Release(); } } }
public async Task Set(ButtplugClientDevice device, DeviceCommandInformation information) { if (_client == null) { return; } try { await _clientLock.WaitAsync(); ButtplugDeviceMessage message = null; if (device.AllowedMessages.ContainsKey(nameof(FleshlightLaunchFW12Cmd))) { message = new FleshlightLaunchFW12Cmd(device.Index, information.SpeedTransformed, information.PositionToTransformed); } else if (device.AllowedMessages.ContainsKey(nameof(KiirooCmd))) { message = new KiirooCmd(device.Index, CommandConverter.LaunchToKiiroo(information.PositionToOriginal, 0, 4)); } /*else if (device.AllowedMessages.ContainsKey(nameof(VibrateCmd))) * { * message = new VibrateCmd(device.Index, new List<VibrateCmd.VibrateSubcommand>{new VibrateCmd.VibrateSubcommand(0, LaunchToVibrator(information.PositionFromOriginal))}); * }*/ else if (device.AllowedMessages.ContainsKey(nameof(SingleMotorVibrateCmd))) { message = new SingleMotorVibrateCmd(device.Index, information.TransformSpeed(CommandConverter.LaunchToVibrator(information.PositionFromOriginal))); } else if (device.AllowedMessages.ContainsKey(nameof(VorzeA10CycloneCmd))) { message = new VorzeA10CycloneCmd(device.Index, CommandConverter.LaunchToVorzeSpeed(information), information.PositionToTransformed > information.PositionFromTransformed); } else if (device.AllowedMessages.ContainsKey(nameof(LovenseCmd))) { //message = new LovenseCmd(device.Index, LaunchToLovense(position, speed)); } if (message == null) { return; } ButtplugMessage response = await _client.SendDeviceMessage(device, message); await CheckResponse(response); } finally { _clientLock.Release(); } }