From 38eac9dddc2d24abbaba21fa6173843d8e42657c Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sun, 22 May 2022 13:19:20 +0100 Subject: [PATCH] xrt: Do not depend on util --- src/xrt/drivers/qwerty/qwerty_device.c | 2 +- src/xrt/drivers/survive/survive_driver.c | 6 +++--- src/xrt/drivers/vive/vive_controller.c | 4 ++-- src/xrt/include/xrt/xrt_defines.h | 3 +-- src/xrt/state_trackers/oxr/oxr_input.c | 2 +- src/xrt/state_trackers/steamvr_drv/ovrd_driver.cpp | 4 ++-- 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/xrt/drivers/qwerty/qwerty_device.c b/src/xrt/drivers/qwerty/qwerty_device.c index 64258e728..77e066c6f 100644 --- a/src/xrt/drivers/qwerty/qwerty_device.c +++ b/src/xrt/drivers/qwerty/qwerty_device.c @@ -130,7 +130,7 @@ qwerty_set_output(struct xrt_device *xd, enum xrt_output_name name, union xrt_ou struct qwerty_device *qd = qwerty_device(xd); float frequency = value->vibration.frequency; float amplitude = value->vibration.amplitude; - time_duration_ns duration = value->vibration.duration; + time_duration_ns duration = value->vibration.duration_ns; if (amplitude || duration || frequency) { QWERTY_INFO(qd, "[%s] Haptic output: \n" diff --git a/src/xrt/drivers/survive/survive_driver.c b/src/xrt/drivers/survive/survive_driver.c index b7f2341be..b660944d4 100644 --- a/src/xrt/drivers/survive/survive_driver.c +++ b/src/xrt/drivers/survive/survive_driver.c @@ -349,11 +349,11 @@ static int survive_controller_haptic_pulse(struct survive_device *survive, union xrt_output_value *value) { float duration_seconds; - if (value->vibration.duration == XRT_MIN_HAPTIC_DURATION) { + if (value->vibration.duration_ns == XRT_MIN_HAPTIC_DURATION) { SURVIVE_TRACE(survive, "Haptic pulse duration: using %f minimum", MIN_HAPTIC_DURATION); duration_seconds = MIN_HAPTIC_DURATION; } else { - duration_seconds = time_ns_to_s(value->vibration.duration); + duration_seconds = time_ns_to_s(value->vibration.duration_ns); } float frequency = value->vibration.frequency; @@ -366,7 +366,7 @@ survive_controller_haptic_pulse(struct survive_device *survive, union xrt_output float amplitude = value->vibration.amplitude; SURVIVE_TRACE(survive, "Got Haptic pulse amp %f, %fHz, %" PRId64 "ns", value->vibration.amplitude, - value->vibration.frequency, value->vibration.duration); + value->vibration.frequency, value->vibration.duration_ns); SURVIVE_TRACE(survive, "Doing Haptic pulse amp %f, %fHz, %fs", amplitude, frequency, duration_seconds); return survive_simple_object_haptic((struct SurviveSimpleObject *)survive->survive_obj, frequency, amplitude, diff --git a/src/xrt/drivers/vive/vive_controller.c b/src/xrt/drivers/vive/vive_controller.c index c31488fb8..c289f33a8 100644 --- a/src/xrt/drivers/vive/vive_controller.c +++ b/src/xrt/drivers/vive/vive_controller.c @@ -421,11 +421,11 @@ static int vive_controller_haptic_pulse(struct vive_controller_device *d, union xrt_output_value *value) { float duration_seconds; - if (value->vibration.duration == XRT_MIN_HAPTIC_DURATION) { + if (value->vibration.duration_ns == XRT_MIN_HAPTIC_DURATION) { VIVE_TRACE(d, "Haptic pulse duration: using %f minimum", MIN_HAPTIC_DURATION); duration_seconds = MIN_HAPTIC_DURATION; } else { - duration_seconds = time_ns_to_s(value->vibration.duration); + duration_seconds = time_ns_to_s(value->vibration.duration_ns); } VIVE_TRACE(d, "Haptic pulse amp %f, %fHz, %fs", value->vibration.amplitude, value->vibration.frequency, diff --git a/src/xrt/include/xrt/xrt_defines.h b/src/xrt/include/xrt/xrt_defines.h index 8f23afaae..357f71f61 100644 --- a/src/xrt/include/xrt/xrt_defines.h +++ b/src/xrt/include/xrt/xrt_defines.h @@ -12,7 +12,6 @@ #pragma once #include "xrt/xrt_compiler.h" -#include "util/u_time.h" #include "xrt/xrt_results.h" @@ -1052,7 +1051,7 @@ union xrt_output_value { { float frequency; float amplitude; - time_duration_ns duration; + int64_t duration_ns; } vibration; }; diff --git a/src/xrt/state_trackers/oxr/oxr_input.c b/src/xrt/state_trackers/oxr/oxr_input.c index 5741c7345..e85dc5195 100644 --- a/src/xrt/state_trackers/oxr/oxr_input.c +++ b/src/xrt/state_trackers/oxr/oxr_input.c @@ -1774,7 +1774,7 @@ set_action_output_vibration(struct oxr_session *sess, union xrt_output_value value = {0}; value.vibration.frequency = data->frequency; value.vibration.amplitude = data->amplitude; - value.vibration.duration = data->duration; + value.vibration.duration_ns = data->duration; for (uint32_t i = 0; i < cache->output_count; i++) { struct oxr_action_output *output = &cache->outputs[i]; diff --git a/src/xrt/state_trackers/steamvr_drv/ovrd_driver.cpp b/src/xrt/state_trackers/steamvr_drv/ovrd_driver.cpp index 6f0b47772..1f7c9d8da 100644 --- a/src/xrt/state_trackers/steamvr_drv/ovrd_driver.cpp +++ b/src/xrt/state_trackers/steamvr_drv/ovrd_driver.cpp @@ -1237,9 +1237,9 @@ CServerDriver_Monado::HandleHapticEvent(vr::VREvent_t *event) union xrt_output_value out; out.vibration.amplitude = amp; if (duration > 0.00001) { - out.vibration.duration = (time_duration_ns)(duration * 1000.f * 1000.f * 1000.f); + out.vibration.duration_ns = (time_duration_ns)(duration * 1000.f * 1000.f * 1000.f); } else { - out.vibration.duration = XRT_MIN_HAPTIC_DURATION; + out.vibration.duration_ns = XRT_MIN_HAPTIC_DURATION; } out.vibration.frequency = freq;