Esempio n. 1
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();
            }
        }