Exemplo n.º 1
0
        public override void OnActivated()
        {
            // Make sure SteamVR_Render instance exist. It Polls New Poses Event
            if (SteamVR_Render.instance == null)
            {
            }

            // setup tracking space
            m_prevTrackingSpace = trackingSpace;
            UpdateTrackingSpaceType();

            EnsureDeviceStateLength(OpenVR.k_unMaxTrackedDeviceCount);

            m_hasInputFocus = inputFocus;

#if VIU_STEAMVR_1_2_1_OR_NEWER
            SteamVR_Events.NewPoses.AddListener(OnSteamVRNewPose);
            SteamVR_Events.InputFocus.AddListener(OnInputFocus);
            SteamVR_Events.System(EVREventType.VREvent_TrackedDeviceRoleChanged).AddListener(OnTrackedDeviceRoleChanged);
#elif VIU_STEAMVR_1_2_0_OR_NEWER
            SteamVR_Events.NewPoses.AddListener(OnSteamVRNewPose);
            SteamVR_Events.InputFocus.AddListener(OnInputFocus);
            SteamVR_Events.System("TrackedDeviceRoleChanged").AddListener(OnTrackedDeviceRoleChanged);
#elif VIU_STEAMVR_1_1_1
            SteamVR_Utils.Event.Listen("new_poses", OnSteamVRNewPoseArgs);
            SteamVR_Utils.Event.Listen("input_focus", OnInputFocusArgs);
            SteamVR_Utils.Event.Listen("TrackedDeviceRoleChanged", OnTrackedDeviceRoleChangedArgs);
#endif
            s_moduleInstance = this;
        }
        private bool TryGetComponentState(CVRSystem vrSystem, CVRRenderModels vrRenderModels, string componentName, out RenderModel_ComponentState_t componentState)
        {
            componentState = default(RenderModel_ComponentState_t);
            var modeState       = default(RenderModel_ControllerMode_State_t);
            var controllerState = default(VRControllerState_t);

            if (!vrSystem.GetControllerState(SteamVRModule.GetTrackedIndexByModuleIndex(m_deviceIndex), ref controllerState, s_sizeOfControllerStats))
            {
                return(false);
            }
            if (!vrRenderModels.GetComponentState(loadedModelName, componentName, ref controllerState, ref modeState, ref componentState))
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 3
0
        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
            s_moduleInstance = null;
        }
Exemplo n.º 4
0
        private bool TryGetComponentState(CVRSystem vrSystem, CVRRenderModels vrRenderModels, string componentName, out RenderModel_ComponentState_t componentState)
        {
            componentState = default(RenderModel_ComponentState_t);
            var modeState = default(RenderModel_ControllerMode_State_t);

            return(vrRenderModels.GetComponentStateForDevicePath(loadedModelName, componentName, SteamVRModule.GetInputSourceHandleForDevice(m_deviceIndex), ref modeState, ref componentState));
        }