st/oxr: Use xrt_device_is_form_factor_available

This commit is contained in:
Jarvis Huang 2023-02-07 11:49:30 +08:00 committed by Jakob Bornecrantz
parent 693641b70b
commit 5380b6c149

View file

@ -25,6 +25,15 @@
DEBUG_GET_ONCE_NUM_OPTION(scale_percentage, "OXR_VIEWPORT_SCALE_PERCENTAGE", 100)
static enum xrt_form_factor
convert_form_factor(XrFormFactor form_factor)
{
switch (form_factor) {
case XR_FORM_FACTOR_HANDHELD_DISPLAY: return XRT_FORM_FACTOR_HANDHELD;
case XR_FORM_FACTOR_HEAD_MOUNTED_DISPLAY: return XRT_FORM_FACTOR_HMD;
default: return XRT_FORM_FACTOR_HMD;
}
}
static bool
oxr_system_matches(struct oxr_logger *log, struct oxr_system *sys, XrFormFactor form_factor)
@ -59,6 +68,13 @@ oxr_system_select(struct oxr_logger *log,
form_factor, systems[0]->form_factor);
}
struct xrt_device *xdev = GET_XDEV_BY_ROLE(selected, head);
if (xdev->form_factor_check_supported &&
!xrt_device_is_form_factor_available(xdev, convert_form_factor(form_factor))) {
return oxr_error(log, XR_ERROR_FORM_FACTOR_UNAVAILABLE, "request form factor %i is unavailable now",
form_factor);
}
*out_selected = selected;
return XR_SUCCESS;