mirror of
https://github.com/mii443/MigawariDriver.git
synced 2025-08-22 16:05:33 +00:00
add initialize check
This commit is contained in:
@ -3,6 +3,7 @@
|
|||||||
#include "openvr_driver.h"
|
#include "openvr_driver.h"
|
||||||
|
|
||||||
struct SharedDevice {
|
struct SharedDevice {
|
||||||
|
bool enabled = false;
|
||||||
vr::DriverPose_t actual_pose;
|
vr::DriverPose_t actual_pose;
|
||||||
|
|
||||||
bool overwrite = false;
|
bool overwrite = false;
|
||||||
|
@ -15,11 +15,13 @@ static Hook<void(*)(vr::IVRServerDriverHost *, uint32_t, const vr::DriverPose_t
|
|||||||
|
|
||||||
static void DetourTrackedDevicePoseUpdated005(vr::IVRServerDriverHost *_this, uint32_t unWhichDevice, const vr::DriverPose_t &newPose, uint32_t unPoseStructSize) {
|
static void DetourTrackedDevicePoseUpdated005(vr::IVRServerDriverHost *_this, uint32_t unWhichDevice, const vr::DriverPose_t &newPose, uint32_t unPoseStructSize) {
|
||||||
auto pose = newPose;
|
auto pose = newPose;
|
||||||
|
Driver->SetSharedDevice(newPose, unWhichDevice);
|
||||||
TrackedDevicePoseUpdatedHook005.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) {
|
static void DetourTrackedDevicePoseUpdated006(vr::IVRServerDriverHost *_this, uint32_t unWhichDevice, const vr::DriverPose_t &newPose, uint32_t unPoseStructSize) {
|
||||||
auto pose = newPose;
|
auto pose = newPose;
|
||||||
|
Driver->SetSharedDevice(newPose, unWhichDevice);
|
||||||
TrackedDevicePoseUpdatedHook006.originalFunc(_this, unWhichDevice, pose, unPoseStructSize);
|
TrackedDevicePoseUpdatedHook006.originalFunc(_this, unWhichDevice, pose, unPoseStructSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ vr::EVRInitError ServerTrackedDeviceProvider::Init(vr::IVRDriverContext *pDriver
|
|||||||
for (int i = 0; i < vr::k_unMaxTrackedDeviceCount; i++) {
|
for (int i = 0; i < vr::k_unMaxTrackedDeviceCount; i++) {
|
||||||
HANDLE pHandle = CreateFileMapping(NULL, NULL, PAGE_READWRITE, NULL, sizeof(SharedDevice), ("MigawariDriver_Device" + std::to_string(i)).c_str());
|
HANDLE pHandle = CreateFileMapping(NULL, NULL, PAGE_READWRITE, NULL, sizeof(SharedDevice), ("MigawariDriver_Device" + std::to_string(i)).c_str());
|
||||||
devices[i] = (SharedDevice*)MapViewOfFile(pHandle, FILE_MAP_ALL_ACCESS, NULL, NULL, sizeof(SharedDevice));
|
devices[i] = (SharedDevice*)MapViewOfFile(pHandle, FILE_MAP_ALL_ACCESS, NULL, NULL, sizeof(SharedDevice));
|
||||||
|
devices[i]->enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
InjectHooks(this, pDriverContext);
|
InjectHooks(this, pDriverContext);
|
||||||
@ -34,6 +35,10 @@ void ServerTrackedDeviceProvider::Cleanup() {
|
|||||||
VR_CLEANUP_SERVER_DRIVER_CONTEXT();
|
VR_CLEANUP_SERVER_DRIVER_CONTEXT();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ServerTrackedDeviceProvider::SetSharedDevice(const vr::DriverPose_t &newPose, uint32_t unWhichDevice) {
|
||||||
|
devices[unWhichDevice]->actual_pose = newPose;
|
||||||
|
}
|
||||||
|
|
||||||
const char * const *ServerTrackedDeviceProvider::GetInterfaceVersions() {
|
const char * const *ServerTrackedDeviceProvider::GetInterfaceVersions() {
|
||||||
return vr::k_InterfaceVersions;
|
return vr::k_InterfaceVersions;
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ public:
|
|||||||
virtual bool ShouldBlockStandbyMode() { return false; };
|
virtual bool ShouldBlockStandbyMode() { return false; };
|
||||||
virtual void EnterStandby() { };
|
virtual void EnterStandby() { };
|
||||||
virtual void LeaveStandby() { };
|
virtual void LeaveStandby() { };
|
||||||
|
virtual void SetSharedDevice(const vr::DriverPose_t &newPose, uint32_t unWhichDevice);
|
||||||
private:
|
private:
|
||||||
SharedDevice* devices[vr::k_unMaxTrackedDeviceCount];
|
SharedDevice* devices[vr::k_unMaxTrackedDeviceCount];
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user