예제 #1
0
        public async Task Set(ButtplugClientDevice device, DeviceCommandInformation information)
        {
            if (_client == null)
            {
                return;
            }

            try
            {
                await _clientLock.WaitAsync();

                if (device.AllowedMessages.ContainsKey(ServerMessage.Types.MessageAttributeType.LinearCmd))
                {
                    await device.SendLinearCmd(
                        (uint)information.DurationStretched.TotalMilliseconds,
                        information.PositionToTransformed);
                }
                else if (device.AllowedMessages.ContainsKey(ServerMessage.Types.MessageAttributeType.VibrateCmd))
                {
                    switch (VibratorConversionMode)
                    {
                    case VibratorConversionMode.PositionToSpeed:
                        await device.SendVibrateCmd(information.TransformSpeed(CommandConverter.LaunchPositionToVibratorSpeed(information.PositionFromOriginal)));

                        break;

                    case VibratorConversionMode.PositionToSpeedInverted:
                        await device.SendVibrateCmd(information.TransformSpeed(CommandConverter.LaunchPositionToVibratorSpeed((byte)(99 - information.PositionFromOriginal))));

                        break;

                    case VibratorConversionMode.SpeedHalfDuration:
                    case VibratorConversionMode.SpeedFullDuration:
                        await device.SendVibrateCmd(information.TransformSpeed(CommandConverter.LaunchSpeedToVibratorSpeed(information.SpeedTransformed)));

                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }
                else if (device.AllowedMessages.ContainsKey(ServerMessage.Types.MessageAttributeType.RotateCmd))
                {
                    await device.SendRotateCmd(CommandConverter.LaunchToVorzeSpeed(information), information.PositionToTransformed > information.PositionFromTransformed);
                }
            }
            catch (Exception e)
            {
                RecordButtplugException("ButtplugAdapter.Set(bcd, dci)", e);
            }
            finally
            {
                _clientLock.Release();
            }
        }
예제 #2
0
        public async Task Set(ButtplugClientDevice device, DeviceCommandInformation information)
        {
            if (_client == null)
            {
                return;
            }

            try
            {
                await _clientLock.WaitAsync();

                if (device.AllowedMessages.ContainsKey(typeof(FleshlightLaunchFW12Cmd)))
                {
                    await device.SendFleshlightLaunchFW12Cmd(information.SpeedTransformed, information.PositionToTransformed);
                }
                else if (device.AllowedMessages.ContainsKey(typeof(VibrateCmd)))
                {
                    switch (VibratorConversionMode)
                    {
                    case VibratorConversionMode.PositionToSpeed:
                        await device.SendVibrateCmd(information.TransformSpeed(CommandConverter.LaunchPositionToVibratorSpeed(information.PositionFromOriginal)));

                        break;

                    case VibratorConversionMode.PositionToSpeedInverted:
                        await device.SendVibrateCmd(information.TransformSpeed(CommandConverter.LaunchPositionToVibratorSpeed((byte)(99 - information.PositionFromOriginal))));

                        break;

                    case VibratorConversionMode.SpeedHalfDuration:
                    case VibratorConversionMode.SpeedFullDuration:
                        await device.SendVibrateCmd(information.TransformSpeed(CommandConverter.LaunchSpeedToVibratorSpeed(information.SpeedTransformed)));

                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }
                else if (device.AllowedMessages.ContainsKey(typeof(VorzeA10CycloneCmd)))
                {
                    await device.SendVorzeA10CycloneCmd(CommandConverter.LaunchToVorzeSpeed(information), information.PositionToTransformed > information.PositionFromTransformed);
                }
            }
            catch (Exception e)
            {
                RecordButtplugException("ButtplugAdapter.Set(bcd, dci)", e);
            }
            finally
            {
                _clientLock.Release();
            }
        }
예제 #3
0
        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();
            }
        }
예제 #4
0
        public async Task Set(ButtplugClientDevice device, DeviceCommandInformation information)
        {
            if (_client == null)
            {
                return;
            }

            try
            {
                await _clientLock.WaitAsync();

                ButtplugDeviceMessage message = null;

                if (device.AllowedMessages.ContainsKey(typeof(FleshlightLaunchFW12Cmd)))
                {
                    message = new FleshlightLaunchFW12Cmd(device.Index, information.SpeedTransformed, information.PositionToTransformed);
                }
                else if (device.AllowedMessages.ContainsKey(typeof(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, LaunchPositionToVibratorSpeed(information.PositionFromOriginal))});
                 * }*/
                else if (device.AllowedMessages.ContainsKey(typeof(SingleMotorVibrateCmd)))
                {
                    switch (VibratorConversionMode)
                    {
                    case VibratorConversionMode.PositionToSpeed:
                        message = new SingleMotorVibrateCmd(device.Index, information.TransformSpeed(CommandConverter.LaunchPositionToVibratorSpeed(information.PositionFromOriginal)));
                        break;

                    case VibratorConversionMode.PositionToSpeedInverted:
                        message = new SingleMotorVibrateCmd(device.Index, information.TransformSpeed(CommandConverter.LaunchPositionToVibratorSpeed((byte)(99 - information.PositionFromOriginal))));
                        break;

                    case VibratorConversionMode.SpeedHalfDuration:
                    case VibratorConversionMode.SpeedFullDuration:
                        message = new SingleMotorVibrateCmd(device.Index, information.TransformSpeed(CommandConverter.LaunchSpeedToVibratorSpeed(information.SpeedTransformed)));
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }
                else if (device.AllowedMessages.ContainsKey(typeof(VorzeA10CycloneCmd)))
                {
                    message = new VorzeA10CycloneCmd(device.Index, CommandConverter.LaunchToVorzeSpeed(information), information.PositionToTransformed > information.PositionFromTransformed);
                }
                else if (device.AllowedMessages.ContainsKey(typeof(LovenseCmd)))
                {
                    //message = new LovenseCmd(device.Index, LaunchToLovense(position, speed));
                }

                if (message == null)
                {
                    return;
                }

                await device.SendMessageAsync(message);

                //ButtplugMessage response = await _client.SendDeviceMessage(device, message);
                //await CheckResponse(response);
            }
            finally
            {
                _clientLock.Release();
            }
        }
예제 #5
0
        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();
                }
            }
        }
예제 #6
0
        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();
                }
            }
        }