From 9e647f9a46c2322adb9c8c6fe90f973114474c83 Mon Sep 17 00:00:00 2001 From: Mario Kleiner Date: Thu, 13 Apr 2023 22:29:28 +0200 Subject: [PATCH] d/vive: Parse/Recognize HTC Vive Pro Eye HMD headphone audio buttons. Does not do anything yet within Monado, but documents how to parse button state of left headphone volume up/down buttons and right headphone microphone mute button. Signed-off-by: Mario Kleiner --- src/xrt/drivers/vive/vive_device.c | 7 +++++++ src/xrt/drivers/vive/vive_device.h | 1 + src/xrt/drivers/vive/vive_protocol.h | 3 ++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/xrt/drivers/vive/vive_device.c b/src/xrt/drivers/vive/vive_device.c index 7a757843d..8e5df1ee2 100644 --- a/src/xrt/drivers/vive/vive_device.c +++ b/src/xrt/drivers/vive/vive_device.c @@ -288,10 +288,17 @@ vive_mainboard_decode_message(struct vive_device *d, struct vive_mainboard_statu d->board.proximity = proximity; } + /* System button on HMD */ if (d->board.button != report->button) { d->board.button = report->button; VIVE_TRACE(d, "Button %d.", report->button); } + + /* Vive Pro headphone buttons, reported mutually exclusive: 1 = Volume up, 2 = Volume down, 4 = Mic mute */ + if (d->board.audio_button != report->audio_button) { + d->board.audio_button = report->audio_button; + VIVE_TRACE(d, "Audio button %d.", report->audio_button); + } } static inline int diff --git a/src/xrt/drivers/vive/vive_device.h b/src/xrt/drivers/vive/vive_device.h index 96b6dbff9..760f97826 100644 --- a/src/xrt/drivers/vive/vive_device.h +++ b/src/xrt/drivers/vive/vive_device.h @@ -56,6 +56,7 @@ struct vive_device uint16_t lens_separation; uint16_t proximity; uint8_t button; + uint8_t audio_button; } board; enum u_logging_level log_level; diff --git a/src/xrt/drivers/vive/vive_protocol.h b/src/xrt/drivers/vive/vive_protocol.h index 665a5bea1..069140a6f 100644 --- a/src/xrt/drivers/vive/vive_protocol.h +++ b/src/xrt/drivers/vive/vive_protocol.h @@ -87,7 +87,8 @@ struct vive_mainboard_status_report uint16_t lens_separation; uint16_t reserved1; uint8_t button; - uint8_t reserved2[3]; + uint8_t audio_button; + uint8_t reserved2[2]; uint8_t proximity_change; uint8_t reserved3; uint16_t proximity;