Monado OpenXR Runtime
u_config_json.h
Go to the documentation of this file.
1// Copyright 2021, Collabora, Ltd.
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Code to manage the settings file.
6 * @author Christoph Haag <christoph.haag@collabora.com>
7 * @ingroup aux_util
8 */
9
10#pragma once
11
12#include "util/u_json.h"
13#include "xrt/xrt_settings.h"
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19/*!
20 * What config is currently active in the config file.
21 */
23{
24 U_ACTIVE_CONFIG_NONE = 0,
25 U_ACTIVE_CONFIG_TRACKING = 1,
26 U_ACTIVE_CONFIG_REMOTE = 2,
27};
28
30{
31 //! For error reporting, was it loaded but not parsed?
33
34 cJSON *root;
35};
36
37void
38u_config_json_close(struct u_config_json *json);
39
40/*!
41 * Load the JSON config file.
42 *
43 * @ingroup aux_util
44 */
45void
47
48/*!
49 * Writes back calibration settings to the main config file.
50 *
51 * @ingroup aux_util
52 */
53void
55
56/*!
57 * Writes back tracking override settings to the main config file.
58 *
59 * @ingroup aux_util
60 */
61void
63 struct xrt_tracking_override *overrides,
64 size_t override_count);
65
66/*!
67 * Read from the JSON loaded json config file and returns the active config,
68 * can be overridden by `P_OVERRIDE_ACTIVE_CONFIG` envirmental variable.
69 *
70 * @ingroup aux_util
71 */
72void
74
75/*!
76 * Extract tracking settings from the JSON.
77 *
78 * @ingroup aux_util
79 * @relatesalso xrt_settings_tracking
80 */
81bool
83
84/*!
85 * Extract tracking override settings from the JSON.
86 *
87 * Caller allocates an array of XRT_MAX_TRACKING_OVERRIDES tracking_override.
88 *
89 * @ingroup aux_util
90 * @relatesalso xrt_settings_tracking
91 */
92bool
94 struct xrt_tracking_override *out_overrides,
95 size_t *out_override_count);
96
97/*!
98 * Extract remote settings from the JSON.
99 *
100 * @ingroup aux_util
101 */
102bool
103u_config_json_get_remote_settings(struct u_config_json *json, int *out_port, uint32_t *out_view_count);
104
105
106enum u_gui_state_scene
107{
108 GUI_STATE_SCENE_CALIBRATE
109};
110
111void
112u_gui_state_open_file(struct u_config_json *json);
113
114struct cJSON *
115u_gui_state_get_scene(struct u_config_json *json, enum u_gui_state_scene scene);
116
117void
118u_gui_state_save_scene(struct u_config_json *json, enum u_gui_state_scene scene, struct cJSON *new_state);
119
120#ifdef __cplusplus
121}
122#endif
bool u_config_json_get_tracking_settings(struct u_config_json *json, struct xrt_settings_tracking *s)
Extract tracking settings from the JSON.
Definition: u_config_json.c:351
void u_config_json_save_overrides(struct u_config_json *json, struct xrt_tracking_override *overrides, size_t override_count)
Writes back tracking override settings to the main config file.
Definition: u_config_json.c:476
void u_config_json_get_active(struct u_config_json *json, enum u_config_json_active_config *out_active)
Read from the JSON loaded json config file and returns the active config, can be overridden by P_OVER...
Definition: u_config_json.c:224
bool u_config_json_get_tracking_overrides(struct u_config_json *json, struct xrt_tracking_override *out_overrides, size_t *out_override_count)
Extract tracking override settings from the JSON.
Definition: u_config_json.c:291
void u_config_json_open_or_create_main_file(struct u_config_json *json)
Load the JSON config file.
Definition: u_config_json.c:91
void u_config_json_save_calibration(struct u_config_json *json, struct xrt_settings_tracking *settings)
Writes back calibration settings to the main config file.
Definition: u_config_json.c:416
bool u_config_json_get_remote_settings(struct u_config_json *json, int *out_port, uint32_t *out_view_count)
Extract remote settings from the JSON.
Definition: u_config_json.c:241
Definition: u_config_json.h:30
bool file_loaded
For error reporting, was it loaded but not parsed?
Definition: u_config_json.h:32
Holding enough information to recreate a tracking pipeline.
Definition: xrt_settings.h:67
Definition: xrt_settings.h:55
u_config_json_active_config
What config is currently active in the config file.
Definition: u_config_json.h:23
Tiny JSON wrapper around cJSON header.
Common settings structs to be transferred between different parts of Monado, mainly for tracking and ...