mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-26 17:37:34 +00:00
d/remote: Get view count from json config
This commit is contained in:
parent
8a74798c0b
commit
368a3842fb
9
doc/example_configs/config_v0.mono_remote.json
Normal file
9
doc/example_configs/config_v0.mono_remote.json
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"$schema": "https://monado.pages.freedesktop.org/monado/config_v0.schema.json",
|
||||
"active": "remote",
|
||||
"remote": {
|
||||
"version": 0,
|
||||
"port": 4242,
|
||||
"view_count": 1
|
||||
}
|
||||
}
|
2
doc/example_configs/config_v0.mono_remote.json.license
Normal file
2
doc/example_configs/config_v0.mono_remote.json.license
Normal file
|
@ -0,0 +1,2 @@
|
|||
Copyright 2024, Collabora, Ltd.
|
||||
SPDX-License-Identifier: CC0-1.0
|
|
@ -238,7 +238,7 @@ u_config_json_get_active(struct u_config_json *json, enum u_config_json_active_c
|
|||
}
|
||||
|
||||
bool
|
||||
u_config_json_get_remote_port(struct u_config_json *json, int *out_port)
|
||||
u_config_json_get_remote_settings(struct u_config_json *json, int *out_port, uint32_t *out_view_count)
|
||||
{
|
||||
cJSON *t = cJSON_GetObjectItemCaseSensitive(json->root, "remote");
|
||||
if (t == NULL) {
|
||||
|
@ -260,8 +260,13 @@ u_config_json_get_remote_port(struct u_config_json *json, int *out_port)
|
|||
if (!get_obj_int(t, "port", &port)) {
|
||||
return false;
|
||||
}
|
||||
int view_count = 0;
|
||||
if (!get_obj_int(t, "view_count", &view_count)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*out_port = port;
|
||||
*out_view_count = view_count;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ u_config_json_get_tracking_overrides(struct u_config_json *json,
|
|||
* @ingroup aux_util
|
||||
*/
|
||||
bool
|
||||
u_config_json_get_remote_port(struct u_config_json *json, int *out_port);
|
||||
u_config_json_get_remote_settings(struct u_config_json *json, int *out_port, uint32_t *out_view_count);
|
||||
|
||||
|
||||
enum u_gui_state_scene
|
||||
|
|
|
@ -159,6 +159,7 @@ r_hmd_create(struct r_hub *r)
|
|||
rh->base.device_type = XRT_DEVICE_TYPE_HMD;
|
||||
rh->base.inputs[0].name = XRT_INPUT_GENERIC_HEAD_POSE;
|
||||
rh->base.inputs[0].active = true;
|
||||
rh->base.hmd->view_count = r->view_count;
|
||||
rh->r = r;
|
||||
|
||||
// Print name.
|
||||
|
@ -166,6 +167,7 @@ r_hmd_create(struct r_hub *r)
|
|||
snprintf(rh->base.serial, sizeof(rh->base.serial), "Remote HMD");
|
||||
|
||||
// Setup info.
|
||||
bool ret = true;
|
||||
struct u_device_simple_info info;
|
||||
info.display.w_pixels = 1920;
|
||||
info.display.h_pixels = 1080;
|
||||
|
@ -173,10 +175,19 @@ r_hmd_create(struct r_hub *r)
|
|||
info.display.h_meters = 0.07f;
|
||||
info.lens_horizontal_separation_meters = 0.13f / 2.0f;
|
||||
info.lens_vertical_position_meters = 0.07f / 2.0f;
|
||||
info.fov[0] = 85.0f * (M_PI / 180.0f);
|
||||
info.fov[1] = 85.0f * (M_PI / 180.0f);
|
||||
|
||||
if (!u_device_setup_split_side_by_side(&rh->base, &info)) {
|
||||
if (rh->r->view_count == 1) {
|
||||
info.fov[0] = 120.0f * (M_PI / 180.0f);
|
||||
ret = u_device_setup_one_eye(&rh->base, &info);
|
||||
} else if (rh->r->view_count == 2) {
|
||||
info.fov[0] = 85.0f * (M_PI / 180.0f);
|
||||
info.fov[1] = 85.0f * (M_PI / 180.0f);
|
||||
ret = u_device_setup_split_side_by_side(&rh->base, &info);
|
||||
} else {
|
||||
U_LOG_E("Invalid view count");
|
||||
ret = false;
|
||||
}
|
||||
if (!ret) {
|
||||
U_LOG_E("Failed to setup basic device info");
|
||||
r_hmd_destroy(&rh->base);
|
||||
return NULL;
|
||||
|
|
|
@ -404,6 +404,7 @@ r_hub_system_devices_destroy(struct xrt_system_devices *xsysd)
|
|||
|
||||
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)
|
||||
|
@ -436,6 +437,7 @@ r_create_devices(uint16_t port,
|
|||
r->gui.left = true;
|
||||
r->gui.right = true;
|
||||
r->port = port;
|
||||
r->view_count = view_count;
|
||||
r->accept_fd = -1;
|
||||
r->rc.fd = -1;
|
||||
|
||||
|
|
|
@ -165,6 +165,7 @@ struct r_remote_connection
|
|||
*/
|
||||
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);
|
||||
|
|
|
@ -50,6 +50,7 @@ struct r_hub
|
|||
r_socket_t accept_fd;
|
||||
|
||||
uint16_t port;
|
||||
uint32_t view_count;
|
||||
|
||||
struct os_thread_helper oth;
|
||||
|
||||
|
|
|
@ -34,12 +34,12 @@
|
|||
*/
|
||||
|
||||
static bool
|
||||
get_settings(cJSON *json, int *port)
|
||||
get_settings(cJSON *json, int *port, uint32_t *view_count)
|
||||
{
|
||||
struct u_config_json config_json = {0};
|
||||
u_config_json_open_or_create_main_file(&config_json);
|
||||
|
||||
bool bret = u_config_json_get_remote_port(&config_json, port);
|
||||
bool bret = u_config_json_get_remote_settings(&config_json, port, view_count);
|
||||
|
||||
u_config_json_close(&config_json);
|
||||
|
||||
|
@ -84,11 +84,13 @@ remote_open_system(struct xrt_builder *xb,
|
|||
|
||||
|
||||
int port = 4242;
|
||||
if (!get_settings(config, &port)) {
|
||||
uint32_t view_count = 1;
|
||||
if (!get_settings(config, &port, &view_count)) {
|
||||
port = 4242;
|
||||
view_count = 1;
|
||||
}
|
||||
|
||||
return r_create_devices(port, broadcast, out_xsysd, out_xso);
|
||||
return r_create_devices(port, view_count, broadcast, out_xsysd, out_xso);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in a new issue