OVR_DeviceMessages.h
Go to the documentation of this file.
00001 /************************************************************************************
00002 
00003 PublicHeader:   OVR.h
00004 Filename    :   OVR_DeviceMessages.h
00005 Content     :   Definition of messages generated by devices
00006 Created     :   February 5, 2013
00007 Authors     :   Lee Cooper
00008 
00009 Copyright   :   Copyright 2013 Oculus VR, Inc. All Rights reserved.
00010 
00011 Use of this software is subject to the terms of the Oculus license
00012 agreement provided at the time of installation or download, or which
00013 otherwise accompanies this software in either electronic or hard copy form.
00014 
00015 *************************************************************************************/
00016 
00017 #ifndef OVR_DeviceMessages_h
00018 #define OVR_DeviceMessages_h
00019 
00020 #include "OVR_DeviceConstants.h"
00021 #include "OVR_DeviceHandle.h"
00022 
00023 #include "Kernel/OVR_Math.h"
00024 #include "Kernel/OVR_Array.h"
00025 #include "Kernel/OVR_Color.h"
00026 
00027 namespace OVR {
00028 
00029 class DeviceBase;
00030 class DeviceHandle;
00031 
00032 
00033 #define OVR_MESSAGETYPE(devName, msgIndex)   ((Device_##devName << 8) | msgIndex)
00034 
00035 // MessageType identifies the structure of the Message class; based on the message,
00036 // casting can be used to obtain the exact value.
00037 enum MessageType
00038 {
00039     // Used for unassigned message types.
00040     Message_None            = 0,
00041 
00042     // Device Manager Messages
00043     Message_DeviceAdded             = OVR_MESSAGETYPE(Manager, 0),  // A new device is detected by manager.
00044     Message_DeviceRemoved           = OVR_MESSAGETYPE(Manager, 1),  // Existing device has been plugged/unplugged.
00045     // Sensor Messages
00046     Message_BodyFrame               = OVR_MESSAGETYPE(Sensor, 0),   // Emitted by sensor at regular intervals.
00047     // Latency Tester Messages
00048     Message_LatencyTestSamples          = OVR_MESSAGETYPE(LatencyTester, 0),
00049     Message_LatencyTestColorDetected    = OVR_MESSAGETYPE(LatencyTester, 1),
00050     Message_LatencyTestStarted          = OVR_MESSAGETYPE(LatencyTester, 2),
00051     Message_LatencyTestButton           = OVR_MESSAGETYPE(LatencyTester, 3),
00052 
00053 };
00054 
00055 //-------------------------------------------------------------------------------------
00056 // Base class for all messages.
00057 class Message
00058 {
00059 public:
00060     Message(MessageType type = Message_None,
00061             DeviceBase* pdev = 0) : Type(type), pDevice(pdev)
00062     { }
00063 
00064     MessageType Type;    // What kind of message this is.
00065     DeviceBase* pDevice; // Device that emitted the message.
00066 };
00067 
00068 
00069 // Sensor BodyFrame notification.
00070 // Sensor uses Right-Handed coordinate system to return results, with the following
00071 // axis definitions:
00072 //  - Y Up positive
00073 //  - X Right Positive
00074 //  - Z Back Positive
00075 // Rotations a counter-clockwise (CCW) while looking in the negative direction
00076 // of the axis. This means they are interpreted as follows:
00077 //  - Roll is rotation around Z, counter-clockwise (tilting left) in XY plane.
00078 //  - Yaw is rotation around Y, positive for turning left.
00079 //  - Pitch is rotation around X, positive for pitching up.
00080 
00081 class MessageBodyFrame : public Message
00082 {
00083 public:
00084     MessageBodyFrame(DeviceBase* dev)
00085         : Message(Message_BodyFrame, dev), Temperature(0.0f), TimeDelta(0.0f)
00086     {
00087     }
00088 
00089     Vector3f Acceleration;   // Acceleration in m/s^2.
00090     Vector3f RotationRate;   // Angular velocity in rad/s^2.
00091     Vector3f MagneticField;  // Magnetic field strength in Gauss.
00092     float    Temperature;    // Temperature reading on sensor surface, in degrees Celsius.
00093     float    TimeDelta;      // Time passed since last Body Frame, in seconds.
00094 };
00095 
00096 // Sent when we receive a device status changes (e.g.:
00097 // Message_DeviceAdded, Message_DeviceRemoved).
00098 class MessageDeviceStatus : public Message
00099 {
00100 public:
00101         MessageDeviceStatus(MessageType type, DeviceBase* dev, const DeviceHandle &hdev)
00102                 : Message(type, dev), Handle(hdev) { }
00103 
00104         DeviceHandle Handle;
00105 };
00106 
00107 //-------------------------------------------------------------------------------------
00108 // ***** Latency Tester
00109 
00110 // Sent when we receive Latency Tester samples.
00111 class MessageLatencyTestSamples : public Message
00112 {
00113 public:
00114     MessageLatencyTestSamples(DeviceBase* dev)
00115         : Message(Message_LatencyTestSamples, dev)
00116     {
00117     }
00118 
00119     Array<Color>     Samples;
00120 };
00121 
00122 // Sent when a Latency Tester 'color detected' event occurs.
00123 class MessageLatencyTestColorDetected : public Message
00124 {
00125 public:
00126     MessageLatencyTestColorDetected(DeviceBase* dev)
00127         : Message(Message_LatencyTestColorDetected, dev)
00128     {
00129     }
00130 
00131     UInt16      Elapsed;
00132     Color       DetectedValue;
00133     Color       TargetValue;
00134 };
00135 
00136 // Sent when a Latency Tester 'change color' event occurs.
00137 class MessageLatencyTestStarted : public Message
00138 {
00139 public:
00140     MessageLatencyTestStarted(DeviceBase* dev)
00141         : Message(Message_LatencyTestStarted, dev)
00142     {
00143     }
00144 
00145     Color    TargetValue;
00146 };
00147 
00148 // Sent when a Latency Tester 'button' event occurs.
00149 class MessageLatencyTestButton : public Message
00150 {
00151 public:
00152     MessageLatencyTestButton(DeviceBase* dev)
00153         : Message(Message_LatencyTestButton, dev)
00154     {
00155     }
00156 
00157 };
00158 
00159 
00160 } // namespace OVR
00161 
00162 #endif


oculus_sdk
Author(s):
autogenerated on Mon Oct 6 2014 03:01:18