Пример #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))
                {
                    double val = information.PositionToTransformed / (double)99;
                    val = Math.Min(1.0, Math.Max(0, val));

                    await device.SendLinearCmd(
                        (uint)information.DurationStretched.TotalMilliseconds, val);
                }
                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;

                    case VibratorConversionMode.SpeedTimesLengthHalfDuration:
                    case VibratorConversionMode.SpeedTimesLengthFullDuration:
                        await device.SendVibrateCmd(information.TransformSpeed(CommandConverter.LaunchSpeedAndLengthToVibratorSpeed(
                                                                                   information.SpeedOriginal,
                                                                                   information.PositionFromTransformed,
                                                                                   information.PositionToTransformed)));

                        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 override async Task Set(DeviceCommandInformation information)
 {
     await _buttplugAdapter.Set(_device, information);
 }
Пример #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(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.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();
            }
        }
Пример #4
0
 public override async Task Set(DeviceCommandInformation information)
 {
     await SetPosition(information.PositionToTransformed, information.SpeedTransformed);
 }