vrclient: Use PROTON_VR_RUNTIME from registry if env var is not there.

CW-Bug-Id: #21036
This commit is contained in:
Paul Gofman 2022-07-28 12:22:30 -05:00 committed by Arkadiusz Hiler
parent 5e7036d566
commit a62a80be58

View file

@ -272,10 +272,32 @@ static int load_vrclient(void)
/* PROTON_VR_RUNTIME is provided by the proton setup script */
if(!GetEnvironmentVariableW(L"PROTON_VR_RUNTIME", pathW, ARRAY_SIZE(pathW)))
{
TRACE("Linux OpenVR runtime is not available\n");
DWORD type, size;
LSTATUS status;
HKEY vr_key;
if ((status = RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Wine\\VR", 0, KEY_READ, &vr_key)))
{
WINE_WARN("Could not create key, status %#x.\n", status);
return 0;
}
size = sizeof(pathW);
if ((status = RegQueryValueExW(vr_key, L"PROTON_VR_RUNTIME", NULL, &type, (BYTE *)pathW, &size)))
{
WINE_WARN("Could not query value, status %#x.\n", status);
RegCloseKey(vr_key);
return 0;
}
if (type != REG_SZ)
{
WINE_ERR("Unexpected value type %#x.\n", type);
RegCloseKey(vr_key);
return 0;
}
RegCloseKey(vr_key);
}
sz = WideCharToMultiByte(CP_UNIXCP, 0, pathW, -1, NULL, 0, NULL, NULL);
if(!sz)
{
@ -289,6 +311,7 @@ static int load_vrclient(void)
if(!sz)
{
ERR("Can't convert path to unixcp! %s\n", wine_dbgstr_w(pathW));
HeapFree(GetProcessHeap(), 0, pathU);
return 0;
}
@ -299,21 +322,25 @@ static int load_vrclient(void)
vrclient_lib = dlopen(pathU, RTLD_NOW);
if(!vrclient_lib){
TRACE("unable to load vrclient.so\n");
HeapFree(GetProcessHeap(), 0, pathU);
return 0;
}
vrclient_HmdSystemFactory = dlsym(vrclient_lib, "HmdSystemFactory");
if(!vrclient_HmdSystemFactory){
ERR("unable to load HmdSystemFactory method\n");
HeapFree(GetProcessHeap(), 0, pathU);
return 0;
}
vrclient_VRClientCoreFactory = dlsym(vrclient_lib, "VRClientCoreFactory");
if(!vrclient_VRClientCoreFactory){
ERR("unable to load VRClientCoreFactory method\n");
HeapFree(GetProcessHeap(), 0, pathU);
return 0;
}
HeapFree(GetProcessHeap(), 0, pathU);
return 1;
}