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 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 enum HDK_VARIANT
18 {
19  HDK_UNKNOWN = 0,
20  HDK_VARIANT_1_2,
21  HDK_VARIANT_1_3_1_4,
22  HDK_VARIANT_2
23 };
24 
25 struct hdk_device
26 {
27  struct xrt_device base;
28  struct os_hid_device *dev;
29  enum HDK_VARIANT variant;
30 
31  bool print_spew;
32  bool print_debug;
33  bool disconnect_notified;
34 };
35 
36 static inline struct hdk_device *
37 hdk_device(struct xrt_device *xdev)
38 {
39  return (struct hdk_device *)xdev;
40 }
41 
42 struct hdk_device *
43 hdk_device_create(struct os_hid_device *dev,
44  enum HDK_VARIANT variant,
45  bool print_spew,
46  bool print_debug);
47 
48 #define HDK_SPEW(c, ...) \
49  do { \
50  if (c->print_spew) { \
51  fprintf(stderr, "%s - ", __func__); \
52  fprintf(stderr, __VA_ARGS__); \
53  fprintf(stderr, "\n"); \
54  } \
55  } while (false)
56 #define HDK_DEBUG(c, ...) \
57  do { \
58  if (c->print_debug) { \
59  fprintf(stderr, "%s - ", __func__); \
60  fprintf(stderr, __VA_ARGS__); \
61  fprintf(stderr, "\n"); \
62  } \
63  } while (false)
64 
65 #define HDK_ERROR(c, ...) \
66  do { \
67  fprintf(stderr, "%s - ", __func__); \
68  fprintf(stderr, __VA_ARGS__); \
69  fprintf(stderr, "\n"); \
70  } while (false)
71 
72 
73 #ifdef __cplusplus
74 }
75 #endif
Representing a single hid interface on a device.
Definition: os_hid.h:26
Definition: hdk_device.h:25
A single HMD or input device.
Definition: xrt_device.h:203