Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef OVR_Linux_HMDDevice_h
00017 #define OVR_Linux_HMDDevice_h
00018
00019 #include "OVR_Linux_DeviceManager.h"
00020 #include "OVR_Profile.h"
00021
00022 namespace OVR { namespace Linux {
00023
00024 class HMDDevice;
00025
00026
00027
00028
00029
00030
00031
00032 class HMDDeviceFactory : public DeviceFactory
00033 {
00034 public:
00035 static HMDDeviceFactory Instance;
00036
00037
00038 virtual void EnumerateDevices(EnumerateVisitor& visitor);
00039
00040 protected:
00041 DeviceManager* getManager() const { return (DeviceManager*) pManager; }
00042 };
00043
00044
00045 class HMDDeviceCreateDesc : public DeviceCreateDesc
00046 {
00047 friend class HMDDevice;
00048
00049 protected:
00050 enum
00051 {
00052 Contents_Screen = 1,
00053 Contents_Distortion = 2,
00054 Contents_7Inch = 4,
00055 };
00056 String DeviceId;
00057 String DisplayDeviceName;
00058 int DesktopX, DesktopY;
00059 unsigned Contents;
00060 unsigned HResolution, VResolution;
00061 float HScreenSize, VScreenSize;
00062 long DisplayId;
00063 float DistortionK[4];
00064
00065 public:
00066 HMDDeviceCreateDesc(DeviceFactory* factory, const String& displayDeviceName, long dispId);
00067 HMDDeviceCreateDesc(const HMDDeviceCreateDesc& other);
00068
00069 virtual DeviceCreateDesc* Clone() const
00070 {
00071 return new HMDDeviceCreateDesc(*this);
00072 }
00073
00074 virtual DeviceBase* NewDeviceInstance();
00075
00076 virtual MatchResult MatchDevice(const DeviceCreateDesc& other,
00077 DeviceCreateDesc**) const;
00078
00079
00080 virtual bool MatchDevice(const String& path);
00081
00082 virtual bool UpdateMatchedCandidate(const DeviceCreateDesc&, bool* newDeviceFlag = NULL);
00083
00084 virtual bool GetDeviceInfo(DeviceInfo* info) const;
00085
00086
00087
00088 Profile* GetProfileAddRef() const;
00089
00090 ProfileType GetProfileType() const
00091 {
00092 return (HResolution >= 1920) ? Profile_RiftDKHD : Profile_RiftDK1;
00093 }
00094
00095
00096 void SetScreenParameters(int x, int y, unsigned hres, unsigned vres, float hsize, float vsize)
00097 {
00098 DesktopX = x;
00099 DesktopY = y;
00100 HResolution = hres;
00101 VResolution = vres;
00102 HScreenSize = hsize;
00103 VScreenSize = vsize;
00104 Contents |= Contents_Screen;
00105 }
00106 void SetDistortion(const float* dks)
00107 {
00108 for (int i = 0; i < 4; i++)
00109 DistortionK[i] = dks[i];
00110 Contents |= Contents_Distortion;
00111 }
00112
00113 void Set7Inch() { Contents |= Contents_7Inch; }
00114
00115 bool Is7Inch() const;
00116 };
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126 class HMDDevice : public DeviceImpl<OVR::HMDDevice>
00127 {
00128 public:
00129 HMDDevice(HMDDeviceCreateDesc* createDesc);
00130 ~HMDDevice();
00131
00132 virtual bool Initialize(DeviceBase* parent);
00133 virtual void Shutdown();
00134
00135
00136
00137 virtual Profile* GetProfile() const;
00138 virtual const char* GetProfileName() const;
00139 virtual bool SetProfileName(const char* name);
00140
00141
00142 virtual OVR::SensorDevice* GetSensor();
00143
00144 protected:
00145 HMDDeviceCreateDesc* getDesc() const { return (HMDDeviceCreateDesc*)pCreateDesc.GetPtr(); }
00146
00147
00148 String ProfileName;
00149 mutable Ptr<Profile> pCachedProfile;
00150 };
00151
00152
00153 }}
00154
00155 #endif // OVR_Linux_HMDDevice_h
00156