diff options
Diffstat (limited to 'LibOVR/Src/OVR_LatencyTestImpl.cpp')
-rw-r--r-- | LibOVR/Src/OVR_LatencyTestImpl.cpp | 64 |
1 files changed, 24 insertions, 40 deletions
diff --git a/LibOVR/Src/OVR_LatencyTestImpl.cpp b/LibOVR/Src/OVR_LatencyTestImpl.cpp index 209487c..9385a37 100644 --- a/LibOVR/Src/OVR_LatencyTestImpl.cpp +++ b/LibOVR/Src/OVR_LatencyTestImpl.cpp @@ -5,16 +5,16 @@ Content : Oculus Latency Tester device implementation. Created : March 7, 2013 Authors : Lee Cooper -Copyright : Copyright 2013 Oculus VR, Inc. All Rights reserved. +Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved. -Licensed under the Oculus VR SDK License Version 2.0 (the "License"); -you may not use the Oculus VR SDK except in compliance with the License, +Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, which is provided at the time of installation or download, or which otherwise accompanies this software in either electronic or hard copy form. You may obtain a copy of the License at -http://www.oculusvr.com/licenses/LICENSE-2.0 +http://www.oculusvr.com/licenses/LICENSE-3.1 Unless required by applicable law or agreed to in writing, the Oculus VR SDK distributed under the License is distributed on an "AS IS" BASIS, @@ -25,9 +25,12 @@ limitations under the License. *************************************************************************************/ #include "OVR_LatencyTestImpl.h" +#include "Kernel/OVR_Alg.h" namespace OVR { +using namespace Alg; + //------------------------------------------------------------------------------------- // ***** Oculus Latency Tester specific packet data structures @@ -36,18 +39,6 @@ enum { LatencyTester_ProductId = 0x0101, }; -// Reported data is little-endian now -static UInt16 DecodeUInt16(const UByte* buffer) -{ - return (UInt16(buffer[1]) << 8) | UInt16(buffer[0]); -} - -/* Unreferenced -static SInt16 DecodeSInt16(const UByte* buffer) -{ - return (SInt16(buffer[1]) << 8) | SInt16(buffer[0]); -}*/ - static void UnpackSamples(const UByte* buffer, UByte* r, UByte* g, UByte* b) { *r = buffer[0]; @@ -355,8 +346,7 @@ struct LatencyTestStartTestImpl UInt16 commandID = 1; Buffer[0] = 8; - Buffer[1] = UByte(commandID & 0xFF); - Buffer[2] = UByte(commandID >> 8); + EncodeUInt16(Buffer+1, commandID); Buffer[3] = TargetColor.R; Buffer[4] = TargetColor.G; Buffer[5] = TargetColor.B; @@ -364,7 +354,7 @@ struct LatencyTestStartTestImpl void Unpack() { -// UInt16 commandID = Buffer[1] | (UInt16(Buffer[2]) << 8); +// UInt16 commandID = DecodeUInt16(Buffer+1); TargetColor.R = Buffer[3]; TargetColor.G = Buffer[4]; TargetColor.B = Buffer[5]; @@ -388,19 +378,13 @@ struct LatencyTestDisplayImpl { Buffer[0] = 9; Buffer[1] = Display.Mode; - Buffer[2] = UByte(Display.Value & 0xFF); - Buffer[3] = UByte((Display.Value >> 8) & 0xFF); - Buffer[4] = UByte((Display.Value >> 16) & 0xFF); - Buffer[5] = UByte((Display.Value >> 24) & 0xFF); + EncodeUInt32(Buffer+2, Display.Value); } void Unpack() { Display.Mode = Buffer[1]; - Display.Value = UInt32(Buffer[2]) | - (UInt32(Buffer[3]) << 8) | - (UInt32(Buffer[4]) << 16) | - (UInt32(Buffer[5]) << 24); + Display.Value = DecodeUInt32(Buffer+2); } }; @@ -471,17 +455,17 @@ bool LatencyTestDeviceCreateDesc::GetDeviceInfo(DeviceInfo* info) const (info->InfoClassType != Device_None)) return false; - OVR_strcpy(info->ProductName, DeviceInfo::MaxNameLength, HIDDesc.Product.ToCStr()); - OVR_strcpy(info->Manufacturer, DeviceInfo::MaxNameLength, HIDDesc.Manufacturer.ToCStr()); - info->Type = Device_LatencyTester; + info->Type = Device_LatencyTester; + info->ProductName = HIDDesc.Product; + info->Manufacturer = HIDDesc.Manufacturer; + info->Version = HIDDesc.VersionNumber; if (info->InfoClassType == Device_LatencyTester) { SensorInfo* sinfo = (SensorInfo*)info; sinfo->VendorId = HIDDesc.VendorId; sinfo->ProductId = HIDDesc.ProductId; - sinfo->Version = HIDDesc.VersionNumber; - OVR_strcpy(sinfo->SerialNumber, sizeof(sinfo->SerialNumber),HIDDesc.SerialNumber.ToCStr()); + sinfo->SerialNumber = HIDDesc.SerialNumber; } return true; } @@ -712,7 +696,7 @@ void LatencyTestDeviceImpl::onLatencyTestSamplesMessage(LatencyTestSamplesMessag // Call OnMessage() within a lock to avoid conflicts with handlers. Lock::Locker scopeLock(HandlerRef.GetLock()); - if (HandlerRef.GetHandler()) + if (HandlerRef.HasHandlers()) { MessageLatencyTestSamples samples(this); for (UByte i = 0; i < s.SampleCount; i++) @@ -720,7 +704,7 @@ void LatencyTestDeviceImpl::onLatencyTestSamplesMessage(LatencyTestSamplesMessag samples.Samples.PushBack(Color(s.Samples[i].Value[0], s.Samples[i].Value[1], s.Samples[i].Value[2])); } - HandlerRef.GetHandler()->OnMessage(samples); + HandlerRef.Call(samples); } } @@ -734,14 +718,14 @@ void LatencyTestDeviceImpl::onLatencyTestColorDetectedMessage(LatencyTestColorDe // Call OnMessage() within a lock to avoid conflicts with handlers. Lock::Locker scopeLock(HandlerRef.GetLock()); - if (HandlerRef.GetHandler()) + if (HandlerRef.HasHandlers()) { MessageLatencyTestColorDetected detected(this); detected.Elapsed = s.Elapsed; detected.DetectedValue = Color(s.TriggerValue[0], s.TriggerValue[1], s.TriggerValue[2]); detected.TargetValue = Color(s.TargetValue[0], s.TargetValue[1], s.TargetValue[2]); - HandlerRef.GetHandler()->OnMessage(detected); + HandlerRef.Call(detected); } } @@ -755,12 +739,12 @@ void LatencyTestDeviceImpl::onLatencyTestStartedMessage(LatencyTestStartedMessag // Call OnMessage() within a lock to avoid conflicts with handlers. Lock::Locker scopeLock(HandlerRef.GetLock()); - if (HandlerRef.GetHandler()) + if (HandlerRef.HasHandlers()) { MessageLatencyTestStarted started(this); started.TargetValue = Color(ts.TargetValue[0], ts.TargetValue[1], ts.TargetValue[2]); - HandlerRef.GetHandler()->OnMessage(started); + HandlerRef.Call(started); } } @@ -774,11 +758,11 @@ void LatencyTestDeviceImpl::onLatencyTestButtonMessage(LatencyTestButtonMessage* // Call OnMessage() within a lock to avoid conflicts with handlers. Lock::Locker scopeLock(HandlerRef.GetLock()); - if (HandlerRef.GetHandler()) + if (HandlerRef.HasHandlers()) { MessageLatencyTestButton button(this); - HandlerRef.GetHandler()->OnMessage(button); + HandlerRef.Call(button); } } |