OVR_Linux_HMDDevice.h
Go to the documentation of this file.
00001 /************************************************************************************
00002 
00003 Filename    :   OVR_Linux_HMDDevice.h
00004 Content     :   Linux HMDDevice implementation
00005 Created     :   June 17, 2013
00006 Authors     :   Brant Lewis
00007 
00008 Copyright   :   Copyright 2013 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_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 // HMDDeviceFactory enumerates attached Oculus HMD devices.
00029 //
00030 // This is currently done by matching monitor device strings.
00031 
00032 class HMDDeviceFactory : public DeviceFactory
00033 {
00034 public:
00035     static HMDDeviceFactory Instance;
00036 
00037     // Enumerates devices, creating and destroying relevant objects in manager.
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     // Matches device by path.
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     // Requests the currently used default profile. This profile affects the
00087     // settings reported by HMDInfo. 
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 // HMDDevice represents an Oculus HMD device unit. An instance of this class
00122 // is typically created from the DeviceManager.
00123 //  After HMD device is created, we its sensor data can be obtained by 
00124 //  first creating a Sensor object and then wrappig it in SensorFusion.
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     // Requests the currently used default profile. This profile affects the
00136     // settings reported by HMDInfo. 
00137     virtual Profile*    GetProfile() const;
00138     virtual const char* GetProfileName() const;
00139     virtual bool        SetProfileName(const char* name);
00140 
00141     // Query associated sensor.
00142     virtual OVR::SensorDevice* GetSensor();  
00143 
00144 protected:
00145     HMDDeviceCreateDesc* getDesc() const { return (HMDDeviceCreateDesc*)pCreateDesc.GetPtr(); }
00146 
00147     // User name for the profile used with this device.
00148     String               ProfileName;
00149     mutable Ptr<Profile> pCachedProfile;
00150 };
00151 
00152 
00153 }} // namespace OVR::Linux
00154 
00155 #endif // OVR_Linux_HMDDevice_h
00156 


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