Monado OpenXR Runtime
oh_device.h
Go to the documentation of this file.
1 // Copyright 2019, Collabora, Ltd.
2 // SPDX-License-Identifier: BSL-1.0
3 /*!
4  * @file
5  * @brief Interface to OpenHMD driver code.
6  * @author Jakob Bornecrantz <jakob@collabora.com>
7  * @ingroup drv_ohmd
8  */
9 
10 #pragma once
11 
12 #include "math/m_api.h"
13 #include "xrt/xrt_device.h"
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 typedef struct ohmd_context ohmd_context;
20 typedef struct ohmd_device ohmd_device;
21 
22 struct oh_device
23 {
24  struct xrt_device base;
25  ohmd_context *ctx;
26  ohmd_device *dev;
27 
28  bool skip_ang_vel;
29 
30  int64_t last_update;
31  struct xrt_space_relation last_relation;
32 
33  bool print_spew;
34  bool print_debug;
35  bool enable_finite_difference;
36 };
37 
38 static inline struct oh_device *
39 oh_device(struct xrt_device *xdev)
40 {
41  return (struct oh_device *)xdev;
42 }
43 
44 struct oh_device *
45 oh_device_create(ohmd_context *ctx,
46  ohmd_device *dev,
47  const char *prod,
48  bool print_spew,
49  bool print_debug);
50 
51 #define OH_SPEW(c, ...) \
52  do { \
53  if (c->print_spew) { \
54  fprintf(stderr, "%s - ", __func__); \
55  fprintf(stderr, __VA_ARGS__); \
56  fprintf(stderr, "\n"); \
57  } \
58  } while (false)
59 
60 #define OH_DEBUG(c, ...) \
61  do { \
62  if (c->print_debug) { \
63  fprintf(stderr, "%s - ", __func__); \
64  fprintf(stderr, __VA_ARGS__); \
65  fprintf(stderr, "\n"); \
66  } \
67  } while (false)
68 
69 #define OH_ERROR(c, ...) \
70  do { \
71  fprintf(stderr, "%s - ", __func__); \
72  fprintf(stderr, __VA_ARGS__); \
73  fprintf(stderr, "\n"); \
74  } while (false)
75 
76 
77 #ifdef __cplusplus
78 }
79 #endif
Definition: oh_device.h:22
Header defining a xrt HMD device.
A relation with two spaces, includes velocity and acceleration.
Definition: xrt_defines.h:334
A single HMD or input device.
Definition: xrt_device.h:203
C interface to math library.