/** * Set the editLocked state */ public void SetMenuMode(bool menuMode) { if (_menuMode != menuMode) { _menuMode = menuMode; MenuModeStateChanged.Send(_menuMode); } }
/** * Read the user's GraphicsConfigurationOverride.xml and parse the HUD color matrix config */ private void LoadHUDColorMatrix() { try { string RedLine; string GreenLine; string BlueLine; try { var doc = XDocument.Load(GraphicsConfigurationOverridePath); var defaultGuiColor = doc.Descendants("GUIColour").Descendants("Default"); RedLine = (from el in defaultGuiColor.Descendants("MatrixRed") select el).FirstOrDefault()?.Value; GreenLine = (from el in defaultGuiColor.Descendants("MatrixGreen") select el).FirstOrDefault()?.Value; BlueLine = (from el in defaultGuiColor.Descendants("MatrixBlue") select el).FirstOrDefault()?.Value; } catch (XmlException e) { throw new HudColorMatrixSyntaxErrorException("Failed to parse XML", e); } hudColorMatrix = new HudColorMatrix( ParseColorLineElement(RedLine ?? "1, 0, 0"), ParseColorLineElement(GreenLine ?? "0, 1, 0"), ParseColorLineElement(BlueLine ?? "0, 0, 1")); HudColorMatrixChanged.Send(hudColorMatrix); } catch (HudColorMatrixSyntaxErrorException e) { hudColorMatrix = HudColorMatrix.Identity(); UnityEngine.Debug.LogErrorFormat("Failed to load your HUD Color Matrix, you have a syntax error in your graphics configuration overrides file:\n{0}", GraphicsConfigurationOverridePath); UnityEngine.Debug.LogWarning(e.Message); if (e.InnerException != null) { UnityEngine.Debug.LogWarning(e.InnerException.Message); } } HudColorMatrixChanged.Send(hudColorMatrix); }
/** * Set the editLocked state */ public void SetEditLocked(bool editLocked) { if (_editLocked != editLocked) { _editLocked = editLocked; EditLockedStateChanged.Send(_editLocked); if (_editLocked) { CockpitStateSave.Save(); } } }
/** * Read the user's GraphicsConfigurationOverride.xml and parse the HUD color matrix config */ private void LoadHUDColorMatrix() { var doc = XDocument.Load(GraphicsConfigurationOverridePath); var defaultGuiColor = doc.Descendants("GUIColour").Descendants("Default"); var RedLine = (from el in defaultGuiColor.Descendants("MatrixRed") select el).First().Value; var GreenLine = (from el in defaultGuiColor.Descendants("MatrixGreen") select el).First().Value; var BlueLine = (from el in defaultGuiColor.Descendants("MatrixBlue") select el).First().Value; hudColorMatrix = new HudColorMatrix( ParseColorLine(RedLine), ParseColorLine(GreenLine), ParseColorLine(BlueLine)); HudColorMatrixChanged.Send(hudColorMatrix); }
/** * Set the editLocked state */ public void SetEditLocked(bool editLocked) { if (_editLocked != editLocked) { _editLocked = editLocked; EditLockedStateChanged.Send(_editLocked); if (_editLocked) { CockpitStateSave.Save(); FindObjectOfType <CockpitUIMode>().Override(CockpitUIMode.CockpitModeOverride.None); } } }
private IEnumerator WatchStatusFile() { var statusFile = StatusFilePath; UnityEngine.Debug.LogFormat("Watching Elite Dangerous Status.json at {0}", statusFile); while (IsEliteDangerousRunning) { try { var text = File.ReadAllText(statusFile); if (text.Length > 0) { var status = JsonUtility.FromJson <EDStatus>(text); if (LastStatus == null || status.timestamp != LastStatus.Value.timestamp) { StatusChanged.Send(status, LastStatus); if (LastStatus == null || LastStatus.Value.GuiFocus != status.GuiFocus) { var guiFocus = Enum.IsDefined(typeof(EDStatus_GuiFocus), status.GuiFocus) ? (EDStatus_GuiFocus)status.GuiFocus : EDStatus_GuiFocus.Unknown; GuiFocus = guiFocus; GuiFocusChanged.Send(guiFocus); } if (LastStatus == null || LastStatus.Value.Flags != status.Flags) { StatusFlags = (EDStatus_Flags)status.Flags; FlagsChanged.Send(StatusFlags); } LastStatus = status; } } } catch (IOException) { // Ignore IO exceptions, these might be caused by inevitably reading while ED is writing } yield return(new WaitForSecondsRealtime(1f)); } }
private void SetCurrentProcess(uint pid) { currentPid = pid; if (pid == 0) { currentProcessName = ""; SetIsEliteDangerousRunning(false); } else { Process p = Process.GetProcessById((int)pid); currentProcessName = p.ProcessName; bool isEliteDangerous = p.ProcessName == EDProcessName32 || p.ProcessName == EDProcessName64; SetIsEliteDangerousRunning(isEliteDangerous); } CurrentProcessChanged.Send(currentPid, currentProcessName); }
private void SetIsEliteDangerousRunning(bool running) { if (IsEliteDangerousRunning == running) { return; } IsEliteDangerousRunning = running; if (IsEliteDangerousRunning) { LoadHUDColorMatrix(); // Reload the HUD color matrix on start LoadControlBindings(); // Reload the control bindings on start StartCoroutine(WatchStatusFile()); EliteDangerousStarted.Send(); } else { EliteDangerousStopped.Send(); LastStatus = null; } }
void OnButtonUnpress(VREvent_t ev) { ButtonPress btn; var hand = GetHandForDevice(ev.trackedDeviceIndex); var button = (EVRButtonId)ev.data.controller.button; if (button == triggerButton) { btn = new ButtonPress(hand, Button.Trigger, false); TriggerUnpress.Send(btn); } if (button == grabButton) { btn = new ButtonPress(hand, Button.Grab, false); GrabUnpress.Send(btn); } if (button == menuButton) { btn = new ButtonPress(hand, Button.Menu, false); MenuUnpress.Send(btn); } if (basicBtnActions.ContainsKey(button)) { var btnAction = basicBtnActions[button]; var press = new ButtonActionsPress(hand, btnAction, false); ButtonActionUnpress.Send(press); } if (button == EVRButtonId.k_EButton_SteamVR_Touchpad) { if (UnpressTouchpadHandler != null) { UnpressTouchpadHandler(); UnpressTouchpadHandler = null; } } }
private void SetCurrentProcess(uint pid) { currentPid = pid; if (pid == 0) { currentProcessName = ""; SetIsEliteDangerousRunning(false); } else { Process p = Process.GetProcessById((int)pid); currentProcessName = p.ProcessName; bool isEliteDangerous = p.ProcessName == EDProcessName32 || p.ProcessName == EDProcessName64; if (isEliteDangerous) { var EDProcessName = p.MainModule?.FileName; EDProcessDirectory = EDProcessName != null?Path.GetDirectoryName(EDProcessName) : null; } SetIsEliteDangerousRunning(isEliteDangerous); } CurrentProcessChanged.Send(currentPid, currentProcessName); }
public static void TooltipUpdate(ITooltip tooltip) { TooltipUpdated.Send(tooltip, tooltip.GetTooltipText()); }
void OnButtonPress(VREvent_t ev) { ButtonPress btn; var hand = GetHandForDevice(ev.trackedDeviceIndex); var button = (EVRButtonId)ev.data.controller.button; if (button == triggerButton) { btn = new ButtonPress(hand, Button.Trigger, true); TriggerPress.Send(btn); } if (button == grabButton) { btn = new ButtonPress(hand, Button.Grab, true); GrabPress.Send(btn); } if (button == menuButton) { btn = new ButtonPress(hand, Button.Menu, true); MenuPress.Send(btn); } if (basicBtnActions.ContainsKey(button)) { var btnAction = basicBtnActions[button]; var press = new ButtonActionsPress(hand, btnAction, true); ButtonActionPress.Send(press); } if (button == EVRButtonId.k_EButton_SteamVR_Touchpad) { var vr = OpenVR.System; // For now this only handles the SteamVR Touchpad // In the future Joysticks and small WMR touchpads should be supported // Though it's probably easiest to switch to get the SteamVR Input API working to replace this first var err = ETrackedPropertyError.TrackedProp_Success; var axisTypeInt = vr.GetInt32TrackedDeviceProperty(ev.trackedDeviceIndex, ETrackedDeviceProperty.Prop_Axis0Type_Int32, ref err); if (err == ETrackedPropertyError.TrackedProp_Success) { var axisType = (EVRControllerAxisType)axisTypeInt; if (axisType == EVRControllerAxisType.k_eControllerAxis_TrackPad) { var state = new VRControllerState_t(); var size = (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(VRControllerState_t)); if (vr.GetControllerState(ev.trackedDeviceIndex, ref state, size)) { var axis = ControllerAxisToVector2(state.rAxis0); float magnitude = 0; Direction dir = GetLargestVectorDirection(axis, ref magnitude); if (magnitude > trackpadCenterButtonRadius) { // Directional button press var dirBtn = new DirectionActionsPress(hand, DirectionAction.D1, dir, true); DirectionActionPress.Send(dirBtn); UnpressTouchpadHandler = () => { var dirBtnUnpress = new DirectionActionsPress(hand, DirectionAction.D1, dir, false); DirectionActionUnpress.Send(dirBtnUnpress); }; } else { // Center button press var press = new ButtonActionsPress(hand, BtnAction.D1, true); ButtonActionPress.Send(press); UnpressTouchpadHandler = () => { var unpress = new ButtonActionsPress(hand, BtnAction.D1, false); ButtonActionUnpress.Send(unpress); }; } } } } } }