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


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