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 Rylie Pavlik <rylie.pavlik@collabora.com>
8 * @ingroup drv_hdk
9 */
10
11#pragma once
12
13#include "os/os_threading.h"
14#include "util/u_logging.h"
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20enum HDK_VARIANT
21{
22 HDK_UNKNOWN = 0,
23 HDK_VARIANT_1_2,
24 HDK_VARIANT_1_3_1_4,
25 HDK_VARIANT_2
26};
27
28/*!
29 * @implements xrt_device
30 */
32{
33 struct xrt_device base;
34 struct os_hid_device *dev;
35 enum HDK_VARIANT variant;
36
37 struct os_thread_helper imu_thread;
38 struct os_mutex lock;
39
40 enum u_logging_level log_level;
41 bool disconnect_notified;
42
43 struct xrt_quat quat;
44 struct xrt_quat ang_vel_quat;
45 bool quat_valid;
46};
47
48static inline struct hdk_device *
49hdk_device(struct xrt_device *xdev)
50{
51 return (struct hdk_device *)xdev;
52}
53
54struct hdk_device *
55hdk_device_create(struct os_hid_device *dev, enum HDK_VARIANT variant);
56
57
58/*
59 *
60 * Printing functions.
61 *
62 */
63
64#define HDK_TRACE(d, ...) U_LOG_XDEV_IFL_T(&d->base, d->log_level, __VA_ARGS__)
65#define HDK_DEBUG(d, ...) U_LOG_XDEV_IFL_D(&d->base, d->log_level, __VA_ARGS__)
66#define HDK_INFO(d, ...) U_LOG_XDEV_IFL_I(&d->base, d->log_level, __VA_ARGS__)
67#define HDK_WARN(d, ...) U_LOG_XDEV_IFL_W(&d->base, d->log_level, __VA_ARGS__)
68#define HDK_ERROR(d, ...) U_LOG_XDEV_IFL_E(&d->base, d->log_level, __VA_ARGS__)
69
70#ifdef __cplusplus
71}
72#endif
u_logging_level
Logging level enum.
Definition: u_logging.h:43
Wrapper around OS threading native functions.
Definition: hdk_device.h:32
Representing a single hid interface on a device.
Definition: os_hid.h:29
A wrapper around a native mutex.
Definition: os_threading.h:55
All in one helper that handles locking, waiting for change and starting a thread.
Definition: os_threading.h:453
A single HMD or input device.
Definition: xrt_device.h:241
A quaternion with single floats.
Definition: xrt_defines.h:216
Basic logging functionality.