Beispiel #1
0
        public void Init()
        {
            StatusUpdateAction.Invoke(false);
            AppUpdateAction.Invoke("");

            _mediaPlayer = new MediaPlayer();

            _workerThread = new Thread(WorkerThread);
            _workerThread.Start();

            if (_settings.EnableServer && _settings.ServerPort != 0)
            {
                _server.StartOrRestart(_settings.ServerPort);
            }
            _server.MessageReceievedAction = (session, message) =>
            {
                var msg = new Remote.ScreenshotMessage();
                try
                {
                    msg = JsonConvert.DeserializeObject <Remote.ScreenshotMessage>(message);
                } catch (JsonReaderException e)
                {
                    Debug.WriteLine(e.Message);
                    _server.SendMessage(session, "Could not parse JSON");
                }
                if (_initComplete && !OpenVR.Overlay.IsDashboardVisible())
                {
                    if (msg.nonce != string.Empty)
                    {
                        msg.session = session;
                        if (msg.delay > 0)
                        {
                            TakeDelayedScreenshot(true, msg);
                        }
                        else
                        {
                            TakeScreenshot(true, msg);                                                       // byUser is true as this should show viewfinder etc.
                        }
                    }
                }
            };
            _server.StatusMessageAction = (session, connected, status) =>
            {
                Debug.WriteLine($"Session: {session}, connected: {connected}, status: {status}");
            };
            _server.StatusAction = (status, count) =>
            {
            };
        }
Beispiel #2
0
        public void Init(string[] actionKeys)
        {
            _actionKeys = actionKeys;

            // Sets default values for status labels
            StatusUpdateAction.Invoke(false);
            AppUpdateAction.Invoke(MainModel.CONFIG_DEFAULT);
            KeyActivatedAction.Invoke(string.Empty, false);

            // Loads default config
            LoadConfig(true);

            // Start background thread
            var workerThread = new Thread(WorkerThread);

            workerThread.Start();
        }
Beispiel #3
0
        private void WorkerThread()
        {
            Thread.CurrentThread.IsBackground = true;
            bool initComplete = false;

            while (true)
            {
                Thread.Sleep(10);
                if (_ovr.IsInitialized())
                {
                    if (!initComplete)
                    {
                        initComplete = true;

                        _ovr.AddApplicationManifest("./app.vrmanifest", "boll7708.openvr2key", true);
                        _ovr.LoadActionManifest("./actions.json");
                        RegisterActions();
                        UpdateAppId();
                        StatusUpdateAction.Invoke(true);
                        UpdateInputSourceHandles();
                        _notificationOverlayHandle = _ovr.InitNotificationOverlay("OpenVR2Key");

                        _ovr.RegisterEvent(EVREventType.VREvent_Quit, (data) =>
                        {
                            _shouldShutDown = true;
                        });
                        _ovr.RegisterEvent(EVREventType.VREvent_SceneApplicationChanged, (data) =>
                        {
                            UpdateAppId();
                        });
                        _ovr.RegisterEvents(new EVREventType[] {
                            EVREventType.VREvent_TrackedDeviceActivated,
                            EVREventType.VREvent_TrackedDeviceRoleChanged,
                            EVREventType.VREvent_TrackedDeviceUpdated
                        },
                                            (data) =>
                        {
                            UpdateInputSourceHandles();
                        }
                                            );
                        _ovr.RegisterEvent(EVREventType.VREvent_DashboardActivated, (data) =>
                        {
                            DashboardVisibleAction.Invoke(true);
                        });
                        _ovr.RegisterEvent(EVREventType.VREvent_DashboardDeactivated, (data) =>
                        {
                            DashboardVisibleAction.Invoke(false);
                        });
                        DashboardVisibleAction.Invoke(OpenVR.Overlay.IsDashboardVisible()); // To convey the initial state if the Dashboard is visible on launch of application.
                    }
                    else
                    {
                        _ovr.UpdateActionStates(_inputSourceHandles);

                        _ovr.UpdateEvents();

                        if (_shouldShutDown)
                        {
                            _shouldShutDown = false;
                            initComplete    = false;
                            _ovr.AcknowledgeShutdown();
                            _ovr.Shutdown();
                            StatusUpdateAction.Invoke(false);
                        }
                    }
                }
                else
                {
                    _ovr.Init();
                    Thread.Sleep(1000);
                }
            }
        }
Beispiel #4
0
        private void WorkerThread()
        {
            Thread.CurrentThread.IsBackground = true;
            bool initComplete = false;

            while (true)
            {
                Thread.Sleep(10);
                if (_ovr.IsInitialized())
                {
                    if (!initComplete)
                    {
                        initComplete = true;

                        _ovr.LoadAppManifest("./app.vrmanifest");
                        _ovr.LoadActionManifest("./actions.json");
                        RegisterActions();
                        UpdateAppId();
                        StatusUpdateAction.Invoke(true);
                        UpdateInputSourceHandles();
                        _notificationOverlayHandle = _ovr.InitNotificationOverlay("OpenVR2Key");

                        _ovr.RegisterEvent(EVREventType.VREvent_Quit, (data) =>
                        {
                            _shouldShutDown = true;
                        });
                        _ovr.RegisterEvent(EVREventType.VREvent_SceneApplicationChanged, (data) =>
                        {
                            UpdateAppId();
                        });
                        _ovr.RegisterEvents(new EVREventType[] {
                            EVREventType.VREvent_TrackedDeviceActivated,
                            EVREventType.VREvent_TrackedDeviceRoleChanged,
                            EVREventType.VREvent_TrackedDeviceUpdated
                        },
                                            (data) =>
                        {
                            UpdateInputSourceHandles();
                        }
                                            );
                    }
                    else
                    {
                        _ovr.UpdateActionStates(new ulong[] {
                            _inputSourceHandleLeft,
                            _inputSourceHandleRight
                        });

                        _ovr.UpdateEvents();

                        if (_shouldShutDown)
                        {
                            _shouldShutDown = false;
                            initComplete    = false;
                            _ovr.AcknowledgeShutdown();
                            _ovr.Shutdown();
                            StatusUpdateAction.Invoke(false);
                        }
                    }
                }
                else
                {
                    _ovr.Init();
                    Thread.Sleep(1000);
                }
            }
        }