oculus1

annotate libovr/Src/OVR_LatencyTestImpl.h @ 17:cfe4979ab3eb

ops, minor error in the last commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 21 Sep 2013 07:09:48 +0300
parents
children
rev   line source
nuclear@1 1 /************************************************************************************
nuclear@1 2
nuclear@1 3 Filename : OVR_LatencyTestImpl.h
nuclear@1 4 Content : Latency Tester specific implementation.
nuclear@1 5 Created : March 7, 2013
nuclear@1 6 Authors : Lee Cooper
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_LatencyTestImpl_h
nuclear@1 17 #define OVR_LatencyTestImpl_h
nuclear@1 18
nuclear@1 19 #include "OVR_HIDDeviceImpl.h"
nuclear@1 20
nuclear@1 21 namespace OVR {
nuclear@1 22
nuclear@1 23 struct LatencyTestSamplesMessage;
nuclear@1 24 struct LatencyTestButtonMessage;
nuclear@1 25 struct LatencyTestStartedMessage;
nuclear@1 26 struct LatencyTestColorDetectedMessage;
nuclear@1 27
nuclear@1 28 //-------------------------------------------------------------------------------------
nuclear@1 29 // LatencyTestDeviceFactory enumerates Oculus Latency Tester devices.
nuclear@1 30 class LatencyTestDeviceFactory : public DeviceFactory
nuclear@1 31 {
nuclear@1 32 public:
nuclear@1 33 static LatencyTestDeviceFactory Instance;
nuclear@1 34
nuclear@1 35 // Enumerates devices, creating and destroying relevant objects in manager.
nuclear@1 36 virtual void EnumerateDevices(EnumerateVisitor& visitor);
nuclear@1 37
nuclear@1 38 virtual bool MatchVendorProduct(UInt16 vendorId, UInt16 productId) const;
nuclear@1 39 virtual bool DetectHIDDevice(DeviceManager* pdevMgr, const HIDDeviceDesc& desc);
nuclear@1 40
nuclear@1 41 protected:
nuclear@1 42 DeviceManager* getManager() const { return (DeviceManager*) pManager; }
nuclear@1 43 };
nuclear@1 44
nuclear@1 45
nuclear@1 46 // Describes a single a Oculus Latency Tester device and supports creating its instance.
nuclear@1 47 class LatencyTestDeviceCreateDesc : public HIDDeviceCreateDesc
nuclear@1 48 {
nuclear@1 49 public:
nuclear@1 50 LatencyTestDeviceCreateDesc(DeviceFactory* factory, const HIDDeviceDesc& hidDesc)
nuclear@1 51 : HIDDeviceCreateDesc(factory, Device_LatencyTester, hidDesc) { }
nuclear@1 52
nuclear@1 53 virtual DeviceCreateDesc* Clone() const
nuclear@1 54 {
nuclear@1 55 return new LatencyTestDeviceCreateDesc(*this);
nuclear@1 56 }
nuclear@1 57
nuclear@1 58 virtual DeviceBase* NewDeviceInstance();
nuclear@1 59
nuclear@1 60 virtual MatchResult MatchDevice(const DeviceCreateDesc& other,
nuclear@1 61 DeviceCreateDesc**) const
nuclear@1 62 {
nuclear@1 63 if ((other.Type == Device_LatencyTester) && (pFactory == other.pFactory))
nuclear@1 64 {
nuclear@1 65 const LatencyTestDeviceCreateDesc& s2 = (const LatencyTestDeviceCreateDesc&) other;
nuclear@1 66 if (MatchHIDDevice(s2.HIDDesc))
nuclear@1 67 return Match_Found;
nuclear@1 68 }
nuclear@1 69 return Match_None;
nuclear@1 70 }
nuclear@1 71
nuclear@1 72 virtual bool MatchHIDDevice(const HIDDeviceDesc& hidDesc) const
nuclear@1 73 {
nuclear@1 74 // should paths comparison be case insensitive?
nuclear@1 75 return ((HIDDesc.Path.CompareNoCase(hidDesc.Path) == 0) &&
nuclear@1 76 (HIDDesc.SerialNumber == hidDesc.SerialNumber));
nuclear@1 77 }
nuclear@1 78 virtual bool GetDeviceInfo(DeviceInfo* info) const;
nuclear@1 79 };
nuclear@1 80
nuclear@1 81
nuclear@1 82 //-------------------------------------------------------------------------------------
nuclear@1 83 // ***** OVR::LatencyTestDeviceImpl
nuclear@1 84
nuclear@1 85 // Oculus Latency Tester interface.
nuclear@1 86
nuclear@1 87 class LatencyTestDeviceImpl : public HIDDeviceImpl<OVR::LatencyTestDevice>
nuclear@1 88 {
nuclear@1 89 public:
nuclear@1 90 LatencyTestDeviceImpl(LatencyTestDeviceCreateDesc* createDesc);
nuclear@1 91 ~LatencyTestDeviceImpl();
nuclear@1 92
nuclear@1 93 // DeviceCommon interface.
nuclear@1 94 virtual bool Initialize(DeviceBase* parent);
nuclear@1 95 virtual void Shutdown();
nuclear@1 96
nuclear@1 97 // DeviceManagerThread::Notifier interface.
nuclear@1 98 virtual void OnInputReport(UByte* pData, UInt32 length);
nuclear@1 99
nuclear@1 100 // LatencyTesterDevice interface
nuclear@1 101 virtual bool SetConfiguration(const OVR::LatencyTestConfiguration& configuration, bool waitFlag = false);
nuclear@1 102 virtual bool GetConfiguration(OVR::LatencyTestConfiguration* configuration);
nuclear@1 103
nuclear@1 104 virtual bool SetCalibrate(const Color& calibrationColor, bool waitFlag = false);
nuclear@1 105
nuclear@1 106 virtual bool SetStartTest(const Color& targetColor, bool waitFlag = false);
nuclear@1 107 virtual bool SetDisplay(const LatencyTestDisplay& display, bool waitFlag = false);
nuclear@1 108
nuclear@1 109 protected:
nuclear@1 110 bool openDevice(const char** errorFormatString);
nuclear@1 111 void closeDevice();
nuclear@1 112 void closeDeviceOnIOError();
nuclear@1 113
nuclear@1 114 bool initializeRead();
nuclear@1 115 bool processReadResult();
nuclear@1 116
nuclear@1 117 bool setConfiguration(const OVR::LatencyTestConfiguration& configuration);
nuclear@1 118 bool getConfiguration(OVR::LatencyTestConfiguration* configuration);
nuclear@1 119 bool setCalibrate(const Color& calibrationColor);
nuclear@1 120 bool setStartTest(const Color& targetColor);
nuclear@1 121 bool setDisplay(const OVR::LatencyTestDisplay& display);
nuclear@1 122
nuclear@1 123 // Called for decoded messages
nuclear@1 124 void onLatencyTestSamplesMessage(LatencyTestSamplesMessage* message);
nuclear@1 125 void onLatencyTestButtonMessage(LatencyTestButtonMessage* message);
nuclear@1 126 void onLatencyTestStartedMessage(LatencyTestStartedMessage* message);
nuclear@1 127 void onLatencyTestColorDetectedMessage(LatencyTestColorDetectedMessage* message);
nuclear@1 128
nuclear@1 129 };
nuclear@1 130
nuclear@1 131 } // namespace OVR
nuclear@1 132
nuclear@1 133 #endif // OVR_LatencyTestImpl_h