private void LostTracking() { if (!IsTracking) { return; } IsTracking = false; TrackingLost?.Invoke(); }
public static void Update() { if (Plugin.shouldQuit) { Console.WriteLine("[OVRManager] OVRPlugin.shouldQuit detected"); Environment.Exit(0); } if (AllowRecenter && Plugin.shouldRecenter) { display.RecenterPose(); } if (trackingOriginType != _trackingOriginType) { trackingOriginType = _trackingOriginType; } Tracker.IsEnabled = usePositionTracking; Plugin.rotation = useRotationTracking; Plugin.useIPDInPositionTracking = useIPDInPositionTracking; // Dispatch HMD events. isHmdPresent = NodeStateProperties.IsHmdPresent(); if (headPoseRelativeOffsetRotation != _headPoseRelativeOffsetRotation) { headPoseRelativeOffsetRotation = _headPoseRelativeOffsetRotation; } if (headPoseRelativeOffsetTranslation != _headPoseRelativeOffsetTranslation) { headPoseRelativeOffsetTranslation = _headPoseRelativeOffsetTranslation; } if (_wasHmdPresent && !isHmdPresent) { try { Console.WriteLine("[OVRManager] HMDLost event"); HMDLost?.Invoke(); } catch (Exception e) { Console.Error.WriteLine("Caught Exception: " + e); } } if (!_wasHmdPresent && isHmdPresent) { try { Console.WriteLine("[OVRManager] HMDAcquired event"); HMDAcquired?.Invoke(); } catch (Exception e) { Console.Error.WriteLine("Caught Exception: " + e); } } _wasHmdPresent = isHmdPresent; // Dispatch HMD mounted events. isUserPresent = Plugin.userPresent; if (_wasUserPresent && !isUserPresent) { try { Console.WriteLine("[OVRManager] HMDUnmounted event"); HMDUnmounted?.Invoke(); } catch (Exception e) { Console.Error.WriteLine("Caught Exception: " + e); } } if (!_wasUserPresent && isUserPresent) { try { Console.WriteLine("[OVRManager] HMDMounted event"); if (HMDMounted != null) { HMDMounted(); } } catch (Exception e) { Console.Error.WriteLine("Caught Exception: " + e); } } _wasUserPresent = isUserPresent; // Dispatch VR Focus events. hasVrFocus = Plugin.hasVrFocus; if (_hadVrFocus && !hasVrFocus) { try { Console.WriteLine("[OVRManager] VrFocusLost event"); VrFocusLost?.Invoke(); } catch (Exception e) { Console.Error.WriteLine("Caught Exception: " + e); } } if (!_hadVrFocus && hasVrFocus) { try { Console.WriteLine("[OVRManager] VrFocusAcquired event"); VrFocusAcquired?.Invoke(); } catch (Exception e) { Console.Error.WriteLine("Caught Exception: " + e); } } _hadVrFocus = hasVrFocus; // Dispatch VR Input events. var hasInputFocus = Plugin.hasInputFocus; if (_hadInputFocus && !hasInputFocus) { try { Console.WriteLine("[OVRManager] InputFocusLost event"); InputFocusLost?.Invoke(); } catch (Exception e) { Console.Error.WriteLine("Caught Exception: " + e); } } if (!_hadInputFocus && hasInputFocus) { try { Console.WriteLine("[OVRManager] InputFocusAcquired event"); InputFocusAcquired?.Invoke(); } catch (Exception e) { Console.Error.WriteLine("Caught Exception: " + e); } } _hadInputFocus = hasInputFocus; // Dispatch Audio Device events. var audioOutId = Plugin.audioOutId; if (!prevAudioOutIdIsCached) { prevAudioOutId = audioOutId; prevAudioOutIdIsCached = true; } else if (audioOutId != prevAudioOutId) { try { Console.WriteLine("[OVRManager] AudioOutChanged event"); AudioOutChanged?.Invoke(); } catch (Exception e) { Console.Error.WriteLine("Caught Exception: " + e); } prevAudioOutId = audioOutId; } var audioInId = Plugin.audioInId; if (!prevAudioInIdIsCached) { prevAudioInId = audioInId; prevAudioInIdIsCached = true; } else if (audioInId != prevAudioInId) { try { Console.WriteLine("[OVRManager] AudioInChanged event"); AudioInChanged?.Invoke(); } catch (Exception e) { Console.Error.WriteLine("Caught Exception: " + e); } prevAudioInId = audioInId; } // Dispatch tracking events. if (wasPositionTracked && !Tracker.IsPositionTracked) { try { Console.WriteLine("[OVRManager] TrackingLost event"); TrackingLost?.Invoke(); } catch (Exception e) { Console.Error.WriteLine("Caught Exception: " + e); } } if (!wasPositionTracked && Tracker.IsPositionTracked) { try { Console.WriteLine("[OVRManager] TrackingAcquired event"); TrackingAcquired?.Invoke(); } catch (Exception e) { Console.Error.WriteLine("Caught Exception: " + e); } } wasPositionTracked = Tracker.IsPositionTracked; display.Update(); }