oculus1

view libovr/Src/OVR_DeviceMessages.h @ 18:1b107de821c1

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