Skip to content

Commit

Permalink
fix crash when no HMD detected
Browse files Browse the repository at this point in the history
  • Loading branch information
sd805 committed May 23, 2022
1 parent d322d5f commit 269b92d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
9 changes: 6 additions & 3 deletions L4D2VR/hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,12 @@ HRESULT __stdcall Hooks::dPresent(IDirect3DDevice9 *pDevice, const RECT *pSource
iD9on12->ReturnUnderlyingResource(mVR->d9RightEyeTexture, 0, nullptr, nullptr);
}

mVR->UpdatePosesAndActions();
mVR->UpdateTracking(mVR->setupOrigin);

if (mVR->isInitialized)
{
mVR->UpdatePosesAndActions();
mVR->UpdateTracking(mVR->setupOrigin);
}

return hkPresent.fOriginal(pDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
}

Expand Down
2 changes: 2 additions & 0 deletions L4D2VR/vr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ VR::VR(Game *game) {

std::thread configParser(&VR::WaitForConfigUpdate, this);
configParser.detach();

isInitialized = true;
}


Expand Down
1 change: 1 addition & 0 deletions L4D2VR/vr.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class VR
IDirect3DTexture9 *d9RightEyeTexture;

bool isVREnabled;
bool isInitialized;

bool mPressedLeftStick = false;
bool mChangedItem = false;
Expand Down

0 comments on commit 269b92d

Please sign in to comment.