oculus1

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