oculus1

annotate libovr/Src/OVR_DeviceMessages.h @ 10:b2abb08c8f94

proper FPS-style vr tracking
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 20 Sep 2013 06:49:39 +0300
parents
children
rev   line source
nuclear@1 1 /************************************************************************************
nuclear@1 2
nuclear@1 3 PublicHeader: OVR.h
nuclear@1 4 Filename : OVR_DeviceMessages.h
nuclear@1 5 Content : Definition of messages generated by devices
nuclear@1 6 Created : February 5, 2013
nuclear@1 7 Authors : Lee Cooper
nuclear@1 8
nuclear@1 9 Copyright : Copyright 2013 Oculus VR, Inc. All Rights reserved.
nuclear@1 10
nuclear@1 11 Use of this software is subject to the terms of the Oculus license
nuclear@1 12 agreement provided at the time of installation or download, or which
nuclear@1 13 otherwise accompanies this software in either electronic or hard copy form.
nuclear@1 14
nuclear@1 15 *************************************************************************************/
nuclear@1 16
nuclear@1 17 #ifndef OVR_DeviceMessages_h
nuclear@1 18 #define OVR_DeviceMessages_h
nuclear@1 19
nuclear@1 20 #include "OVR_DeviceConstants.h"
nuclear@1 21 #include "OVR_DeviceHandle.h"
nuclear@1 22
nuclear@1 23 #include "Kernel/OVR_Math.h"
nuclear@1 24 #include "Kernel/OVR_Array.h"
nuclear@1 25 #include "Kernel/OVR_Color.h"
nuclear@1 26
nuclear@1 27 namespace OVR {
nuclear@1 28
nuclear@1 29 class DeviceBase;
nuclear@1 30 class DeviceHandle;
nuclear@1 31
nuclear@1 32
nuclear@1 33 #define OVR_MESSAGETYPE(devName, msgIndex) ((Device_##devName << 8) | msgIndex)
nuclear@1 34
nuclear@1 35 // MessageType identifies the structure of the Message class; based on the message,
nuclear@1 36 // casting can be used to obtain the exact value.
nuclear@1 37 enum MessageType
nuclear@1 38 {
nuclear@1 39 // Used for unassigned message types.
nuclear@1 40 Message_None = 0,
nuclear@1 41
nuclear@1 42 // Device Manager Messages
nuclear@1 43 Message_DeviceAdded = OVR_MESSAGETYPE(Manager, 0), // A new device is detected by manager.
nuclear@1 44 Message_DeviceRemoved = OVR_MESSAGETYPE(Manager, 1), // Existing device has been plugged/unplugged.
nuclear@1 45 // Sensor Messages
nuclear@1 46 Message_BodyFrame = OVR_MESSAGETYPE(Sensor, 0), // Emitted by sensor at regular intervals.
nuclear@1 47 // Latency Tester Messages
nuclear@1 48 Message_LatencyTestSamples = OVR_MESSAGETYPE(LatencyTester, 0),
nuclear@1 49 Message_LatencyTestColorDetected = OVR_MESSAGETYPE(LatencyTester, 1),
nuclear@1 50 Message_LatencyTestStarted = OVR_MESSAGETYPE(LatencyTester, 2),
nuclear@1 51 Message_LatencyTestButton = OVR_MESSAGETYPE(LatencyTester, 3),
nuclear@1 52
nuclear@1 53 };
nuclear@1 54
nuclear@1 55 //-------------------------------------------------------------------------------------
nuclear@1 56 // Base class for all messages.
nuclear@1 57 class Message
nuclear@1 58 {
nuclear@1 59 public:
nuclear@1 60 Message(MessageType type = Message_None,
nuclear@1 61 DeviceBase* pdev = 0) : Type(type), pDevice(pdev)
nuclear@1 62 { }
nuclear@1 63
nuclear@1 64 MessageType Type; // What kind of message this is.
nuclear@1 65 DeviceBase* pDevice; // Device that emitted the message.
nuclear@1 66 };
nuclear@1 67
nuclear@1 68
nuclear@1 69 // Sensor BodyFrame notification.
nuclear@1 70 // Sensor uses Right-Handed coordinate system to return results, with the following
nuclear@1 71 // axis definitions:
nuclear@1 72 // - Y Up positive
nuclear@1 73 // - X Right Positive
nuclear@1 74 // - Z Back Positive
nuclear@1 75 // Rotations a counter-clockwise (CCW) while looking in the negative direction
nuclear@1 76 // of the axis. This means they are interpreted as follows:
nuclear@1 77 // - Roll is rotation around Z, counter-clockwise (tilting left) in XY plane.
nuclear@1 78 // - Yaw is rotation around Y, positive for turning left.
nuclear@1 79 // - Pitch is rotation around X, positive for pitching up.
nuclear@1 80
nuclear@1 81 class MessageBodyFrame : public Message
nuclear@1 82 {
nuclear@1 83 public:
nuclear@1 84 MessageBodyFrame(DeviceBase* dev)
nuclear@1 85 : Message(Message_BodyFrame, dev), Temperature(0.0f), TimeDelta(0.0f)
nuclear@1 86 {
nuclear@1 87 }
nuclear@1 88
nuclear@1 89 Vector3f Acceleration; // Acceleration in m/s^2.
nuclear@1 90 Vector3f RotationRate; // Angular velocity in rad/s^2.
nuclear@1 91 Vector3f MagneticField; // Magnetic field strength in Gauss.
nuclear@1 92 float Temperature; // Temperature reading on sensor surface, in degrees Celsius.
nuclear@1 93 float TimeDelta; // Time passed since last Body Frame, in seconds.
nuclear@1 94 };
nuclear@1 95
nuclear@1 96 // Sent when we receive a device status changes (e.g.:
nuclear@1 97 // Message_DeviceAdded, Message_DeviceRemoved).
nuclear@1 98 class MessageDeviceStatus : public Message
nuclear@1 99 {
nuclear@1 100 public:
nuclear@1 101 MessageDeviceStatus(MessageType type, DeviceBase* dev, const DeviceHandle &hdev)
nuclear@1 102 : Message(type, dev), Handle(hdev) { }
nuclear@1 103
nuclear@1 104 DeviceHandle Handle;
nuclear@1 105 };
nuclear@1 106
nuclear@1 107 //-------------------------------------------------------------------------------------
nuclear@1 108 // ***** Latency Tester
nuclear@1 109
nuclear@1 110 // Sent when we receive Latency Tester samples.
nuclear@1 111 class MessageLatencyTestSamples : public Message
nuclear@1 112 {
nuclear@1 113 public:
nuclear@1 114 MessageLatencyTestSamples(DeviceBase* dev)
nuclear@1 115 : Message(Message_LatencyTestSamples, dev)
nuclear@1 116 {
nuclear@1 117 }
nuclear@1 118
nuclear@1 119 Array<Color> Samples;
nuclear@1 120 };
nuclear@1 121
nuclear@1 122 // Sent when a Latency Tester 'color detected' event occurs.
nuclear@1 123 class MessageLatencyTestColorDetected : public Message
nuclear@1 124 {
nuclear@1 125 public:
nuclear@1 126 MessageLatencyTestColorDetected(DeviceBase* dev)
nuclear@1 127 : Message(Message_LatencyTestColorDetected, dev)
nuclear@1 128 {
nuclear@1 129 }
nuclear@1 130
nuclear@1 131 UInt16 Elapsed;
nuclear@1 132 Color DetectedValue;
nuclear@1 133 Color TargetValue;
nuclear@1 134 };
nuclear@1 135
nuclear@1 136 // Sent when a Latency Tester 'change color' event occurs.
nuclear@1 137 class MessageLatencyTestStarted : public Message
nuclear@1 138 {
nuclear@1 139 public:
nuclear@1 140 MessageLatencyTestStarted(DeviceBase* dev)
nuclear@1 141 : Message(Message_LatencyTestStarted, dev)
nuclear@1 142 {
nuclear@1 143 }
nuclear@1 144
nuclear@1 145 Color TargetValue;
nuclear@1 146 };
nuclear@1 147
nuclear@1 148 // Sent when a Latency Tester 'button' event occurs.
nuclear@1 149 class MessageLatencyTestButton : public Message
nuclear@1 150 {
nuclear@1 151 public:
nuclear@1 152 MessageLatencyTestButton(DeviceBase* dev)
nuclear@1 153 : Message(Message_LatencyTestButton, dev)
nuclear@1 154 {
nuclear@1 155 }
nuclear@1 156
nuclear@1 157 };
nuclear@1 158
nuclear@1 159
nuclear@1 160 } // namespace OVR
nuclear@1 161
nuclear@1 162 #endif