예제 #1
0
        private Task <ButtplugMessage> HandleFleshlightLaunchFW12Cmd([NotNull] ButtplugDeviceMessage aMsg, CancellationToken aToken)
        {
            var cmdMsg = CheckMessageHandler <FleshlightLaunchFW12Cmd>(aMsg);

            var pos = Convert.ToDouble(cmdMsg.Position) / 99.0;
            var dur = Convert.ToUInt32(FleshlightHelper.GetDuration(Math.Abs((1 - pos) - _currentPosition), cmdMsg.Speed / 99.0));

            return(HandleLinearCmd(LinearCmd.Create(cmdMsg.DeviceIndex, cmdMsg.Id, dur, pos, 1), aToken));
        }
예제 #2
0
        private async Task <ButtplugMessage> HandleFleshlightLaunchFW12Cmd(ButtplugDeviceMessage aMsg, CancellationToken aToken)
        {
            var cmdMsg = CheckMessageHandler <FleshlightLaunchFW12Cmd>(aMsg);

            // We'll need to figure out the duration of the Fleshlight move, in
            // order to translate to a LinearCmd message.

            var position = (cmdMsg.Position / 99.0);

            var distance = Math.Abs(_currentPosition - position);

            var duration = FleshlightHelper.GetDuration(distance, (cmdMsg.Speed / 99.0));
            var vectors  = new List <LinearCmd.VectorSubcommand>();

            vectors.Add(new LinearCmd.VectorSubcommand(0, (uint)duration, position));
            var msg = new LinearCmd(aMsg.DeviceIndex, vectors, aMsg.Id);

            return(await HandleLinearCmd(msg, aToken));
        }
예제 #3
0
        private Task <ButtplugMessage> HandleFleshlightLaunchCmd(ButtplugDeviceMessage aMsg, CancellationToken aToken)
        {
            var cmdMsg = CheckMessageHandler <FleshlightLaunchFW12Cmd>(aMsg);

            _speed    = (Convert.ToDouble(cmdMsg.Speed) / 99) * 100;
            _position = (Convert.ToDouble(cmdMsg.Position) / 99) * 100;

            _position = _position < 0 ? 0 : _position;
            _position = _position > 100 ? 100 : _position;
            _speed    = _speed < 20 ? 20 : _speed;
            _speed    = _speed > 100 ? 100 : _speed;

            // This is @funjack's algorithm for converting Fleshlight Launch commands into absolute
            // distance (percent) / duration (millisecond) values
            var distance = Math.Abs(_position - _currentPosition);
            var duration = FleshlightHelper.GetDuration(distance / 100, _speed / 100);

            // We convert those into "position" increments for our OnUpdate() timer event.
            _increment = 1.5 * (distance / (duration / _updateInterval));

            return(Task.FromResult <ButtplugMessage>(new Ok(aMsg.Id)));
        }