public void StopFramework() { if (Status != FrameworkStatus.STOP) { if (EnableLipVersion == SupportedLipVersion.version1) { Error result = SRanipal_API.Release(SRanipal_Lip.ANIPAL_TYPE_LIP); if (result == Error.WORK) { Debug.Log("[SRanipal] Release Lip : " + result); } else { Debug.LogError("[SRanipal] Release Lip : " + result); } } else { Error result = SRanipal_API.Release(SRanipal_Lip_v2.ANIPAL_TYPE_LIP_V2); if (result == Error.WORK) { Debug.Log("[SRanipal] Release Version 2 Lip : " + result); } else { Debug.LogError("[SRanipal] Release Version 2 Lip : " + result); } } } else { Debug.Log("[SRanipal] Stop Framework : module not on"); } Status = FrameworkStatus.STOP; }
private static void HandleErrors(Error eyeError, Error faceError) { if (eyeError.IsRealError()) { // Msg instead of Warning under the assumption most people will be using only lip tracking MelonLogger.Msg($"Eye Tracking will be unavailable for this session. ({eyeError})"); } else if (eyeError == Error.WORK) { MainMod.AppendEyeParams(); EyeEnabled = true; MelonLogger.Msg("SRanipal Eye Initialized!"); } if (faceError.IsRealError()) { MelonLogger.Warning($"Lip Tracking will be unavailable for this session. ({faceError})"); } else if (faceError == (Error)1051) { while (faceError == (Error)1051) { faceError = SRanipal_API.Initial(SRanipal_Lip_v2.ANIPAL_TYPE_LIP_V2, IntPtr.Zero); } } if (faceError == Error.WORK) { MainMod.AppendLipParams(); FaceEnabled = true; MelonLogger.Msg("SRanipal Lip Initialized!"); } }
// ******************************************************************************************************************** // // Check if the system works properly. // // ******************************************************************************************************************** void SystemCheck() { if (SRanipal_Eye_API.GetEyeData_v2(ref eyeData) == ViveSR.Error.WORK) { Debug.Log("Device is working properly."); } if (SRanipal_Eye_API.GetEyeParameter(ref eye_parameter) == ViveSR.Error.WORK) { Debug.Log("Eye parameters are measured."); } // Check again if the initialisation of eye tracking functions successfully. If not, we stop playing Unity. Error result_eye_init = SRanipal_API.Initial(SRanipal_Eye_v2.ANIPAL_TYPE_EYE_V2, IntPtr.Zero); if (result_eye_init == Error.WORK) { Debug.Log("[SRanipal] Initial Eye v2: " + result_eye_init); } else { Debug.LogError("[SRanipal] Initial Eye v2: " + result_eye_init); if (UnityEditor.EditorApplication.isPlaying) { UnityEditor.EditorApplication.isPlaying = false; // Stops Unity editor. } } }
public void StartFramework() { if (!EnableEye) { return; } if (Status == FrameworkStatus.WORKING) { return; } if (!SRanipal_Eye.IsViveProEye()) { Status = FrameworkStatus.NOT_SUPPORT; return; } Status = FrameworkStatus.START; Error result = SRanipal_API.Initial(SRanipal_Eye.ANIPAL_TYPE_EYE, IntPtr.Zero); if (result == Error.WORK) { Debug.Log("[SRanipal] Initial Eye : " + result); Status = FrameworkStatus.WORKING; } else { Debug.LogError("[SRanipal] Initial Eye : " + result); Status = FrameworkStatus.ERROR; } }
public void StartFramework() { if (!EnableEye) { return; } if (Status == FrameworkStatus.WORKING || Status == FrameworkStatus.NOT_SUPPORT) { return; } if (EnableEyeVersion == SupportedEyeVersion.version1) { Error result = SRanipal_API.Initial(SRanipal_Eye.ANIPAL_TYPE_EYE, IntPtr.Zero); if (result == Error.WORK) { Status = FrameworkStatus.WORKING; Debug.Log("[SRanipal] Initial Eye success!"); } else { if (result == Error.NOT_SUPPORT_EYE_TRACKING) { Status = FrameworkStatus.NOT_SUPPORT; EnableEyeDataCallback = false; Debug.Log("[SRanipal] Current HMD do not support eye tracking!"); } else { Status = FrameworkStatus.ERROR; Debug.LogError("[SRanipal] Initial Eye : " + result); } } } else { Error result = SRanipal_API.Initial(SRanipal_Eye_v2.ANIPAL_TYPE_EYE_V2, IntPtr.Zero); if (result == Error.WORK) { Status = FrameworkStatus.WORKING; Debug.Log("[SRanipal] Initial Eye v2 success!"); } else { if (result == Error.NOT_SUPPORT_EYE_TRACKING) { Status = FrameworkStatus.NOT_SUPPORT; EnableEyeDataCallback = false; Debug.Log("[SRanipal] Current HMD do not support eye tracking!"); } else { Status = FrameworkStatus.ERROR; Debug.LogError("[SRanipal] Initial Eye v2: " + result); } } } }
public static void Start() { _framework.EnableEye = true; _framework.EnableEyeDataCallback = false; _framework.EnableEyeVersion = SRanipal_Eye_Framework.SupportedEyeVersion.version1; _framework.StartFramework(); SRanipal_API.Initial(SRanipal_Eye_v2.ANIPAL_TYPE_EYE_V2, IntPtr.Zero); Updater.Start(); }
private void Start() { if (!SRanipal_Eye_API.IsViveProEye()) { _logger.Trace($"Is not ProEye, exit."); return; } _eyeMgr = GetComponentInChildren <EyeTrackingManager>(); if (_eyeMgr) { _logger.Trace($"Found EyeTrackingManager."); } _mesh = _eyeMgr.targetMesh; if (_mesh) { _logger.Trace($"Found SkinnedMeshRenderer."); } _animator = GetComponentInChildren <Animator>(); if (!_animator) { return; } var leftEyeTransform = _animator.GetBoneTransform(HumanBodyBones.LeftEye); var rightEyeTransform = _animator.GetBoneTransform(HumanBodyBones.RightEye); if (!leftEyeTransform || !rightEyeTransform) { _logger.Trace($"Eye Tracking: Cannnot get Eye Transform."); return; } basicLeftEyeRot = leftEyeTransform.localRotation; basicRightEyeRot = rightEyeTransform.localRotation; if (SRStatus == FrameworkStatus.WORKING) { workable = true; return; } Error result = SRanipal_API.Initial(SRanipal_Eye.ANIPAL_TYPE_EYE, IntPtr.Zero); if (result == Error.WORK) { _logger.Trace($"Initial Eye: {result}"); SRStatus = FrameworkStatus.WORKING; workable = true; } else { _logger.Error($"Initial Eye: {result}"); SRStatus = FrameworkStatus.ERROR; } }
public static void Stop() { CancellationToken.Cancel(); if (EyeEnabled) { SRanipal_API.Release(SRanipal_Eye_v2.ANIPAL_TYPE_EYE_V2); } if (FaceEnabled) { SRanipal_API.Release(SRanipal_Lip_v2.ANIPAL_TYPE_LIP_V2); } CancellationToken.Dispose(); }
public void StartFramework() { if (!EnableLip) { return; } if (Status == FrameworkStatus.WORKING) { return; } Status = FrameworkStatus.START; if (EnableLipVersion == SupportedLipVersion.version1) { Error result = SRanipal_API.Initial(SRanipal_Lip.ANIPAL_TYPE_LIP, IntPtr.Zero); if (result == Error.WORK) { Debug.Log("[SRanipal] Initial Lip : " + result); Status = FrameworkStatus.WORKING; } else { Debug.LogError("[SRanipal] Initial Lip : " + result); Status = FrameworkStatus.ERROR; } } else { Error result = SRanipal_API.Initial(SRanipal_Lip_v2.ANIPAL_TYPE_LIP_V2, IntPtr.Zero); if (result == Error.WORK) { Debug.Log("[SRanipal] Initial Version 2 Lip : " + result); Status = FrameworkStatus.WORKING; } else { Debug.LogError("[SRanipal] Initial Version 2 Lip : " + result); Status = FrameworkStatus.ERROR; } } }
public static void Initialize(bool eye = true, bool lip = true) { MelonLogger.Msg($"Initializing SRanipal..."); Error eyeError = Error.UNDEFINED, faceError = Error.UNDEFINED; if (eye) { if (EyeEnabled) { MelonLogger.Msg("Releasing previously initialized eye module..."); SRanipal_API.Release(SRanipal_Eye_v2.ANIPAL_TYPE_EYE_V2); } eyeError = SRanipal_API.Initial(SRanipal_Eye_v2.ANIPAL_TYPE_EYE_V2, IntPtr.Zero); } if (lip) { if (FaceEnabled) { MelonLogger.Msg("Releasing previously initialized lip module..."); SRanipal_API.Release(SRanipal_Lip_v2.ANIPAL_TYPE_LIP_V2); } faceError = SRanipal_API.Initial(SRanipal_Lip_v2.ANIPAL_TYPE_LIP_V2, IntPtr.Zero); } HandleErrors(eyeError, faceError); if (SceneManager.GetActiveScene().buildIndex == -1 && QuickModeMenu.MainMenu != null) { MainMod.MainThreadExecutionQueue.Add(() => QuickModeMenu.MainMenu.UpdateEnabledTabs(EyeEnabled, FaceEnabled)); } if (!SRanipalWorker.IsAlive) { SRanipalWorker.Start(); } }
public void StopFramework() { if (Status != FrameworkStatus.NOT_SUPPORT) { if (Status != FrameworkStatus.STOP) { if (EnableEyeVersion == SupportedEyeVersion.version1) { Error result = SRanipal_API.Release(SRanipal_Eye.ANIPAL_TYPE_EYE); if (result == Error.WORK) { Debug.Log("[SRanipal] Release Eye : " + result); } else { Debug.LogError("[SRanipal] Release Eye : " + result); } } else { Error result = SRanipal_API.Release(SRanipal_Eye_v2.ANIPAL_TYPE_EYE_V2); if (result == Error.WORK) { Debug.Log("[SRanipal] Release Eye v2: " + result); } else { Debug.LogError("[SRanipal] Release Eye v2: " + result); } } } else { Debug.Log("[SRanipal] Stop Framework : module not on"); } } Status = FrameworkStatus.STOP; }
public static void Initialize(bool eye = true, bool lip = true) { MelonLogger.Msg($"Initializing SRanipal..."); Error eyeError = Error.UNDEFINED, faceError = Error.UNDEFINED; if (eye) { if (EyeEnabled) { MelonLogger.Msg("Releasing previously initialized eye module..."); SRanipal_API.Release(SRanipal_Eye_v2.ANIPAL_TYPE_EYE_V2); } eyeError = SRanipal_API.Initial(SRanipal_Eye_v2.ANIPAL_TYPE_EYE_V2, IntPtr.Zero); } /*if (lip) * { * if (FaceEnabled) * { * MelonLogger.Msg("Releasing previously initialized lip module..."); * SRanipal_API.Release(SRanipal_Lip_v2.ANIPAL_TYPE_LIP_V2); * } * * faceError = SRanipal_API.Initial(SRanipal_Lip_v2.ANIPAL_TYPE_LIP_V2, IntPtr.Zero); * }*/ HandleErrors(eyeError, faceError); //if (SceneManager.GetActiveScene().buildIndex == -1) // MainMod.MainThreadExecutionQueue.Add(QuickModeMenu.CheckIfShouldInit); if (!SRanipalWorker.IsAlive) { SRanipalWorker.Start(); } }
public void StopFramework() { if (SRanipal_Eye.IsViveProEye()) { if (Status != FrameworkStatus.STOP) { Error result = SRanipal_API.Release(SRanipal_Eye.ANIPAL_TYPE_EYE); if (result == Error.WORK) { Debug.Log("[SRanipal] Release Eye : " + result); } else { Debug.LogError("[SRanipal] Release Eye : " + result); } } else { Debug.Log("[SRanipal] Stop Framework : module not on"); } } Status = FrameworkStatus.STOP; }