mirror of
https://github.com/mii443/MigawariDriver.git
synced 2025-08-22 16:05:33 +00:00
add shared device
This commit is contained in:
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -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
|
||||
|
10
driver_files/src/Device.hpp
Normal file
10
driver_files/src/Device.hpp
Normal 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;
|
||||
};
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
1
lib/minhook
Submodule
Submodule lib/minhook added at c1a7c3843b
Reference in New Issue
Block a user