oculus1

diff libovr/Src/OVR_LatencyTestImpl.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/OVR_LatencyTestImpl.h	Sat Sep 14 16:14:59 2013 +0300
     1.3 @@ -0,0 +1,133 @@
     1.4 +/************************************************************************************
     1.5 +
     1.6 +Filename    :   OVR_LatencyTestImpl.h
     1.7 +Content     :   Latency Tester specific implementation.
     1.8 +Created     :   March 7, 2013
     1.9 +Authors     :   Lee Cooper
    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_LatencyTestImpl_h
    1.20 +#define OVR_LatencyTestImpl_h
    1.21 +
    1.22 +#include "OVR_HIDDeviceImpl.h"
    1.23 +
    1.24 +namespace OVR {
    1.25 +
    1.26 +struct LatencyTestSamplesMessage;
    1.27 +struct LatencyTestButtonMessage;
    1.28 +struct LatencyTestStartedMessage;
    1.29 +struct LatencyTestColorDetectedMessage;
    1.30 +
    1.31 +//-------------------------------------------------------------------------------------
    1.32 +// LatencyTestDeviceFactory enumerates Oculus Latency Tester devices.
    1.33 +class LatencyTestDeviceFactory : public DeviceFactory
    1.34 +{
    1.35 +public:
    1.36 +    static LatencyTestDeviceFactory Instance;
    1.37 +
    1.38 +    // Enumerates devices, creating and destroying relevant objects in manager.
    1.39 +    virtual void EnumerateDevices(EnumerateVisitor& visitor);
    1.40 +
    1.41 +    virtual bool MatchVendorProduct(UInt16 vendorId, UInt16 productId) const;
    1.42 +    virtual bool DetectHIDDevice(DeviceManager* pdevMgr, const HIDDeviceDesc& desc);
    1.43 +
    1.44 +protected:
    1.45 +    DeviceManager* getManager() const { return (DeviceManager*) pManager; }   
    1.46 +};
    1.47 +
    1.48 +
    1.49 +// Describes a single a Oculus Latency Tester device and supports creating its instance.
    1.50 +class LatencyTestDeviceCreateDesc : public HIDDeviceCreateDesc
    1.51 +{
    1.52 +public:
    1.53 +    LatencyTestDeviceCreateDesc(DeviceFactory* factory, const HIDDeviceDesc& hidDesc)
    1.54 +        : HIDDeviceCreateDesc(factory, Device_LatencyTester, hidDesc) { }
    1.55 +    
    1.56 +    virtual DeviceCreateDesc* Clone() const
    1.57 +    {
    1.58 +        return new LatencyTestDeviceCreateDesc(*this);
    1.59 +    }
    1.60 +
    1.61 +    virtual DeviceBase* NewDeviceInstance();
    1.62 +
    1.63 +    virtual MatchResult MatchDevice(const DeviceCreateDesc& other,
    1.64 +                                    DeviceCreateDesc**) const
    1.65 +    {
    1.66 +        if ((other.Type == Device_LatencyTester) && (pFactory == other.pFactory))
    1.67 +        {            
    1.68 +            const LatencyTestDeviceCreateDesc& s2 = (const LatencyTestDeviceCreateDesc&) other;
    1.69 +            if (MatchHIDDevice(s2.HIDDesc))
    1.70 +                return Match_Found;
    1.71 +        }
    1.72 +        return Match_None;
    1.73 +    }
    1.74 +
    1.75 +    virtual bool MatchHIDDevice(const HIDDeviceDesc& hidDesc) const
    1.76 +    {
    1.77 +        // should paths comparison be case insensitive?
    1.78 +        return ((HIDDesc.Path.CompareNoCase(hidDesc.Path) == 0) &&
    1.79 +                (HIDDesc.SerialNumber == hidDesc.SerialNumber));
    1.80 +    }
    1.81 +    virtual bool        GetDeviceInfo(DeviceInfo* info) const;
    1.82 +};
    1.83 +
    1.84 +
    1.85 +//-------------------------------------------------------------------------------------
    1.86 +// ***** OVR::LatencyTestDeviceImpl
    1.87 +
    1.88 +// Oculus Latency Tester interface.
    1.89 +
    1.90 +class LatencyTestDeviceImpl : public HIDDeviceImpl<OVR::LatencyTestDevice>
    1.91 +{
    1.92 +public:
    1.93 +     LatencyTestDeviceImpl(LatencyTestDeviceCreateDesc* createDesc);
    1.94 +    ~LatencyTestDeviceImpl();
    1.95 +
    1.96 +    // DeviceCommon interface.
    1.97 +    virtual bool Initialize(DeviceBase* parent);
    1.98 +    virtual void Shutdown();
    1.99 +
   1.100 +    // DeviceManagerThread::Notifier interface.
   1.101 +    virtual void OnInputReport(UByte* pData, UInt32 length);
   1.102 +
   1.103 +    // LatencyTesterDevice interface
   1.104 +    virtual bool SetConfiguration(const OVR::LatencyTestConfiguration& configuration, bool waitFlag = false);
   1.105 +    virtual bool GetConfiguration(OVR::LatencyTestConfiguration* configuration);
   1.106 +
   1.107 +    virtual bool SetCalibrate(const Color& calibrationColor, bool waitFlag = false);
   1.108 +
   1.109 +    virtual bool SetStartTest(const Color& targetColor, bool waitFlag = false);
   1.110 +    virtual bool SetDisplay(const LatencyTestDisplay& display, bool waitFlag = false);
   1.111 +
   1.112 +protected:
   1.113 +    bool    openDevice(const char** errorFormatString);
   1.114 +    void    closeDevice();
   1.115 +    void    closeDeviceOnIOError();
   1.116 +
   1.117 +    bool    initializeRead();
   1.118 +    bool    processReadResult();
   1.119 +
   1.120 +    bool    setConfiguration(const OVR::LatencyTestConfiguration& configuration);
   1.121 +    bool    getConfiguration(OVR::LatencyTestConfiguration* configuration);
   1.122 +    bool    setCalibrate(const Color& calibrationColor);
   1.123 +    bool    setStartTest(const Color& targetColor);
   1.124 +    bool    setDisplay(const OVR::LatencyTestDisplay& display);
   1.125 +
   1.126 +    // Called for decoded messages
   1.127 +    void onLatencyTestSamplesMessage(LatencyTestSamplesMessage* message);
   1.128 +    void onLatencyTestButtonMessage(LatencyTestButtonMessage* message);
   1.129 +    void onLatencyTestStartedMessage(LatencyTestStartedMessage* message);
   1.130 +    void onLatencyTestColorDetectedMessage(LatencyTestColorDetectedMessage* message);
   1.131 +
   1.132 +};
   1.133 +
   1.134 +} // namespace OVR
   1.135 +
   1.136 +#endif // OVR_LatencyTestImpl_h