OVR_Win32_HMDDevice.h
Go to the documentation of this file.
00001 /************************************************************************************
00002 
00003 Filename    :   OVR_Win32_HMDDevice.h
00004 Content     :   Win32 HMDDevice implementation
00005 Created     :   September 21, 2012
00006 Authors     :   Michael Antonov
00007 
00008 Copyright   :   Copyright 2012 Oculus VR, Inc. All Rights reserved.
00009 
00010 Use of this software is subject to the terms of the Oculus license
00011 agreement provided at the time of installation or download, or which
00012 otherwise accompanies this software in either electronic or hard copy form.
00013 
00014 *************************************************************************************/
00015 
00016 #ifndef OVR_Win32_HMDDevice_h
00017 #define OVR_Win32_HMDDevice_h
00018 
00019 #include "OVR_Win32_DeviceManager.h"
00020 #include "OVR_Profile.h"
00021 
00022 namespace OVR { namespace Win32 {
00023 
00024 class HMDDevice;
00025 
00026 
00027 //-------------------------------------------------------------------------------------
00028 
00029 // HMDDeviceFactory enumerates attached Oculus HMD devices.
00030 //
00031 // This is currently done by matching monitor device strings.
00032 
00033 class HMDDeviceFactory : public DeviceFactory
00034 {
00035 public:
00036     static HMDDeviceFactory Instance;
00037 
00038     // Enumerates devices, creating and destroying relevant objects in manager.
00039     virtual void EnumerateDevices(EnumerateVisitor& visitor);
00040 
00041 protected:
00042     DeviceManager* getManager() const { return (DeviceManager*) pManager; }
00043 };
00044 
00045 
00046 class HMDDeviceCreateDesc : public DeviceCreateDesc
00047 {
00048     friend class HMDDevice;
00049 
00050 protected:
00051     enum
00052     {
00053         Contents_Screen     = 1,
00054         Contents_Distortion = 2,
00055         Contents_7Inch      = 4,
00056     };
00057     String      DeviceId;
00058     String      DisplayDeviceName;
00059     int         DesktopX, DesktopY;
00060     unsigned    Contents;
00061     unsigned    HResolution, VResolution;
00062     float       HScreenSize, VScreenSize;
00063     float       DistortionK[4];
00064 
00065 public:
00066     HMDDeviceCreateDesc(DeviceFactory* factory, 
00067                         const String& deviceId, const String& displayDeviceName);
00068     HMDDeviceCreateDesc(const HMDDeviceCreateDesc& other);
00069 
00070     virtual DeviceCreateDesc* Clone() const
00071     {
00072         return new HMDDeviceCreateDesc(*this);
00073     }
00074 
00075     virtual DeviceBase* NewDeviceInstance();
00076 
00077     virtual MatchResult MatchDevice(const DeviceCreateDesc& other,
00078                                     DeviceCreateDesc**) const;
00079 
00080     // Matches device by path.
00081     virtual bool        MatchDevice(const String& path);
00082 
00083     virtual bool        UpdateMatchedCandidate(const DeviceCreateDesc&, bool* newDeviceFlag = NULL);
00084 
00085     virtual bool GetDeviceInfo(DeviceInfo* info) const;
00086 
00087     // Requests the currently used default profile. This profile affects the
00088     // settings reported by HMDInfo. 
00089     Profile* GetProfileAddRef() const;
00090 
00091     ProfileType GetProfileType() const
00092     {
00093         return (HResolution >= 1920) ? Profile_RiftDKHD : Profile_RiftDK1;
00094     }
00095 
00096 
00097     void  SetScreenParameters(int x, int y, unsigned hres, unsigned vres, float hsize, float vsize)
00098     {
00099         DesktopX = x;
00100         DesktopY = y;
00101         HResolution = hres;
00102         VResolution = vres;
00103         HScreenSize = hsize;
00104         VScreenSize = vsize;
00105         Contents |= Contents_Screen;
00106     }
00107     void SetDistortion(const float* dks)
00108     {
00109         for (int i = 0; i < 4; i++)
00110             DistortionK[i] = dks[i];
00111         Contents |= Contents_Distortion;
00112     }
00113 
00114     void Set7Inch() { Contents |= Contents_7Inch; }
00115 
00116     bool Is7Inch() const;
00117 };
00118 
00119 
00120 //-------------------------------------------------------------------------------------
00121 
00122 // HMDDevice represents an Oculus HMD device unit. An instance of this class
00123 // is typically created from the DeviceManager.
00124 //  After HMD device is created, we its sensor data can be obtained by 
00125 //  first creating a Sensor object and then wrappig it in SensorFusion.
00126 
00127 class HMDDevice : public DeviceImpl<OVR::HMDDevice>
00128 {
00129 public:
00130     HMDDevice(HMDDeviceCreateDesc* createDesc);
00131     ~HMDDevice();    
00132 
00133     virtual bool Initialize(DeviceBase* parent);
00134     virtual void Shutdown();
00135 
00136     // Requests the currently used default profile. This profile affects the
00137     // settings reported by HMDInfo. 
00138     virtual Profile*    GetProfile() const;
00139     virtual const char* GetProfileName() const;
00140     virtual bool        SetProfileName(const char* name);
00141 
00142     // Query associated sensor.
00143     virtual OVR::SensorDevice* GetSensor();  
00144 
00145 protected:
00146     HMDDeviceCreateDesc* getDesc() const { return (HMDDeviceCreateDesc*)pCreateDesc.GetPtr(); }
00147 
00148     // User name for the profile used with this device.
00149     String               ProfileName;
00150     mutable Ptr<Profile> pCachedProfile;
00151 };
00152 
00153 
00154 }} // namespace OVR::Win32
00155 
00156 #endif // OVR_Win32_HMDDevice_h
00157 


oculus_sdk
Author(s): Tully Foote
autogenerated on Thu Jun 6 2019 20:13:49