diff --git a/src/xrt/drivers/wmr/wmr_hmd.c b/src/xrt/drivers/wmr/wmr_hmd.c index 79a47f5eb..eb8b3a232 100644 --- a/src/xrt/drivers/wmr/wmr_hmd.c +++ b/src/xrt/drivers/wmr/wmr_hmd.c @@ -326,15 +326,22 @@ control_ipd_value_decode(struct wmr_hmd *wh, const unsigned char *buffer, int si } uint8_t id = read8(&buffer); - uint8_t unknown = read8(&buffer); - uint16_t value = read16(&buffer); + if (id != 0x1) { + WMR_ERROR(wh, "Invalid control IPD distance packet ID (expected 0x1 but got %u)", id); + return; + } - (void)id; - (void)unknown; + uint8_t proximity = read8(&buffer); + uint16_t ipd_value = read16(&buffer); - wh->raw_ipd = value; + bool changed = (wh->raw_ipd != ipd_value) || (wh->proximity_sensor != proximity); - WMR_DEBUG(wh, "Got IPD value: %04x", value); + wh->raw_ipd = ipd_value; + wh->proximity_sensor = proximity; + + if (changed) { + WMR_DEBUG(wh, "Proximity sensor %d IPD: %d", proximity, ipd_value); + } } static bool diff --git a/src/xrt/drivers/wmr/wmr_hmd.h b/src/xrt/drivers/wmr/wmr_hmd.h index 04babb776..37d3d960f 100644 --- a/src/xrt/drivers/wmr/wmr_hmd.h +++ b/src/xrt/drivers/wmr/wmr_hmd.h @@ -99,6 +99,8 @@ struct wmr_hmd //! Latest raw IPD value from the device. uint16_t raw_ipd; + //! Latest proximity sensor value from the device. + uint8_t proximity_sensor; /* Distortion related parameters */ struct wmr_hmd_distortion_params distortion_params[2];