Refactor OpenVR init code to separate class
The OpenVR init code is currently being run in the OverlayController constructor. Member objects that are initialized before the OverlayController (ideally all of them) can't use OpenVR APIs before the first line of the OverlayController constructor. Implementing the OpenVR Init code as a class means that it is able to initialize before all the other objects and allow them to use OpenVR APIs in their constructors. The class has been placed in a folder called "overlaycontroller" to signify that it should only be used by the OverlayController. openvr_init.h uses #pragma once despite it being unofficial since it is supported on all modern compilers. The copy constructor, copy assignment operator, move constructor and move assignment operator have been explicitly deleted in order to make sure nobody tries to use the object in an unintended way, and to document that these functions should not be automatically created. The version error messages have been replaced with a single lambda, since they were all identical. The version error text should maybe tell the user to update Advanced Settings instead of OpenVR, since Advanced Settings contains the version strings in the binary. No other exit functions were documented on the official docs besides VR_Shutdown().
This commit is contained in:
@@ -23,6 +23,9 @@
|
||||
#include <QSoundEffect>
|
||||
#include <memory>
|
||||
#include <easylogging++.h>
|
||||
|
||||
#include "overlaycontroller/openvr_init.h"
|
||||
|
||||
#include "utils/ChaperoneUtils.h"
|
||||
|
||||
#include "tabcontrollers/SteamVRTabController.h"
|
||||
@@ -80,6 +83,11 @@ private:
|
||||
QSoundEffect m_focusChangedSoundEffect;
|
||||
QSoundEffect m_alarm01SoundEffect;
|
||||
|
||||
// OpenVR_Init must be declared before any other class that uses OpenVR
|
||||
// function calls since objects are initialized in order of declaration in
|
||||
// the class.
|
||||
OpenVR_Init openVrInit;
|
||||
|
||||
public: // I know it's an ugly hack to make them public to enable external
|
||||
// access, but I am too lazy to implement getters.
|
||||
SteamVRTabController m_steamVRTabController;
|
||||
|
||||
Reference in New Issue
Block a user