From 0566f3e0e3a0ed74ee8a76c2b14626442361a736 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 22 May 2025 17:44:12 +0100 Subject: [PATCH] st/oxr: Tidy oxr_system.c file Part-of: --- src/xrt/state_trackers/oxr/oxr_system.c | 88 +++++++++++++++---------- 1 file changed, 53 insertions(+), 35 deletions(-) diff --git a/src/xrt/state_trackers/oxr/oxr_system.c b/src/xrt/state_trackers/oxr/oxr_system.c index 3f3ce1df5..24db766fd 100644 --- a/src/xrt/state_trackers/oxr/oxr_system.c +++ b/src/xrt/state_trackers/oxr/oxr_system.c @@ -26,6 +26,12 @@ #include "oxr_conversions.h" +/* + * + * General helpers + * + */ + DEBUG_GET_ONCE_NUM_OPTION(scale_percentage, "OXR_VIEWPORT_SCALE_PERCENTAGE", 100) @@ -36,6 +42,53 @@ oxr_system_matches(struct oxr_logger *log, struct oxr_system *sys, XrFormFactor return xr_form_factor_to_xrt(form_factor) == sys->xsys->properties.form_factor; } +static bool +oxr_system_get_body_tracking_support(struct oxr_logger *log, + struct oxr_instance *inst, + const enum xrt_input_name body_tracking_name) +{ + struct oxr_system *sys = &inst->system; + const struct xrt_device *body = GET_XDEV_BY_ROLE(sys, body); + if (body == NULL || !body->supported.body_tracking || body->inputs == NULL) { + return false; + } + + for (size_t input_idx = 0; input_idx < body->input_count; ++input_idx) { + const struct xrt_input *input = &body->inputs[input_idx]; + if (input->name == body_tracking_name) { + return true; + } + } + return false; +} + + +/* + * + * Two-call helpers. + * + */ + +static void +view_configuration_view_fill_in(XrViewConfigurationView *target_view, XrViewConfigurationView *source_view) +{ + // clang-format off + target_view->recommendedImageRectWidth = source_view->recommendedImageRectWidth; + target_view->maxImageRectWidth = source_view->maxImageRectWidth; + target_view->recommendedImageRectHeight = source_view->recommendedImageRectHeight; + target_view->maxImageRectHeight = source_view->maxImageRectHeight; + target_view->recommendedSwapchainSampleCount = source_view->recommendedSwapchainSampleCount; + target_view->maxSwapchainSampleCount = source_view->maxSwapchainSampleCount; + // clang-format on +} + + +/* + * + * 'Exported' functions. + * + */ + XrResult oxr_system_select(struct oxr_logger *log, struct oxr_system **systems, @@ -98,8 +151,6 @@ oxr_system_get_by_id(struct oxr_logger *log, struct oxr_instance *inst, XrSystem return XR_SUCCESS; } - - XrResult oxr_system_fill_in( struct oxr_logger *log, struct oxr_instance *inst, XrSystemId systemId, uint32_t view_count, struct oxr_system *sys) @@ -352,26 +403,6 @@ oxr_system_get_face_tracking2_fb_support(struct oxr_logger *log, return; } -static bool -oxr_system_get_body_tracking_support(struct oxr_logger *log, - struct oxr_instance *inst, - const enum xrt_input_name body_tracking_name) -{ - struct oxr_system *sys = &inst->system; - const struct xrt_device *body = GET_XDEV_BY_ROLE(sys, body); - if (body == NULL || !body->supported.body_tracking || body->inputs == NULL) { - return false; - } - - for (size_t input_idx = 0; input_idx < body->input_count; ++input_idx) { - const struct xrt_input *input = &body->inputs[input_idx]; - if (input->name == body_tracking_name) { - return true; - } - } - return false; -} - bool oxr_system_get_body_tracking_fb_support(struct oxr_logger *log, struct oxr_instance *inst) { @@ -629,19 +660,6 @@ oxr_system_get_view_conf_properties(struct oxr_logger *log, return XR_SUCCESS; } -static void -view_configuration_view_fill_in(XrViewConfigurationView *target_view, XrViewConfigurationView *source_view) -{ - // clang-format off - target_view->recommendedImageRectWidth = source_view->recommendedImageRectWidth; - target_view->maxImageRectWidth = source_view->maxImageRectWidth; - target_view->recommendedImageRectHeight = source_view->recommendedImageRectHeight; - target_view->maxImageRectHeight = source_view->maxImageRectHeight; - target_view->recommendedSwapchainSampleCount = source_view->recommendedSwapchainSampleCount; - target_view->maxSwapchainSampleCount = source_view->maxSwapchainSampleCount; - // clang-format on -} - XrResult oxr_system_enumerate_view_conf_views(struct oxr_logger *log, struct oxr_system *sys, -- 2.51.2