Add ability to change IVRInput bindings, move openvr_init into namespace
openvr_init was not in a namespace. This led to it being globally available. This was not intended. The solution to overlays not showing up in the bindings interface was chosen for ease of implementation and relative ease of end user use. The Kinect2VR project are using a solution where there is a button to shutdown background mode and use scene mode temporarily. This did not work for our project for unknown reasons. The IVRInput system would become non responsive and spam error messages when VR was shut down. Implementation is here: https://github.com/sharkyh20/KinectToVR/blob/12aeb8b33ab20eeb588c72c5d5186dd4d87784d7/SFMLProject/inc/GUIHandler.h#L700 The command line flag will be represented as a .bat file for the end user, like desktop mode and restarting the VR server. When Valve solves the issue of overlays not showing up in the bindings menu, the entire function can essentially be deleted. Official issues here: https://github.com/ValveSoftware/openvr/issues/914 https://github.com/ValveSoftware/openvr/issues/926 https://github.com/ValveSoftware/openvr/issues/879 It is also possible to make the app appear by changing the C:\Program Files (x86)\Steam\config\vrappconfig\*.vrappconfig file for the project to have a "last_launch_time" of something greater than zero. From experimentation it seems that there's a cutoff time around 2 weeks before the current time. Setting it to the day before seems to be a good bet. (In unix time).
This commit is contained in:
@@ -2,10 +2,13 @@
|
||||
#include <openvr.h>
|
||||
#include <QMessageBox>
|
||||
#include "openvr_init.h"
|
||||
#include <easylogging++.h>
|
||||
#include "../ivrinput/ivrinput_manifest.h"
|
||||
|
||||
OpenVR_Init::OpenVR_Init()
|
||||
namespace openvr_init
|
||||
{
|
||||
void initializeProperly()
|
||||
{
|
||||
// Loading the OpenVR Runtime
|
||||
auto initError = vr::VRInitError_None;
|
||||
vr::VR_Init( &initError, vr::VRApplication_Overlay );
|
||||
if ( initError != vr::VRInitError_None )
|
||||
@@ -22,6 +25,66 @@ OpenVR_Init::OpenVR_Init()
|
||||
+ std::string(
|
||||
vr::VR_GetVRInitErrorAsEnglishDescription( initError ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG( INFO ) << "OpenVR initialized successfully.";
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Initializes OpenVR to be in the bindings menu and then exits.
|
||||
This is needed because all applications initialized with OpenVR that aren't of
|
||||
type vr::VRApplication_Scene do not show up the in bindings menu.
|
||||
|
||||
This is obviously an ugly hack and should be done away with as soon as Valve
|
||||
fixes this issue.
|
||||
|
||||
Official Issues for this:
|
||||
https://github.com/ValveSoftware/openvr/issues/914
|
||||
https://github.com/ValveSoftware/openvr/issues/926
|
||||
https://github.com/ValveSoftware/openvr/issues/879
|
||||
|
||||
You can also make it appear by changing the
|
||||
C:\Program Files (x86)\Steam\config\vrappconfig\*.vrappconfig file for your
|
||||
project to have a "last_launch_time" of something greater than zero.
|
||||
From experimentation it seems that there's a cutoff time around 2 weeks before
|
||||
the current time. Setting it to the day before seems to be a good bet. (In unix
|
||||
time).
|
||||
*/
|
||||
[[noreturn]] void openBindingsMenu()
|
||||
{
|
||||
// Prefix the logs with this to visibly document that this isn't how things
|
||||
// are supposed to be. Hopefully someone reads the logs and comes here after
|
||||
// Valve has fixed it.
|
||||
constexpr auto logPrefix = "[HACK]::openBindingsMenu ";
|
||||
|
||||
auto initError = vr::VRInitError_None;
|
||||
LOG( INFO ) << logPrefix << "Initializing application as scene.";
|
||||
|
||||
vr::VR_Init( &initError, vr::VRApplication_Scene );
|
||||
|
||||
if ( initError != vr::VRInitError_None )
|
||||
{
|
||||
LOG( ERROR ) << logPrefix << "Error initializing application as scene.";
|
||||
exit( 2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG( INFO ) << logPrefix << "Application initialized as scene.";
|
||||
}
|
||||
|
||||
input::Manifest manifest;
|
||||
|
||||
// SteamVR just needs a good enough time to start up comfortably and for the
|
||||
// user to get into the bindings menu.
|
||||
while ( true )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
OpenVR_Init::OpenVR_Init()
|
||||
{
|
||||
initializeProperly();
|
||||
|
||||
// The function call and error message was the same for all version checks.
|
||||
// Specific error messages are unlikely to be necessary since both the type
|
||||
@@ -80,3 +143,4 @@ OpenVR_Init::~OpenVR_Init()
|
||||
{
|
||||
vr::VR_Shutdown();
|
||||
}
|
||||
} // namespace openvr_init
|
||||
|
||||
Reference in New Issue
Block a user