27 #ifndef OVR_Sensor2ImplUtil_h
28 #define OVR_Sensor2ImplUtil_h
41 enum { PacketSize = 13 };
48 for (
int i=0; i<PacketSize; i++)
67 Buffer[3] = Settings.Pattern;
68 Buffer[4] =
UByte(Settings.Enable << 0 |
69 Settings.Autoincrement << 1 |
70 Settings.UseCarrier << 2 |
71 Settings.SyncInput << 3 |
72 Settings.VsyncLock << 4 |
73 Settings.CustomPattern << 5);
78 Buffer[12] = Settings.DutyCycle;
84 Settings.Pattern = Buffer[3];
85 Settings.Enable = (Buffer[4] & 0x01) != 0;
86 Settings.Autoincrement = (Buffer[4] & 0x02) != 0;
87 Settings.UseCarrier = (Buffer[4] & 0x04) != 0;
88 Settings.SyncInput = (Buffer[4] & 0x08) != 0;
89 Settings.VsyncLock = (Buffer[4] & 0x10) != 0;
90 Settings.CustomPattern = (Buffer[4] & 0x20) != 0;
94 Settings.DutyCycle = Buffer[12];
101 enum { PacketSize = 16 };
108 for (
int i=0; i<PacketSize; i++)
127 Buffer[3] = Settings.Brightness;
128 Buffer[4] =
UByte( (Settings.ShutterType & 0x0F) |
129 (Settings.CurrentLimit & 0x03) << 4 |
130 (Settings.UseRolling ? 0x40 : 0) |
131 (Settings.ReverseRolling ? 0x80 : 0));
132 Buffer[5] =
UByte( (Settings.HighBrightness ? 0x01 : 0) |
133 (Settings.SelfRefresh ? 0x02 : 0) |
134 (Settings.ReadPixel ? 0x04 : 0) |
135 (Settings.DirectPentile ? 0x08 : 0));
146 Settings.Brightness = Buffer[3];
149 Settings.UseRolling = (Buffer[4] & 0x40) != 0;
150 Settings.ReverseRolling = (Buffer[4] & 0x80) != 0;
151 Settings.HighBrightness = (Buffer[5] & 0x01) != 0;
152 Settings.SelfRefresh = (Buffer[5] & 0x02) != 0;
153 Settings.ReadPixel = (Buffer[5] & 0x04) != 0;
154 Settings.DirectPentile = (Buffer[5] & 0x08) != 0;
165 enum { PacketSize = 52 };
172 memset(Buffer, 0,
sizeof(Buffer));
186 Buffer[3] = Settings.Version;
188 for (
int i = 0; i < 3; i++)
189 for (
int j = 0; j < 4; j++)
191 SInt32 value =
SInt32(Settings.Calibration.M[i][j] * 1e4f);
199 Settings.Version = Buffer[3];
201 for (
int i = 0; i < 3; i++)
202 for (
int j = 0; j < 4; j++)
205 Settings.Calibration.M[i][j] = (float)value * 1e-4f;
216 enum { PacketSize = 30 };
223 for (
int i=0; i<PacketSize; i++)
242 Buffer[3] = Settings.Version;
244 Vector3d position = Settings.Position * 1e6;
249 Vector3d normal = Settings.Normal * 1e6;
254 double rotation = Settings.Angle * 1e4;
265 Settings.Version = Buffer[3];
286 enum { PacketSize = 22 };
293 for (
int i=0; i<PacketSize; i++)
312 Buffer[3] = Settings.Version;
314 Vector3d position = Settings.Position * 1e6;
328 Settings.Version = Buffer[3];
343 enum { PacketSize = 12 };
350 for (
int i=0; i<PacketSize; i++)
369 Buffer[3] = Settings.SequenceLength;
378 Settings.SequenceLength = Buffer[3];
388 enum { PacketSize = 16 };
395 memset(Buffer, 0,
sizeof(Buffer));
409 Buffer[3] = Settings.NumStages;
410 Buffer[4] = Settings.Stage;
411 Buffer[5] = Settings.StageVersion;
420 Settings.NumStages = Buffer[3];
421 Settings.Stage = Buffer[4];
422 Settings.StageVersion = Buffer[5];
432 enum { PacketSize = 23 };
439 memset(Buffer, 0,
sizeof(Buffer));
453 for (
int i = 0; i < 20; ++i)
454 Buffer[3 + i] = Settings.UUIDValue[i];
460 for (
int i = 0; i < 20; ++i)
461 Settings.UUIDValue[i] = Buffer[3 + i];
468 enum { PacketSize = 64 };
475 memset(Buffer, 0,
sizeof(Buffer));
490 Buffer[3] = Settings.NumDistortions;
491 Buffer[4] = Settings.DistortionIndex;
492 Buffer[5] = Settings.Bitmask;
497 for (
int i = 0; i < 11; ++i)
501 EncodeUInt16(Buffer+36, Settings.MetersPerTanAngleAtCenter);
503 for (
int i = 0; i < 4; ++i)
504 EncodeUInt16(Buffer+38+2*i, Settings.ChromaticAberration[i]);
511 Settings.NumDistortions = Buffer[3];
512 Settings.DistortionIndex = Buffer[4];
513 Settings.Bitmask = Buffer[5];
518 for (
int i = 0; i < 11; ++i)
519 Settings.KCoefficients[i] =
DecodeUInt16(Buffer+12+2*i);
522 Settings.MetersPerTanAngleAtCenter =
DecodeUInt16(Buffer+36);
524 for (
int i = 0; i < 4; ++i)
525 Settings.ChromaticAberration[i] =
DecodeUInt16(Buffer+38+2*i);
532 enum { PacketSize = 6 };
539 memset(Buffer, 0,
sizeof(Buffer));
553 Buffer[3] = Settings.INReport;
560 Settings.INReport = Buffer[3];
568 enum { PacketSize = 24 };
575 memset(Buffer, 0,
sizeof(Buffer));
590 Buffer[3] = Settings.Version;
592 Buffer[4] = Settings.NumBins;
593 Buffer[5] = Settings.Bin;
594 Buffer[6] = Settings.NumSamples;
595 Buffer[7] = Settings.Sample;
602 Vector3d offset = Settings.Offset * 1e4;
609 Settings.Version = Buffer[3];
611 Settings.NumBins = Buffer[4];
612 Settings.Bin = Buffer[5];
613 Settings.NumSamples = Buffer[6];
614 Settings.Sample = Buffer[7];
616 Settings.TargetTemperature =
DecodeSInt16(Buffer + 8) * 1e-2;
617 Settings.ActualTemperature =
DecodeSInt16(Buffer + 10) * 1e-2;
623 Settings.Offset =
Vector3d(x, y, z) * 1e-4;
630 enum { PacketSize = 18 };
637 memset(Buffer, 0,
sizeof(Buffer));
651 Buffer[1] =
UByte(Settings.CommandId & 0xFF);
652 Buffer[2] =
UByte(Settings.CommandId >> 8);
653 Buffer[3] =
UByte(Settings.Version);
655 Vector3d offset = Settings.Offset * 1e4;
668 Settings.Offset =
Vector3d(x, y, z) * 1e-4f;
670 Settings.Temperature =
DecodeSInt16(Buffer + 16) * 1e-2;
676 #endif // OVR_Sensor2ImplUtil_h
UUIDImpl(const UUIDReport &settings)
ManufacturingReport Settings
ManufacturingImpl(const ManufacturingReport &settings)
KeepAliveMuxReport Settings
LensDistortionImpl(const LensDistortionReport &settings)
void EncodeUInt32(UByte *buffer, UInt32 val)
CustomPatternReport Settings
SInt32 DecodeSInt32(const UByte *buffer)
void EncodeUInt16(UByte *buffer, UInt16 val)
TemperatureImpl(const TemperatureReport &settings)
UInt32 DecodeUInt32(const UByte *buffer)
UInt16 DecodeUInt16(const UByte *buffer)
PositionCalibrationImpl_Pre5()
TemperatureReport Settings
DisplayImpl(const DisplayReport &settings)
PositionCalibrationImpl_Pre5(const PositionCalibrationReport &settings)
MagCalibrationReport Settings
LensDistortionReport Settings
void PackSensor(UByte *buffer, SInt32 x, SInt32 y, SInt32 z)
PositionCalibrationReport Settings
Vector3< double > Vector3d
CustomPatternImpl(const CustomPatternReport &settings)
GyroOffsetImpl(const GyroOffsetReport &settings)
PositionCalibrationImpl()
MagCalibrationImpl(const MagCalibrationReport &settings)
PositionCalibrationReport Settings
KeepAliveMuxImpl(const KeepAliveMuxReport &settings)
PositionCalibrationImpl(const PositionCalibrationReport &settings)
__BEGIN_NAMESPACE_STD void void __END_NAMESPACE_STD void __BEGIN_NAMESPACE_STD void * memset(void *__s, int __c, size_t __n) __THROW __nonnull((1))
void UnpackSensor(const UByte *buffer, SInt32 *x, SInt32 *y, SInt32 *z)
void EncodeSInt16(UByte *buffer, SInt16 val)
TrackingImpl(const TrackingReport &settings)
SInt16 DecodeSInt16(const UByte *buffer)
GyroOffsetReport Settings
void EncodeSInt32(UByte *buffer, SInt32 val)