From 24b13de593b21e257b7018173dd57c3b1730848b Mon Sep 17 00:00:00 2001 From: Shawn Wallace Date: Fri, 15 Dec 2023 00:48:55 -0500 Subject: [PATCH] d/qwerty: Fix input timestamps --- src/xrt/drivers/qwerty/qwerty_device.c | 36 +++++++++++++++++++++----- src/xrt/drivers/qwerty/qwerty_device.h | 2 ++ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/xrt/drivers/qwerty/qwerty_device.c b/src/xrt/drivers/qwerty/qwerty_device.c index cdc09aade..d0a2c4b04 100644 --- a/src/xrt/drivers/qwerty/qwerty_device.c +++ b/src/xrt/drivers/qwerty/qwerty_device.c @@ -19,6 +19,7 @@ #include "util/u_logging.h" #include "util/u_time.h" #include "util/u_misc.h" +#include "os/os_time.h" #include "qwerty_device.h" @@ -116,7 +117,9 @@ qwerty_update_inputs(struct xrt_device *xd) QWERTY_TRACE(qd, "select: %u, menu: %u", qc->select_clicked, qc->menu_clicked); xd->inputs[QWERTY_SELECT].value.boolean = qc->select_clicked; + xd->inputs[QWERTY_SELECT].timestamp = qc->select_timestamp; xd->inputs[QWERTY_MENU].value.boolean = qc->menu_clicked; + xd->inputs[QWERTY_MENU].timestamp = qc->menu_timestamp; } static void @@ -501,12 +504,33 @@ qwerty_release_all(struct qwerty_device *qd) // Controller methods -// clang-format off -void qwerty_press_select(struct qwerty_controller *qc) { qc->select_clicked = true; } -void qwerty_release_select(struct qwerty_controller *qc) { qc->select_clicked = false; } -void qwerty_press_menu(struct qwerty_controller *qc) { qc->menu_clicked = true; } -void qwerty_release_menu(struct qwerty_controller *qc) { qc->menu_clicked = false; } -// clang-format on +void +qwerty_press_select(struct qwerty_controller *qc) +{ + qc->select_clicked = true; + qc->select_timestamp = os_monotonic_get_ns(); +} + +void +qwerty_release_select(struct qwerty_controller *qc) +{ + qc->select_clicked = false; + qc->select_timestamp = os_monotonic_get_ns(); +} + +void +qwerty_press_menu(struct qwerty_controller *qc) +{ + qc->menu_clicked = true; + qc->menu_timestamp = os_monotonic_get_ns(); +} + +void +qwerty_release_menu(struct qwerty_controller *qc) +{ + qc->menu_clicked = false; + qc->menu_timestamp = os_monotonic_get_ns(); +} void qwerty_follow_hmd(struct qwerty_controller *qc, bool follow) diff --git a/src/xrt/drivers/qwerty/qwerty_device.h b/src/xrt/drivers/qwerty/qwerty_device.h index 0d714ac7c..88eb7c2b9 100644 --- a/src/xrt/drivers/qwerty/qwerty_device.h +++ b/src/xrt/drivers/qwerty/qwerty_device.h @@ -91,7 +91,9 @@ struct qwerty_controller struct qwerty_device base; bool select_clicked; + int64_t select_timestamp; bool menu_clicked; + int64_t menu_timestamp; /*! * Only used when a qwerty_hmd exists in the system.