oculus1

annotate libovr/Src/osx/OVR_OSX_HMDDevice.h @ 1:e2f9e4603129

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