private void Shutdown() { Console.WriteLine("SteamVR connection lost."); _vr_system.AcknowledgeQuit_Exiting(); OpenVR.Shutdown(); isConnected = false; }
private void CleanupOVR() { overlay.DestroyOverlay(overlayHandle); vr.AcknowledgeQuit_Exiting(); OpenVR.Shutdown(); }
public void Run() { var ev = new VREvent_t(); var evSize = (uint)Marshal.SizeOf(typeof(VREvent_t)); var actionSets = new VRActiveActionSet_t[] { new VRActiveActionSet_t { ulActionSet = inputSet, }, }; var actionSetSize = (uint)Marshal.SizeOf(typeof(VRActiveActionSet_t)); var actionData = new InputDigitalActionData_t(); var actionDataSize = (uint)Marshal.SizeOf(typeof(InputDigitalActionData_t)); Console.WriteLine("Brightness panic button is running. Input bindings may be changed through SteamVR's input bindings."); var sleepTime = (int)Math.Round(1000 * DT); while (running) { while (vrSystem.PollNextEvent(ref ev, evSize)) { switch ((EVREventType)ev.eventType) { case EVREventType.VREvent_DriverRequestedQuit: case EVREventType.VREvent_Quit: vrSystem.AcknowledgeQuit_Exiting(); running = false; break; } } var inputError = vrInput.UpdateActionState(actionSets, actionSetSize); if (inputError != EVRInputError.None) { var message = inputError.ToString(); throw new Exception($"Failed to update action state: {message}"); } inputError = vrInput.GetDigitalActionData(inputActivate, ref actionData, actionDataSize, 0); if (inputError != EVRInputError.None) { var message = inputError.ToString(); throw new Exception($"Failed to get Activate action state: {message}"); } var activatePressed = actionData.bChanged && actionData.bState; inputError = vrInput.GetDigitalActionData(inputResetAuto, ref actionData, actionDataSize, 0); if (inputError != EVRInputError.None) { var message = inputError.ToString(); throw new Exception($"Failed to get Reset (Auto) action state: {message}"); } var resetAutoPressed = actionData.bChanged && actionData.bState; inputError = vrInput.GetDigitalActionData(inputResetHold, ref actionData, actionDataSize, 0); if (inputError != EVRInputError.None) { var message = inputError.ToString(); throw new Exception($"Failed to get Reset (Hold) action state: {message}"); } var resetHoldChanged = actionData.bChanged; var resetHoldHeld = actionData.bState; if (activatePressed) { TriggerActivate(); } if (initialBrightness.HasValue && resetAutoPressed) { resetting = !resetting; if (resetting) { Console.WriteLine("Starting automatic reset."); } else { Console.WriteLine("Cancelling automatic reset."); } } if (initialBrightness.HasValue && resetHoldChanged) { resetting = resetHoldHeld; if (resetting) { Console.WriteLine("Starting held reset."); } else { Console.WriteLine("Cancelling held reset."); } } if (resetting) { resetting = TriggerReset(DT * RESET_SPEED); if (resetting && (resetAutoPressed || resetHoldChanged)) { try { resetSound.Play(); } catch (FileNotFoundException) {} } } Thread.Sleep(sleepTime); } }