public TouchRunner (UIWindow window) { if (window == null) throw new ArgumentNullException ("window"); this.window = window; options = new TouchOptions (); }
public override void ParseMessage(SPPMessage msg) { if (msg.Id != HandledType) { return; } OptionType = DeviceSpec.TouchMap.FromByte(msg.Payload[0]); }
//Constructor //--------------------------------------------------// public XRCameraControlHelper( RuntimePlatform PlatformType, GyroOptions gyroOptions, MouseOptions mouseOptions, KeyCode[] mouseRequiresOneOfTheseKeysHeldToUse, TouchOptions touchOptions ) //--------------------------------------------------// { this.PlatformType = PlatformType; this.gyroOptions = gyroOptions; this.mouseOptions = mouseOptions; this.mouseRequiresOneOfTheseKeysHeldToUse = mouseRequiresOneOfTheseKeysHeldToUse; this.touchOptions = touchOptions; } //END XRCameraControlHelper
private void InstanceOnExtendedStatusUpdate(object?sender, ExtendedStatusUpdateParser e) { _lock.IsChecked = e.TouchpadLock; _edgeTouch.IsChecked = e.OutsideDoubleTap; _lastLeftOption = e.TouchpadOptionL; _lastRightOption = e.TouchpadOptionR; _leftOption.Description = e.TouchpadOptionL.GetDescription(); _rightOption.Description = e.TouchpadOptionR.GetDescription(); UpdateMenuDescriptions(); }
private async void CustomTouchActionPageOnAccepted(object?sender, CustomAction e) { if (MainWindow.Instance.CustomTouchActionPage.CurrentSide == Devices.L) { _lastLeftOption = TouchOptions.OtherL; _leftOption.Description = $"{Loc.Resolve("touchoption_custom_prefix")} {e}"; } else { _lastRightOption = TouchOptions.OtherR; _rightOption.Description = $"{Loc.Resolve("touchoption_custom_prefix")} {e}"; } await MessageComposer.Touch.SetOptions(_lastLeftOption, _lastRightOption); }
public static async Task SetOptions(TouchOptions left, TouchOptions right) { byte[] payload = new byte[2]; if (left == TouchOptions.NoiseControl) { await NoiseControl.SetTouchNoiseControls(true, true, false); } if (right == TouchOptions.NoiseControl) { await NoiseControl.SetTouchNoiseControls(true, true, false); } payload[0] = BluetoothImpl.Instance.DeviceSpec.TouchMap.ToByte(left); payload[1] = BluetoothImpl.Instance.DeviceSpec.TouchMap.ToByte(right); await BluetoothImpl.Instance.SendRequestAsync(SPPMessage.MessageIds.SET_TOUCHPAD_OPTION, payload); }
private async void ItemClicked(Devices device, TouchOptions option) { if (option == TouchOptions.OtherL || option == TouchOptions.OtherR) { /* Open custom action selector first and await user input, * do not send the updated options ids just yet */ MainWindow.Instance.ShowCustomActionSelection(device); } else { if (device == Devices.L) { _lastLeftOption = option; } else { _lastRightOption = option; } UpdateMenuDescriptions(); await MessageComposer.Touch.SetOptions(_lastLeftOption, _lastRightOption); } }
private void HandleOtherTouchOption(object?sender, TouchOptions e) { ICustomAction action = e == TouchOptions.OtherL ? SettingsProvider.Instance.CustomActionLeft : SettingsProvider.Instance.CustomActionRight; switch (action.Action) { case CustomAction.Actions.Event: EventDispatcher.Instance.Dispatch(Enum.Parse <EventDispatcher.Event>(action.Parameter), true); break; case CustomAction.Actions.RunExternalProgram: try { var psi = new ProcessStartInfo { FileName = action.Parameter, UseShellExecute = true }; Process.Start(psi); } catch (FileNotFoundException ex) { new MessageBox() { Title = "Custom long-press action failed", Description = $"Unable to launch external application.\n" + $"File not found: '{ex.FileName}'" }.Show(this); } catch (Win32Exception ex) { if (ex.NativeErrorCode == 13 && PlatformUtils.IsLinux) { new MessageBox() { Title = "Custom long-press action failed", Description = $"Unable to launch external application.\n\n" + $"Insufficient permissions. Please add execute permissions for your user/group to this file.\n\n" + $"Run this command in a terminal: chmod +x \"{action.Parameter}\"" }.Show(this); } else { new MessageBox() { Title = "Custom long-press action failed", Description = $"Unable to launch external application.\n\n" + $"Detailed information:\n\n" + $"{ex.Message}" }.Show(this); } } break; case CustomAction.Actions.TriggerHotkey: var keys = new List <Key>(); try { keys.AddRange(action.Parameter.Split(',').Select(Enum.Parse <Key>)); } catch (Exception ex) { Log.Error("CustomAction.HotkeyBroadcast: Cannot parse saved key-combo: " + ex.Message); Log.Error("CustomAction.HotkeyBroadcast: Caused by combo: " + action.Parameter); return; } HotkeyBroadcastImpl.Instance.SendKeys(keys); break; } }