tangled
alpha
login
or
join now
matrixfurry.com
/
monado
0
fork
atom
The open source OpenXR runtime
0
fork
atom
overview
issues
pulls
pipelines
d/remote: Get view count from json config
Meng Jiao
2 years ago
368a3842
8a74798c
+42
-9
9 changed files
expand all
collapse all
unified
split
doc
example_configs
config_v0.mono_remote.json
config_v0.mono_remote.json.license
src
xrt
auxiliary
util
u_config_json.c
u_config_json.h
drivers
remote
r_hmd.c
r_hub.c
r_interface.h
r_internal.h
targets
common
target_builder_remote.c
+9
doc/example_configs/config_v0.mono_remote.json
···
1
1
+
{
2
2
+
"$schema": "https://monado.pages.freedesktop.org/monado/config_v0.schema.json",
3
3
+
"active": "remote",
4
4
+
"remote": {
5
5
+
"version": 0,
6
6
+
"port": 4242,
7
7
+
"view_count": 1
8
8
+
}
9
9
+
}
+2
doc/example_configs/config_v0.mono_remote.json.license
···
1
1
+
Copyright 2024, Collabora, Ltd.
2
2
+
SPDX-License-Identifier: CC0-1.0
+6
-1
src/xrt/auxiliary/util/u_config_json.c
···
238
238
}
239
239
240
240
bool
241
241
-
u_config_json_get_remote_port(struct u_config_json *json, int *out_port)
241
241
+
u_config_json_get_remote_settings(struct u_config_json *json, int *out_port, uint32_t *out_view_count)
242
242
{
243
243
cJSON *t = cJSON_GetObjectItemCaseSensitive(json->root, "remote");
244
244
if (t == NULL) {
···
260
260
if (!get_obj_int(t, "port", &port)) {
261
261
return false;
262
262
}
263
263
+
int view_count = 0;
264
264
+
if (!get_obj_int(t, "view_count", &view_count)) {
265
265
+
return false;
266
266
+
}
263
267
264
268
*out_port = port;
269
269
+
*out_view_count = view_count;
265
270
266
271
return true;
267
272
}
+1
-1
src/xrt/auxiliary/util/u_config_json.h
···
100
100
* @ingroup aux_util
101
101
*/
102
102
bool
103
103
-
u_config_json_get_remote_port(struct u_config_json *json, int *out_port);
103
103
+
u_config_json_get_remote_settings(struct u_config_json *json, int *out_port, uint32_t *out_view_count);
104
104
105
105
106
106
enum u_gui_state_scene
+14
-3
src/xrt/drivers/remote/r_hmd.c
···
159
159
rh->base.device_type = XRT_DEVICE_TYPE_HMD;
160
160
rh->base.inputs[0].name = XRT_INPUT_GENERIC_HEAD_POSE;
161
161
rh->base.inputs[0].active = true;
162
162
+
rh->base.hmd->view_count = r->view_count;
162
163
rh->r = r;
163
164
164
165
// Print name.
···
166
167
snprintf(rh->base.serial, sizeof(rh->base.serial), "Remote HMD");
167
168
168
169
// Setup info.
170
170
+
bool ret = true;
169
171
struct u_device_simple_info info;
170
172
info.display.w_pixels = 1920;
171
173
info.display.h_pixels = 1080;
···
173
175
info.display.h_meters = 0.07f;
174
176
info.lens_horizontal_separation_meters = 0.13f / 2.0f;
175
177
info.lens_vertical_position_meters = 0.07f / 2.0f;
176
176
-
info.fov[0] = 85.0f * (M_PI / 180.0f);
177
177
-
info.fov[1] = 85.0f * (M_PI / 180.0f);
178
178
179
179
-
if (!u_device_setup_split_side_by_side(&rh->base, &info)) {
179
179
+
if (rh->r->view_count == 1) {
180
180
+
info.fov[0] = 120.0f * (M_PI / 180.0f);
181
181
+
ret = u_device_setup_one_eye(&rh->base, &info);
182
182
+
} else if (rh->r->view_count == 2) {
183
183
+
info.fov[0] = 85.0f * (M_PI / 180.0f);
184
184
+
info.fov[1] = 85.0f * (M_PI / 180.0f);
185
185
+
ret = u_device_setup_split_side_by_side(&rh->base, &info);
186
186
+
} else {
187
187
+
U_LOG_E("Invalid view count");
188
188
+
ret = false;
189
189
+
}
190
190
+
if (!ret) {
180
191
U_LOG_E("Failed to setup basic device info");
181
192
r_hmd_destroy(&rh->base);
182
193
return NULL;
+2
src/xrt/drivers/remote/r_hub.c
···
404
404
405
405
xrt_result_t
406
406
r_create_devices(uint16_t port,
407
407
+
uint32_t view_count,
407
408
struct xrt_session_event_sink *broadcast,
408
409
struct xrt_system_devices **out_xsysd,
409
410
struct xrt_space_overseer **out_xso)
···
436
437
r->gui.left = true;
437
438
r->gui.right = true;
438
439
r->port = port;
440
440
+
r->view_count = view_count;
439
441
r->accept_fd = -1;
440
442
r->rc.fd = -1;
441
443
+1
src/xrt/drivers/remote/r_interface.h
···
165
165
*/
166
166
xrt_result_t
167
167
r_create_devices(uint16_t port,
168
168
+
uint32_t view_count,
168
169
struct xrt_session_event_sink *broadcast,
169
170
struct xrt_system_devices **out_xsysd,
170
171
struct xrt_space_overseer **out_xso);
+1
src/xrt/drivers/remote/r_internal.h
···
50
50
r_socket_t accept_fd;
51
51
52
52
uint16_t port;
53
53
+
uint32_t view_count;
53
54
54
55
struct os_thread_helper oth;
55
56
+6
-4
src/xrt/targets/common/target_builder_remote.c
···
34
34
*/
35
35
36
36
static bool
37
37
-
get_settings(cJSON *json, int *port)
37
37
+
get_settings(cJSON *json, int *port, uint32_t *view_count)
38
38
{
39
39
struct u_config_json config_json = {0};
40
40
u_config_json_open_or_create_main_file(&config_json);
41
41
42
42
-
bool bret = u_config_json_get_remote_port(&config_json, port);
42
42
+
bool bret = u_config_json_get_remote_settings(&config_json, port, view_count);
43
43
44
44
u_config_json_close(&config_json);
45
45
···
84
84
85
85
86
86
int port = 4242;
87
87
-
if (!get_settings(config, &port)) {
87
87
+
uint32_t view_count = 1;
88
88
+
if (!get_settings(config, &port, &view_count)) {
88
89
port = 4242;
90
90
+
view_count = 1;
89
91
}
90
92
91
91
-
return r_create_devices(port, broadcast, out_xsysd, out_xso);
93
93
+
return r_create_devices(port, view_count, broadcast, out_xsysd, out_xso);
92
94
}
93
95
94
96
static void