forked from terminal29/Simple-OpenVR-Driver-Tutorial
-
Notifications
You must be signed in to change notification settings - Fork 14
/
HMDDevice.hpp
53 lines (42 loc) · 2.22 KB
/
HMDDevice.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#pragma once
#include <chrono>
#include "cmath_fix.h"
#include <linalg.h>
#include <Driver/IVRDevice.hpp>
#include <Native/DriverFactory.hpp>
namespace ExampleDriver {
class HMDDevice : public IVRDevice, public vr::IVRDisplayComponent {
public:
HMDDevice(std::string serial);
~HMDDevice() = default;
// Inherited via IVRDevice
virtual std::string GetSerial() override;
virtual void Update() override;
virtual vr::TrackedDeviceIndex_t GetDeviceIndex() override;
virtual DeviceType GetDeviceType() override;
virtual vr::EVRInitError Activate(uint32_t unObjectId) override;
virtual void Deactivate() override;
virtual void EnterStandby() override;
virtual void* GetComponent(const char* pchComponentNameAndVersion) override;
virtual void DebugRequest(const char* pchRequest, char* pchResponseBuffer, uint32_t unResponseBufferSize) override;
virtual vr::DriverPose_t GetPose() override;
// Inherited via IVRDisplayComponent
virtual void GetWindowBounds(int32_t* pnX, int32_t* pnY, uint32_t* pnWidth, uint32_t* pnHeight) override;
virtual bool IsDisplayOnDesktop() override;
virtual bool IsDisplayRealDisplay() override;
virtual void GetRecommendedRenderTargetSize(uint32_t* pnWidth, uint32_t* pnHeight) override;
virtual void GetEyeOutputViewport(vr::EVREye eEye, uint32_t* pnX, uint32_t* pnY, uint32_t* pnWidth, uint32_t* pnHeight) override;
virtual void GetProjectionRaw(vr::EVREye eEye, float* pfLeft, float* pfRight, float* pfTop, float* pfBottom) override;
virtual vr::DistortionCoordinates_t ComputeDistortion(vr::EVREye eEye, float fU, float fV) override;
private:
vr::TrackedDeviceIndex_t device_index_ = vr::k_unTrackedDeviceIndexInvalid;
std::string serial_;
vr::DriverPose_t last_pose_ = IVRDevice::MakeDefaultPose();
uint32_t window_x_ = 0;
uint32_t window_y_ = 0;
uint32_t window_width_ = 1920;
uint32_t window_height_ = 1080;
float pos_x_ = 0, pos_y_ = 0, pos_z_ = 0;
float rot_y_ = 0, rot_x_ = 0;
};
};