d/wmr: Use proximity sensor value in IPD message.

The first byte after the packet ID toggles when
the proximity sensor is activated.
This commit is contained in:
Jan Schmidt 2021-11-15 00:27:52 +11:00 committed by Jakob Bornecrantz
parent 5efe0da713
commit 733d463ec4
2 changed files with 15 additions and 6 deletions

View file

@ -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

View file

@ -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];