Пример #1
0
        public FleshlightLaunchFW12Cmd Translate(KiirooCmd aMsg)
        {
            var elapsed = _stopwatch.ElapsedMilliseconds;

            _stopwatch.Stop();
            _currentGoalPosition = aMsg.Position;
            if (_currentGoalPosition == _previousKiirooPosition)
            {
                return(new FleshlightLaunchFW12Cmd(aMsg.DeviceIndex, 0, _previousPosition, aMsg.Id));
            }

            _previousKiirooPosition = _currentGoalPosition;
            _currentSpeed           = 0;

            // Speed Conversion
            if (elapsed > 2000)
            {
                _currentSpeed = 50;
            }
            else if (elapsed > 1000)
            {
                _currentSpeed = 20;
            }
            else
            {
                _currentSpeed = (uint)(100 - ((elapsed / 100.0) + (elapsed / 100.0 * .1)));
                if (_currentSpeed > _previousSpeed)
                {
                    _currentSpeed = _previousSpeed + ((_currentSpeed - _previousSpeed) / 6);
                }
                else if (_currentSpeed <= _previousSpeed)
                {
                    _currentSpeed = _previousSpeed - (_currentSpeed / 2);
                }
            }

            if (_currentSpeed < 20)
            {
                _currentSpeed = 20;
            }

            _stopwatch.Start();

            // Position Conversion
            var position = (ushort)(_currentGoalPosition > 2 ? 95 : 5);

            if (elapsed <= 150)
            {
                if (_limitedSpeed == 0)
                {
                    _limitedSpeed = _currentSpeed;
                }

                return(new FleshlightLaunchFW12Cmd(aMsg.DeviceIndex, _limitedSpeed, position, aMsg.Id));
            }

            _limitedSpeed = 0;
            return(new FleshlightLaunchFW12Cmd(aMsg.DeviceIndex, _currentSpeed, position, aMsg.Id));
        }
Пример #2
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();
            }
        }
Пример #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.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();
            }
        }