private void PoseUpdateEvent_ControllerStateUpdate(params Valve.VR.TrackedDevicePose_t[] args)
 {
     for (int i = 0; i < args.Length; i++)
     {
         for (int j = 0; j < 2; j++)
         {
             if (GameplayReferences.GetControllerInfo(j, out tempControllerInfo))
             {
                 if (tempControllerInfo.id == i)
                 {
                     tempControllerInfo.connected = args[i].bDeviceIsConnected;
                     tempControllerInfo.visible   = args[i].bPoseIsValid;
                 }
             }
         }
     }
 }
        void Update()
        {
            if (initResponse != Error.None)
            {
                return;
            }

            Core.InvokeUpdateEvent(Time.deltaTime);
            UpdateSendHotkeyCheck();

#if CVR_STEAMVR || CVR_STEAMVR2
            var system = Valve.VR.OpenVR.System;
            if (system != null)
            {
                var vrEvent = new Valve.VR.VREvent_t();
                var size    = (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(Valve.VR.VREvent_t));
                for (int i = 0; i < 64; i++)
                {
                    if (!system.PollNextEvent(ref vrEvent, size))
                    {
                        break;
                    }
                    OnPoseEvent((Valve.VR.EVREventType)vrEvent.eventType);
                }
            }
#endif

#if CVR_OCULUS
            if (GameplayReferences.GetControllerInfo(false, out tempControllerInfo))
            {
                tempControllerInfo.connected = OVRInput.IsControllerConnected(OVRInput.Controller.LTouch);
                tempControllerInfo.visible   = OVRInput.GetControllerPositionTracked(OVRInput.Controller.LTouch);
            }

            if (GameplayReferences.GetControllerInfo(true, out tempControllerInfo))
            {
                tempControllerInfo.connected = OVRInput.IsControllerConnected(OVRInput.Controller.RTouch);
                tempControllerInfo.visible   = OVRInput.GetControllerPositionTracked(OVRInput.Controller.RTouch);
            }
#endif
        }
示例#3
0
        public void BeginExitPoll(ExitPollParameters parameters)
        {
            myparameters = parameters;

            //spawn pointers if override isn't set
            if (parameters.PointerType == ExitPoll.PointerType.SceneObject)
            {
                //spawn nothing. something in the scene is already set
                pointerInstance = parameters.PointerOverride;
            }
            else if (parameters.PointerType == ExitPoll.PointerType.HMDPointer)
            {
                GameObject prefab = Resources.Load <GameObject>("HMDPointer");
                if (prefab != null)
                {
                    pointerInstance = GameObject.Instantiate(prefab);
                }
                else
                {
                    Debug.LogError("Spawning Exitpoll HMD Pointer, but cannot find prefab \"HMDPointer\" in Resources!");
                }
            }
            else if (parameters.PointerType == ExitPoll.PointerType.ControllerPointer)
            {
                GameObject prefab = Resources.Load <GameObject>("ControllerPointer");
                if (prefab != null)
                {
                    pointerInstance = GameObject.Instantiate(prefab);
                }
                else
                {
                    Debug.LogError("Spawning Exitpoll Controller Pointer, but cannot find prefab \"ControllerPointer\" in Resources!");
                }
            }
            else if (parameters.PointerType == ExitPoll.PointerType.CustomPointer)
            {
                if (parameters.PointerOverride != null)
                {
                    pointerInstance = GameObject.Instantiate(parameters.PointerOverride);
                }
                else
                {
                    Debug.LogError("Spawning Exitpoll Pointer, but cannot pointer override prefab is null!");
                }
            }

            if (pointerInstance != null)
            {
                if (parameters.PointerParent == ExitPoll.PointerSource.HMD)
                {
                    //parent to hmd and zero position
                    pointerInstance.transform.SetParent(GameplayReferences.HMD);
                    pointerInstance.transform.localPosition = Vector3.zero;
                    pointerInstance.transform.localRotation = Quaternion.identity;
                }
                else if (parameters.PointerParent == ExitPoll.PointerSource.RightHand)
                {
                    Transform t = null;
                    if (GameplayReferences.GetController(true, out t))
                    {
                        pointerInstance.transform.SetParent(t);
                        pointerInstance.transform.localPosition = Vector3.zero;
                        pointerInstance.transform.localRotation = Quaternion.identity;
                    }
                }
                else if (parameters.PointerParent == ExitPoll.PointerSource.LeftHand)
                {
                    Transform t = null;
                    if (GameplayReferences.GetController(false, out t))
                    {
                        pointerInstance.transform.SetParent(t);
                        pointerInstance.transform.localPosition = Vector3.zero;
                        pointerInstance.transform.localRotation = Quaternion.identity;
                    }
                }
                else if (parameters.PointerParent == ExitPoll.PointerSource.Other)
                {
                    if (parameters.PointerParentOverride != null)
                    {
                        pointerInstance.transform.SetParent(parameters.PointerParentOverride);
                        pointerInstance.transform.localPosition = Vector3.zero;
                        pointerInstance.transform.localRotation = Quaternion.identity;
                    }
                }
            }

            //this should take all previously set variables (from functions) and create an exitpoll parameters object

            currentPanelIndex = 0;
            if (string.IsNullOrEmpty(myparameters.Hook))
            {
                Cleanup(false);
                Util.logDebug("CognitiveVR Exit Poll. You haven't specified a question hook to request!");
                return;
            }

            if (CognitiveVR_Manager.Instance != null)
            {
                CognitiveVR.NetworkManager.GetExitPollQuestions(myparameters.Hook, QuestionSetResponse, 3);
            }
            else
            {
                Util.logDebug("Cannot display exitpoll. cognitiveVRManager not present in scene");
                Cleanup(false);
            }
        }