mirror of
https://github.com/mii443/MigawariDriver.git
synced 2025-08-22 16:05:33 +00:00
support overwrite
This commit is contained in:
@ -15,13 +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);
|
Driver->SetSharedDevice(pose, 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);
|
Driver->SetSharedDevice(pose, unWhichDevice);
|
||||||
TrackedDevicePoseUpdatedHook006.originalFunc(_this, unWhichDevice, pose, unPoseStructSize);
|
TrackedDevicePoseUpdatedHook006.originalFunc(_this, unWhichDevice, pose, unPoseStructSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,11 +19,8 @@ vr::EVRInitError ServerTrackedDeviceProvider::Init(vr::IVRDriverContext *pDriver
|
|||||||
std::string message = "Initializing migawari driver...\n";
|
std::string message = "Initializing migawari driver...\n";
|
||||||
vr::VRDriverLog()->Log(message.c_str());
|
vr::VRDriverLog()->Log(message.c_str());
|
||||||
|
|
||||||
for (int i = 0; i < vr::k_unMaxTrackedDeviceCount; i++) {
|
auto hMapFile = CreateFileMapping(NULL, NULL, PAGE_READWRITE, NULL, sizeof(SharedDevice) * 64, "MigawariDriver_Devices");
|
||||||
HANDLE pHandle = CreateFileMapping(NULL, NULL, PAGE_READWRITE, NULL, sizeof(SharedDevice), ("MigawariDriver_Device" + std::to_string(i)).c_str());
|
devices = (SharedDevice*)MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, NULL, NULL, sizeof(SharedDevice) * 64);
|
||||||
devices[i] = (SharedDevice*)MapViewOfFile(pHandle, FILE_MAP_ALL_ACCESS, NULL, NULL, sizeof(SharedDevice));
|
|
||||||
devices[i]->enabled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
InjectHooks(this, pDriverContext);
|
InjectHooks(this, pDriverContext);
|
||||||
#endif
|
#endif
|
||||||
@ -35,8 +32,20 @@ void ServerTrackedDeviceProvider::Cleanup() {
|
|||||||
VR_CLEANUP_SERVER_DRIVER_CONTEXT();
|
VR_CLEANUP_SERVER_DRIVER_CONTEXT();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerTrackedDeviceProvider::SetSharedDevice(const vr::DriverPose_t &newPose, uint32_t unWhichDevice) {
|
void ServerTrackedDeviceProvider::SetSharedDevice(vr::DriverPose_t &newPose, uint32_t unWhichDevice) {
|
||||||
devices[unWhichDevice]->actual_pose = newPose;
|
devices[unWhichDevice].actual_pose = newPose;
|
||||||
|
|
||||||
|
if (devices[unWhichDevice].overwrite) {
|
||||||
|
auto overwrite_pose = devices[unWhichDevice].overwrite_pose;
|
||||||
|
newPose.qRotation = overwrite_pose.qRotation;
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
newPose.vecAcceleration[i] = overwrite_pose.vecAcceleration[i];
|
||||||
|
newPose.vecAngularAcceleration[i] = overwrite_pose.vecAngularAcceleration[i];
|
||||||
|
newPose.vecPosition[i] = overwrite_pose.vecPosition[i];
|
||||||
|
newPose.vecVelocity[i] = overwrite_pose.vecVelocity[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * const *ServerTrackedDeviceProvider::GetInterfaceVersions() {
|
const char * const *ServerTrackedDeviceProvider::GetInterfaceVersions() {
|
||||||
|
@ -2,10 +2,13 @@
|
|||||||
|
|
||||||
#include "Device.hpp"
|
#include "Device.hpp"
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
#include <openvr_driver.h>
|
#include <openvr_driver.h>
|
||||||
|
|
||||||
class ServerTrackedDeviceProvider : public vr::IServerTrackedDeviceProvider {
|
class ServerTrackedDeviceProvider : public vr::IServerTrackedDeviceProvider {
|
||||||
public:
|
public:
|
||||||
|
ServerTrackedDeviceProvider() : devices(nullptr) {}
|
||||||
|
|
||||||
virtual vr::EVRInitError Init(vr::IVRDriverContext *pDriverContext) override;
|
virtual vr::EVRInitError Init(vr::IVRDriverContext *pDriverContext) override;
|
||||||
virtual void Cleanup() override;
|
virtual void Cleanup() override;
|
||||||
virtual const char * const *GetInterfaceVersions() override;
|
virtual const char * const *GetInterfaceVersions() override;
|
||||||
@ -13,7 +16,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);
|
virtual void SetSharedDevice(vr::DriverPose_t &newPose, uint32_t unWhichDevice);
|
||||||
private:
|
private:
|
||||||
SharedDevice* devices[vr::k_unMaxTrackedDeviceCount];
|
SharedDevice* devices;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user