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;
27 
29 
30  int64_t last_update;
32 
33  bool print_spew;
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 *
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
struct ohmd_device ohmd_device
Definition: oh_device.h:20
struct xrt_device base
Definition: oh_device.h:24
Definition: oh_device.h:22
ohmd_context * ctx
Definition: oh_device.h:25
Header defining a xrt HMD device.
A relation with two spaces, includes velocity and acceleration.
Definition: xrt_defines.h:336
bool enable_finite_difference
Definition: oh_device.h:35
bool print_debug
Definition: oh_device.h:34
struct oh_device * oh_device_create(ohmd_context *ctx, ohmd_device *dev, const char *prod, bool print_spew, bool print_debug)
Definition: oh_device.c:376
struct ohmd_context ohmd_context
Definition: oh_device.h:19
bool skip_ang_vel
Definition: oh_device.h:28
int64_t last_update
Definition: oh_device.h:30
ohmd_device * dev
Definition: oh_device.h:26
bool print_spew
Definition: oh_device.h:33
A single HMD or input device.
Definition: xrt_device.h:202
C interface to math library.
struct xrt_space_relation last_relation
Definition: oh_device.h:31