Monado OpenXR Runtime
daydream_device.h
Go to the documentation of this file.
1 // Copyright 2019-2020, Collabora, Ltd.
2 // SPDX-License-Identifier: BSL-1.0
3 /*!
4  * @file
5  * @brief Interface to Daydream driver code.
6  * @author Pete Black <pete.black@collabora.com>
7  * @ingroup drv_daydream
8  */
9 
10 #pragma once
11 
12 #include "math/m_api.h"
13 #include "math/m_imu_pre.h"
14 #include "math/m_imu_3dof.h"
15 
16 #include "xrt/xrt_device.h"
17 
18 #include "os/os_threading.h"
19 #include "os/os_ble.h"
20 
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 
27 /*!
28  * A parsed sample of accel and gyro.
29  */
31 {
34  struct xrt_vec3_i32 mag;
35 };
36 
38 {
44 };
45 
47 {
53 };
54 
56 {
57  uint8_t buttons;
58  int timestamp;
59  uint16_t timestamp_last;
60  struct xrt_vec2_i32 touchpad;
62 };
63 
65 {
66  struct xrt_device base;
67  struct os_ble_device *ble;
68  struct os_thread_helper oth;
69  char mac[128];
70  char path[128];
71 
72  struct
73  {
74  //! Lock for last and fusion.
75  struct os_mutex lock;
76 
77  //! Last sensor read.
78  struct daydream_parsed_input last;
79 
80  struct m_imu_pre_filter pre_filter;
81  struct m_imu_3dof fusion;
82  };
83 
84  bool print_spew;
86 
87  struct
88  {
89  bool last;
90  } gui;
91 };
92 
93 
94 struct daydream_device *
96  bool print_spew,
97  bool print_debug);
98 
99 
100 #define DAYDREAM_SPEW(c, ...) \
101  do { \
102  if (c->print_spew) { \
103  fprintf(stderr, "%s - ", __func__); \
104  fprintf(stderr, __VA_ARGS__); \
105  fprintf(stderr, "\n"); \
106  } \
107  } while (false)
108 
109 #define DAYDREAM_DEBUG(c, ...) \
110  do { \
111  if (c->print_debug) { \
112  fprintf(stderr, "%s - ", __func__); \
113  fprintf(stderr, __VA_ARGS__); \
114  fprintf(stderr, "\n"); \
115  } \
116  } while (false)
117 
118 #define DAYDREAM_ERROR(c, ...) \
119  do { \
120  fprintf(stderr, "%s - ", __func__); \
121  fprintf(stderr, __VA_ARGS__); \
122  fprintf(stderr, "\n"); \
123  } while (false)
124 
125 
126 #ifdef __cplusplus
127 }
128 #endif
Definition: daydream_device.h:51
A IMU fusion specially made for 3dof devices.
Definition: daydream_device.h:41
int timestamp
Definition: daydream_device.h:58
struct xrt_vec3_i32 gyro
Definition: daydream_device.h:33
Definition: daydream_device.h:48
This is a common IMU pre-filter which takes raw &#39;ticks&#39; from an IMU measurement and converts it into ...
Definition: m_imu_pre.h:46
A parsed sample of accel and gyro.
Definition: daydream_device.h:30
Wrapper around OS threading native functions.
bool print_debug
Definition: daydream_device.h:85
IMU pre filter struct.
Header defining a xrt HMD device.
struct daydream_device * daydream_device_create(struct os_ble_device *ble, bool print_spew, bool print_debug)
Definition: daydream_device.c:339
Definition: daydream_device.h:52
A 2 element vector with 32 bit integers.
Definition: xrt_defines.h:157
uint8_t buttons
Definition: daydream_device.h:57
All in one helper that handles locking, waiting for change and starting a thread. ...
Definition: os_threading.h:151
A 3 element vector with 32 bit integers.
Definition: xrt_defines.h:145
Definition: daydream_device.h:49
Definition: daydream_device.h:55
Definition: daydream_device.h:40
Definition: daydream_device.h:50
bool print_spew
Definition: daydream_device.h:84
daydream_button_bits
Definition: daydream_device.h:37
Definition: daydream_device.h:42
struct vive_imu_sample sample[3]
Definition: vive_protocol.h:210
Definition: daydream_device.h:64
void lock(struct oxr_instance *inst)
Definition: oxr_event.c:30
A wrapper around a native mutex.
Definition: os_threading.h:41
struct xrt_vec3_i32 accel
Definition: daydream_device.h:32
Representing a single ble notify attribute on a device.
Definition: os_ble.h:27
Definition: daydream_device.h:39
struct os_ble_device * ble
Definition: daydream_device.h:67
A single HMD or input device.
Definition: xrt_device.h:202
C interface to math library.
Definition: m_imu_3dof.h:34
struct xrt_vec3_i32 mag
Definition: daydream_device.h:34
daydream_button_masks
Definition: daydream_device.h:46
bool last
Definition: daydream_device.h:89
uint16_t timestamp_last
Definition: daydream_device.h:59
Wrapper around OS native BLE functions.
Definition: daydream_device.h:43