Exemplo n.º 1
0
        public virtual void Update()
        {
            if (!_isRendering)
            {
                return;
            }

            PreUpdateCallback?.Invoke(this, new EventArgs());

            // Mouse inputs are for dashboards only right now.

            if (DashboardOverlay != null && !DashboardOverlay.IsVisible())
            {
                if (_wasVisible)
                {
                    _wasVisible = false;
                    HandleMouseLeaveEvent();
                }
                return;
            }

            _wasVisible = true;

            // We'll handle mouse events here eventually.

            if (DashboardOverlay != null)
            {
                while (DashboardOverlay.PollEvent(ref ovrEvent))
                {
                    HandleEvent();
                }
            }

            PostUpdateCallback?.Invoke(this, new EventArgs());
        }
Exemplo n.º 2
0
        public virtual void Update()
        {
            if (!_isRendering)
            {
                return;
            }

            PreUpdateCallback?.Invoke(this, new EventArgs());

            // Mouse inputs are for dashboards only right now.

            if (InGameOverlay != null)
            {
                while (InGameOverlay.PollEvent(ref eventData))
                {
                    EVREventType type = (EVREventType)eventData.eventType;

                    HandleEvent(type, eventData);
                }
            }

            if (DashboardOverlay != null)
            {
                while (DashboardOverlay.PollEvent(ref eventData))
                {
                    EVREventType type = (EVREventType)eventData.eventType;

                    HandleEvent(type, eventData);
                }
            }

            if ((!EnableNonDashboardInput || InGameOverlay == null) && DashboardOverlay != null && !DashboardOverlay.IsVisible())
            {
                if (_wasVisible)
                {
                    _wasVisible = false;
                    HandleMouseLeaveEvent();
                }
                return;
            }

            _wasVisible = true;

            PostUpdateCallback?.Invoke(this, new EventArgs());
        }
        public static void RunOverlays()
        {
            Stopwatch fpsWatch    = new Stopwatch();
            VREvent_t eventData   = new VREvent_t();
            uint      vrEventSize = (uint)Marshal.SizeOf <VREvent_t>();

            while (!_doStop)
            {
                fpsWatch.Restart();

                UpdatePoses();

                PreUpdateCallback?.Invoke(null, null);

                foreach (WebKitOverlay overlay in Overlays)
                {
                    overlay.Update();
                }
                while (OpenVR.System.PollNextEvent(ref eventData, vrEventSize))
                {
                    SteamVR_Event.Send(((EVREventType)eventData.eventType).ToString().Replace("VREvent_", ""), eventData);
                }

                PostUpdateCallback?.Invoke(null, null);

                PreDrawCallback?.Invoke(null, null);

                foreach (WebKitOverlay overlay in Overlays)
                {
                    overlay.Draw();
                }

                PostDrawCallback?.Invoke(null, null);

                fpsWatch.Stop();
                Thread.Sleep(fpsWatch.ElapsedMilliseconds >= _frameSleep ? 0 : (int)(_frameSleep - fpsWatch.ElapsedMilliseconds));
            }

            CefShutdown();
        }