add shared device

This commit is contained in:
mii443
2024-10-29 10:32:21 +09:00
parent 33f0635702
commit e957836b3d
5 changed files with 27 additions and 5 deletions

3
.gitmodules vendored
View File

@ -1,3 +1,6 @@
[submodule "lib/openvr"]
path = lib/openvr
url = https://github.com/ValveSoftware/openvr
[submodule "lib/minhook"]
path = lib/minhook
url = https://github.com/TsudaKageyu/minhook

View File

@ -0,0 +1,10 @@
#pragma once
#include "openvr_driver.h"
struct SharedDevice {
vr::DriverPose_t actual_pose;
bool overwrite = false;
vr::DriverPose_t overwrite_pose;
};

View File

@ -1,19 +1,25 @@
#include "ServerTrackedDeviceProvider.hpp"
#include "Device.hpp"
#include <Windows.h>
vr::EVRInitError ServerTrackedDeviceProvider::Init(vr::IVRDriverContext *pDriverContext) {
VR_INIT_SERVER_DRIVER_CONTEXT(pDriverContext);
auto name = "MigawariDriver";
auto name = "MigawariDriver_k_unMaxTrackedDeviceCount";
auto size = 4;
HANDLE hSharedMemory = CreateFileMapping(NULL, NULL, PAGE_READWRITE, NULL, size, name);
pMemory = (int*)MapViewOfFile(hSharedMemory, FILE_MAP_ALL_ACCESS, NULL, NULL, size);
auto pMemory = (uint32_t*)MapViewOfFile(hSharedMemory, FILE_MAP_ALL_ACCESS, NULL, NULL, size);
*pMemory = 100;
*pMemory = vr::k_unMaxTrackedDeviceCount;
std::string message = "Migawari driver initialized!\n";
std::string message = "Initializing migawari driver...\n";
vr::VRDriverLog()->Log(message.c_str());
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());
devices[i] = (SharedDevice*)MapViewOfFile(pHandle, FILE_MAP_ALL_ACCESS, NULL, NULL, sizeof(SharedDevice));
}
return vr::VRInitError_None;
}

View File

@ -1,5 +1,7 @@
#pragma once
#include "Device.hpp"
#include <openvr_driver.h>
class ServerTrackedDeviceProvider : public vr::IServerTrackedDeviceProvider {
@ -12,5 +14,5 @@ public:
virtual void EnterStandby() { };
virtual void LeaveStandby() { };
private:
int *pMemory;
SharedDevice* devices[vr::k_unMaxTrackedDeviceCount];
};

1
lib/minhook Submodule

Submodule lib/minhook added at c1a7c3843b