oculus1

annotate libovr/Src/win32/OVR_Win32_HMDDevice.h @ 12:d797639e0234

moving on to the distortion... not correct yet
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 20 Sep 2013 10:14:29 +0300
parents
children
rev   line source
nuclear@1 1 /************************************************************************************
nuclear@1 2
nuclear@1 3 Filename : OVR_Win32_HMDDevice.h
nuclear@1 4 Content : Win32 HMDDevice implementation
nuclear@1 5 Created : September 21, 2012
nuclear@1 6 Authors : Michael Antonov
nuclear@1 7
nuclear@1 8 Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved.
nuclear@1 9
nuclear@1 10 Use of this software is subject to the terms of the Oculus license
nuclear@1 11 agreement provided at the time of installation or download, or which
nuclear@1 12 otherwise accompanies this software in either electronic or hard copy form.
nuclear@1 13
nuclear@1 14 *************************************************************************************/
nuclear@1 15
nuclear@1 16 #ifndef OVR_Win32_HMDDevice_h
nuclear@1 17 #define OVR_Win32_HMDDevice_h
nuclear@1 18
nuclear@1 19 #include "OVR_Win32_DeviceManager.h"
nuclear@1 20 #include "OVR_Profile.h"
nuclear@1 21
nuclear@1 22 namespace OVR { namespace Win32 {
nuclear@1 23
nuclear@1 24 class HMDDevice;
nuclear@1 25
nuclear@1 26
nuclear@1 27 //-------------------------------------------------------------------------------------
nuclear@1 28
nuclear@1 29 // HMDDeviceFactory enumerates attached Oculus HMD devices.
nuclear@1 30 //
nuclear@1 31 // This is currently done by matching monitor device strings.
nuclear@1 32
nuclear@1 33 class HMDDeviceFactory : public DeviceFactory
nuclear@1 34 {
nuclear@1 35 public:
nuclear@1 36 static HMDDeviceFactory Instance;
nuclear@1 37
nuclear@1 38 // Enumerates devices, creating and destroying relevant objects in manager.
nuclear@1 39 virtual void EnumerateDevices(EnumerateVisitor& visitor);
nuclear@1 40
nuclear@1 41 protected:
nuclear@1 42 DeviceManager* getManager() const { return (DeviceManager*) pManager; }
nuclear@1 43 };
nuclear@1 44
nuclear@1 45
nuclear@1 46 class HMDDeviceCreateDesc : public DeviceCreateDesc
nuclear@1 47 {
nuclear@1 48 friend class HMDDevice;
nuclear@1 49
nuclear@1 50 protected:
nuclear@1 51 enum
nuclear@1 52 {
nuclear@1 53 Contents_Screen = 1,
nuclear@1 54 Contents_Distortion = 2,
nuclear@1 55 Contents_7Inch = 4,
nuclear@1 56 };
nuclear@1 57 String DeviceId;
nuclear@1 58 String DisplayDeviceName;
nuclear@1 59 int DesktopX, DesktopY;
nuclear@1 60 unsigned Contents;
nuclear@1 61 unsigned HResolution, VResolution;
nuclear@1 62 float HScreenSize, VScreenSize;
nuclear@1 63 float DistortionK[4];
nuclear@1 64
nuclear@1 65 public:
nuclear@1 66 HMDDeviceCreateDesc(DeviceFactory* factory,
nuclear@1 67 const String& deviceId, const String& displayDeviceName);
nuclear@1 68 HMDDeviceCreateDesc(const HMDDeviceCreateDesc& other);
nuclear@1 69
nuclear@1 70 virtual DeviceCreateDesc* Clone() const
nuclear@1 71 {
nuclear@1 72 return new HMDDeviceCreateDesc(*this);
nuclear@1 73 }
nuclear@1 74
nuclear@1 75 virtual DeviceBase* NewDeviceInstance();
nuclear@1 76
nuclear@1 77 virtual MatchResult MatchDevice(const DeviceCreateDesc& other,
nuclear@1 78 DeviceCreateDesc**) const;
nuclear@1 79
nuclear@1 80 // Matches device by path.
nuclear@1 81 virtual bool MatchDevice(const String& path);
nuclear@1 82
nuclear@1 83 virtual bool UpdateMatchedCandidate(const DeviceCreateDesc&, bool* newDeviceFlag = NULL);
nuclear@1 84
nuclear@1 85 virtual bool GetDeviceInfo(DeviceInfo* info) const;
nuclear@1 86
nuclear@1 87 // Requests the currently used default profile. This profile affects the
nuclear@1 88 // settings reported by HMDInfo.
nuclear@1 89 Profile* GetProfileAddRef() const;
nuclear@1 90
nuclear@1 91 ProfileType GetProfileType() const
nuclear@1 92 {
nuclear@1 93 return (HResolution >= 1920) ? Profile_RiftDKHD : Profile_RiftDK1;
nuclear@1 94 }
nuclear@1 95
nuclear@1 96
nuclear@1 97 void SetScreenParameters(int x, int y, unsigned hres, unsigned vres, float hsize, float vsize)
nuclear@1 98 {
nuclear@1 99 DesktopX = x;
nuclear@1 100 DesktopY = y;
nuclear@1 101 HResolution = hres;
nuclear@1 102 VResolution = vres;
nuclear@1 103 HScreenSize = hsize;
nuclear@1 104 VScreenSize = vsize;
nuclear@1 105 Contents |= Contents_Screen;
nuclear@1 106 }
nuclear@1 107 void SetDistortion(const float* dks)
nuclear@1 108 {
nuclear@1 109 for (int i = 0; i < 4; i++)
nuclear@1 110 DistortionK[i] = dks[i];
nuclear@1 111 Contents |= Contents_Distortion;
nuclear@1 112 }
nuclear@1 113
nuclear@1 114 void Set7Inch() { Contents |= Contents_7Inch; }
nuclear@1 115
nuclear@1 116 bool Is7Inch() const;
nuclear@1 117 };
nuclear@1 118
nuclear@1 119
nuclear@1 120 //-------------------------------------------------------------------------------------
nuclear@1 121
nuclear@1 122 // HMDDevice represents an Oculus HMD device unit. An instance of this class
nuclear@1 123 // is typically created from the DeviceManager.
nuclear@1 124 // After HMD device is created, we its sensor data can be obtained by
nuclear@1 125 // first creating a Sensor object and then wrappig it in SensorFusion.
nuclear@1 126
nuclear@1 127 class HMDDevice : public DeviceImpl<OVR::HMDDevice>
nuclear@1 128 {
nuclear@1 129 public:
nuclear@1 130 HMDDevice(HMDDeviceCreateDesc* createDesc);
nuclear@1 131 ~HMDDevice();
nuclear@1 132
nuclear@1 133 virtual bool Initialize(DeviceBase* parent);
nuclear@1 134 virtual void Shutdown();
nuclear@1 135
nuclear@1 136 // Requests the currently used default profile. This profile affects the
nuclear@1 137 // settings reported by HMDInfo.
nuclear@1 138 virtual Profile* GetProfile() const;
nuclear@1 139 virtual const char* GetProfileName() const;
nuclear@1 140 virtual bool SetProfileName(const char* name);
nuclear@1 141
nuclear@1 142 // Query associated sensor.
nuclear@1 143 virtual OVR::SensorDevice* GetSensor();
nuclear@1 144
nuclear@1 145 protected:
nuclear@1 146 HMDDeviceCreateDesc* getDesc() const { return (HMDDeviceCreateDesc*)pCreateDesc.GetPtr(); }
nuclear@1 147
nuclear@1 148 // User name for the profile used with this device.
nuclear@1 149 String ProfileName;
nuclear@1 150 mutable Ptr<Profile> pCachedProfile;
nuclear@1 151 };
nuclear@1 152
nuclear@1 153
nuclear@1 154 }} // namespace OVR::Win32
nuclear@1 155
nuclear@1 156 #endif // OVR_Win32_HMDDevice_h
nuclear@1 157