Monado OpenXR Runtime
hdk_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 direct OSVR HDK driver code.
6  * @author Jakob Bornecrantz <jakob@collabora.com>
7  * @author Ryan Pavlik <ryan.pavlik@collabora.com>
8  * @ingroup drv_hdk
9  */
10 
11 #pragma once
12 
13 #include "os/os_threading.h"
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
20 {
25 };
26 
27 struct hdk_device
28 {
29  struct xrt_device base;
30  struct os_hid_device *dev;
32 
34 
35  bool print_spew;
38 
39  struct xrt_quat quat;
41  bool quat_valid;
42 };
43 
44 static inline struct hdk_device *
45 hdk_device(struct xrt_device *xdev)
46 {
47  return (struct hdk_device *)xdev;
48 }
49 
50 struct hdk_device *
52  enum HDK_VARIANT variant,
53  bool print_spew,
54  bool print_debug);
55 
56 #define HDK_SPEW(c, ...) \
57  do { \
58  if (c->print_spew) { \
59  fprintf(stderr, "%s - ", __func__); \
60  fprintf(stderr, __VA_ARGS__); \
61  fprintf(stderr, "\n"); \
62  } \
63  } while (false)
64 #define HDK_DEBUG(c, ...) \
65  do { \
66  if (c->print_debug) { \
67  fprintf(stderr, "%s - ", __func__); \
68  fprintf(stderr, __VA_ARGS__); \
69  fprintf(stderr, "\n"); \
70  } \
71  } while (false)
72 
73 #define HDK_ERROR(c, ...) \
74  do { \
75  fprintf(stderr, "%s - ", __func__); \
76  fprintf(stderr, __VA_ARGS__); \
77  fprintf(stderr, "\n"); \
78  } while (false)
79 
80 
81 #ifdef __cplusplus
82 }
83 #endif
Definition: hdk_device.h:23
bool print_spew
Definition: hdk_device.h:35
bool quat_valid
Definition: hdk_device.h:41
bool print_debug
Definition: hdk_device.h:36
HDK_VARIANT
Definition: hdk_device.h:19
struct os_hid_device * dev
Definition: hdk_device.h:30
Definition: hdk_device.h:21
A quaternion with single floats.
Definition: xrt_defines.h:99
Wrapper around OS threading native functions.
struct xrt_device base
Definition: hdk_device.h:29
struct hdk_device * hdk_device_create(struct os_hid_device *dev, enum HDK_VARIANT variant, bool print_spew, bool print_debug)
Definition: hdk_device.cpp:311
All in one helper that handles locking, waiting for change and starting a thread. ...
Definition: os_threading.h:151
enum HDK_VARIANT variant
Definition: hdk_device.h:31
bool disconnect_notified
Definition: hdk_device.h:37
Representing a single hid interface on a device.
Definition: os_hid.h:26
struct os_thread_helper imu_thread
Definition: hdk_device.h:33
Definition: hdk_device.h:24
Definition: hdk_device.h:22
Definition: hdk_device.h:27
A single HMD or input device.
Definition: xrt_device.h:202
struct xrt_quat quat
Definition: hdk_device.h:39
struct xrt_quat ang_vel_quat
Definition: hdk_device.h:40