void Awake() { newPosesAction = SteamVR_Events.NewPosesAction(OnNewPoses); HmdMatrix44_t mat = new HmdMatrix44_t(); /**************************************/ /* * -0.102501 0.19387 0.975658 0.690977 * 0.00933648 0.980968 -0.193944 0.545085 * -0.994689 -0.0107702 -0.10236 -0.111363 * 0 0 0 1 */ /* * mat.m0 = -0.102501f; * mat.m1 = 0.19387f; * mat.m2 = 0.975658f; * mat.m3 = 0.690977f; * mat.m4 = 0.00933648f; * mat.m5 = 0.980968f; * mat.m6 = -0.193944f; * mat.m7 = 0.545085f; * mat.m8 = -0.994689f; * mat.m9 = -0.0107702f; * mat.m10 = -0.10236f; * mat.m11 = -0.111363f; * mat.m12 = 0; * mat.m13 = 0; * mat.m14 = 0; * mat.m15 = 1; */ mat.m0 = -0.102501f; mat.m4 = 0.19387f; mat.m8 = 0.975658f; mat.m12 = 0.690977f; mat.m1 = 0.00933648f; mat.m5 = 0.980968f; mat.m9 = -0.193944f; mat.m13 = 0.545085f; mat.m2 = -0.994689f; mat.m6 = -0.0107702f; mat.m10 = -0.10236f; mat.m14 = -0.111363f; mat.m3 = 0; mat.m7 = 0; mat.m11 = 0; mat.m15 = 1; /**************************************/ BMatInv = new SteamVR_Utils.RigidTransform(mat); BMatInv.Inverse(); }
public override void OnActivated() { m_digitalDataSize = (uint)Marshal.SizeOf(new InputDigitalActionData_t()); m_analogDataSize = (uint)Marshal.SizeOf(new InputAnalogActionData_t()); m_originInfoSize = (uint)Marshal.SizeOf(new InputOriginInfo_t()); m_activeActionSetSize = (uint)Marshal.SizeOf(new VRActiveActionSet_t()); m_poses = new TrackedDevicePose_t[OpenVR.k_unMaxTrackedDeviceCount]; m_gamePoses = new TrackedDevicePose_t[0]; m_originDataCache = new Dictionary <ulong, OriginData>((int)OpenVR.k_unMaxActionOriginCount); InitializeHandles(); #if VIU_STEAMVR_2_1_0_OR_NEWER SteamVR_Input.GetActionSet(ACTION_SET_NAME).Activate(SteamVR_Input_Sources.Any, 0, false); #else var actionSet = SteamVR_Input.GetActionSetFromPath(ACTION_SET_PATH); if (actionSet != null) { actionSet.ActivatePrimary(); } #endif #if !VIU_STEAMVR_2_1_0_OR_NEWER m_activeActionSets = new VRActiveActionSet_t[1] { new VRActiveActionSet_t() { ulActionSet = s_actionSetHandle, } }; #endif #if VIU_STEAMVR_2_2_0_OR_NEWER SteamVR_Input.onNonVisualActionsUpdated += UpdateDeviceInput; SteamVR_Input.onPosesUpdated += UpdateDevicePose; #else SteamVR_Input.OnNonVisualActionsUpdated += UpdateDeviceInput; SteamVR_Input.OnPosesUpdated += UpdateDevicePose; #endif s_devicePathHandles = new ulong[OpenVR.k_unMaxTrackedDeviceCount]; EnsureDeviceStateLength(OpenVR.k_unMaxTrackedDeviceCount); // preserve previous tracking space m_prevTrackingSpace = trackingSpace; m_hasInputFocus = inputFocus; SteamVR_Events.InputFocus.AddListener(OnInputFocus); SteamVR_Events.System(EVREventType.VREvent_TrackedDeviceRoleChanged).AddListener(OnTrackedDeviceRoleChanged); s_moduleInstance = this; }
void OnEnable() { SteamVR_Events.Initialized.Listen(OnRuntimeInitialized); SteamVR_Events.System(EVREventType.VREvent_TrackedDeviceActivated).Listen(OnTrackedDeviceEvent); SteamVR_Events.System(EVREventType.VREvent_TrackedDeviceDeactivated).Listen(OnTrackedDeviceEvent); SteamVR_Events.System(EVREventType.VREvent_TrackedDeviceUpdated).Listen(OnTrackedDeviceEvent); SteamVR_Events.System(EVREventType.VREvent_TrackedDeviceRoleChanged).Listen(OnTrackedDeviceEvent); newPosesAction.enabled = true; RescanDevices(); }
private void Awake() { this.inputFocusAction = SteamVR_Events.InputFocusAction(new UnityAction <bool>(this.OnInputFocus)); if (this.hoverSphereTransform == null) { this.hoverSphereTransform = base.transform; } this.applicationLostFocusObject = new GameObject("_application_lost_focus"); this.applicationLostFocusObject.transform.parent = base.transform; this.applicationLostFocusObject.SetActive(false); }
public override void OnDeactivated() { var compositor = OpenVR.Compositor; if (compositor != null) { compositor.SetTrackingSpace(m_prevTrackingSpace); } SteamVR_Events.InputFocus.RemoveListener(OnInputFocus); SteamVR_Events.System(EVREventType.VREvent_TrackedDeviceRoleChanged).RemoveListener(OnTrackedDeviceRoleChanged); }
public void OpenKeyboard() { if (Field == null) { return; } #if !UNITY_EDITOR && !UNITY_STANDALONE SteamVR_Events.System(EVREventType.VREvent_KeyboardDone).RemoveAllListeners(); SteamVR_Events.System(EVREventType.VREvent_KeyboardDone).Listen(delegate { StringBuilder stringBuilder = new StringBuilder(256); SteamVR.instance.overlay.GetKeyboardText(stringBuilder, 256); string value = stringBuilder.ToString(); object modified = Field.GetValue(Instance); switch (Type) { default: modified = Convert.ChangeType(value, Field.FieldType); break; case ObjectType.Vectors: { value = value.Replace("(", "").Replace(")", ""); string[] inputNumbers = value.Split(','); if (Field.FieldType == typeof(Vector3)) { modified = new Vector3( float.Parse(inputNumbers[0]), float.Parse(inputNumbers[1]), float.Parse(inputNumbers[2]) ); } else { modified = new Vector2( float.Parse(inputNumbers[0]), float.Parse(inputNumbers[1]) ); } break; } } Field.SetValue(Instance, modified); UpdateDisplay(); }); SteamVR.instance.overlay.ShowKeyboard((int)EGamepadTextInputMode.k_EGamepadTextInputModeNormal, (int)EGamepadTextInputLineMode.k_EGamepadTextInputLineModeSingleLine, "Enter the name of an asset.", 256, Field.GetValue(Instance).ToString(), false, 0); #endif }
public override void OnDeactivated() { SteamVR_Events.InputFocus.RemoveListener(OnInputFocus); SteamVR_Events.System(EVREventType.VREvent_TrackedDeviceRoleChanged).RemoveListener(OnTrackedDeviceRoleChanged); SteamVR_Input.OnNonVisualActionsUpdated -= UpdateDeviceInput; SteamVR_Input.OnPosesUpdated -= UpdateDevicePose; trackingSpace = m_prevTrackingSpace; s_moduleInstance = null; }
private void Awake() { this.trackedDeviceRoleChangedAction = SteamVR_Events.SystemAction(EVREventType.VREvent_TrackedDeviceRoleChanged, new UnityAction <VREvent_t>(this.OnTrackedDeviceRoleChanged)); this.inputFocusAction = SteamVR_Events.InputFocusAction(new UnityAction <bool>(this.OnInputFocus)); if (this.hoverSphereTransform == null) { this.hoverSphereTransform = base.transform; } this.applicationLostFocusObject = new GameObject("_application_lost_focus"); this.applicationLostFocusObject.transform.parent = base.transform; this.applicationLostFocusObject.SetActive(false); }
void OnDisable() { StopAllCoroutines(); SteamVR_Events.InputFocus.Remove(OnInputFocus); SteamVR_Events.System(EVREventType.VREvent_Quit).Remove(OnQuit); SteamVR_Events.System(EVREventType.VREvent_RequestScreenshot).Remove(OnRequestScreenshot); #if UNITY_2017_1_OR_NEWER Application.onBeforeRender -= OnBeforeRender; #else Camera.onPreCull -= OnCameraPreCull; #endif }
void Awake() { UIManager = GameObject.Find("UI_Manager_Prefab"); PlayerManager = GameObject.Find("PlayerManager_Prefab"); Player = GameObject.Find("Player_Prefab"); //SteamVR_Utils.Event.Listen("KeyboardCharInput", OnKeyboard); //SteamVR_Utils.Event.Listen("KeyboardClosed", OnKeyboardClosed); SteamVR_Events.System(EVREventType.VREvent_KeyboardCharInput).Listen(OnKeyboard); SteamVR_Events.System(EVREventType.VREvent_KeyboardClosed).Listen(OnKeyboardClosed); }
private void OnDisable() { if (this._isDuplicateCleanup) { return; } base.StopAllCoroutines(); SteamVR_Events.InputFocus.Remove(new UnityAction <bool>(this.OnInputFocus)); SteamVR_Events.System(EVREventType.VREvent_Quit).Remove(new UnityAction <VREvent_t>(this.OnQuit)); SteamVR_Events.System(EVREventType.VREvent_RequestScreenshot).Remove(new UnityAction <VREvent_t>(this.OnRequestScreenshot)); Camera.onPreCull = (Camera.CameraCallback)Delegate.Remove(Camera.onPreCull, new Camera.CameraCallback(this.OnCameraPreCull)); }
static OverlayKeyboardSample() { #if VIU_STEAMVR_1_2_1_OR_NEWER SteamVR_Events.System(Valve.VR.EVREventType.VREvent_KeyboardCharInput).AddListener(OnKeyboardCharInput); SteamVR_Events.System(Valve.VR.EVREventType.VREvent_KeyboardClosed).AddListener(OnKeyboardClosed); #elif VIU_STEAMVR_1_2_0_OR_NEWER SteamVR_Events.System("KeyboardCharInput").AddListener(OnKeyboardCharInput); SteamVR_Events.System("KeyboardClosed").AddListener(OnKeyboardClosed); #elif VIU_STEAMVR_1_1_1 SteamVR_Utils.Event.Listen("KeyboardCharInput", OnKeyboardCharInputArgs); SteamVR_Utils.Event.Listen("KeyboardClosed", OnKeyboardClosedArgs); #endif }
//------------------------------------------------- void Awake() { inputFocusAction = SteamVR_Events.InputFocusAction(OnInputFocus); if (hoverSphereTransform == null) { hoverSphereTransform = this.transform; } applicationLostFocusObject = new GameObject("_application_lost_focus"); applicationLostFocusObject.transform.parent = transform; applicationLostFocusObject.SetActive(false); }
private void OnEnable() { #if UNITY_EDITOR if (!Application.isPlaying) { return; } #endif keyboardCharInputAction = SteamVR_Events.SystemAction(EVREventType.VREvent_KeyboardCharInput, OnKeyboard); keyboardCharInputAction.enabled = true; keyboardClosedAction = SteamVR_Events.SystemAction(EVREventType.VREvent_KeyboardClosed, OnKeyboardClosed); keyboardClosedAction.enabled = true; }
void OnEnable() { var render = SteamVR_Render.instance; if (render == null) { enabled = false; return; } newPosesAction = SteamVR_Events.NewPosesAction(OnNewPoses); newPosesAction.enabled = true; }
protected virtual void Awake() { if (MixCastCameras.Instance != null) { MixCastCameras.Instance.OnBeforeRender += LateUpdate; } #if MIXCAST_STEAMVR newPosesAppliedAction = SteamVR_Events.NewPosesAppliedAction(OnNewPosesApplied); isTrackedDeviceReady = true; #endif }
void Awake() { newPosesAction = SteamVR_Events.NewPosesAction(OnNewPoses); headCamera = GameObject.Find(cameraName); headTracking = GameObject.Find(headTrackingName); var error = EVRSettingsError.None; if (OpenVR.Settings.GetBool(OpenVR.k_pch_SteamVR_Section, OpenVR.k_pch_SteamVR_ForceFadeOnBadTracking_Bool, ref error)) { OpenVR.Settings.SetBool(OpenVR.k_pch_SteamVR_Section, OpenVR.k_pch_SteamVR_ForceFadeOnBadTracking_Bool, false, ref error); OpenVR.Settings.Sync(true, ref error); } }
public override void OnDeactivated() { var compositor = OpenVR.Compositor; if (compositor != null) { compositor.SetTrackingSpace(m_prevTrackingSpace); } #if VIU_STEAMVR_1_2_1_OR_NEWER SteamVR_Events.System(EVREventType.VREvent_TrackedDeviceRoleChanged).RemoveListener(OnTrackedDeviceRoleChanged); #elif VIU_STEAMVR_1_2_0_OR_NEWER SteamVR_Events.System("TrackedDeviceRoleChanged").RemoveListener(OnTrackedDeviceRoleChanged); #else SteamVR_Utils.Event.Remove("TrackedDeviceRoleChanged", OnTrackedDeviceRoleChangedArgs); #endif }
public override void OnActivated() { var compositor = OpenVR.Compositor; if (compositor != null) { m_prevTrackingSpace = compositor.GetTrackingSpace(); UpdateTrackingSpaceType(); } #if VIU_STEAMVR_1_2_1_OR_NEWER SteamVR_Events.System(EVREventType.VREvent_TrackedDeviceRoleChanged).AddListener(OnTrackedDeviceRoleChanged); #elif VIU_STEAMVR_1_2_0_OR_NEWER SteamVR_Events.System("TrackedDeviceRoleChanged").AddListener(OnTrackedDeviceRoleChanged); #elif VIU_STEAMVR_1_1_1 SteamVR_Utils.Event.Listen("TrackedDeviceRoleChanged", OnTrackedDeviceRoleChangedArgs); #endif }
/// <summary> /// Initialized all the components /// </summary> void Start() { newPoses = SteamVR_Events.NewPosesAction(OnNewPoses); newPoses.enabled = true; RegisterExistingPads(); HideGameObjectFromZED(); if (UnityEngine.XR.XRDevice.model.Contains("Oculus")) { model = HMD.OCULUS; } else { model = HMD.STEAMVR; } }
// Token: 0x06000DD0 RID: 3536 RVA: 0x00057A6C File Offset: 0x00055C6C private void OnEnable() { base.StartCoroutine(this.RenderLoop()); SteamVR_Events.InputFocus.Listen(new UnityAction <bool>(this.OnInputFocus)); SteamVR_Events.System(EVREventType.VREvent_Quit).Listen(new UnityAction <VREvent_t>(this.OnQuit)); SteamVR_Events.System(EVREventType.VREvent_RequestScreenshot).Listen(new UnityAction <VREvent_t>(this.OnRequestScreenshot)); Application.onBeforeRender += this.OnBeforeRender; if (SteamVR.instance == null) { base.enabled = false; return; } EVRScreenshotType[] pSupportedTypes = new EVRScreenshotType[] { EVRScreenshotType.StereoPanorama }; OpenVR.Screenshots.HookScreenshot(pSupportedTypes); }
public override void CognitiveVR_Init(Error initError) { if (initError != Error.None) { return; } base.CognitiveVR_Init(initError); //CognitiveVR_Manager.PoseEvent += CognitiveVR_Manager_PoseEventHandler; SteamVR_Events.System(Valve.VR.EVREventType.VREvent_Compositor_ChaperoneBoundsHidden).AddListener(OnChaperoneChanged); SteamVR_Events.System(Valve.VR.EVREventType.VREvent_Compositor_ChaperoneBoundsShown).AddListener(OnChaperoneChanged); if (Valve.VR.OpenVR.Chaperone.AreBoundsVisible()) { new CustomEvent("cvr.boundary").Send(); Util.logDebug("chaperone visible"); } }
/// <summary> /// Initializes, and caches the position/rotation of the centroid. /// </summary> void Awake() { posesAction = SteamVR_Events.NewPosesAction(OnNewPoses); module = GetComponent <ViveModule>() as ViveModule; if (!module.cameraRig) { Debug.Log("Holojam.Vive.ViveCalibrator: ViveModule camera rig not assigned!"); return; } cachedPosition = module.cameraRig.transform.localPosition; cachedRotation = module.cameraRig.transform.localRotation; calibratedPosition = cachedPosition; calibratedRotation = cachedRotation; Tools.InfoPanel.SetString("calibrator", "Calibrator: waiting"); }
// Token: 0x06005F60 RID: 24416 RVA: 0x00217F24 File Offset: 0x00216324 private void OnEnable() { base.StartCoroutine(this.RenderLoop()); SteamVR_Events.InputFocus.Listen(new UnityAction <bool>(this.OnInputFocus)); SteamVR_Events.System(EVREventType.VREvent_Quit).Listen(new UnityAction <VREvent_t>(this.OnQuit)); SteamVR_Events.System(EVREventType.VREvent_RequestScreenshot).Listen(new UnityAction <VREvent_t>(this.OnRequestScreenshot)); Camera.onPreCull = (Camera.CameraCallback)Delegate.Combine(Camera.onPreCull, new Camera.CameraCallback(this.OnCameraPreCull)); if (SteamVR.instance == null) { base.enabled = false; return; } EVRScreenshotType[] pSupportedTypes = new EVRScreenshotType[] { EVRScreenshotType.StereoPanorama }; OpenVR.Screenshots.HookScreenshot(pSupportedTypes); }
private void OnEnable() { StartCoroutine("RenderLoop"); SteamVR_Events.InputFocus.Listen(OnInputFocus); SteamVR_Events.System(EVREventType.VREvent_Quit).Listen(OnQuit); SteamVR_Events.System(EVREventType.VREvent_RequestScreenshot).Listen(OnRequestScreenshot); var vr = SteamVR.instance; if (vr == null) { enabled = false; return; } var types = new[] { EVRScreenshotType.StereoPanorama }; OpenVR.Screenshots.HookScreenshot(types); }
public override void OnDeactivated() { trackingSpace = m_prevTrackingSpace; #if VIU_STEAMVR_1_2_1_OR_NEWER SteamVR_Events.NewPoses.RemoveListener(OnSteamVRNewPose); SteamVR_Events.InputFocus.RemoveListener(OnInputFocus); SteamVR_Events.System(EVREventType.VREvent_TrackedDeviceRoleChanged).RemoveListener(OnTrackedDeviceRoleChanged); #elif VIU_STEAMVR_1_2_0_OR_NEWER SteamVR_Events.NewPoses.RemoveListener(OnSteamVRNewPose); SteamVR_Events.InputFocus.RemoveListener(OnInputFocus); SteamVR_Events.System("TrackedDeviceRoleChanged").RemoveListener(OnTrackedDeviceRoleChanged); #elif VIU_STEAMVR_1_1_1 SteamVR_Utils.Event.Remove("new_poses", OnSteamVRNewPoseArgs); SteamVR_Utils.Event.Remove("input_focus", OnInputFocusArgs); SteamVR_Utils.Event.Remove("TrackedDeviceRoleChanged", OnTrackedDeviceRoleChangedArgs); #endif }
public static void start(InputField inputField, bool returnOnClose = false, UnityAction closedAction = null) { _inputField = inputField; _returnOnClose = returnOnClose; _closedAction = closedAction; if (_inputField.text == "...") { _inputField.text = ""; } if (!initialized) { SteamVR_Events.System(EVREventType.VREvent_KeyboardClosed).Listen(OnKeyboardClosed); initialized = true; } SteamVR.instance.overlay.ShowKeyboard(0, 0, 0, "TextInput", 256, _inputField.text, 1); }
/// <summary> /// Dispatch other miscellaneous OpenVR-specific events. /// </summary> private void DispatchOpenVREvents() { // copied from SteamVR_Render var vrEvent = new VREvent_t(); var size = (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(VREvent_t)); for (int i = 0; i < 64; i++) { if (!OpenVR.System.PollNextEvent(ref vrEvent, size)) { break; } switch ((EVREventType)vrEvent.eventType) { case EVREventType.VREvent_InputFocusCaptured: // another app has taken focus (likely dashboard) if (vrEvent.data.process.oldPid == 0) { SteamVR_Events.InputFocus.Send(false); } break; case EVREventType.VREvent_InputFocusReleased: // that app has released input focus if (vrEvent.data.process.pid == 0) { SteamVR_Events.InputFocus.Send(true); } break; case EVREventType.VREvent_ShowRenderModels: SteamVR_Events.HideRenderModels.Send(false); break; case EVREventType.VREvent_HideRenderModels: SteamVR_Events.HideRenderModels.Send(true); break; default: SteamVR_Events.System((EVREventType)vrEvent.eventType).Send(vrEvent); break; } } }
// //C# Events (using Action delegate) // //Listen to function -> {updateD += FunctionName;} // public event Action updateD; // Use this for initialization void Start() { //--------------Initialize events----------------------------- HmdLostTrack = new CalibrationEvents(); ChaperoneDataChanged = new CalibrationEvents(); LighthouseDatabaseChanged = new CalibrationEvents(); FloorFixed = new CalibrationEvents(); //------------------------------------------------------------- universe = new Universe(); SteamVR_Events.NewPoses.Listen(OnNewPoses); SteamVR_Events.System(EVREventType.VREvent_ChaperoneDataHasChanged).Listen(OnChaperoneDataChanged); SteamVR_Events.System(EVREventType.VREvent_ChaperoneUniverseHasChanged).Listen(OnUniverseChanged); if (errorCanvas != null) { errorCanvas.SetActive(false); errorText = errorCanvas.GetComponentInChildren <Text> (); } // hmdSerialNumber = SteamVR.instance.hmd_SerialNumber; // hmdSerialNumber = "2056355165"; //Invoke in a delay because the function requires current universe ID, which got from //SteamVR events ["OnUniverseChanged"], and this script ["Start" function] fires up before the event call from SteamVR Invoke("GetUniverseOffsetDelay", 0.1f); Invoke("GetHmdSerialNumberJson", 0.1f); gameManager = GetComponent <GameManager> (); ////-------------Use File Watcher to monitor file changes-------------------------------------------------------------------------------------- // string filePath = @"C:\Program Files (x86)\Steam\config\lighthouse"; // string fileType = "*.json"; // // watcher = new FileSystemWatcher (filePath, fileType); // watcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.LastAccess | NotifyFilters.DirectoryName; // watcher.Changed += new FileSystemEventHandler(OnFileChanged); // // watcher.EnableRaisingEvents = true; ////-------------------------------------------------------------------------------------------------------------------------------------------------------------- }
public override void OnActivated() { var system = OpenVR.System; if (system != null) { m_hasInputFocus = !system.IsInputFocusCapturedByAnotherProcess(); } var compositor = OpenVR.Compositor; if (compositor != null) { m_prevTrackingSpace = compositor.GetTrackingSpace(); UpdateTrackingSpaceType(); } SteamVR_Events.InputFocus.AddListener(OnInputFocus); SteamVR_Events.System(EVREventType.VREvent_TrackedDeviceRoleChanged).AddListener(OnTrackedDeviceRoleChanged); }