Bike-X  0.8
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
OVR_LatencyTestImpl.h
Go to the documentation of this file.
1 /************************************************************************************
2 
3 Filename : OVR_LatencyTestImpl.h
4 Content : Latency Tester specific implementation.
5 Created : March 7, 2013
6 Authors : Lee Cooper
7 
8 Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 
10 Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 you may not use the Oculus VR Rift SDK except in compliance with the License,
12 which is provided at the time of installation or download, or which
13 otherwise accompanies this software in either electronic or hard copy form.
14 
15 You may obtain a copy of the License at
16 
17 http://www.oculusvr.com/licenses/LICENSE-3.1
18 
19 Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 distributed under the License is distributed on an "AS IS" BASIS,
21 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 See the License for the specific language governing permissions and
23 limitations under the License.
24 
25 *************************************************************************************/
26 
27 #ifndef OVR_LatencyTestImpl_h
28 #define OVR_LatencyTestImpl_h
29 
30 #include "OVR_HIDDeviceImpl.h"
31 
32 namespace OVR {
33 
34 struct LatencyTestSamplesMessage;
35 struct LatencyTestButtonMessage;
36 struct LatencyTestStartedMessage;
37 struct LatencyTestColorDetectedMessage;
38 
39 //-------------------------------------------------------------------------------------
40 // LatencyTestDeviceFactory enumerates Oculus Latency Tester devices.
42 {
43 public:
45 
46  // Enumerates devices, creating and destroying relevant objects in manager.
47  virtual void EnumerateDevices(EnumerateVisitor& visitor);
48 
49  virtual bool MatchVendorProduct(UInt16 vendorId, UInt16 productId) const;
50  virtual bool DetectHIDDevice(DeviceManager* pdevMgr, const HIDDeviceDesc& desc);
51 
52 protected:
54 };
55 
56 
57 // Describes a single a Oculus Latency Tester device and supports creating its instance.
59 {
60 public:
62  : HIDDeviceCreateDesc(factory, Device_LatencyTester, hidDesc) { }
63 
64  virtual DeviceCreateDesc* Clone() const
65  {
66  return new LatencyTestDeviceCreateDesc(*this);
67  }
68 
69  virtual DeviceBase* NewDeviceInstance();
70 
72  DeviceCreateDesc**) const
73  {
74  if ((other.Type == Device_LatencyTester) && (pFactory == other.pFactory))
75  {
77  if (MatchHIDDevice(s2.HIDDesc))
78  return Match_Found;
79  }
80  return Match_None;
81  }
82 
83  virtual bool MatchHIDDevice(const HIDDeviceDesc& hidDesc) const
84  {
85  // should paths comparison be case insensitive?
86  return ((HIDDesc.Path.CompareNoCase(hidDesc.Path) == 0) &&
87  (HIDDesc.SerialNumber == hidDesc.SerialNumber));
88  }
89  virtual bool GetDeviceInfo(DeviceInfo* info) const;
90 };
91 
92 
93 //-------------------------------------------------------------------------------------
94 // ***** OVR::LatencyTestDeviceImpl
95 
96 // Oculus Latency Tester interface.
97 
98 class LatencyTestDeviceImpl : public HIDDeviceImpl<OVR::LatencyTestDevice>
99 {
100 public:
103 
104  // DeviceCommon interface.
105  virtual bool Initialize(DeviceBase* parent);
106  virtual void Shutdown();
107 
108  // DeviceManagerThread::Notifier interface.
109  virtual void OnInputReport(UByte* pData, UInt32 length);
110 
111  // LatencyTesterDevice interface
112  virtual bool SetConfiguration(const OVR::LatencyTestConfiguration& configuration, bool waitFlag = false);
113  virtual bool GetConfiguration(OVR::LatencyTestConfiguration* configuration);
114 
115  virtual bool SetCalibrate(const Color& calibrationColor, bool waitFlag = false);
116 
117  virtual bool SetStartTest(const Color& targetColor, bool waitFlag = false);
118  virtual bool SetDisplay(const LatencyTestDisplay& display, bool waitFlag = false);
119 
120 protected:
121  bool openDevice(const char** errorFormatString);
122  void closeDevice();
123  void closeDeviceOnIOError();
124 
125  bool initializeRead();
126  bool processReadResult();
127 
128  bool setConfiguration(const OVR::LatencyTestConfiguration& configuration);
129  bool getConfiguration(OVR::LatencyTestConfiguration* configuration);
130  bool setCalibrate(const Color& calibrationColor);
131  bool setStartTest(const Color& targetColor);
132  bool setDisplay(const OVR::LatencyTestDisplay& display);
133 
134  // Called for decoded messages
139 
140 };
141 
142 } // namespace OVR
143 
144 #endif // OVR_LatencyTestImpl_h
virtual bool SetCalibrate(const Color &calibrationColor, bool waitFlag=false)
DeviceFactory *const pFactory
void onLatencyTestColorDetectedMessage(LatencyTestColorDetectedMessage *message)
virtual DeviceBase * NewDeviceInstance()
bool setCalibrate(const Color &calibrationColor)
bool setConfiguration(const OVR::LatencyTestConfiguration &configuration)
virtual bool DetectHIDDevice(DeviceManager *pdevMgr, const HIDDeviceDesc &desc)
virtual void EnumerateDevices(EnumerateVisitor &visitor)
void onLatencyTestStartedMessage(LatencyTestStartedMessage *message)
static LatencyTestDeviceFactory & GetInstance()
LatencyTestDeviceCreateDesc(DeviceFactory *factory, const HIDDeviceDesc &hidDesc)
uint16_t UInt16
Definition: OVR_Types.h:251
virtual bool MatchHIDDevice(const HIDDeviceDesc &hidDesc) const
void onLatencyTestSamplesMessage(LatencyTestSamplesMessage *message)
uint32_t UInt32
Definition: OVR_Types.h:253
virtual MatchResult MatchDevice(const DeviceCreateDesc &other, DeviceCreateDesc **) const
bool setDisplay(const OVR::LatencyTestDisplay &display)
void onLatencyTestButtonMessage(LatencyTestButtonMessage *message)
uint8_t UByte
Definition: OVR_Types.h:249
DeviceManager * getManager() const
virtual bool SetStartTest(const Color &targetColor, bool waitFlag=false)
LatencyTestDeviceImpl(LatencyTestDeviceCreateDesc *createDesc)
virtual bool GetDeviceInfo(DeviceInfo *info) const
const DeviceType Type
DeviceManagerImpl * pManager
virtual bool SetDisplay(const LatencyTestDisplay &display, bool waitFlag=false)
bool getConfiguration(OVR::LatencyTestConfiguration *configuration)
virtual void OnInputReport(UByte *pData, UInt32 length)
virtual DeviceCreateDesc * Clone() const
virtual bool MatchVendorProduct(UInt16 vendorId, UInt16 productId) const
bool setStartTest(const Color &targetColor)
bool openDevice(const char **errorFormatString)
virtual bool GetConfiguration(OVR::LatencyTestConfiguration *configuration)
virtual bool SetConfiguration(const OVR::LatencyTestConfiguration &configuration, bool waitFlag=false)
virtual bool Initialize(DeviceBase *parent)
static int OVR_STDCALL CompareNoCase(const char *a, const char *b)
Definition: OVR_String.cpp:488