From 8323d64b2d997c03bcfb3a8a82cbec4e630ad71c Mon Sep 17 00:00:00 2001 From: Justin Li Date: Wed, 2 Sep 2020 11:54:55 -0400 Subject: [PATCH] Support IVRServerDriverHost_006 --- OpenVR-SpaceCalibrator/UserInterface.cpp | 2 +- .../InterfaceHookInjector.cpp | 33 +++++++++++++++---- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/OpenVR-SpaceCalibrator/UserInterface.cpp b/OpenVR-SpaceCalibrator/UserInterface.cpp index 4e5f24d..6981651 100644 --- a/OpenVR-SpaceCalibrator/UserInterface.cpp +++ b/OpenVR-SpaceCalibrator/UserInterface.cpp @@ -9,7 +9,7 @@ #include #include -#define VERSION_STRING "1.0" +#define VERSION_STRING "1.1" struct VRDevice { diff --git a/OpenVR-SpaceCalibratorDriver/InterfaceHookInjector.cpp b/OpenVR-SpaceCalibratorDriver/InterfaceHookInjector.cpp index 5053502..6211746 100644 --- a/OpenVR-SpaceCalibratorDriver/InterfaceHookInjector.cpp +++ b/OpenVR-SpaceCalibratorDriver/InterfaceHookInjector.cpp @@ -9,15 +9,28 @@ static Hook GetGenericInterfaceHook("IVRDriverContext::GetGenericInterface"); static Hook - TrackedDevicePoseUpdatedHook("IVRServerDriverHost005::TrackedDevicePoseUpdated"); + TrackedDevicePoseUpdatedHook005("IVRServerDriverHost005::TrackedDevicePoseUpdated"); -static void DetourTrackedDevicePoseUpdated(vr::IVRServerDriverHost *_this, uint32_t unWhichDevice, const vr::DriverPose_t &newPose, uint32_t unPoseStructSize) +static Hook + TrackedDevicePoseUpdatedHook006("IVRServerDriverHost006::TrackedDevicePoseUpdated"); + +static void DetourTrackedDevicePoseUpdated005(vr::IVRServerDriverHost *_this, uint32_t unWhichDevice, const vr::DriverPose_t &newPose, uint32_t unPoseStructSize) { //TRACE("ServerTrackedDeviceProvider::DetourTrackedDevicePoseUpdated(%d)", unWhichDevice); auto pose = newPose; if (Driver->HandleDevicePoseUpdated(unWhichDevice, pose)) { - TrackedDevicePoseUpdatedHook.originalFunc(_this, unWhichDevice, pose, unPoseStructSize); + TrackedDevicePoseUpdatedHook005.originalFunc(_this, unWhichDevice, pose, unPoseStructSize); + } +} + +static void DetourTrackedDevicePoseUpdated006(vr::IVRServerDriverHost *_this, uint32_t unWhichDevice, const vr::DriverPose_t &newPose, uint32_t unPoseStructSize) +{ + //TRACE("ServerTrackedDeviceProvider::DetourTrackedDevicePoseUpdated(%d)", unWhichDevice); + auto pose = newPose; + if (Driver->HandleDevicePoseUpdated(unWhichDevice, pose)) + { + TrackedDevicePoseUpdatedHook006.originalFunc(_this, unWhichDevice, pose, unPoseStructSize); } } @@ -29,10 +42,18 @@ static void *DetourGetGenericInterface(vr::IVRDriverContext *_this, const char * std::string iface(pchInterfaceVersion); if (iface == "IVRServerDriverHost_005") { - if (!IHook::Exists(TrackedDevicePoseUpdatedHook.name)) + if (!IHook::Exists(TrackedDevicePoseUpdatedHook005.name)) { - TrackedDevicePoseUpdatedHook.CreateHookInObjectVTable(originalInterface, 1, &DetourTrackedDevicePoseUpdated); - IHook::Register(&TrackedDevicePoseUpdatedHook); + TrackedDevicePoseUpdatedHook005.CreateHookInObjectVTable(originalInterface, 1, &DetourTrackedDevicePoseUpdated005); + IHook::Register(&TrackedDevicePoseUpdatedHook005); + } + } + else if (iface == "IVRServerDriverHost_006") + { + if (!IHook::Exists(TrackedDevicePoseUpdatedHook006.name)) + { + TrackedDevicePoseUpdatedHook006.CreateHookInObjectVTable(originalInterface, 1, &DetourTrackedDevicePoseUpdated006); + IHook::Register(&TrackedDevicePoseUpdatedHook006); } }