From c248670f2f137d1186f312bbffe57dcff7b23a1b Mon Sep 17 00:00:00 2001 From: Christoph Haag Date: Tue, 11 Apr 2023 01:36:06 +0200 Subject: [PATCH] d/survive: Add vive ipd range --- src/xrt/auxiliary/vive/vive_config.h | 8 ++++++++ src/xrt/drivers/survive/survive_driver.c | 22 ++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/xrt/auxiliary/vive/vive_config.h b/src/xrt/auxiliary/vive/vive_config.h index 460450c76..9738d7b5b 100644 --- a/src/xrt/auxiliary/vive/vive_config.h +++ b/src/xrt/auxiliary/vive/vive_config.h @@ -21,6 +21,14 @@ #define INDEX_MIN_IPD 0.058 #define INDEX_MAX_IPD 0.07 +// https://vr-compare.com/headset/htcvive +// #define VIVE_MIN_IPD 0.061 +// #define VIVE_MAX_IPD 0.072 + +// steamvr goes from ~60 to 75 +#define VIVE_MIN_IPD 0.060 +#define VIVE_MAX_IPD 0.075 + // arbitrary default values #define DEFAULT_HAPTIC_FREQ 150.0f #define MIN_HAPTIC_DURATION 0.05f diff --git a/src/xrt/drivers/survive/survive_driver.c b/src/xrt/drivers/survive/survive_driver.c index 800a4f9fa..c7caeef3c 100644 --- a/src/xrt/drivers/survive/survive_driver.c +++ b/src/xrt/drivers/survive/survive_driver.c @@ -712,9 +712,27 @@ _process_hmd_button_event(struct survive_device *survive, const struct SurviveSi if (e->axis_ids[i] == SURVIVE_AXIS_IPD) { float ipd = val; - float range = INDEX_MAX_IPD - INDEX_MIN_IPD; + + // arbitrary default values + float max = 70; + float min = 60; + if (survive->hmd.config.variant == VIVE_VARIANT_INDEX) { + max = INDEX_MAX_IPD; + min = INDEX_MIN_IPD; + } else if (survive->hmd.config.variant == VIVE_VARIANT_VIVE) { + max = VIVE_MAX_IPD; + min = VIVE_MIN_IPD; + } else { + if (!survive->hmd.use_default_ipd) { + SURVIVE_WARN(survive, + "No IPD range for this HMD, falling back to default"); + survive->hmd.use_default_ipd = true; + } + } + + float range = max - min; ipd *= range; - ipd += INDEX_MIN_IPD; + ipd += min; survive->hmd.ipd = ipd; // SURVIVE_DEBUG(survive, "ipd: %f meter", ipd);