Monado OpenXR Runtime
Loading...
Searching...
No Matches
r_interface.h
Go to the documentation of this file.
1// Copyright 2020-2023, Collabora, Ltd.
2// Copyright 2026, NVIDIA CORPORATION.
3// SPDX-License-Identifier: BSL-1.0
4/*!
5 * @file
6 * @brief Interface to remote driver.
7 * @author Jakob Bornecrantz <jakob@collabora.com>
8 * @ingroup drv_remote
9 */
10
11#pragma once
12
13// winsock2.h must be included before windows.h, or the winsock interface will be
14// defined instead of the winsock2 interface.
15// Given that some of the Monado headers could include windows.h, winsock2 is to be
16// included before anything else.
17// As a consequence, this header must also be the first included in the file using
18// it.
19#include "xrt/xrt_config_os.h"
20#ifdef XRT_OS_WINDOWS
21#include <winsock2.h> // For SOCKET
22#endif
23
24#include "xrt/xrt_defines.h"
25#include "util/u_logging.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31
35
36/*!
37 * @defgroup drv_remote Remote debugging driver
38 * @ingroup drv
39 *
40 * @brief Driver for creating remote debugging devices.
41 */
42
43/*!
44 * @dir drivers/remote
45 *
46 * @brief @ref drv_remote files.
47 */
48
49#ifdef XRT_OS_WINDOWS
50/*!
51 * The type for a socket descriptor
52 *
53 * On Windows, this is a SOCKET.
54 */
55typedef SOCKET r_socket_t;
56#else
57/*!
58 * The type for a socket descriptor
59 *
60 * On non-Windows, this is a file descriptor.
61 */
62typedef int r_socket_t;
63#endif
64
65/*!
66 * Header value to be set in the packet.
67 *
68 * @ingroup drv_remote
69 */
70#define R_HEADER_VALUE (*(uint64_t *)"mndrmt3\0")
71
72/*!
73 * Data per controller.
74 */
76{
77 struct xrt_pose pose;
78 struct xrt_vec3 linear_velocity;
79 struct xrt_vec3 angular_velocity;
80
81 float hand_curl[5];
82
83 struct xrt_vec1 trigger_value;
84 struct xrt_vec1 squeeze_value;
85 struct xrt_vec1 squeeze_force;
86 struct xrt_vec2 thumbstick;
87 struct xrt_vec1 trackpad_force;
88 struct xrt_vec2 trackpad;
89
90 bool hand_tracking_active;
91 bool active;
92
93 bool system_click;
94 bool system_touch;
95 bool a_click;
96 bool a_touch;
97 bool b_click;
98 bool b_touch;
99 bool trigger_click;
100 bool trigger_touch;
101 bool thumbstick_click;
102 bool thumbstick_touch;
103 bool trackpad_touch;
104 bool _pad0;
105 bool _pad1;
106 bool _pad2;
107 // active(2) + bools(11) + pad(3) = 16
108};
109
111{
112 struct
113 {
114 //! The field of view values of this view.
115 struct xrt_fov fov;
116
117 //! The pose of this view relative to @ref r_head_data::center.
119
120 //! Padded to fov(16) + pose(16 + 12) + 4 = 48
121 uint32_t _pad;
122 } views[2];
123
124 //! The center of the head, in OpenXR terms the view space.
126
127 //! Is the per view data valid and should be used?
129
130 //! pose(16 + 12) bool(1) + pad(3) = 32.
131 bool _pad0, _pad1, _pad2;
132};
133
134/*!
135 * Remote data sent from the debugger to the hub.
136 *
137 * @ingroup drv_remote
138 */
140{
141 uint64_t header;
142
143 struct r_head_data head;
144
145 struct r_remote_controller_data left, right;
146};
147
148/*!
149 * Shared connection.
150 *
151 * @ingroup drv_remote
152 */
154{
155 //! Logging level to be used.
157
158 //! Socket.
160};
161
162/*!
163 * Creates the remote system devices.
164 *
165 * @ingroup drv_remote
166 */
168r_create_devices(uint16_t port, uint32_t view_count, struct xrt_system_devices **out_xsysd);
169
170/*!
171 * Initializes and connects the connection.
172 *
173 * @ingroup drv_remote
174 */
176r_remote_connection_init(struct r_remote_connection *rc, const char *addr, uint16_t port);
177
178int
179r_remote_connection_read_one(struct r_remote_connection *rc, struct r_remote_data *data);
180
181int
182r_remote_connection_write_one(struct r_remote_connection *rc, const struct r_remote_data *data);
183
184
185#ifdef __cplusplus
186}
187#endif
u_logging_level
Logging level enum.
Definition u_logging.h:45
xrt_result_t r_create_devices(uint16_t port, uint32_t view_count, struct xrt_system_devices **out_xsysd)
Creates the remote system devices.
Definition r_hub.c:409
r_socket_t r_remote_connection_init(struct r_remote_connection *rc, const char *addr, uint16_t port)
Initializes and connects the connection.
Definition r_hub.c:511
enum xrt_result xrt_result_t
Result type used across Monado.
int r_socket_t
The type for a socket descriptor.
Definition r_interface.h:62
Definition r_interface.h:111
bool _pad0
pose(16 + 12) bool(1) + pad(3) = 32.
Definition r_interface.h:131
bool per_view_data_valid
Is the per view data valid and should be used?
Definition r_interface.h:128
struct xrt_pose center
The center of the head, in OpenXR terms the view space.
Definition r_interface.h:125
struct xrt_pose pose
The pose of this view relative to r_head_data::center.
Definition r_interface.h:118
uint32_t _pad
Padded to fov(16) + pose(16 + 12) + 4 = 48.
Definition r_interface.h:121
struct xrt_fov fov
The field of view values of this view.
Definition r_interface.h:115
Shared connection.
Definition r_interface.h:154
enum u_logging_level log_level
Logging level to be used.
Definition r_interface.h:156
r_socket_t fd
Socket.
Definition r_interface.h:159
Data per controller.
Definition r_interface.h:76
Remote data sent from the debugger to the hub.
Definition r_interface.h:140
Describes a projection matrix fov.
Definition xrt_defines.h:499
A pose composed of a position and orientation.
Definition xrt_defines.h:479
Used internally from producers of events to push events into session, some sinks might multiplex even...
Definition xrt_session.h:237
Object that oversees and manages spaces, one created for each XR system.
Definition xrt_space.h:97
A collection of xrt_device, and an interface for identifying the roles they have been assigned.
Definition xrt_system.h:214
A 1 element vector with single floats.
Definition xrt_defines.h:258
A 2 element vector with single floats.
Definition xrt_defines.h:268
A 3 element vector with single floats.
Definition xrt_defines.h:289
Basic logging functionality.
Auto detect OS and certain features.
Common defines and enums for XRT.