oculus1

annotate libovr/Src/linux/OVR_Linux_HMDDevice.h @ 29:9a973ef0e2a3

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