Skip to content

Commit 269b92d

Browse files
committed
fix crash when no HMD detected
1 parent d322d5f commit 269b92d

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

L4D2VR/hooks.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,12 @@ HRESULT __stdcall Hooks::dPresent(IDirect3DDevice9 *pDevice, const RECT *pSource
210210
iD9on12->ReturnUnderlyingResource(mVR->d9RightEyeTexture, 0, nullptr, nullptr);
211211
}
212212

213-
mVR->UpdatePosesAndActions();
214-
mVR->UpdateTracking(mVR->setupOrigin);
215-
213+
if (mVR->isInitialized)
214+
{
215+
mVR->UpdatePosesAndActions();
216+
mVR->UpdateTracking(mVR->setupOrigin);
217+
}
218+
216219
return hkPresent.fOriginal(pDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
217220
}
218221

L4D2VR/vr.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ VR::VR(Game *game) {
7272

7373
std::thread configParser(&VR::WaitForConfigUpdate, this);
7474
configParser.detach();
75+
76+
isInitialized = true;
7577
}
7678

7779

L4D2VR/vr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ class VR
101101
IDirect3DTexture9 *d9RightEyeTexture;
102102

103103
bool isVREnabled;
104+
bool isInitialized;
104105

105106
bool mPressedLeftStick = false;
106107
bool mChangedItem = false;

0 commit comments

Comments
 (0)