Monado OpenXR Runtime
android_sensors.h
Go to the documentation of this file.
1// Copyright 2020, Collabora, Ltd.
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Android sensors driver header.
6 * @author Lubosz Sarnecki <lubosz.sarnecki@collabora.com>
7 * @ingroup drv_android
8 */
9
10#pragma once
11
12#include <android/sensor.h>
13
14#include "math/m_api.h"
15#include "math/m_imu_pre.h"
16#include "math/m_imu_3dof.h"
17
18#include "xrt/xrt_device.h"
19
20#include "os/os_threading.h"
21
22#include "util/u_logging.h"
23#include "util/u_distortion.h"
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29/*!
30 * @implements xrt_device
31 */
33{
34 struct xrt_device base;
35 struct os_thread_helper oth;
36
37 ASensorManager *sensor_manager;
38 const ASensor *accelerometer;
39 const ASensor *gyroscope;
40 ASensorEventQueue *event_queue;
41 struct u_cardboard_distortion cardboard;
42
43
44 struct
45 {
46 //! Lock for last and fusion.
47 struct os_mutex lock;
48 struct m_imu_3dof fusion;
49 };
50
51 enum u_logging_level log_level;
52};
53
54
55struct android_device *
56android_device_create();
57
58
59/*
60 *
61 * Printing functions.
62 *
63 */
64
65#define ANDROID_TRACE(d, ...) U_LOG_XDEV_IFL_T(&d->base, d->log_level, __VA_ARGS__)
66#define ANDROID_DEBUG(d, ...) U_LOG_XDEV_IFL_D(&d->base, d->log_level, __VA_ARGS__)
67#define ANDROID_INFO(d, ...) U_LOG_XDEV_IFL_I(&d->base, d->log_level, __VA_ARGS__)
68#define ANDROID_WARN(d, ...) U_LOG_XDEV_IFL_W(&d->base, d->log_level, __VA_ARGS__)
69#define ANDROID_ERROR(d, ...) U_LOG_XDEV_IFL_E(&d->base, d->log_level, __VA_ARGS__)
70
71#ifdef __cplusplus
72}
73#endif
u_logging_level
Logging level enum.
Definition: u_logging.h:40
C interface to math library.
A IMU fusion specially made for 3dof devices.
IMU pre filter struct.
Wrapper around OS threading native functions.
Definition: android_sensors.h:33
struct os_mutex lock
Lock for last and fusion.
Definition: android_sensors.h:47
Definition: m_imu_3dof.h:35
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
Both given and derived values needed for cardboard distortion.
Definition: u_distortion.h:89
A single HMD or input device.
Definition: xrt_device.h:230
Code to handle distortion parameters and fov.
Basic logging functionality.
Header defining an xrt display or controller device.