summaryrefslogtreecommitdiffstats
path: root/gfx/vr/service/osvr/Util/ClientReportTypesC.h
blob: 09769d2462c85fe59b7cb3f8be7e571a89ed5d73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
/** @file
    @brief Header

    Must be c-safe!

    @date 2014

    @author
    Sensics, Inc.
    <http://sensics.com/osvr>
*/

/*
// Copyright 2014 Sensics, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
*/

#ifndef INCLUDED_ClientReportTypesC_h_GUID_E79DAB07_78B7_4795_1EB9_CA6EEB274AEE
#define INCLUDED_ClientReportTypesC_h_GUID_E79DAB07_78B7_4795_1EB9_CA6EEB274AEE

/* Internal Includes */
#include <osvr/Util/APIBaseC.h>
#include <osvr/Util/Pose3C.h>
#include <osvr/Util/StdInt.h>

#include <osvr/Util/Vec2C.h>
#include <osvr/Util/Vec3C.h>
#include <osvr/Util/ChannelCountC.h>
#include <osvr/Util/BoolC.h>

/* Library/third-party includes */
/* none */

/* Standard includes */
/* none */

OSVR_EXTERN_C_BEGIN

/** @addtogroup ClientKit
    @{
*/

/** @name State types
@{
*/
/** @brief Type of position state */
typedef OSVR_Vec3 OSVR_PositionState;

/** @brief Type of orientation state */
typedef OSVR_Quaternion OSVR_OrientationState;

/** @brief Type of pose state */
typedef OSVR_Pose3 OSVR_PoseState;

/** @brief Type of linear velocity state */
typedef OSVR_Vec3 OSVR_LinearVelocityState;

/** @brief The quaternion represents the incremental rotation taking place over
    a period of dt seconds. Use of dt (which does not necessarily
    have to be 1, as other velocity/acceleration representations imply) and an
    incremental quaternion allows device reports to be scaled to avoid aliasing
*/
typedef struct OSVR_IncrementalQuaternion {
  OSVR_Quaternion incrementalRotation;
  double dt;
} OSVR_IncrementalQuaternion;

/** @brief Type of angular velocity state: an incremental quaternion, providing
    the incremental rotation taking place due to velocity over a period of dt
    seconds.
*/
typedef OSVR_IncrementalQuaternion OSVR_AngularVelocityState;

/** @brief Struct for combined velocity state */
typedef struct OSVR_VelocityState {
  OSVR_LinearVelocityState linearVelocity;
  /** @brief Whether the data source reports valid data for
      #OSVR_VelocityState::linearVelocity */
  OSVR_CBool linearVelocityValid;

  OSVR_AngularVelocityState angularVelocity;
  /** @brief Whether the data source reports valid data for
  #OSVR_VelocityState::angularVelocity */
  OSVR_CBool angularVelocityValid;
} OSVR_VelocityState;

/** @brief Type of linear acceleration state */
typedef OSVR_Vec3 OSVR_LinearAccelerationState;

/** @brief Type of angular acceleration state
 */
typedef OSVR_IncrementalQuaternion OSVR_AngularAccelerationState;

/** @brief Struct for combined acceleration state */
typedef struct OSVR_AccelerationState {
  OSVR_LinearAccelerationState linearAcceleration;
  /** @brief Whether the data source reports valid data for
  #OSVR_AccelerationState::linearAcceleration */
  OSVR_CBool linearAccelerationValid;

  OSVR_AngularAccelerationState angularAcceleration;
  /** @brief Whether the data source reports valid data for
  #OSVR_AccelerationState::angularAcceleration */
  OSVR_CBool angularAccelerationValid;
} OSVR_AccelerationState;

/** @brief Type of button state */
typedef uint8_t OSVR_ButtonState;

/** @brief OSVR_ButtonState value indicating "button down" */
#define OSVR_BUTTON_PRESSED (1)

/** @brief OSVR_ButtonState value indicating "button up" */
#define OSVR_BUTTON_NOT_PRESSED (0)

/** @brief Type of analog channel state */
typedef double OSVR_AnalogState;

/** @} */

/** @name Report types
    @{
*/
/** @brief Report type for a position callback on a tracker interface */
typedef struct OSVR_PositionReport {
  /** @brief Identifies the sensor that the report comes from */
  int32_t sensor;
  /** @brief The position vector */
  OSVR_PositionState xyz;
} OSVR_PositionReport;

/** @brief Report type for an orientation callback on a tracker interface */
typedef struct OSVR_OrientationReport {
  /** @brief Identifies the sensor that the report comes from */
  int32_t sensor;
  /** @brief The rotation unit quaternion */
  OSVR_OrientationState rotation;
} OSVR_OrientationReport;

/** @brief Report type for a pose (position and orientation) callback on a
    tracker interface
*/
typedef struct OSVR_PoseReport {
  /** @brief Identifies the sensor that the report comes from */
  int32_t sensor;
  /** @brief The pose structure, containing a position vector and a rotation
      quaternion
  */
  OSVR_PoseState pose;
} OSVR_PoseReport;

/** @brief Report type for a velocity (linear and angular) callback on a
    tracker interface
*/
typedef struct OSVR_VelocityReport {
  /** @brief Identifies the sensor that the report comes from */
  int32_t sensor;
  /** @brief The data state - note that not all fields are neccesarily valid,
      use the `Valid` members to check the status of the other fields.
  */
  OSVR_VelocityState state;
} OSVR_VelocityReport;

/** @brief Report type for a linear velocity callback on a tracker interface
 */
typedef struct OSVR_LinearVelocityReport {
  /** @brief Identifies the sensor that the report comes from */
  int32_t sensor;
  /** @brief The state itself */
  OSVR_LinearVelocityState state;
} OSVR_LinearVelocityReport;

/** @brief Report type for an angular velocity callback on a tracker interface
 */
typedef struct OSVR_AngularVelocityReport {
  /** @brief Identifies the sensor that the report comes from */
  int32_t sensor;
  /** @brief The state itself */
  OSVR_AngularVelocityState state;
} OSVR_AngularVelocityReport;

/** @brief Report type for an acceleration (linear and angular) callback on a
    tracker interface
*/
typedef struct OSVR_AccelerationReport {
  /** @brief Identifies the sensor that the report comes from */
  int32_t sensor;
  /** @brief The data state - note that not all fields are neccesarily valid,
      use the `Valid` members to check the status of the other fields.
  */
  OSVR_AccelerationState state;
} OSVR_AccelerationReport;

/** @brief Report type for a linear acceleration callback on a tracker interface
 */
typedef struct OSVR_LinearAccelerationReport {
  /** @brief Identifies the sensor that the report comes from */
  int32_t sensor;
  /** @brief The state itself */
  OSVR_LinearAccelerationState state;
} OSVR_LinearAccelerationReport;

/** @brief Report type for an angular acceleration callback on a tracker
    interface
*/
typedef struct OSVR_AngularAccelerationReport {
  /** @brief Identifies the sensor that the report comes from */
  int32_t sensor;
  /** @brief The state itself */
  OSVR_AngularAccelerationState state;
} OSVR_AngularAccelerationReport;

/** @brief Report type for a callback on a button interface */
typedef struct OSVR_ButtonReport {
  /** @brief Identifies the sensor that the report comes from */
  int32_t sensor;
  /** @brief The button state: 1 is pressed, 0 is not pressed. */
  OSVR_ButtonState state;
} OSVR_ButtonReport;

/** @brief Report type for a callback on an analog interface */
typedef struct OSVR_AnalogReport {
  /** @brief Identifies the sensor/channel that the report comes from */
  int32_t sensor;
  /** @brief The analog state. */
  OSVR_AnalogState state;
} OSVR_AnalogReport;

/** @brief Type of location within a 2D region/surface, in normalized
    coordinates (in range [0, 1] in standard OSVR coordinate system)
*/
typedef OSVR_Vec2 OSVR_Location2DState;

/** @brief Report type for 2D location */
typedef struct OSVR_Location2DReport {
  OSVR_ChannelCount sensor;
  OSVR_Location2DState location;
} OSVR_Location2DReport;

/** @brief Type of unit directional vector in 3D with no particular origin */
typedef OSVR_Vec3 OSVR_DirectionState;

/** @brief Report type for 3D Direction vector */
typedef struct OSVR_DirectionReport {
  OSVR_ChannelCount sensor;
  OSVR_DirectionState direction;
} OSVR_DirectionReport;

/** @brief Type of eye gaze direction in 3D which contains 3D vector (position)
    containing gaze base point of the user's respective eye in 3D device
    coordinates.
*/
typedef OSVR_PositionState OSVR_EyeGazeBasePoint3DState;

/** @brief Type of eye gaze position in 2D which contains users's gaze/point of
    regard in normalized display coordinates (in range [0, 1] in standard OSVR
    coordinate system)
*/
typedef OSVR_Location2DState OSVR_EyeGazePosition2DState;

// typedef OSVR_DirectionState OSVR_EyeGazeBasePoint3DState;

/** @brief Type of 3D vector (direction vector) containing the normalized gaze
    direction of user's respective eye */
typedef OSVR_DirectionState OSVR_EyeGazeDirectionState;

/** @brief State for 3D gaze report */
typedef struct OSVR_EyeTracker3DState {
  OSVR_CBool directionValid;
  OSVR_DirectionState direction;
  OSVR_CBool basePointValid;
  OSVR_PositionState basePoint;
} OSVR_EyeTracker3DState;

/** @brief Report type for 3D gaze report */
typedef struct OSVR_EyeTracker3DReport {
  OSVR_ChannelCount sensor;
  OSVR_EyeTracker3DState state;
} OSVR_EyeTracker3DReport;

/** @brief State for 2D location report */
typedef OSVR_Location2DState OSVR_EyeTracker2DState;

/** @brief Report type for 2D location report */
typedef struct OSVR_EyeTracker2DReport {
  OSVR_ChannelCount sensor;
  OSVR_EyeTracker2DState state;
} OSVR_EyeTracker2DReport;

/** @brief State for a blink event */
typedef OSVR_ButtonState OSVR_EyeTrackerBlinkState;

/** @brief OSVR_EyeTrackerBlinkState value indicating an eyes blink had occurred
 */
#define OSVR_EYE_BLINK (1)

/** @brief OSVR_EyeTrackerBlinkState value indicating eyes are not blinking */
#define OSVR_EYE_NO_BLINK (0)

/** @brief Report type for a blink event */
typedef struct OSVR_EyeTrackerBlinkReport {
  OSVR_ChannelCount sensor;
  OSVR_EyeTrackerBlinkState state;
} OSVR_EyeTrackerBlinkReport;

/** @brief Report type for an Imaging callback (forward declaration) */
struct OSVR_ImagingReport;

/** @brief Type of Navigation Velocity state */
typedef OSVR_Vec2 OSVR_NaviVelocityState;

/** @brief Type of Navigation Position state */
typedef OSVR_Vec2 OSVR_NaviPositionState;

/** @brief Report type for an navigation velocity callback on a tracker
 * interface */
typedef struct OSVR_NaviVelocityReport {
  OSVR_ChannelCount sensor;
  /** @brief The 2D vector in world coordinate system, in meters/second */
  OSVR_NaviVelocityState state;
} OSVR_NaviVelocityReport;

/** @brief Report type for an navigation position callback on a tracker
 * interface */
typedef struct OSVR_NaviPositionReport {
  OSVR_ChannelCount sensor;
  /** @brief The 2D vector in world coordinate system, in meters, relative to
   * starting position */
  OSVR_NaviPositionState state;
} OSVR_NaviPositionReport;

/** @} */

/** @} */
OSVR_EXTERN_C_END

#endif