diff --git a/src/xrt/state_trackers/oxr/oxr_input.c b/src/xrt/state_trackers/oxr/oxr_input.c index 936053928..28f769dce 100644 --- a/src/xrt/state_trackers/oxr/oxr_input.c +++ b/src/xrt/state_trackers/oxr/oxr_input.c @@ -77,6 +77,39 @@ oxr_action_bind_io(struct oxr_logger *log, struct oxr_interaction_profile *profile, enum oxr_subaction_path subaction_path); +/*! + * Helper function to combine @ref oxr_subaction_paths structs, but skipping + * @ref oxr_subaction_paths::any. + * + * If a real (non-"any") subaction path in @p new_subaction_paths is true, it will be + * true in @p subaction_paths. + * + * @private @memberof oxr_subaction_paths + */ +static inline void +oxr_subaction_paths_accumulate_except_any(struct oxr_subaction_paths *subaction_paths, + const struct oxr_subaction_paths *new_subaction_paths) +{ +#define ACCUMULATE_SUBACTION_PATHS(X) subaction_paths->X |= new_subaction_paths->X; + OXR_FOR_EACH_SUBACTION_PATH(ACCUMULATE_SUBACTION_PATHS) +#undef ACCUMULATE_SUBACTION_PATHS +} + +/*! + * Helper function to combine @ref oxr_subaction_paths structs. + * + * If a subaction path in @p new_subaction_paths is true, it will be true in @p subaction_paths. + * + * @private @memberof oxr_subaction_paths + */ +static inline void +oxr_subaction_paths_accumulate(struct oxr_subaction_paths *subaction_paths, + const struct oxr_subaction_paths *new_subaction_paths) +{ + subaction_paths->any |= new_subaction_paths->any; + oxr_subaction_paths_accumulate_except_any(subaction_paths, new_subaction_paths); +} + /* * * Action attachment functions diff --git a/src/xrt/state_trackers/oxr/oxr_objects.h b/src/xrt/state_trackers/oxr/oxr_objects.h index 546da745b..a0b087f9e 100644 --- a/src/xrt/state_trackers/oxr/oxr_objects.h +++ b/src/xrt/state_trackers/oxr/oxr_objects.h @@ -1914,6 +1914,24 @@ struct oxr_subaction_paths #undef OXR_SUBPATH_MEMBER }; +/*! + * Helper function to determine if the set of paths in @p a is a subset of the + * paths in @p b. + * + * @public @memberof oxr_subaction_paths + */ +static inline bool +oxr_subaction_paths_is_subset_of(const struct oxr_subaction_paths *a, const struct oxr_subaction_paths *b) +{ +#define OXR_CHECK_SUBACTION_PATHS(X) \ + if (a->X && !b->X) { \ + return false; \ + } + OXR_FOR_EACH_SUBACTION_PATH(OXR_CHECK_SUBACTION_PATHS) +#undef OXR_CHECK_SUBACTION_PATHS + return true; +} + /*! * The data associated with the attachment of an Action Set (@ref * oxr_action_set) to as Session (@ref oxr_session).