monado/src/xrt/drivers/wmr/wmr_protocol.h
nima01 027ce21bd5 d/wmr: Initial 3DoF WinMR driver
Only supports HP Reverb G1 and G2 for now.

Squash of the following commits:

Initial boilerplate code for HP Reverb G1 driver implementation
Detect and open MS HoloLens Sensors interface
Power up HMD display when headset is detected, and som general code cleanup
Add Reverb G2 PID
reverb_g1: Fix defines
reverb_g1: Run clang format
wmr: Rename Reverb G1 driver to WMR driver
d/wmr: Code style
d/wmr: Flesh out driver a bit more
d/wmr: Code style
Add basic 3dof rotational tracking
d/wmr: Code style
d/wmr: More tidy
xrt: Remove XRT_DEVICE_REVERB_G1
d/wmr: Even more tidy
d/wmr: Changes for Reverb G2
d/wmr: Fixes since last commit
wmr: Fix the meson build and auto-enable the driver
d/wmr: Sleep for compositor to get modes
d/wmr: Use os_hid for control device
d/wmr: Remove hidapi as a dependancy
d/wmr: Move sensor reading to own thread and fix locking
d/wmr: Read from control device and handle more unknown messages
d/wmr: Decode IPD value from control device
d/wmr: Remove all left over dummy driver fields

Co-author: nima01 <nima_zero_one@protonmail.com>
Co-author: Jakob Bornecrantz <jakob@collabora.com>
Co-author: Jan Schmidt <jan@centricular.com>
2021-04-19 13:33:01 +00:00

127 lines
2.6 KiB
C

// Copyright 2018, Philipp Zabel.
// Copyright 2020-2021, N Madsen.
// Copyright 2020-2021, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief WMR and MS HoloLens protocol constants, structures and helpers header
* @author Philipp Zabel <philipp.zabel@gmail.com>
* @author nima01 <nima_zero_one@protonmail.com>
* @ingroup drv_wmr
*/
#pragma once
#include "math/m_vec2.h"
#ifdef __cplusplus
extern "C" {
#endif
/*!
* WMR and MS HoloLens Sensors protocol constants and structures
*
* @ingroup drv_wmr
* @{
*/
#define WMR_FEATURE_BUFFER_SIZE 497
#define WMR_MS_HOLOLENS_NS_PER_TICK 100
#define WMR_MS_HOLOLENS_MSG_SENSORS 0x01
#define WMR_MS_HOLOLENS_MSG_CONTROL 0x02
#define WMR_MS_HOLOLENS_MSG_DEBUG 0x03
#define WMR_MS_HOLOLENS_MSG_UNKNOWN_05 0x05
#define WMR_MS_HOLOLENS_MSG_UNKNOWN_06 0x06
#define WMR_MS_HOLOLENS_MSG_UNKNOWN_0E 0x0E
#define WMR_MS_HOLOLENS_MSG_UNKNOWN_17 0x17
#define WMR_CONTROL_MSG_IPD_VALUE 0x01
#define WMR_CONTROL_MSG_UNKNOWN_05 0x05
static const unsigned char hololens_sensors_imu_on[64] = {0x02, 0x07};
struct hololens_sensors_packet
{
uint8_t id;
uint16_t temperature[4];
uint64_t gyro_timestamp[4];
int16_t gyro[3][32];
uint64_t accel_timestamp[4];
int32_t accel[3][4];
uint64_t video_timestamp[4];
};
/*!
* @}
*/
/*!
* WMR and MS HoloLens Sensors protocol helpers
*
* @ingroup drv_wmr
* @{
*/
void
vec3_from_hololens_accel(int32_t sample[3][4], int i, struct xrt_vec3 *out_vec);
void
vec3_from_hololens_gyro(int16_t sample[3][32], int i, struct xrt_vec3 *out_vec);
static inline uint8_t
read8(const unsigned char **buffer)
{
uint8_t ret = **buffer;
*buffer += 1;
return ret;
}
static inline int16_t
read16(const unsigned char **buffer)
{
int16_t ret = (*(*buffer + 0) << 0) | //
(*(*buffer + 1) << 8);
*buffer += 2;
return ret;
}
static inline int32_t
read32(const unsigned char **buffer)
{
int32_t ret = (*(*buffer + 0) << 0) | //
(*(*buffer + 1) << 8) | //
(*(*buffer + 2) << 16) | //
(*(*buffer + 3) << 24);
*buffer += 4;
return ret;
}
static inline uint64_t
read64(const unsigned char **buffer)
{
uint64_t ret = ((uint64_t) * (*buffer + 0) << 0) | //
((uint64_t) * (*buffer + 1) << 8) | //
((uint64_t) * (*buffer + 2) << 16) | //
((uint64_t) * (*buffer + 3) << 24) | //
((uint64_t) * (*buffer + 4) << 32) | //
((uint64_t) * (*buffer + 5) << 40) | //
((uint64_t) * (*buffer + 6) << 48) | //
((uint64_t) * (*buffer + 7) << 56);
*buffer += 8;
return ret;
}
/*!
* @}
*/
#ifdef __cplusplus
}
#endif