From 54083a99de670791ca5602371b8c3ae1eef4eecf Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sat, 22 Apr 2023 21:54:24 +0100 Subject: [PATCH] a/vive: Tidy vive_config.c [NFC] --- src/xrt/auxiliary/vive/vive_config.c | 74 +++++++++++++++++++++------- 1 file changed, 55 insertions(+), 19 deletions(-) diff --git a/src/xrt/auxiliary/vive/vive_config.c b/src/xrt/auxiliary/vive/vive_config.c index 884f0b4f1..8611832ca 100644 --- a/src/xrt/auxiliary/vive/vive_config.c +++ b/src/xrt/auxiliary/vive/vive_config.c @@ -8,21 +8,26 @@ * @ingroup drv_vive */ -#include +#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 "util/u_debug.h" -#include "util/u_misc.h" -#include "util/u_json.h" -#include "util/u_distortion_mesh.h" +#include -#include "math/m_api.h" - -#include "tracking/t_tracking.h" -#include "math/m_vec3.h" -#include "math/m_space.h" +/* + * + * Defines. + * + */ #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__) @@ -37,9 +42,25 @@ #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)) -#define printf_pose(pose) \ - printf("%f %f %f %f %f %f %f\n", pose.position.x, pose.position.y, pose.position.z, pose.orientation.x, \ - pose.orientation.y, pose.orientation.z, pose.orientation.w); + +/* + * + * Printing helpers. + * + */ + +static void +_print_vec3(const char *title, struct xrt_vec3 *vec) +{ + U_LOG_D("%s = %f %f %f", title, (double)vec->x, (double)vec->y, (double)vec->z); +} + + +/* + * + * Loading helpers. + * + */ static void _get_color_coeffs(struct u_vive_values *values, const cJSON *coeffs, uint8_t eye, uint8_t channel) @@ -185,12 +206,6 @@ _get_lighthouse(struct vive_config *d, const cJSON *json) } } -static void -_print_vec3(const char *title, struct xrt_vec3 *vec) -{ - U_LOG_D("%s = %f %f %f", title, (double)vec->x, (double)vec->y, (double)vec->z); -} - static bool _get_camera(struct index_camera *cam, const cJSON *cam_json) { @@ -285,6 +300,13 @@ _get_cameras(struct vive_config *d, const cJSON *cameras_json) return true; } + +/* + * + * General helpers. + * + */ + static void vive_init_defaults(struct vive_config *d) { @@ -314,6 +336,13 @@ vive_init_defaults(struct vive_config *d) } } + +/* + * + * 'Exported' hmd functions. + * + */ + bool vive_config_parse(struct vive_config *d, char *json_string, enum u_logging_level log_level) { @@ -469,6 +498,13 @@ vive_config_teardown(struct vive_config *config) } } + +/* + * + * 'Exported' controller functions. + * + */ + bool vive_config_parse_controller(struct vive_controller_config *d, char *json_string, enum u_logging_level log_level) {