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