The open source OpenXR runtime
1// Copyright 2023 Jan Schmidt
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Implementation of tunnelled controller connection,
6 * that translates messages passing via an HP G2 or Sasmung Odyssey+ HMD
7 * @author Jan Schmidt <jan@centricular.com>
8 * @ingroup drv_wmr
9 */
10#include <stdint.h>
11
12#include "os/os_threading.h"
13#include "xrt/xrt_device.h"
14
15#include "wmr_controller_base.h"
16
17#pragma once
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23struct wmr_hmd_controller_connection
24{
25 struct wmr_controller_connection base;
26
27 /* Controller and HMD each hold a reference. It's
28 * only cleaned up once both release it. */
29 struct xrt_reference ref;
30 enum u_logging_level log_level;
31
32 uint8_t hmd_cmd_base;
33
34 /* Protect access when sending / receiving data */
35 struct os_mutex lock;
36 bool disconnected; /* Set to true once disconnect() is called */
37
38 struct wmr_hmd *hmd;
39};
40
41struct wmr_hmd_controller_connection *
42wmr_hmd_controller_create(struct wmr_hmd *hmd,
43 uint8_t hmd_cmd_base,
44 enum xrt_device_type controller_type,
45 uint16_t vid,
46 uint16_t pid,
47 enum u_logging_level log_level);
48
49struct xrt_device *
50wmr_hmd_controller_connection_get_controller(struct wmr_hmd_controller_connection *wcc);
51
52#ifdef __cplusplus
53}
54#endif