MCPcopy Create free account
hub / github.com/ValveSoftware/openvr / VR_LoadHmdSystemInternal

Function VR_LoadHmdSystemInternal

src/openvr_api_public.cpp:111–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109}
110
111EVRInitError VR_LoadHmdSystemInternal()
112{
113 std::string sRuntimePath, sConfigPath, sLogPath;
114
115 bool bReadPathRegistry = CVRPathRegistry_Public::GetPaths( &sRuntimePath, &sConfigPath, &sLogPath, NULL, NULL );
116 if( !bReadPathRegistry )
117 {
118 return vr::VRInitError_Init_PathRegistryNotFound;
119 }
120
121 // figure out where we're going to look for vrclient.dll
122 // see if the specified path actually exists.
123 if( !Path_IsDirectory( sRuntimePath ) )
124 {
125 return vr::VRInitError_Init_InstallationNotFound;
126 }
127
128 // Because we don't have a way to select debug vs. release yet we'll just
129 // use debug if it's there
130#if defined( WIN32 ) || defined( LINUX32 )
131 std::string sTestPath = Path_Join( sRuntimePath, "bin" );
132#else
133 std::string sTestPath = Path_Join( sRuntimePath, "bin", PLATSUBDIR );
134#endif
135 if( !Path_IsDirectory( sTestPath ) )
136 {
137 return vr::VRInitError_Init_InstallationCorrupt;
138 }
139
140#if defined( WIN64 )
141 std::string sDLLPath = Path_Join( sTestPath, "vrclient_x64" DYNAMIC_LIB_EXT );
142#else
143 std::string sDLLPath = Path_Join( sTestPath, "vrclient" DYNAMIC_LIB_EXT );
144#endif
145
146 // only look in the override
147 void *pMod = SharedLib_Load( sDLLPath.c_str() );
148 // nothing more to do if we can't load the DLL
149 if( !pMod )
150 {
151 return vr::VRInitError_Init_VRClientDLLNotFound;
152 }
153
154 VRClientCoreFactoryFn fnFactory = ( VRClientCoreFactoryFn )( SharedLib_GetFunction( pMod, "VRClientCoreFactory" ) );
155 if( !fnFactory )
156 {
157 SharedLib_Unload( pMod );
158 return vr::VRInitError_Init_FactoryNotFound;
159 }
160
161 int nReturnCode = 0;
162 g_pHmdSystem = static_cast< IVRClientCore * > ( fnFactory( vr::IVRClientCore_Version, &nReturnCode ) );
163 if( !g_pHmdSystem )
164 {
165 SharedLib_Unload( pMod );
166 return vr::VRInitError_Init_InterfaceNotFound;
167 }
168

Callers 2

VR_InitInternal2Function · 0.85
VR_IsHmdPresentFunction · 0.85

Calls 5

SharedLib_LoadFunction · 0.85
SharedLib_GetFunctionFunction · 0.85
SharedLib_UnloadFunction · 0.85
Path_IsDirectoryFunction · 0.50
Path_JoinFunction · 0.50

Tested by

no test coverage detected