oculus1

view libovr/Src/win32/OVR_Win32_HMDDevice.h @ 17:cfe4979ab3eb

ops, minor error in the last commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 21 Sep 2013 07:09:48 +0300
parents
children
line source
1 /************************************************************************************
3 Filename : OVR_Win32_HMDDevice.h
4 Content : Win32 HMDDevice implementation
5 Created : September 21, 2012
6 Authors : Michael Antonov
8 Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved.
10 Use of this software is subject to the terms of the Oculus license
11 agreement provided at the time of installation or download, or which
12 otherwise accompanies this software in either electronic or hard copy form.
14 *************************************************************************************/
16 #ifndef OVR_Win32_HMDDevice_h
17 #define OVR_Win32_HMDDevice_h
19 #include "OVR_Win32_DeviceManager.h"
20 #include "OVR_Profile.h"
22 namespace OVR { namespace Win32 {
24 class HMDDevice;
27 //-------------------------------------------------------------------------------------
29 // HMDDeviceFactory enumerates attached Oculus HMD devices.
30 //
31 // This is currently done by matching monitor device strings.
33 class HMDDeviceFactory : public DeviceFactory
34 {
35 public:
36 static HMDDeviceFactory Instance;
38 // Enumerates devices, creating and destroying relevant objects in manager.
39 virtual void EnumerateDevices(EnumerateVisitor& visitor);
41 protected:
42 DeviceManager* getManager() const { return (DeviceManager*) pManager; }
43 };
46 class HMDDeviceCreateDesc : public DeviceCreateDesc
47 {
48 friend class HMDDevice;
50 protected:
51 enum
52 {
53 Contents_Screen = 1,
54 Contents_Distortion = 2,
55 Contents_7Inch = 4,
56 };
57 String DeviceId;
58 String DisplayDeviceName;
59 int DesktopX, DesktopY;
60 unsigned Contents;
61 unsigned HResolution, VResolution;
62 float HScreenSize, VScreenSize;
63 float DistortionK[4];
65 public:
66 HMDDeviceCreateDesc(DeviceFactory* factory,
67 const String& deviceId, const String& displayDeviceName);
68 HMDDeviceCreateDesc(const HMDDeviceCreateDesc& other);
70 virtual DeviceCreateDesc* Clone() const
71 {
72 return new HMDDeviceCreateDesc(*this);
73 }
75 virtual DeviceBase* NewDeviceInstance();
77 virtual MatchResult MatchDevice(const DeviceCreateDesc& other,
78 DeviceCreateDesc**) const;
80 // Matches device by path.
81 virtual bool MatchDevice(const String& path);
83 virtual bool UpdateMatchedCandidate(const DeviceCreateDesc&, bool* newDeviceFlag = NULL);
85 virtual bool GetDeviceInfo(DeviceInfo* info) const;
87 // Requests the currently used default profile. This profile affects the
88 // settings reported by HMDInfo.
89 Profile* GetProfileAddRef() const;
91 ProfileType GetProfileType() const
92 {
93 return (HResolution >= 1920) ? Profile_RiftDKHD : Profile_RiftDK1;
94 }
97 void SetScreenParameters(int x, int y, unsigned hres, unsigned vres, float hsize, float vsize)
98 {
99 DesktopX = x;
100 DesktopY = y;
101 HResolution = hres;
102 VResolution = vres;
103 HScreenSize = hsize;
104 VScreenSize = vsize;
105 Contents |= Contents_Screen;
106 }
107 void SetDistortion(const float* dks)
108 {
109 for (int i = 0; i < 4; i++)
110 DistortionK[i] = dks[i];
111 Contents |= Contents_Distortion;
112 }
114 void Set7Inch() { Contents |= Contents_7Inch; }
116 bool Is7Inch() const;
117 };
120 //-------------------------------------------------------------------------------------
122 // HMDDevice represents an Oculus HMD device unit. An instance of this class
123 // is typically created from the DeviceManager.
124 // After HMD device is created, we its sensor data can be obtained by
125 // first creating a Sensor object and then wrappig it in SensorFusion.
127 class HMDDevice : public DeviceImpl<OVR::HMDDevice>
128 {
129 public:
130 HMDDevice(HMDDeviceCreateDesc* createDesc);
131 ~HMDDevice();
133 virtual bool Initialize(DeviceBase* parent);
134 virtual void Shutdown();
136 // Requests the currently used default profile. This profile affects the
137 // settings reported by HMDInfo.
138 virtual Profile* GetProfile() const;
139 virtual const char* GetProfileName() const;
140 virtual bool SetProfileName(const char* name);
142 // Query associated sensor.
143 virtual OVR::SensorDevice* GetSensor();
145 protected:
146 HMDDeviceCreateDesc* getDesc() const { return (HMDDeviceCreateDesc*)pCreateDesc.GetPtr(); }
148 // User name for the profile used with this device.
149 String ProfileName;
150 mutable Ptr<Profile> pCachedProfile;
151 };
154 }} // namespace OVR::Win32
156 #endif // OVR_Win32_HMDDevice_h