private async void HandleKiirooPlatformMessage(object aObj, KiirooPlatformEventArgs aEvent) { await Dispatcher.InvokeAsync(async() => { FleshlightLaunchFW12Cmd currentTranslatedCommand = null; foreach (var device in _devices) { if (device.SupportsMessage(typeof(KiirooCmd))) { await _bpServer.SendMessage(new KiirooCmd(device.Index, aEvent.Position)); } else if (device.SupportsMessage(typeof(FleshlightLaunchFW12Cmd)) || device.SupportsMessage(typeof(SingleMotorVibrateCmd))) { if (currentTranslatedCommand == null) { currentTranslatedCommand = _translator.Translate(new KiirooCmd(device.Index, aEvent.Position)); } currentTranslatedCommand.DeviceIndex = device.Index; if (device.SupportsMessage(typeof(FleshlightLaunchFW12Cmd))) { await _bpServer.SendMessage(currentTranslatedCommand); } } } }); }
private async void HandleKiirooPlatformMessage(object aObj, KiirooPlatformEventArgs aEvent) { await Dispatcher.InvokeAsync(async() => { var currentDevices = DeviceListBox.SelectedItems.Cast <Device>().ToList(); FleshlightLaunchFW12Cmd currentTranslatedCommand = null; foreach (var device in currentDevices) { if (device.Messages.Contains(typeof(KiirooCmd).Name)) { await _bpServer.SendMessage(new KiirooCmd(device.Index, aEvent.Position)); } else if (device.Messages.Contains("FleshlightLaunchFW12Cmd") || device.Messages.Contains("SingleMotorVibrateCmd")) { if (currentTranslatedCommand == null) { currentTranslatedCommand = _translator.Translate(new KiirooCmd(device.Index, aEvent.Position)); } currentTranslatedCommand.DeviceIndex = device.Index; if (device.Messages.Contains("FleshlightLaunchFW12Cmd")) { await _bpServer.SendMessage(currentTranslatedCommand); } } } }); }
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(); } }
public async Task TestFleshlightLaunchFW12Cmd() { var msg = new FleshlightLaunchFW12Cmd(4, 35, 23); await testUtil.TestDeviceMessageDelayed(msg, new List <(byte[], string)>() { (Encoding.ASCII.GetBytes("1,\n"), Endpoints.Tx), (Encoding.ASCII.GetBytes("2,\n"), Endpoints.Tx), (Encoding.ASCII.GetBytes("3,\n"), Endpoints.Tx), }, false, 400); msg = new FleshlightLaunchFW12Cmd(4, 30, 51); await testUtil.TestDeviceMessageDelayed(msg, new List <(byte[], string)>() { (Encoding.ASCII.GetBytes("2,\n"), Endpoints.Tx), }, false, 500); }
public async Task TestFleshlightLaunchFW12Cmd() { var msg = new FleshlightLaunchFW12Cmd(4, 35, 23); await testUtil.TestDeviceMessageDelayed(msg, new List <(byte[], uint)>() { (Encoding.ASCII.GetBytes("1,\n"), (uint)KiirooBluetoothInfo.Chrs.Tx), (Encoding.ASCII.GetBytes("2,\n"), (uint)KiirooBluetoothInfo.Chrs.Tx), (Encoding.ASCII.GetBytes("3,\n"), (uint)KiirooBluetoothInfo.Chrs.Tx), }, false, 400); msg = new FleshlightLaunchFW12Cmd(4, 30, 51); await testUtil.TestDeviceMessageDelayed(msg, new List <(byte[], uint)>() { (Encoding.ASCII.GetBytes("2,\n"), (uint)KiirooBluetoothInfo.Chrs.Tx), }, false, 500); }
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(); } }