Monado OpenXR Runtime
Loading...
Searching...
No Matches

Vive json implementation. More...

#include "math/m_api.h"
#include "math/m_mathinclude.h"
#include "util/u_misc.h"
#include "util/u_json.h"
#include "util/u_debug.h"
#include "util/u_distortion_mesh.h"
#include "tracking/t_tracking.h"
#include "vive_config.h"
#include "vive_tweaks.h"
#include <stdio.h>
Include dependency graph for vive_config.c:

Macros

#define VIVE_TRACE(d, ...)   U_LOG_IFL_T(d->log_level, __VA_ARGS__)
 
#define VIVE_DEBUG(d, ...)   U_LOG_IFL_D(d->log_level, __VA_ARGS__)
 
#define VIVE_INFO(d, ...)   U_LOG_IFL_I(d->log_level, __VA_ARGS__)
 
#define VIVE_WARN(d, ...)   U_LOG_IFL_W(d->log_level, __VA_ARGS__)
 
#define VIVE_ERROR(d, ...)   U_LOG_IFL_E(d->log_level, __VA_ARGS__)
 
#define JSON_INT(a, b, c)   u_json_get_int(u_json_get(a, b), c)
 
#define JSON_FLOAT(a, b, c)   u_json_get_float(u_json_get(a, b), c)
 
#define JSON_DOUBLE(a, b, c)   u_json_get_double(u_json_get(a, b), c)
 
#define JSON_VEC3(a, b, c)   u_json_get_vec3_array(u_json_get(a, b), c)
 
#define JSON_MATRIX_3X3(a, b, c)   u_json_get_matrix_3x3(u_json_get(a, b), c)
 
#define JSON_STRING(a, b, c)   u_json_get_string_into_array(u_json_get(a, b), c, sizeof(c))
 

Functions

static void _print_vec3 (const char *title, struct xrt_vec3 *vec)
 
static void _get_color_coeffs (struct u_vive_values *values, const cJSON *coeffs, uint8_t eye, uint8_t channel)
 
static void _get_pose_from_pos_x_z (const cJSON *obj, struct xrt_pose *pose)
 
static void _get_distortion_properties (struct vive_config *d, const cJSON *eye_transform_json, uint8_t eye)
 
static void _get_lighthouse (struct vive_config *d, const cJSON *json)
 
static bool _get_camera (struct index_camera *cam, const cJSON *cam_json)
 
static bool _get_cameras (struct vive_config *d, const cJSON *cameras_json)
 
static void vive_init_defaults (struct vive_config *d)
 
static void _calculate_fov (struct vive_config *d)
 
bool vive_config_parse (struct vive_config *d, char *json_string, enum u_logging_level log_level)
 Parse a headset config.
 
void vive_config_teardown (struct vive_config *config)
 Free any allocated resources on this config.
 
bool vive_config_parse_controller (struct vive_controller_config *d, char *json_string, enum u_logging_level log_level)
 Parse a controller config.
 

Detailed Description

Function Documentation

◆ _calculate_fov()

static void _calculate_fov ( struct vive_config d)
static

This function calculates the angles from the center of the view to the edges of the display to obtain the 4 FOV values. The center and focus values form a right-angled triangle, where the focal distance (distance to display) is the adjacent, and distance between edge and center being the opposite, as shown by the diagram below.

[---— s ---—] [- c -] +--—+------—+ display \ | / | | / \ |f / \ | / | | / | /

  • eye s = screen size (width or height) c = center f = focus

The 4 FOV angles can be calculated by taking the arctan of the opposite (distance between screen edge and center) over the adjacent (focal distance).

References vive_tweak_fov().

Referenced by vive_config_parse().