oculus1
view libovr/Src/linux/OVR_Linux_HMDDevice.h @ 20:ff3bfd4da86b
removed unnecessary check for framebuffer resizing when not using vr mode
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Tue, 01 Oct 2013 12:51:20 +0300 |
parents | |
children |
line source
1 /************************************************************************************
3 Filename : OVR_Linux_HMDDevice.h
4 Content : Linux HMDDevice implementation
5 Created : June 17, 2013
6 Authors : Brant Lewis
8 Copyright : Copyright 2013 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_Linux_HMDDevice_h
17 #define OVR_Linux_HMDDevice_h
19 #include "OVR_Linux_DeviceManager.h"
20 #include "OVR_Profile.h"
22 namespace OVR { namespace Linux {
24 class HMDDevice;
26 //-------------------------------------------------------------------------------------
28 // HMDDeviceFactory enumerates attached Oculus HMD devices.
29 //
30 // This is currently done by matching monitor device strings.
32 class HMDDeviceFactory : public DeviceFactory
33 {
34 public:
35 static HMDDeviceFactory Instance;
37 // Enumerates devices, creating and destroying relevant objects in manager.
38 virtual void EnumerateDevices(EnumerateVisitor& visitor);
40 protected:
41 DeviceManager* getManager() const { return (DeviceManager*) pManager; }
42 };
45 class HMDDeviceCreateDesc : public DeviceCreateDesc
46 {
47 friend class HMDDevice;
49 protected:
50 enum
51 {
52 Contents_Screen = 1,
53 Contents_Distortion = 2,
54 Contents_7Inch = 4,
55 };
56 String DeviceId;
57 String DisplayDeviceName;
58 int DesktopX, DesktopY;
59 unsigned Contents;
60 unsigned HResolution, VResolution;
61 float HScreenSize, VScreenSize;
62 long DisplayId;
63 float DistortionK[4];
65 public:
66 HMDDeviceCreateDesc(DeviceFactory* factory, const String& displayDeviceName, long dispId);
67 HMDDeviceCreateDesc(const HMDDeviceCreateDesc& other);
69 virtual DeviceCreateDesc* Clone() const
70 {
71 return new HMDDeviceCreateDesc(*this);
72 }
74 virtual DeviceBase* NewDeviceInstance();
76 virtual MatchResult MatchDevice(const DeviceCreateDesc& other,
77 DeviceCreateDesc**) const;
79 // Matches device by path.
80 virtual bool MatchDevice(const String& path);
82 virtual bool UpdateMatchedCandidate(const DeviceCreateDesc&, bool* newDeviceFlag = NULL);
84 virtual bool GetDeviceInfo(DeviceInfo* info) const;
86 // Requests the currently used default profile. This profile affects the
87 // settings reported by HMDInfo.
88 Profile* GetProfileAddRef() const;
90 ProfileType GetProfileType() const
91 {
92 return (HResolution >= 1920) ? Profile_RiftDKHD : Profile_RiftDK1;
93 }
96 void SetScreenParameters(int x, int y, unsigned hres, unsigned vres, float hsize, float vsize)
97 {
98 DesktopX = x;
99 DesktopY = y;
100 HResolution = hres;
101 VResolution = vres;
102 HScreenSize = hsize;
103 VScreenSize = vsize;
104 Contents |= Contents_Screen;
105 }
106 void SetDistortion(const float* dks)
107 {
108 for (int i = 0; i < 4; i++)
109 DistortionK[i] = dks[i];
110 Contents |= Contents_Distortion;
111 }
113 void Set7Inch() { Contents |= Contents_7Inch; }
115 bool Is7Inch() const;
116 };
119 //-------------------------------------------------------------------------------------
121 // HMDDevice represents an Oculus HMD device unit. An instance of this class
122 // is typically created from the DeviceManager.
123 // After HMD device is created, we its sensor data can be obtained by
124 // first creating a Sensor object and then wrappig it in SensorFusion.
126 class HMDDevice : public DeviceImpl<OVR::HMDDevice>
127 {
128 public:
129 HMDDevice(HMDDeviceCreateDesc* createDesc);
130 ~HMDDevice();
132 virtual bool Initialize(DeviceBase* parent);
133 virtual void Shutdown();
135 // Requests the currently used default profile. This profile affects the
136 // settings reported by HMDInfo.
137 virtual Profile* GetProfile() const;
138 virtual const char* GetProfileName() const;
139 virtual bool SetProfileName(const char* name);
141 // Query associated sensor.
142 virtual OVR::SensorDevice* GetSensor();
144 protected:
145 HMDDeviceCreateDesc* getDesc() const { return (HMDDeviceCreateDesc*)pCreateDesc.GetPtr(); }
147 // User name for the profile used with this device.
148 String ProfileName;
149 mutable Ptr<Profile> pCachedProfile;
150 };
153 }} // namespace OVR::Linux
155 #endif // OVR_Linux_HMDDevice_h