From 9f5e8963a9fcea5801956db9576c57ad044b48a8 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Wed, 19 Apr 2023 15:43:50 +0100 Subject: [PATCH] a/vive: Add tweaks for FoV values --- src/xrt/auxiliary/vive/CMakeLists.txt | 2 + src/xrt/auxiliary/vive/vive_config.c | 4 ++ src/xrt/auxiliary/vive/vive_tweaks.c | 77 +++++++++++++++++++++++++++ src/xrt/auxiliary/vive/vive_tweaks.h | 33 ++++++++++++ 4 files changed, 116 insertions(+) create mode 100644 src/xrt/auxiliary/vive/vive_tweaks.c create mode 100644 src/xrt/auxiliary/vive/vive_tweaks.h diff --git a/src/xrt/auxiliary/vive/CMakeLists.txt b/src/xrt/auxiliary/vive/CMakeLists.txt index c13b23a7c..e2fa48101 100644 --- a/src/xrt/auxiliary/vive/CMakeLists.txt +++ b/src/xrt/auxiliary/vive/CMakeLists.txt @@ -11,6 +11,8 @@ add_library( vive_config.c vive_poses.h vive_poses.c + vive_tweaks.c + vive_tweaks.h ) target_link_libraries( aux_vive diff --git a/src/xrt/auxiliary/vive/vive_config.c b/src/xrt/auxiliary/vive/vive_config.c index b9e50c95a..7ce614107 100644 --- a/src/xrt/auxiliary/vive/vive_config.c +++ b/src/xrt/auxiliary/vive/vive_config.c @@ -19,6 +19,7 @@ #include "tracking/t_tracking.h" #include "vive_config.h" +#include "vive_tweaks.h" #include @@ -381,6 +382,9 @@ _calculate_fov(struct vive_config *d) } } + // Apply any tweaks to the FoV. + vive_tweak_fov(d); + return true; } diff --git a/src/xrt/auxiliary/vive/vive_tweaks.c b/src/xrt/auxiliary/vive/vive_tweaks.c new file mode 100644 index 000000000..a8f89234d --- /dev/null +++ b/src/xrt/auxiliary/vive/vive_tweaks.c @@ -0,0 +1,77 @@ +// Copyright 2023, Collabora, Ltd. +// SPDX-License-Identifier: BSL-1.0 +/*! + * @file + * @brief Tweaks for various bits on Vive and Index headsets. + * @author Jakob Bornecrantz + * @ingroup drv_vive + */ + +#include "xrt/xrt_defines.h" + +#include "vive_config.h" +#include "vive_tweaks.h" + +#include +#include + + +/* + * + * Tweaks for FOV. + * + */ + +struct fov_entry +{ + const char *device_serial_number; + const struct xrt_fov fovs[2]; +}; + +static const struct fov_entry fovs[1] = { + { + .device_serial_number = "LHR-4DC3ADD6", + .fovs = + { + { + .angle_left = -0.907983, + .angle_right = 0.897738, + .angle_up = 0.954823, + .angle_down = -0.953044, + }, + { + + .angle_left = -0.897050, + .angle_right = 0.908661, + .angle_up = 0.954474, + .angle_down = -0.953057, + }, + }, + }, +}; + + +/* + * + * 'Exported' functions. + * + */ + +void +vive_tweak_fov(struct vive_config *config) +{ + const char *device_serial_number = config->firmware.device_serial_number; + + for (size_t i = 0; i < ARRAY_SIZE(fovs); i++) { + const struct fov_entry *e = &fovs[i]; + + if (strcmp(device_serial_number, e->device_serial_number) != 0) { + continue; + } + + U_LOG_I("Applying FoV tweaks to device serial '%s'", device_serial_number); + + config->distortion.fov[0] = e->fovs[0]; + config->distortion.fov[1] = e->fovs[1]; + } +} diff --git a/src/xrt/auxiliary/vive/vive_tweaks.h b/src/xrt/auxiliary/vive/vive_tweaks.h new file mode 100644 index 000000000..d91524c23 --- /dev/null +++ b/src/xrt/auxiliary/vive/vive_tweaks.h @@ -0,0 +1,33 @@ +// Copyright 2023, Collabora, Ltd. +// SPDX-License-Identifier: BSL-1.0 +/*! + * @file + * @brief Tweaks for various bits on Vive and Index headsets. + * @author Jakob Bornecrantz + * @ingroup drv_vive + */ + +#pragma once + +#include "xrt/xrt_compiler.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +struct vive_config; + + +/*! + * Tweak the fov for the views on the given config, to make it better. + * + * @ingroup drv_vive + */ +void +vive_tweak_fov(struct vive_config *config); + + +#ifdef __cplusplus +} // extern "C" +#endif