Exemplo n.º 1
0
        public void PollingVREvents()
        {
            if (openVR != null)
            {
                var       size   = (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(Valve.VR.VREvent_t));
                VREvent_t pEvent = new VREvent_t();
                while (openVR.PollNextEvent(ref pEvent, size))
                {//Receive VREvent
                    EVREventType type = (EVREventType)pEvent.eventType;
                    switch (type)
                    {
                    case EVREventType.VREvent_Quit:
                        if (OnOVRConnected != null)
                        {
                            OnOVRConnected.Invoke(this, new OVRConnectedEventArgs(false));
                        }
                        break;
                        //ほかにもイベントはいろいろある
                    }

                    if (OnOVREvent != null)
                    {
                        OnOVREvent.Invoke(this, new OVREventArgs(pEvent));
                    }
                }
            }
        }
Exemplo n.º 2
0
        public bool Setup(EVRApplicationType applicationType = EVRApplicationType.VRApplication_Scene)
        {
            var error = EVRInitError.None;

            openvr = OpenVR.Init(ref error, applicationType);

            if (error != EVRInitError.None)
            {
                Close();
                return(false);
            }

            OnOVRConnected?.Invoke(this, new OVRConnectedEventArgs(true));
            return(true);
        }
Exemplo n.º 3
0
        public bool Setup()
        {
            var error = EVRInitError.None;

            openVR = OpenVR.Init(ref error, EVRApplicationType.VRApplication_Background);

            if (error != EVRInitError.None)
            { //Error Init OpenVR
                Close();
                return(false);
            }

            OnOVRConnected?.Invoke(this, new OVRConnectedEventArgs(true));

            return(true);
        }
Exemplo n.º 4
0
        public bool Setup()
        {
            var error = EVRInitError.None;

            openVR = OpenVR.Init(ref error, EVRApplicationType.VRApplication_Overlay);

            if (error == EVRInitError.Init_HmdNotFound)
            {
                Close();
                //HMD require fallback
                openVR = OpenVR.Init(ref error, EVRApplicationType.VRApplication_Background);
            }

            if (error != EVRInitError.None)
            { //Error Init OpenVR
                Close();
                System.IO.File.WriteAllText(Application.dataPath + "/../OpenVRInitError.txt", error.ToString());
                return(false);
            }

            OnOVRConnected?.Invoke(this, new OVRConnectedEventArgs(true));

            return(true);
        }