oculus1

diff 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
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libovr/Src/osx/OVR_OSX_HMDDevice.h	Sat Sep 14 16:14:59 2013 +0300
     1.3 @@ -0,0 +1,160 @@
     1.4 +/************************************************************************************
     1.5 +
     1.6 +Filename    :   OVR_OSX_HMDDevice.h
     1.7 +Content     :   OSX HMDDevice implementation
     1.8 +Created     :   September 21, 2012
     1.9 +Authors     :   Michael Antonov
    1.10 +
    1.11 +Copyright   :   Copyright 2012 Oculus VR, Inc. All Rights reserved.
    1.12 +
    1.13 +Use of this software is subject to the terms of the Oculus license
    1.14 +agreement provided at the time of installation or download, or which
    1.15 +otherwise accompanies this software in either electronic or hard copy form.
    1.16 +
    1.17 +*************************************************************************************/
    1.18 +
    1.19 +#ifndef OVR_OSX_HMDDevice_h
    1.20 +#define OVR_OSX_HMDDevice_h
    1.21 +
    1.22 +#include "OVR_DeviceImpl.h"
    1.23 +#include <Kernel/OVR_String.h>
    1.24 +#include "OVR_Profile.h"
    1.25 +
    1.26 +namespace OVR { namespace OSX {
    1.27 +
    1.28 +class HMDDevice;
    1.29 +
    1.30 +
    1.31 +//-------------------------------------------------------------------------------------
    1.32 +
    1.33 +// HMDDeviceFactory enumerates attached Oculus HMD devices.
    1.34 +//
    1.35 +// This is currently done by matching monitor device strings.
    1.36 +
    1.37 +class HMDDeviceFactory : public DeviceFactory
    1.38 +{
    1.39 +public:
    1.40 +    static HMDDeviceFactory Instance;
    1.41 +
    1.42 +    // Enumerates devices, creating and destroying relevant objects in manager.
    1.43 +    virtual void EnumerateDevices(EnumerateVisitor& visitor);
    1.44 +
    1.45 +protected:
    1.46 +    DeviceManager* getManager() const { return (DeviceManager*) pManager; }
    1.47 +};
    1.48 +
    1.49 +
    1.50 +class HMDDeviceCreateDesc : public DeviceCreateDesc
    1.51 +{
    1.52 +    friend class HMDDevice;
    1.53 +
    1.54 +protected:
    1.55 +    enum
    1.56 +    {
    1.57 +        Contents_Screen     = 1,
    1.58 +        Contents_Distortion = 2,
    1.59 +        Contents_7Inch      = 4,
    1.60 +    };
    1.61 +
    1.62 +public:
    1.63 +
    1.64 +    HMDDeviceCreateDesc(DeviceFactory* factory,
    1.65 +                        UInt32 vendor, UInt32 product, const String& displayDeviceName, long dispId);
    1.66 +    HMDDeviceCreateDesc(const HMDDeviceCreateDesc& other);
    1.67 +
    1.68 +    virtual DeviceCreateDesc* Clone() const
    1.69 +    {
    1.70 +        return new HMDDeviceCreateDesc(*this);
    1.71 +    }
    1.72 +
    1.73 +    virtual DeviceBase* NewDeviceInstance();
    1.74 +
    1.75 +    virtual MatchResult MatchDevice(const DeviceCreateDesc& other,
    1.76 +                                    DeviceCreateDesc**) const;
    1.77 +
    1.78 +    virtual bool        UpdateMatchedCandidate(const DeviceCreateDesc&, bool* newDeviceFlag = NULL);
    1.79 +
    1.80 +    virtual bool GetDeviceInfo(DeviceInfo* info) const;
    1.81 +
    1.82 +    // Requests the currently used default profile. This profile affects the
    1.83 +    // settings reported by HMDInfo. 
    1.84 +    Profile* GetProfileAddRef() const;
    1.85 +
    1.86 +    ProfileType GetProfileType() const
    1.87 +    {
    1.88 +        return (HResolution >= 1920) ? Profile_RiftDKHD : Profile_RiftDK1;
    1.89 +    }
    1.90 +	
    1.91 +    void  SetScreenParameters(int x, int y, unsigned hres, unsigned vres, float hsize, float vsize)
    1.92 +    {
    1.93 +        DesktopX = x;
    1.94 +        DesktopY = y;
    1.95 +        HResolution = hres;
    1.96 +        VResolution = vres;
    1.97 +        HScreenSize = hsize;
    1.98 +        VScreenSize = vsize;
    1.99 +        Contents |= Contents_Screen;
   1.100 +    }
   1.101 +
   1.102 +    void SetDistortion(const float* dks)
   1.103 +    {
   1.104 +        for (int i = 0; i < 4; i++)
   1.105 +            DistortionK[i] = dks[i];
   1.106 +        Contents |= Contents_Distortion;
   1.107 +    }
   1.108 +
   1.109 +    void Set7Inch() { Contents |= Contents_7Inch; }
   1.110 +
   1.111 +    bool Is7Inch() const;
   1.112 +
   1.113 +protected:
   1.114 +    String      DeviceId;
   1.115 +    String      DisplayDeviceName;
   1.116 +    int         DesktopX, DesktopY;
   1.117 +    unsigned    Contents;
   1.118 +    unsigned    HResolution, VResolution;
   1.119 +    float       HScreenSize, VScreenSize;
   1.120 +    long        DisplayId;
   1.121 +    float       DistortionK[4];
   1.122 +};
   1.123 +
   1.124 +
   1.125 +//-------------------------------------------------------------------------------------
   1.126 +
   1.127 +// HMDDevice represents an Oculus HMD device unit. An instance of this class
   1.128 +// is typically created from the DeviceManager.
   1.129 +//  After HMD device is created, we its sensor data can be obtained by 
   1.130 +//  first creating a Sensor object and then wrappig it in SensorFusion.
   1.131 +
   1.132 +class HMDDevice : public DeviceImpl<OVR::HMDDevice>
   1.133 +{
   1.134 +public:
   1.135 +    HMDDevice(HMDDeviceCreateDesc* createDesc);
   1.136 +    ~HMDDevice();
   1.137 +
   1.138 +    virtual bool Initialize(DeviceBase* parent);
   1.139 +    virtual void Shutdown();
   1.140 +
   1.141 +
   1.142 +    // Requests the currently used default profile. This profile affects the
   1.143 +    // settings reported by HMDInfo. 
   1.144 +    virtual Profile*    GetProfile() const;
   1.145 +    virtual const char* GetProfileName() const;
   1.146 +    virtual bool        SetProfileName(const char* name);
   1.147 +
   1.148 +    // Query associated sensor.
   1.149 +    virtual OVR::SensorDevice* GetSensor();  
   1.150 +
   1.151 +protected:
   1.152 +    HMDDeviceCreateDesc* getDesc() const { return (HMDDeviceCreateDesc*)pCreateDesc.GetPtr(); }
   1.153 +
   1.154 +    // User name for the profile used with this device.
   1.155 +    String               ProfileName;
   1.156 +    mutable Ptr<Profile> pCachedProfile;
   1.157 +};
   1.158 +
   1.159 +
   1.160 +}} // namespace OVR::OSX
   1.161 +
   1.162 +#endif // OVR_OSX_HMDDevice_h
   1.163 +