mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-06 07:06:10 +00:00
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:
parent
5efe0da713
commit
733d463ec4
|
@ -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 id = read8(&buffer);
|
||||||
uint8_t unknown = read8(&buffer);
|
if (id != 0x1) {
|
||||||
uint16_t value = read16(&buffer);
|
WMR_ERROR(wh, "Invalid control IPD distance packet ID (expected 0x1 but got %u)", id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
(void)id;
|
uint8_t proximity = read8(&buffer);
|
||||||
(void)unknown;
|
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
|
static bool
|
||||||
|
|
|
@ -99,6 +99,8 @@ struct wmr_hmd
|
||||||
|
|
||||||
//! Latest raw IPD value from the device.
|
//! Latest raw IPD value from the device.
|
||||||
uint16_t raw_ipd;
|
uint16_t raw_ipd;
|
||||||
|
//! Latest proximity sensor value from the device.
|
||||||
|
uint8_t proximity_sensor;
|
||||||
|
|
||||||
/* Distortion related parameters */
|
/* Distortion related parameters */
|
||||||
struct wmr_hmd_distortion_params distortion_params[2];
|
struct wmr_hmd_distortion_params distortion_params[2];
|
||||||
|
|
Loading…
Reference in a new issue