OVR_LatencyTestImpl.h
Go to the documentation of this file.
00001 /************************************************************************************
00002 
00003 Filename    :   OVR_LatencyTestImpl.h
00004 Content     :   Latency Tester specific implementation.
00005 Created     :   March 7, 2013
00006 Authors     :   Lee Cooper
00007 
00008 Copyright   :   Copyright 2013 Oculus VR, Inc. All Rights reserved.
00009 
00010 Use of this software is subject to the terms of the Oculus license
00011 agreement provided at the time of installation or download, or which
00012 otherwise accompanies this software in either electronic or hard copy form.
00013 
00014 *************************************************************************************/
00015 
00016 #ifndef OVR_LatencyTestImpl_h
00017 #define OVR_LatencyTestImpl_h
00018 
00019 #include "OVR_HIDDeviceImpl.h"
00020 
00021 namespace OVR {
00022 
00023 struct LatencyTestSamplesMessage;
00024 struct LatencyTestButtonMessage;
00025 struct LatencyTestStartedMessage;
00026 struct LatencyTestColorDetectedMessage;
00027 
00028 //-------------------------------------------------------------------------------------
00029 // LatencyTestDeviceFactory enumerates Oculus Latency Tester devices.
00030 class LatencyTestDeviceFactory : public DeviceFactory
00031 {
00032 public:
00033     static LatencyTestDeviceFactory Instance;
00034 
00035     // Enumerates devices, creating and destroying relevant objects in manager.
00036     virtual void EnumerateDevices(EnumerateVisitor& visitor);
00037 
00038     virtual bool MatchVendorProduct(UInt16 vendorId, UInt16 productId) const;
00039     virtual bool DetectHIDDevice(DeviceManager* pdevMgr, const HIDDeviceDesc& desc);
00040 
00041 protected:
00042     DeviceManager* getManager() const { return (DeviceManager*) pManager; }   
00043 };
00044 
00045 
00046 // Describes a single a Oculus Latency Tester device and supports creating its instance.
00047 class LatencyTestDeviceCreateDesc : public HIDDeviceCreateDesc
00048 {
00049 public:
00050     LatencyTestDeviceCreateDesc(DeviceFactory* factory, const HIDDeviceDesc& hidDesc)
00051         : HIDDeviceCreateDesc(factory, Device_LatencyTester, hidDesc) { }
00052     
00053     virtual DeviceCreateDesc* Clone() const
00054     {
00055         return new LatencyTestDeviceCreateDesc(*this);
00056     }
00057 
00058     virtual DeviceBase* NewDeviceInstance();
00059 
00060     virtual MatchResult MatchDevice(const DeviceCreateDesc& other,
00061                                     DeviceCreateDesc**) const
00062     {
00063         if ((other.Type == Device_LatencyTester) && (pFactory == other.pFactory))
00064         {            
00065             const LatencyTestDeviceCreateDesc& s2 = (const LatencyTestDeviceCreateDesc&) other;
00066             if (MatchHIDDevice(s2.HIDDesc))
00067                 return Match_Found;
00068         }
00069         return Match_None;
00070     }
00071 
00072     virtual bool MatchHIDDevice(const HIDDeviceDesc& hidDesc) const
00073     {
00074         // should paths comparison be case insensitive?
00075         return ((HIDDesc.Path.CompareNoCase(hidDesc.Path) == 0) &&
00076                 (HIDDesc.SerialNumber == hidDesc.SerialNumber));
00077     }
00078     virtual bool        GetDeviceInfo(DeviceInfo* info) const;
00079 };
00080 
00081 
00082 //-------------------------------------------------------------------------------------
00083 // ***** OVR::LatencyTestDeviceImpl
00084 
00085 // Oculus Latency Tester interface.
00086 
00087 class LatencyTestDeviceImpl : public HIDDeviceImpl<OVR::LatencyTestDevice>
00088 {
00089 public:
00090      LatencyTestDeviceImpl(LatencyTestDeviceCreateDesc* createDesc);
00091     ~LatencyTestDeviceImpl();
00092 
00093     // DeviceCommon interface.
00094     virtual bool Initialize(DeviceBase* parent);
00095     virtual void Shutdown();
00096 
00097     // DeviceManagerThread::Notifier interface.
00098     virtual void OnInputReport(UByte* pData, UInt32 length);
00099 
00100     // LatencyTesterDevice interface
00101     virtual bool SetConfiguration(const OVR::LatencyTestConfiguration& configuration, bool waitFlag = false);
00102     virtual bool GetConfiguration(OVR::LatencyTestConfiguration* configuration);
00103 
00104     virtual bool SetCalibrate(const Color& calibrationColor, bool waitFlag = false);
00105 
00106     virtual bool SetStartTest(const Color& targetColor, bool waitFlag = false);
00107     virtual bool SetDisplay(const LatencyTestDisplay& display, bool waitFlag = false);
00108 
00109 protected:
00110     bool    openDevice(const char** errorFormatString);
00111     void    closeDevice();
00112     void    closeDeviceOnIOError();
00113 
00114     bool    initializeRead();
00115     bool    processReadResult();
00116 
00117     bool    setConfiguration(const OVR::LatencyTestConfiguration& configuration);
00118     bool    getConfiguration(OVR::LatencyTestConfiguration* configuration);
00119     bool    setCalibrate(const Color& calibrationColor);
00120     bool    setStartTest(const Color& targetColor);
00121     bool    setDisplay(const OVR::LatencyTestDisplay& display);
00122 
00123     // Called for decoded messages
00124     void onLatencyTestSamplesMessage(LatencyTestSamplesMessage* message);
00125     void onLatencyTestButtonMessage(LatencyTestButtonMessage* message);
00126     void onLatencyTestStartedMessage(LatencyTestStartedMessage* message);
00127     void onLatencyTestColorDetectedMessage(LatencyTestColorDetectedMessage* message);
00128 
00129 };
00130 
00131 } // namespace OVR
00132 
00133 #endif // OVR_LatencyTestImpl_h


oculus_sdk
Author(s):
autogenerated on Fri Aug 28 2015 11:53:11