Skip to content

Commit

Permalink
update controller indexes while running
Browse files Browse the repository at this point in the history
  • Loading branch information
sd805 committed Jun 6, 2022
1 parent 3f01162 commit 703b5bd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 31 deletions.
5 changes: 0 additions & 5 deletions L4D2VR/hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,9 @@ void __fastcall Hooks::dRenderView(void *ecx, void *edx, CViewSetup &setup, CVie
{
IMatRenderContext *rndrContext = m_Game->m_MaterialSystem->GetRenderContext();

int clearflags = 0;

CViewSetup leftEyeView = setup;
CViewSetup rightEyeView = setup;

int width_VR = m_VR->m_FrameBufferWidth / 2;
int height_VR = m_VR->m_FrameBufferHeight;

// Left eye CViewSetup
leftEyeView.x = 0;
leftEyeView.width = m_VR->m_RenderWidth;
Expand Down
22 changes: 6 additions & 16 deletions L4D2VR/vr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,6 @@ int VR::SetActionManifest(const char *fileName) {
m_ActiveActionSet = {};
m_ActiveActionSet.ulActionSet = m_ActionSet;

// Get index for each controller
vr::VRInputValueHandle_t leftControllerHandle{};
vr::VRInputValueHandle_t rightControllerHandle{};
m_Input->GetInputSourceHandle("/user/hand/left", &leftControllerHandle);
m_Input->GetInputSourceHandle("/user/hand/right", &rightControllerHandle);

vr::InputOriginInfo_t leftOriginInfo{};
vr::InputOriginInfo_t rightOriginInfo{};
m_Input->GetOriginTrackedDeviceInfo(leftControllerHandle, &leftOriginInfo, sizeof(leftOriginInfo));
m_Input->GetOriginTrackedDeviceInfo(rightControllerHandle, &rightOriginInfo, sizeof(rightOriginInfo));

m_LeftControllerIndex = leftOriginInfo.trackedDeviceIndex;
m_RightControllerIndex = rightOriginInfo.trackedDeviceIndex;

return 0;
}

Expand Down Expand Up @@ -209,8 +195,12 @@ void VR::GetPoses()
vr::TrackedDevicePose_t pose;

vr::TrackedDevicePose_t hmdPose = m_Poses[vr::k_unTrackedDeviceIndex_Hmd];
vr::TrackedDevicePose_t leftControllerPose = m_Poses[m_LeftControllerIndex];
vr::TrackedDevicePose_t rightControllerPose = m_Poses[m_RightControllerIndex];

vr::TrackedDeviceIndex_t leftControllerIndex = m_System->GetTrackedDeviceIndexForControllerRole(vr::TrackedControllerRole_LeftHand);
vr::TrackedDevicePose_t leftControllerPose = m_Poses[leftControllerIndex];

vr::TrackedDeviceIndex_t rightControllerIndex = m_System->GetTrackedDeviceIndexForControllerRole(vr::TrackedControllerRole_RightHand);
vr::TrackedDevicePose_t rightControllerPose = m_Poses[rightControllerIndex];

GetPoseData(hmdPose, m_HmdPose);
GetPoseData(leftControllerPose, m_LeftControllerPose);
Expand Down
12 changes: 2 additions & 10 deletions L4D2VR/vr.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct TrackedDevicePoseData {

struct SharedTextureHolder {
vr::VRVulkanTextureData_t m_VulkanData;
vr::Texture_t m_VRTexture;
vr::Texture_t m_VRTexture;
};


Expand All @@ -32,6 +32,7 @@ class VR

vr::IVRSystem *m_System = nullptr;
vr::IVRInput *m_Input = nullptr;

float m_HorizontalOffsetLeft;
float m_VerticalOffsetLeft;
float m_HorizontalOffsetRight;
Expand Down Expand Up @@ -76,9 +77,6 @@ class VR
Vector m_RightControllerPosAbs;
QAngle m_RightControllerAngAbs;

int m_FrameBufferWidth;
int m_FrameBufferHeight;

float m_Ipd;
float m_EyeZ;

Expand All @@ -87,9 +85,6 @@ class VR
ITexture *m_LeftEyeTexture;
ITexture *m_RightEyeTexture;

IDirect3DTexture9 *m_D9LeftEyeTexture;
IDirect3DTexture9 *m_D9RightEyeTexture;

IDirect3DSurface9 *m_D9LeftEyeSurface;
IDirect3DSurface9 *m_D9RightEyeSurface;

Expand Down Expand Up @@ -128,9 +123,6 @@ class VR
vr::VRActionHandle_t m_ActionFlashlight;
vr::VRActionHandle_t m_ActionActivateVR;

int m_LeftControllerIndex;
int m_RightControllerIndex;

TrackedDevicePoseData m_HmdPose;
TrackedDevicePoseData m_LeftControllerPose;
TrackedDevicePoseData m_RightControllerPose;
Expand Down

0 comments on commit 703b5bd

Please sign in to comment.