public async Task Set(ButtplugClientDevice device, IntermediateCommandInformation information) { if (_client == null) { return; } if (device.AllowedMessages.Contains(nameof(SingleMotorVibrateCmd))) { double speedFrom = LaunchToVibrator(information.DeviceInformation.PositionFromOriginal); double speedTo = LaunchToVibrator(information.DeviceInformation.PositionToOriginal); double speed = Math.Min(1, Math.Max(0, speedFrom * (1 - information.Progress) + speedTo * information.Progress)); try { await _clientLock.WaitAsync(); ButtplugMessage response = await _client.SendDeviceMessage(device, new SingleMotorVibrateCmd(device.Index, speed, _client.nextMsgId)); await CheckResponse(response); } finally { _clientLock.Release(); } } }
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 override async Task Set(IntermediateCommandInformation information) { try { await _buttplugAdapter.Set(Device, information); } catch (Exception e) { Debug.WriteLine(e.Message); OnDisconnected(e); } }
public override async Task Set(IntermediateCommandInformation information) { return; // Does not apply }
public async Task Set(ButtplugClientDevice device, IntermediateCommandInformation information) { if (_client == null) { return; } if (device.AllowedMessages.ContainsKey(typeof(SingleMotorVibrateCmd))) { double speed; switch (VibratorConversionMode) { case VibratorConversionMode.PositionToSpeed: { double speedFrom = CommandConverter.LaunchPositionToVibratorSpeed(information.DeviceInformation.PositionFromOriginal); double speedTo = CommandConverter.LaunchPositionToVibratorSpeed(information.DeviceInformation.PositionToOriginal); speed = speedFrom * (1 - information.Progress) + speedTo * information.Progress * information.DeviceInformation.SpeedMultiplier; speed = information.DeviceInformation.TransformSpeed(speed); break; } case VibratorConversionMode.PositionToSpeedInverted: { double speedFrom = CommandConverter.LaunchPositionToVibratorSpeed((byte)(99 - information.DeviceInformation.PositionFromOriginal)); double speedTo = CommandConverter.LaunchPositionToVibratorSpeed((byte)(99 - information.DeviceInformation.PositionToOriginal)); speed = speedFrom * (1 - information.Progress) + speedTo * information.Progress * information.DeviceInformation.SpeedMultiplier; speed = information.DeviceInformation.TransformSpeed(speed); break; } case VibratorConversionMode.SpeedHalfDuration: { if (information.Progress < 0.5) { speed = CommandConverter.LaunchSpeedToVibratorSpeed(information.DeviceInformation.SpeedTransformed); } else { speed = 0.0; } break; } case VibratorConversionMode.SpeedFullDuration: { speed = CommandConverter.LaunchSpeedToVibratorSpeed(information.DeviceInformation.SpeedTransformed); break; } default: throw new ArgumentOutOfRangeException(); } try { await _clientLock.WaitAsync(); await device.SendMessageAsync(new SingleMotorVibrateCmd(device.Index, speed)); //ButtplugMessage response = await device.SendMessageAsync(new SingleMotorVibrateCmd(device.Index, speed)); //await CheckResponse(response); } finally { _clientLock.Release(); } } }
public override Task Set(IntermediateCommandInformation information) { return(Task.CompletedTask); // Does not apply }
public override async Task Set(IntermediateCommandInformation information) { await _buttplugAdapter.Set(_device, information); }
public async Task Set(ButtplugClientDevice device, IntermediateCommandInformation information) { if (_client == null) { return; } if (device.AllowedMessages.ContainsKey(ServerMessage.Types.MessageAttributeType.VibrateCmd)) { double speed; switch (VibratorConversionMode) { case VibratorConversionMode.PositionToSpeed: { double speedFrom = CommandConverter.LaunchPositionToVibratorSpeed(information.DeviceInformation.PositionFromTransformed); double speedTo = CommandConverter.LaunchPositionToVibratorSpeed(information.DeviceInformation.PositionToTransformed); speed = speedFrom * (1 - information.Progress) + speedTo * information.Progress * information.DeviceInformation.SpeedMultiplier; speed = information.DeviceInformation.TransformSpeed(speed); break; } case VibratorConversionMode.PositionToSpeedInverted: { double speedFrom = CommandConverter.LaunchPositionToVibratorSpeed((byte)(99 - information.DeviceInformation.PositionFromTransformed)); double speedTo = CommandConverter.LaunchPositionToVibratorSpeed((byte)(99 - information.DeviceInformation.PositionToTransformed)); speed = speedFrom * (1 - information.Progress) + speedTo * information.Progress * information.DeviceInformation.SpeedMultiplier; speed = information.DeviceInformation.TransformSpeed(speed); break; } case VibratorConversionMode.SpeedHalfDuration: { if ((information.Progress < 0.5) & (information.DeviceInformation.Duration.TotalMilliseconds < 2000)) { speed = CommandConverter.LaunchSpeedToVibratorSpeed(information.DeviceInformation.SpeedTransformed); } else { speed = 0.0; } break; } case VibratorConversionMode.SpeedFullDuration: { speed = CommandConverter.LaunchSpeedToVibratorSpeed(information.DeviceInformation.SpeedTransformed); break; } case VibratorConversionMode.SpeedTimesLengthFullDuration: { speed = CommandConverter.LaunchSpeedAndLengthToVibratorSpeed( information.DeviceInformation.SpeedTransformed, information.DeviceInformation.PositionFromTransformed, information.DeviceInformation.PositionToTransformed); speed *= 5.0; break; } case VibratorConversionMode.SpeedTimesLengthHalfDuration: { if ((information.Progress < 0.5) & (information.DeviceInformation.Duration.TotalMilliseconds < 2000)) { speed = CommandConverter.LaunchSpeedAndLengthToVibratorSpeed( information.DeviceInformation.SpeedTransformed, information.DeviceInformation.PositionFromTransformed, information.DeviceInformation.PositionToTransformed); speed *= 5.0; } else { speed = 0.0; } break; } default: throw new ArgumentOutOfRangeException(); } try { await _clientLock.WaitAsync(); await device.SendVibrateCmd(speed); //ButtplugMessage response = await device.SendMessageAsync(new SingleMotorVibrateCmd(device.Index, speed)); //await CheckResponse(response); } catch (Exception e) { RecordButtplugException("ButtplugAdapter.Set(bcd, ici)", e); } finally { _clientLock.Release(); } } }