st/oxr: Rename some types, functions, and variables for clarity

This commit is contained in:
Ryan Pavlik 2020-06-15 14:16:38 -05:00
parent 6fe801e766
commit 894aa8d61f
3 changed files with 345 additions and 264 deletions

View file

@ -31,15 +31,17 @@
*/ */
static void static void
oxr_session_get_source_set(struct oxr_session *sess, oxr_session_get_action_set_attachment(
XrActionSet actionSet, struct oxr_session *sess,
struct oxr_source_set **src_set, XrActionSet actionSet,
struct oxr_action_set **act_set); struct oxr_action_set_attachment **act_set_attached,
struct oxr_action_set **act_set);
static void static void
oxr_session_get_source(struct oxr_session *sess, oxr_session_get_action_attachment(
uint32_t act_key, struct oxr_session *sess,
struct oxr_source **out_src); uint32_t act_key,
struct oxr_action_attachment **out_act_attached);
static void static void
oxr_source_cache_update(struct oxr_logger *log, oxr_source_cache_update(struct oxr_logger *log,
@ -48,12 +50,15 @@ oxr_source_cache_update(struct oxr_logger *log,
int64_t time, int64_t time,
bool select); bool select);
/*!
* @private @memberof oxr_action_attachment
*/
static void static void
oxr_source_update(struct oxr_logger *log, oxr_action_attachment_update(struct oxr_logger *log,
struct oxr_session *sess, struct oxr_session *sess,
struct oxr_source *src, struct oxr_action_attachment *act_attached,
int64_t time, int64_t time,
struct oxr_sub_paths sub_paths); struct oxr_sub_paths sub_paths);
static void static void
oxr_source_bind_inputs(struct oxr_logger *log, oxr_source_bind_inputs(struct oxr_logger *log,
@ -65,16 +70,23 @@ oxr_source_bind_inputs(struct oxr_logger *log,
enum oxr_sub_action_path sub_path); enum oxr_sub_action_path sub_path);
static XrResult static XrResult
oxr_source_destroy_cb(struct oxr_logger *log, struct oxr_handle_base *hb); oxr_action_attachment_destroy_cb(struct oxr_logger *log,
struct oxr_handle_base *hb);
/*!
* Create an action attachment in the given action set attachment, for the
* specified action.
*
* @private @memberof oxr_action_set_attachment
*/
static XrResult static XrResult
oxr_source_create(struct oxr_logger *log, oxr_action_attachment_create(struct oxr_logger *log,
struct oxr_source_set *src_set, struct oxr_action_set_attachment *act_set_attached,
struct oxr_action *act, struct oxr_action *act,
struct oxr_interaction_profile *head, struct oxr_interaction_profile *head,
struct oxr_interaction_profile *left, struct oxr_interaction_profile *left,
struct oxr_interaction_profile *right, struct oxr_interaction_profile *right,
struct oxr_interaction_profile *gamepad); struct oxr_interaction_profile *gamepad);
/* /*
@ -200,9 +212,11 @@ oxr_action_create(struct oxr_logger *log,
// Mod music for all! // Mod music for all!
static uint32_t key_gen = 1; static uint32_t key_gen = 1;
oxr_classify_sub_action_paths(log, inst, if (!oxr_classify_sub_action_paths(
createInfo->countSubactionPaths, log, inst, createInfo->countSubactionPaths,
createInfo->subactionPaths, &sub_paths); createInfo->subactionPaths, &sub_paths)) {
return XR_ERROR_PATH_UNSUPPORTED;
}
struct oxr_action *act = NULL; struct oxr_action *act = NULL;
OXR_ALLOCATE_HANDLE_OR_RETURN(log, act, OXR_XR_DEBUG_ACTION, OXR_ALLOCATE_HANDLE_OR_RETURN(log, act, OXR_XR_DEBUG_ACTION,
@ -233,7 +247,7 @@ oxr_action_create(struct oxr_logger *log,
* *
*/ */
void bool
oxr_classify_sub_action_paths(struct oxr_logger *log, oxr_classify_sub_action_paths(struct oxr_logger *log,
struct oxr_instance *inst, struct oxr_instance *inst,
uint32_t num_subaction_paths, uint32_t num_subaction_paths,
@ -242,13 +256,14 @@ oxr_classify_sub_action_paths(struct oxr_logger *log,
{ {
const char *str = NULL; const char *str = NULL;
size_t length = 0; size_t length = 0;
bool ret = true;
// Reset the sub_paths completely. // Reset the sub_paths completely.
U_ZERO(sub_paths); U_ZERO(sub_paths);
if (num_subaction_paths == 0) { if (num_subaction_paths == 0) {
sub_paths->any = true; sub_paths->any = true;
return; return ret;
} }
for (uint32_t i = 0; i < num_subaction_paths; i++) { for (uint32_t i = 0; i < num_subaction_paths; i++) {
@ -273,8 +288,10 @@ oxr_classify_sub_action_paths(struct oxr_logger *log,
oxr_warn(log, " unrecognized sub action path '%s'", oxr_warn(log, " unrecognized sub action path '%s'",
str); str);
ret = false;
} }
} }
return ret;
} }
XrResult XrResult
@ -282,36 +299,40 @@ oxr_source_get_pose_input(struct oxr_logger *log,
struct oxr_session *sess, struct oxr_session *sess,
uint32_t act_key, uint32_t act_key,
const struct oxr_sub_paths *sub_paths, const struct oxr_sub_paths *sub_paths,
struct oxr_source_input **out_input) struct oxr_action_input **out_input)
{ {
struct oxr_source *src = NULL; struct oxr_action_attachment *act_attached = NULL;
oxr_session_get_source(sess, act_key, &src); oxr_session_get_action_attachment(sess, act_key, &act_attached);
if (src == NULL) { if (act_attached == NULL) {
return XR_SUCCESS; return XR_SUCCESS;
} }
// Priority of inputs. // Priority of inputs.
if (src->head.current.active && (sub_paths->head || sub_paths->any)) { if (act_attached->head.current.active &&
*out_input = src->head.inputs; (sub_paths->head || sub_paths->any)) {
*out_input = act_attached->head.inputs;
return XR_SUCCESS; return XR_SUCCESS;
} }
if (src->left.current.active && (sub_paths->left || sub_paths->any)) { if (act_attached->left.current.active &&
*out_input = src->left.inputs; (sub_paths->left || sub_paths->any)) {
*out_input = act_attached->left.inputs;
return XR_SUCCESS; return XR_SUCCESS;
} }
if (src->right.current.active && (sub_paths->right || sub_paths->any)) { if (act_attached->right.current.active &&
*out_input = src->right.inputs; (sub_paths->right || sub_paths->any)) {
*out_input = act_attached->right.inputs;
return XR_SUCCESS; return XR_SUCCESS;
} }
if (src->gamepad.current.active && if (act_attached->gamepad.current.active &&
(sub_paths->gamepad || sub_paths->any)) { (sub_paths->gamepad || sub_paths->any)) {
*out_input = src->gamepad.inputs; *out_input = act_attached->gamepad.inputs;
return XR_SUCCESS; return XR_SUCCESS;
} }
if (src->user.current.active && (sub_paths->user || sub_paths->any)) { if (act_attached->user.current.active &&
*out_input = src->user.inputs; (sub_paths->user || sub_paths->any)) {
*out_input = act_attached->user.inputs;
return XR_SUCCESS; return XR_SUCCESS;
} }
@ -328,7 +349,7 @@ oxr_source_get_pose_input(struct oxr_logger *log,
static bool static bool
do_inputs(struct oxr_binding *bind, do_inputs(struct oxr_binding *bind,
struct xrt_device *xdev, struct xrt_device *xdev,
struct oxr_source_input inputs[16], struct oxr_action_input inputs[16],
uint32_t *num_inputs) uint32_t *num_inputs)
{ {
struct xrt_input *input = NULL; struct xrt_input *input = NULL;
@ -349,7 +370,7 @@ do_inputs(struct oxr_binding *bind,
static bool static bool
do_outputs(struct oxr_binding *bind, do_outputs(struct oxr_binding *bind,
struct xrt_device *xdev, struct xrt_device *xdev,
struct oxr_source_output outputs[16], struct oxr_action_output outputs[16],
uint32_t *num_outputs) uint32_t *num_outputs)
{ {
struct xrt_output *output = NULL; struct xrt_output *output = NULL;
@ -375,9 +396,9 @@ static bool
do_io_bindings(struct oxr_binding *b, do_io_bindings(struct oxr_binding *b,
struct oxr_action *act, struct oxr_action *act,
struct xrt_device *xdev, struct xrt_device *xdev,
struct oxr_source_input inputs[16], struct oxr_action_input inputs[16],
uint32_t *num_inputs, uint32_t *num_inputs,
struct oxr_source_output outputs[16], struct oxr_action_output outputs[16],
uint32_t *num_outputs) uint32_t *num_outputs)
{ {
bool found = false; bool found = false;
@ -411,7 +432,7 @@ oxr_source_cache_determine_redirect(struct oxr_logger *log,
cache->redirect = INPUT_REDIRECT_DEFAULT; cache->redirect = INPUT_REDIRECT_DEFAULT;
struct oxr_source_input *input = &cache->inputs[0]; struct oxr_action_input *input = &cache->inputs[0];
if (input == NULL) if (input == NULL)
return; return;
@ -462,9 +483,9 @@ get_binding(struct oxr_logger *log,
struct oxr_action *act, struct oxr_action *act,
struct oxr_interaction_profile *profile, struct oxr_interaction_profile *profile,
enum oxr_sub_action_path sub_path, enum oxr_sub_action_path sub_path,
struct oxr_source_input inputs[16], struct oxr_action_input inputs[16],
uint32_t *num_inputs, uint32_t *num_inputs,
struct oxr_source_output outputs[16], struct oxr_action_output outputs[16],
uint32_t *num_outputs, uint32_t *num_outputs,
XrPath *bound_path) XrPath *bound_path)
{ {
@ -560,33 +581,35 @@ get_binding(struct oxr_logger *log,
*/ */
static XrResult static XrResult
oxr_source_set_destroy_cb(struct oxr_logger *log, struct oxr_handle_base *hb) oxr_action_set_attachment_destroy_cb(struct oxr_logger *log, struct oxr_handle_base *hb)
{ {
//! @todo Move to oxr_objects.h //! @todo Move to oxr_objects.h
struct oxr_source_set *src_set = (struct oxr_source_set *)hb; struct oxr_action_set_attachment *act_set_attached =
(struct oxr_action_set_attachment *)hb;
free(src_set); free(act_set_attached);
return XR_SUCCESS; return XR_SUCCESS;
} }
static XrResult static XrResult
oxr_source_set_create(struct oxr_logger *log, oxr_action_set_attachment_create(struct oxr_logger *log,
struct oxr_session *sess, struct oxr_session *sess,
struct oxr_action_set *act_set, struct oxr_action_set *act_set,
struct oxr_source_set **out_src_set) struct oxr_action_set_attachment **out_src_set)
{ {
struct oxr_source_set *src_set = NULL; struct oxr_action_set_attachment *act_set_attached = NULL;
OXR_ALLOCATE_HANDLE_OR_RETURN(log, src_set, OXR_XR_DEBUG_SOURCESET, OXR_ALLOCATE_HANDLE_OR_RETURN(log, act_set_attached,
oxr_source_set_destroy_cb, &sess->handle); OXR_XR_DEBUG_SOURCESET,
oxr_action_set_attachment_destroy_cb, &sess->handle);
src_set->sess = sess; act_set_attached->sess = sess;
u_hashmap_int_insert(sess->act_sets, act_set->key, src_set); u_hashmap_int_insert(sess->act_sets, act_set->key, act_set_attached);
src_set->next = sess->src_set_list; act_set_attached->next = sess->src_set_list;
sess->src_set_list = src_set; sess->src_set_list = act_set_attached;
*out_src_set = src_set; *out_src_set = act_set_attached;
return XR_SUCCESS; return XR_SUCCESS;
} }
@ -612,68 +635,76 @@ oxr_source_cache_teardown(struct oxr_source_cache *cache)
} }
static XrResult static XrResult
oxr_source_destroy_cb(struct oxr_logger *log, struct oxr_handle_base *hb) oxr_action_attachment_destroy_cb(struct oxr_logger *log,
struct oxr_handle_base *hb)
{ {
//! @todo Move to oxr_objects.h //! @todo Move to oxr_objects.h
struct oxr_source *src = (struct oxr_source *)hb; struct oxr_action_attachment *act_attached =
oxr_source_cache_teardown(&(src->user)); (struct oxr_action_attachment *)hb;
oxr_source_cache_teardown(&(src->head)); oxr_source_cache_teardown(&(act_attached->user));
oxr_source_cache_teardown(&(src->left)); oxr_source_cache_teardown(&(act_attached->head));
oxr_source_cache_teardown(&(src->right)); oxr_source_cache_teardown(&(act_attached->left));
oxr_source_cache_teardown(&(src->gamepad)); oxr_source_cache_teardown(&(act_attached->right));
free(src); oxr_source_cache_teardown(&(act_attached->gamepad));
free(act_attached);
return XR_SUCCESS; return XR_SUCCESS;
} }
static XrResult static XrResult
oxr_source_create(struct oxr_logger *log, oxr_action_attachment_create(struct oxr_logger *log,
struct oxr_source_set *src_set, struct oxr_action_set_attachment *act_set_attached,
struct oxr_action *act, struct oxr_action *act,
struct oxr_interaction_profile *head, struct oxr_interaction_profile *head,
struct oxr_interaction_profile *left, struct oxr_interaction_profile *left,
struct oxr_interaction_profile *right, struct oxr_interaction_profile *right,
struct oxr_interaction_profile *gamepad) struct oxr_interaction_profile *gamepad)
{ {
struct oxr_session *sess = src_set->sess; struct oxr_session *sess = act_set_attached->sess;
struct oxr_source *src = NULL; struct oxr_action_attachment *act_attached = NULL;
struct oxr_sink_logger slog = {0}; struct oxr_sink_logger slog = {0};
OXR_ALLOCATE_HANDLE_OR_RETURN(log, src, OXR_XR_DEBUG_SOURCE, OXR_ALLOCATE_HANDLE_OR_RETURN(log, act_attached, OXR_XR_DEBUG_SOURCE,
oxr_source_destroy_cb, &src_set->handle); oxr_action_attachment_destroy_cb,
&act_set_attached->handle);
u_hashmap_int_insert(src_set->sess->sources, act->key, src); u_hashmap_int_insert(act_set_attached->sess->sources, act->key,
act_attached);
// Need to copy this. // Need to copy this.
src->action_type = act->action_type; act_attached->action_type = act->action_type;
// Start logging into a single buffer. // Start logging into a single buffer.
oxr_slog(&slog, ": Binding %s/%s\n", act->act_set->name, act->name); oxr_slog(&slog, ": Binding %s/%s\n", act->act_set->name, act->name);
if (act->sub_paths.user || act->sub_paths.any) { if (act->sub_paths.user || act->sub_paths.any) {
#if 0 #if 0
oxr_source_bind_inputs(log, slog, sess, act, &src->user, user, oxr_source_bind_inputs(log, slog, sess, act, &act_attached->user, user,
OXR_SUB_ACTION_PATH_USER); OXR_SUB_ACTION_PATH_USER);
#endif #endif
} }
if (act->sub_paths.head || act->sub_paths.any) { if (act->sub_paths.head || act->sub_paths.any) {
oxr_source_bind_inputs(log, &slog, sess, act, &src->head, head, oxr_source_bind_inputs(log, &slog, sess, act,
&act_attached->head, head,
OXR_SUB_ACTION_PATH_HEAD); OXR_SUB_ACTION_PATH_HEAD);
} }
if (act->sub_paths.left || act->sub_paths.any) { if (act->sub_paths.left || act->sub_paths.any) {
oxr_source_bind_inputs(log, &slog, sess, act, &src->left, left, oxr_source_bind_inputs(log, &slog, sess, act,
&act_attached->left, left,
OXR_SUB_ACTION_PATH_LEFT); OXR_SUB_ACTION_PATH_LEFT);
} }
if (act->sub_paths.right || act->sub_paths.any) { if (act->sub_paths.right || act->sub_paths.any) {
oxr_source_bind_inputs(log, &slog, sess, act, &src->right, oxr_source_bind_inputs(log, &slog, sess, act,
right, OXR_SUB_ACTION_PATH_RIGHT); &act_attached->right, right,
OXR_SUB_ACTION_PATH_RIGHT);
} }
if (act->sub_paths.gamepad || act->sub_paths.any) { if (act->sub_paths.gamepad || act->sub_paths.any) {
oxr_source_bind_inputs(log, &slog, sess, act, &src->gamepad, oxr_source_bind_inputs(log, &slog, sess, act,
gamepad, OXR_SUB_ACTION_PATH_GAMEPAD); &act_attached->gamepad, gamepad,
OXR_SUB_ACTION_PATH_GAMEPAD);
} }
oxr_slog(&slog, "\tDone"); oxr_slog(&slog, "\tDone");
@ -699,7 +730,7 @@ oxr_source_cache_stop_output(struct oxr_logger *log,
union xrt_output_value value = {0}; union xrt_output_value value = {0};
for (uint32_t i = 0; i < cache->num_outputs; i++) { for (uint32_t i = 0; i < cache->num_outputs; i++) {
struct oxr_source_output *output = &cache->outputs[i]; struct oxr_action_output *output = &cache->outputs[i];
struct xrt_device *xdev = output->xdev; struct xrt_device *xdev = output->xdev;
xrt_device_set_output(xdev, output->name, &value); xrt_device_set_output(xdev, output->name, &value);
@ -713,7 +744,7 @@ oxr_source_cache_update(struct oxr_logger *log,
int64_t time, int64_t time,
bool selected) bool selected)
{ {
struct oxr_source_state last = cache->current; struct oxr_action_state last = cache->current;
if (!selected) { if (!selected) {
if (cache->stop_output_time > 0) { if (cache->stop_output_time > 0) {
@ -803,42 +834,42 @@ oxr_source_cache_update(struct oxr_logger *log,
} }
#define BOOL_CHECK(NAME) \ #define BOOL_CHECK(NAME) \
if (src->NAME.current.active) { \ if (act_attached->NAME.current.active) { \
active |= true; \ active |= true; \
value |= src->NAME.current.value.boolean; \ value |= act_attached->NAME.current.value.boolean; \
timestamp = src->NAME.current.timestamp; \ timestamp = act_attached->NAME.current.timestamp; \
} }
#define VEC1_CHECK(NAME) \ #define VEC1_CHECK(NAME) \
if (src->NAME.current.active) { \ if (act_attached->NAME.current.active) { \
active |= true; \ active |= true; \
if (value < src->NAME.current.value.vec1.x) { \ if (value < act_attached->NAME.current.value.vec1.x) { \
value = src->NAME.current.value.vec1.x; \ value = act_attached->NAME.current.value.vec1.x; \
timestamp = src->NAME.current.timestamp; \ timestamp = act_attached->NAME.current.timestamp; \
} \ } \
} }
#define VEC2_CHECK(NAME) \ #define VEC2_CHECK(NAME) \
if (src->NAME.current.active) { \ if (act_attached->NAME.current.active) { \
active |= true; \ active |= true; \
float curr_x = src->NAME.current.value.vec2.x; \ float curr_x = act_attached->NAME.current.value.vec2.x; \
float curr_y = src->NAME.current.value.vec2.y; \ float curr_y = act_attached->NAME.current.value.vec2.y; \
float curr_d = curr_x * curr_x + curr_y * curr_y; \ float curr_d = curr_x * curr_x + curr_y * curr_y; \
if (distance < curr_d) { \ if (distance < curr_d) { \
x = curr_x; \ x = curr_x; \
y = curr_y; \ y = curr_y; \
distance = curr_d; \ distance = curr_d; \
timestamp = src->NAME.current.timestamp; \ timestamp = act_attached->NAME.current.timestamp; \
} \ } \
} }
static void static void
oxr_source_update(struct oxr_logger *log, oxr_action_attachment_update(struct oxr_logger *log,
struct oxr_session *sess, struct oxr_session *sess,
struct oxr_source *src, struct oxr_action_attachment *act_attached,
int64_t time, int64_t time,
struct oxr_sub_paths sub_paths) struct oxr_sub_paths sub_paths)
{ {
// This really shouldn't be happening. // This really shouldn't be happening.
if (src == NULL) { if (act_attached == NULL) {
return; return;
} }
@ -851,26 +882,26 @@ oxr_source_update(struct oxr_logger *log,
bool select_gamepad = sub_paths.gamepad || sub_paths.any; bool select_gamepad = sub_paths.gamepad || sub_paths.any;
// clang-format off // clang-format off
oxr_source_cache_update(log, sess, &src->head, time, select_head); oxr_source_cache_update(log, sess, &act_attached->head, time, select_head);
oxr_source_cache_update(log, sess, &src->left, time, select_left); oxr_source_cache_update(log, sess, &act_attached->left, time, select_left);
oxr_source_cache_update(log, sess, &src->right, time, select_right); oxr_source_cache_update(log, sess, &act_attached->right, time, select_right);
oxr_source_cache_update(log, sess, &src->gamepad, time, select_gamepad); oxr_source_cache_update(log, sess, &act_attached->gamepad, time, select_gamepad);
// clang-format on // clang-format on
if (!select_any) { if (!select_any) {
U_ZERO(&src->any_state); U_ZERO(&act_attached->any_state);
return; return;
} }
/* /*
* Any state. * Any state.
*/ */
struct oxr_source_state last = src->any_state; struct oxr_action_state last = act_attached->any_state;
bool active = false; bool active = false;
bool changed = false; bool changed = false;
XrTime timestamp = 0; XrTime timestamp = 0;
switch (src->action_type) { switch (act_attached->action_type) {
case XR_ACTION_TYPE_BOOLEAN_INPUT: { case XR_ACTION_TYPE_BOOLEAN_INPUT: {
bool value = false; bool value = false;
BOOL_CHECK(user); BOOL_CHECK(user);
@ -880,7 +911,7 @@ oxr_source_update(struct oxr_logger *log,
BOOL_CHECK(gamepad); BOOL_CHECK(gamepad);
changed = (last.value.boolean != value); changed = (last.value.boolean != value);
src->any_state.value.boolean = value; act_attached->any_state.value.boolean = value;
break; break;
} }
case XR_ACTION_TYPE_FLOAT_INPUT: { case XR_ACTION_TYPE_FLOAT_INPUT: {
@ -892,7 +923,7 @@ oxr_source_update(struct oxr_logger *log,
VEC1_CHECK(gamepad); VEC1_CHECK(gamepad);
changed = last.value.vec1.x != value; changed = last.value.vec1.x != value;
src->any_state.value.vec1.x = value; act_attached->any_state.value.vec1.x = value;
break; break;
} }
case XR_ACTION_TYPE_VECTOR2F_INPUT: { case XR_ACTION_TYPE_VECTOR2F_INPUT: {
@ -906,8 +937,8 @@ oxr_source_update(struct oxr_logger *log,
VEC2_CHECK(gamepad); VEC2_CHECK(gamepad);
changed = (last.value.vec2.x != x) || (last.value.vec2.y != y); changed = (last.value.vec2.x != x) || (last.value.vec2.y != y);
src->any_state.value.vec2.x = x; act_attached->any_state.value.vec2.x = x;
src->any_state.value.vec2.y = y; act_attached->any_state.value.vec2.y = y;
break; break;
} }
default: default:
@ -919,19 +950,19 @@ oxr_source_update(struct oxr_logger *log,
} }
if (!active) { if (!active) {
U_ZERO(&src->any_state); U_ZERO(&act_attached->any_state);
} else if (last.active && changed) { } else if (last.active && changed) {
src->any_state.timestamp = timestamp; act_attached->any_state.timestamp = timestamp;
src->any_state.changed = true; act_attached->any_state.changed = true;
src->any_state.active = true; act_attached->any_state.active = true;
} else if (last.active) { } else if (last.active) {
src->any_state.timestamp = last.timestamp; act_attached->any_state.timestamp = last.timestamp;
src->any_state.changed = false; act_attached->any_state.changed = false;
src->any_state.active = true; act_attached->any_state.active = true;
} else { } else {
src->any_state.timestamp = timestamp; act_attached->any_state.timestamp = timestamp;
src->any_state.changed = false; act_attached->any_state.changed = false;
src->any_state.active = true; act_attached->any_state.active = true;
} }
} }
@ -944,9 +975,9 @@ oxr_source_bind_inputs(struct oxr_logger *log,
struct oxr_interaction_profile *profile, struct oxr_interaction_profile *profile,
enum oxr_sub_action_path sub_path) enum oxr_sub_action_path sub_path)
{ {
struct oxr_source_input inputs[16] = {0}; struct oxr_action_input inputs[16] = {0};
uint32_t num_inputs = 0; uint32_t num_inputs = 0;
struct oxr_source_output outputs[16] = {0}; struct oxr_action_output outputs[16] = {0};
uint32_t num_outputs = 0; uint32_t num_outputs = 0;
//! @todo Should this be asserted to be none-null? //! @todo Should this be asserted to be none-null?
@ -959,7 +990,7 @@ oxr_source_bind_inputs(struct oxr_logger *log,
if (num_inputs > 0) { if (num_inputs > 0) {
cache->current.active = true; cache->current.active = true;
cache->inputs = cache->inputs =
U_TYPED_ARRAY_CALLOC(struct oxr_source_input, num_inputs); U_TYPED_ARRAY_CALLOC(struct oxr_action_input, num_inputs);
for (uint32_t i = 0; i < num_inputs; i++) { for (uint32_t i = 0; i < num_inputs; i++) {
cache->inputs[i] = inputs[i]; cache->inputs[i] = inputs[i];
} }
@ -969,7 +1000,7 @@ oxr_source_bind_inputs(struct oxr_logger *log,
if (num_outputs > 0) { if (num_outputs > 0) {
cache->current.active = true; cache->current.active = true;
cache->outputs = cache->outputs =
U_TYPED_ARRAY_CALLOC(struct oxr_source_output, num_outputs); U_TYPED_ARRAY_CALLOC(struct oxr_action_output, num_outputs);
for (uint32_t i = 0; i < num_outputs; i++) { for (uint32_t i = 0; i < num_outputs; i++) {
cache->outputs[i] = outputs[i]; cache->outputs[i] = outputs[i];
} }
@ -986,11 +1017,18 @@ oxr_source_bind_inputs(struct oxr_logger *log,
* *
*/ */
/*!
* Given an Action Set handle, return the @ref oxr_action_set and the associated
* @ref oxr_action_set_attachment in the given Session.
*
* @private @memberof oxr_session
*/
static void static void
oxr_session_get_source_set(struct oxr_session *sess, oxr_session_get_action_set_attachment(
XrActionSet actionSet, struct oxr_session *sess,
struct oxr_source_set **src_set, XrActionSet actionSet,
struct oxr_action_set **act_set) struct oxr_action_set_attachment **act_set_attached,
struct oxr_action_set **act_set)
{ {
void *ptr = NULL; void *ptr = NULL;
*act_set = *act_set =
@ -998,20 +1036,27 @@ oxr_session_get_source_set(struct oxr_session *sess,
int ret = u_hashmap_int_find(sess->act_sets, (*act_set)->key, &ptr); int ret = u_hashmap_int_find(sess->act_sets, (*act_set)->key, &ptr);
if (ret == 0) { if (ret == 0) {
*src_set = (struct oxr_source_set *)ptr; *act_set_attached = (struct oxr_action_set_attachment *)ptr;
} }
} }
/*!
* Given an action key, look up the @ref oxr_action_attachment of the associated
* action in the given Session.
*
* @private @memberof oxr_session
*/
static void static void
oxr_session_get_source(struct oxr_session *sess, oxr_session_get_action_attachment(
uint32_t act_key, struct oxr_session *sess,
struct oxr_source **out_src) uint32_t act_key,
struct oxr_action_attachment **out_act_attached)
{ {
void *ptr = NULL; void *ptr = NULL;
int ret = u_hashmap_int_find(sess->sources, act_key, &ptr); int ret = u_hashmap_int_find(sess->sources, act_key, &ptr);
if (ret == 0) { if (ret == 0) {
*out_src = (struct oxr_source *)ptr; *out_act_attached = (struct oxr_action_attachment *)ptr;
} }
} }
@ -1025,7 +1070,7 @@ oxr_session_attach_action_sets(struct oxr_logger *log,
struct oxr_interaction_profile *left = NULL; struct oxr_interaction_profile *left = NULL;
struct oxr_interaction_profile *right = NULL; struct oxr_interaction_profile *right = NULL;
struct oxr_action_set *act_set = NULL; struct oxr_action_set *act_set = NULL;
struct oxr_source_set *src_set = NULL; struct oxr_action_set_attachment *act_set_attached = NULL;
struct oxr_action *act = NULL; struct oxr_action *act = NULL;
oxr_find_profile_for_device(log, inst, sess->sys->head, &head); oxr_find_profile_for_device(log, inst, sess->sys->head, &head);
@ -1038,7 +1083,7 @@ oxr_session_attach_action_sets(struct oxr_logger *log,
bindInfo->actionSets[i]); bindInfo->actionSets[i]);
act_set->attached = true; act_set->attached = true;
oxr_source_set_create(log, sess, act_set, &src_set); oxr_action_set_attachment_create(log, sess, act_set, &act_set_attached);
for (uint32_t k = 0; k < XRT_MAX_HANDLE_CHILDREN; k++) { for (uint32_t k = 0; k < XRT_MAX_HANDLE_CHILDREN; k++) {
act = (struct oxr_action *)act_set->handle.children[k]; act = (struct oxr_action *)act_set->handle.children[k];
@ -1046,8 +1091,8 @@ oxr_session_attach_action_sets(struct oxr_logger *log,
continue; continue;
} }
oxr_source_create(log, src_set, act, head, left, right, oxr_action_attachment_create(log, act_set_attached, act,
NULL); head, left, right, NULL);
} }
} }
@ -1073,13 +1118,13 @@ oxr_action_sync_data(struct oxr_logger *log,
const XrActiveActionSet *actionSets) const XrActiveActionSet *actionSets)
{ {
struct oxr_action_set *act_set = NULL; struct oxr_action_set *act_set = NULL;
struct oxr_source_set *src_set = NULL; struct oxr_action_set_attachment *act_set_attached = NULL;
// Check that all action sets has been attached. // Check that all action sets has been attached.
for (uint32_t i = 0; i < countActionSets; i++) { for (uint32_t i = 0; i < countActionSets; i++) {
oxr_session_get_source_set(sess, actionSets[i].actionSet, oxr_session_get_action_set_attachment(
&src_set, &act_set); sess, actionSets[i].actionSet, &act_set_attached, &act_set);
if (src_set == NULL) { if (act_set_attached == NULL) {
return oxr_error( return oxr_error(
log, XR_ERROR_ACTIONSET_NOT_ATTACHED, log, XR_ERROR_ACTIONSET_NOT_ATTACHED,
"(actionSets[%i].actionSet) action set '%s' has " "(actionSets[%i].actionSet) action set '%s' has "
@ -1097,54 +1142,60 @@ oxr_action_sync_data(struct oxr_logger *log,
} }
// Reset all requested source sets. // Reset all requested source sets.
src_set = sess->src_set_list; act_set_attached = sess->src_set_list;
while (src_set != NULL) { while (act_set_attached != NULL) {
U_ZERO(&src_set->requested_sub_paths); U_ZERO(&act_set_attached->requested_sub_paths);
// Grab the next one. // Grab the next one.
src_set = src_set->next; act_set_attached = act_set_attached->next;
} }
// Go over all action sets and update them. // Go over all action sets and update them.
for (uint32_t i = 0; i < countActionSets; i++) { for (uint32_t i = 0; i < countActionSets; i++) {
struct oxr_sub_paths sub_paths; struct oxr_sub_paths sub_paths;
oxr_session_get_source_set(sess, actionSets[i].actionSet, oxr_session_get_action_set_attachment(
&src_set, &act_set); sess, actionSets[i].actionSet, &act_set_attached, &act_set);
assert(src_set != NULL); assert(act_set_attached != NULL);
oxr_classify_sub_action_paths(log, sess->sys->inst, 1, if (!oxr_classify_sub_action_paths(log, sess->sys->inst, 1,
&actionSets[i].subactionPath, &actionSets[i].subactionPath,
&sub_paths); &sub_paths)) {
return XR_ERROR_PATH_UNSUPPORTED;
}
src_set->requested_sub_paths.any |= sub_paths.any; act_set_attached->requested_sub_paths.any |= sub_paths.any;
src_set->requested_sub_paths.user |= sub_paths.user; act_set_attached->requested_sub_paths.user |= sub_paths.user;
src_set->requested_sub_paths.head |= sub_paths.head; act_set_attached->requested_sub_paths.head |= sub_paths.head;
src_set->requested_sub_paths.left |= sub_paths.left; act_set_attached->requested_sub_paths.left |= sub_paths.left;
src_set->requested_sub_paths.right |= sub_paths.right; act_set_attached->requested_sub_paths.right |= sub_paths.right;
src_set->requested_sub_paths.gamepad |= sub_paths.gamepad; act_set_attached->requested_sub_paths.gamepad |=
sub_paths.gamepad;
} }
// Reset all source sets. // Reset all source sets.
src_set = sess->src_set_list; act_set_attached = sess->src_set_list;
while (src_set != NULL) { while (act_set_attached != NULL) {
struct oxr_sub_paths sub_paths = src_set->requested_sub_paths; struct oxr_sub_paths sub_paths =
act_set_attached->requested_sub_paths;
for (uint32_t k = 0; k < XRT_MAX_HANDLE_CHILDREN; k++) { for (uint32_t k = 0; k < XRT_MAX_HANDLE_CHILDREN; k++) {
// This assumes that all children of a // This assumes that all children of a
// source set are actions. // source set are actions.
struct oxr_source *src = struct oxr_action_attachment *act_attached =
(struct oxr_source *)src_set->handle.children[k]; (struct oxr_action_attachment *)
act_set_attached->handle.children[k];
if (src == NULL) { if (act_attached == NULL) {
continue; continue;
} }
oxr_source_update(log, sess, src, now, sub_paths); oxr_action_attachment_update(log, sess, act_attached,
now, sub_paths);
} }
// Grab the next one. // Grab the next one.
src_set = src_set->next; act_set_attached = act_set_attached->next;
} }
@ -1159,7 +1210,7 @@ oxr_action_sync_data(struct oxr_logger *log,
*/ */
static void static void
get_state_from_state_bool(struct oxr_source_state *state, get_state_from_state_bool(struct oxr_action_state *state,
XrActionStateBoolean *data, XrActionStateBoolean *data,
enum xrt_source_value_redirect redirect) enum xrt_source_value_redirect redirect)
{ {
@ -1170,7 +1221,7 @@ get_state_from_state_bool(struct oxr_source_state *state,
} }
static void static void
get_state_from_state_vec1(struct oxr_source_state *state, get_state_from_state_vec1(struct oxr_action_state *state,
XrActionStateFloat *data, XrActionStateFloat *data,
enum xrt_source_value_redirect redirect) enum xrt_source_value_redirect redirect)
{ {
@ -1191,7 +1242,7 @@ get_state_from_state_vec1(struct oxr_source_state *state,
} }
static void static void
get_state_from_state_vec2(struct oxr_source_state *state, get_state_from_state_vec2(struct oxr_action_state *state,
XrActionStateVector2f *data, XrActionStateVector2f *data,
enum xrt_source_value_redirect redirect) enum xrt_source_value_redirect redirect)
{ {
@ -1203,29 +1254,31 @@ get_state_from_state_vec2(struct oxr_source_state *state,
} }
#define OXR_ACTION_GET_FILLER(TYPE) \ #define OXR_ACTION_GET_FILLER(TYPE) \
if (sub_paths.any && src->any_state.active) { \ if (sub_paths.any && act_attached->any_state.active) { \
get_state_from_state_##TYPE(&src->any_state, data, \ get_state_from_state_##TYPE(&act_attached->any_state, data, \
INPUT_REDIRECT_DEFAULT); \ INPUT_REDIRECT_DEFAULT); \
} \ } \
if (sub_paths.user && src->user.current.active) { \ if (sub_paths.user && act_attached->user.current.active) { \
get_state_from_state_##TYPE(&src->user.current, data, \ get_state_from_state_##TYPE(&act_attached->user.current, data, \
src->user.redirect); \ act_attached->user.redirect); \
} \ } \
if (sub_paths.head && src->head.current.active) { \ if (sub_paths.head && act_attached->head.current.active) { \
get_state_from_state_##TYPE(&src->head.current, data, \ get_state_from_state_##TYPE(&act_attached->head.current, data, \
src->head.redirect); \ act_attached->head.redirect); \
} \ } \
if (sub_paths.left && src->left.current.active) { \ if (sub_paths.left && act_attached->left.current.active) { \
get_state_from_state_##TYPE(&src->left.current, data, \ get_state_from_state_##TYPE(&act_attached->left.current, data, \
src->left.redirect); \ act_attached->left.redirect); \
} \ } \
if (sub_paths.right && src->right.current.active) { \ if (sub_paths.right && act_attached->right.current.active) { \
get_state_from_state_##TYPE(&src->right.current, data, \ get_state_from_state_##TYPE(&act_attached->right.current, \
src->right.redirect); \ data, \
act_attached->right.redirect); \
} \ } \
if (sub_paths.gamepad && src->gamepad.current.active) { \ if (sub_paths.gamepad && act_attached->gamepad.current.active) { \
get_state_from_state_##TYPE(&src->gamepad.current, data, \ get_state_from_state_##TYPE(&act_attached->gamepad.current, \
src->gamepad.redirect); \ data, \
act_attached->gamepad.redirect); \
} }
@ -1236,10 +1289,10 @@ oxr_action_get_boolean(struct oxr_logger *log,
struct oxr_sub_paths sub_paths, struct oxr_sub_paths sub_paths,
XrActionStateBoolean *data) XrActionStateBoolean *data)
{ {
struct oxr_source *src = NULL; struct oxr_action_attachment *act_attached = NULL;
oxr_session_get_source(sess, key, &src); oxr_session_get_action_attachment(sess, key, &act_attached);
if (src == NULL) { if (act_attached == NULL) {
return oxr_error( return oxr_error(
log, XR_ERROR_ACTIONSET_NOT_ATTACHED, log, XR_ERROR_ACTIONSET_NOT_ATTACHED,
"Action has not been attached to this session"); "Action has not been attached to this session");
@ -1261,10 +1314,10 @@ oxr_action_get_vector1f(struct oxr_logger *log,
struct oxr_sub_paths sub_paths, struct oxr_sub_paths sub_paths,
XrActionStateFloat *data) XrActionStateFloat *data)
{ {
struct oxr_source *src = NULL; struct oxr_action_attachment *act_attached = NULL;
oxr_session_get_source(sess, key, &src); oxr_session_get_action_attachment(sess, key, &act_attached);
if (src == NULL) { if (act_attached == NULL) {
return oxr_error( return oxr_error(
log, XR_ERROR_ACTIONSET_NOT_ATTACHED, log, XR_ERROR_ACTIONSET_NOT_ATTACHED,
"Action has not been attached to this session"); "Action has not been attached to this session");
@ -1285,10 +1338,10 @@ oxr_action_get_vector2f(struct oxr_logger *log,
struct oxr_sub_paths sub_paths, struct oxr_sub_paths sub_paths,
XrActionStateVector2f *data) XrActionStateVector2f *data)
{ {
struct oxr_source *src = NULL; struct oxr_action_attachment *act_attached = NULL;
oxr_session_get_source(sess, key, &src); oxr_session_get_action_attachment(sess, key, &act_attached);
if (src == NULL) { if (act_attached == NULL) {
return oxr_error( return oxr_error(
log, XR_ERROR_ACTIONSET_NOT_ATTACHED, log, XR_ERROR_ACTIONSET_NOT_ATTACHED,
"Action has not been attached to this session"); "Action has not been attached to this session");
@ -1309,10 +1362,10 @@ oxr_action_get_pose(struct oxr_logger *log,
struct oxr_sub_paths sub_paths, struct oxr_sub_paths sub_paths,
XrActionStatePose *data) XrActionStatePose *data)
{ {
struct oxr_source *src = NULL; struct oxr_action_attachment *act_attached = NULL;
oxr_session_get_source(sess, key, &src); oxr_session_get_action_attachment(sess, key, &act_attached);
if (src == NULL) { if (act_attached == NULL) {
return oxr_error( return oxr_error(
log, XR_ERROR_ACTIONSET_NOT_ATTACHED, log, XR_ERROR_ACTIONSET_NOT_ATTACHED,
"Action has not been attached to this session"); "Action has not been attached to this session");
@ -1321,19 +1374,19 @@ oxr_action_get_pose(struct oxr_logger *log,
data->isActive = XR_FALSE; data->isActive = XR_FALSE;
if (sub_paths.user || sub_paths.any) { if (sub_paths.user || sub_paths.any) {
data->isActive |= src->user.current.active; data->isActive |= act_attached->user.current.active;
} }
if (sub_paths.head || sub_paths.any) { if (sub_paths.head || sub_paths.any) {
data->isActive |= src->head.current.active; data->isActive |= act_attached->head.current.active;
} }
if (sub_paths.left || sub_paths.any) { if (sub_paths.left || sub_paths.any) {
data->isActive |= src->left.current.active; data->isActive |= act_attached->left.current.active;
} }
if (sub_paths.right || sub_paths.any) { if (sub_paths.right || sub_paths.any) {
data->isActive |= src->right.current.active; data->isActive |= act_attached->right.current.active;
} }
if (sub_paths.gamepad || sub_paths.any) { if (sub_paths.gamepad || sub_paths.any) {
data->isActive |= src->gamepad.current.active; data->isActive |= act_attached->gamepad.current.active;
} }
return oxr_session_success_result(sess); return oxr_session_success_result(sess);
@ -1347,7 +1400,7 @@ oxr_action_get_pose(struct oxr_logger *log,
*/ */
static void static void
set_source_output_vibration(struct oxr_session *sess, set_action_output_vibration(struct oxr_session *sess,
struct oxr_source_cache *cache, struct oxr_source_cache *cache,
int64_t stop, int64_t stop,
const XrHapticVibration *data) const XrHapticVibration *data)
@ -1360,7 +1413,7 @@ set_source_output_vibration(struct oxr_session *sess,
value.vibration.duration = data->duration; value.vibration.duration = data->duration;
for (uint32_t i = 0; i < cache->num_outputs; i++) { for (uint32_t i = 0; i < cache->num_outputs; i++) {
struct oxr_source_output *output = &cache->outputs[i]; struct oxr_action_output *output = &cache->outputs[i];
struct xrt_device *xdev = output->xdev; struct xrt_device *xdev = output->xdev;
xrt_device_set_output(xdev, output->name, &value); xrt_device_set_output(xdev, output->name, &value);
@ -1376,10 +1429,10 @@ oxr_action_apply_haptic_feedback(struct oxr_logger *log,
struct oxr_sub_paths sub_paths, struct oxr_sub_paths sub_paths,
const XrHapticBaseHeader *hapticEvent) const XrHapticBaseHeader *hapticEvent)
{ {
struct oxr_source *src = NULL; struct oxr_action_attachment *act_attached = NULL;
oxr_session_get_source(sess, key, &src); oxr_session_get_action_attachment(sess, key, &act_attached);
if (src == NULL) { if (act_attached == NULL) {
return oxr_error( return oxr_error(
log, XR_ERROR_ACTIONSET_NOT_ATTACHED, log, XR_ERROR_ACTIONSET_NOT_ATTACHED,
"Action has not been attached to this session"); "Action has not been attached to this session");
@ -1391,20 +1444,20 @@ oxr_action_apply_haptic_feedback(struct oxr_logger *log,
int64_t stop = data->duration <= 0 ? now : now + data->duration; int64_t stop = data->duration <= 0 ? now : now + data->duration;
// clang-format off // clang-format off
if (src->user.current.active && (sub_paths.user || sub_paths.any)) { if (act_attached->user.current.active && (sub_paths.user || sub_paths.any)) {
set_source_output_vibration(sess, &src->user, stop, data); set_action_output_vibration(sess, &act_attached->user, stop, data);
} }
if (src->head.current.active && (sub_paths.head || sub_paths.any)) { if (act_attached->head.current.active && (sub_paths.head || sub_paths.any)) {
set_source_output_vibration(sess, &src->head, stop, data); set_action_output_vibration(sess, &act_attached->head, stop, data);
} }
if (src->left.current.active && (sub_paths.left || sub_paths.any)) { if (act_attached->left.current.active && (sub_paths.left || sub_paths.any)) {
set_source_output_vibration(sess, &src->left, stop, data); set_action_output_vibration(sess, &act_attached->left, stop, data);
} }
if (src->right.current.active && (sub_paths.right || sub_paths.any)) { if (act_attached->right.current.active && (sub_paths.right || sub_paths.any)) {
set_source_output_vibration(sess, &src->right, stop, data); set_action_output_vibration(sess, &act_attached->right, stop, data);
} }
if (src->gamepad.current.active && (sub_paths.gamepad || sub_paths.any)) { if (act_attached->gamepad.current.active && (sub_paths.gamepad || sub_paths.any)) {
set_source_output_vibration(sess, &src->gamepad, stop, data); set_action_output_vibration(sess, &act_attached->gamepad, stop, data);
} }
// clang-format on // clang-format on
@ -1417,30 +1470,30 @@ oxr_action_stop_haptic_feedback(struct oxr_logger *log,
uint64_t key, uint64_t key,
struct oxr_sub_paths sub_paths) struct oxr_sub_paths sub_paths)
{ {
struct oxr_source *src = NULL; struct oxr_action_attachment *act_attached = NULL;
oxr_session_get_source(sess, key, &src); oxr_session_get_action_attachment(sess, key, &act_attached);
if (src == NULL) { if (act_attached == NULL) {
return oxr_error( return oxr_error(
log, XR_ERROR_ACTIONSET_NOT_ATTACHED, log, XR_ERROR_ACTIONSET_NOT_ATTACHED,
"Action has not been attached to this session"); "Action has not been attached to this session");
} }
// clang-format off // clang-format off
if (src->user.current.active && (sub_paths.user || sub_paths.any)) { if (act_attached->user.current.active && (sub_paths.user || sub_paths.any)) {
oxr_source_cache_stop_output(log, sess, &src->user); oxr_source_cache_stop_output(log, sess, &act_attached->user);
} }
if (src->head.current.active && (sub_paths.head || sub_paths.any)) { if (act_attached->head.current.active && (sub_paths.head || sub_paths.any)) {
oxr_source_cache_stop_output(log, sess, &src->head); oxr_source_cache_stop_output(log, sess, &act_attached->head);
} }
if (src->left.current.active && (sub_paths.left || sub_paths.any)) { if (act_attached->left.current.active && (sub_paths.left || sub_paths.any)) {
oxr_source_cache_stop_output(log, sess, &src->left); oxr_source_cache_stop_output(log, sess, &act_attached->left);
} }
if (src->right.current.active && (sub_paths.right || sub_paths.any)) { if (act_attached->right.current.active && (sub_paths.right || sub_paths.any)) {
oxr_source_cache_stop_output(log, sess, &src->right); oxr_source_cache_stop_output(log, sess, &act_attached->right);
} }
if (src->gamepad.current.active && (sub_paths.gamepad || sub_paths.any)) { if (act_attached->gamepad.current.active && (sub_paths.gamepad || sub_paths.any)) {
oxr_source_cache_stop_output(log, sess, &src->gamepad); oxr_source_cache_stop_output(log, sess, &act_attached->gamepad);
} }
// clang-format on // clang-format on

View file

@ -105,10 +105,10 @@ struct oxr_action;
struct oxr_debug_messenger; struct oxr_debug_messenger;
struct oxr_handle_base; struct oxr_handle_base;
struct oxr_sub_paths; struct oxr_sub_paths;
struct oxr_source; struct oxr_action_attachment;
struct oxr_source_set; struct oxr_action_set_attachment;
struct oxr_source_input; struct oxr_action_input;
struct oxr_source_output; struct oxr_action_output;
struct oxr_binding; struct oxr_binding;
struct oxr_interaction_profile; struct oxr_interaction_profile;
@ -363,9 +363,17 @@ oxr_action_to_openxr(struct oxr_action *act)
/*! /*!
* Helper function to classify sub_paths. * Helper function to classify sub_paths.
* *
* Sets all members of @p sub_paths ( @ref oxr_sub_paths ) as appropriate based
* on the subaction paths found in the list.
*
* If no paths are provided, @p sub_paths->any will be true.
*
* @return false if an invalid subaction path is provided.
*
* @public @memberof oxr_instance * @public @memberof oxr_instance
* @relatesalso oxr_sub_paths
*/ */
void bool
oxr_classify_sub_action_paths(struct oxr_logger *log, oxr_classify_sub_action_paths(struct oxr_logger *log,
struct oxr_instance *inst, struct oxr_instance *inst,
uint32_t num_subaction_paths, uint32_t num_subaction_paths,
@ -382,7 +390,7 @@ oxr_source_get_pose_input(struct oxr_logger *log,
struct oxr_session *sess, struct oxr_session *sess,
uint32_t key, uint32_t key,
const struct oxr_sub_paths *sub_paths, const struct oxr_sub_paths *sub_paths,
struct oxr_source_input **out_input); struct oxr_action_input **out_input);
/*! /*!
* @public @memberof oxr_instance * @public @memberof oxr_instance
*/ */
@ -1177,7 +1185,7 @@ struct oxr_session
struct u_hashmap_int *sources; struct u_hashmap_int *sources;
//! List of created source sets. //! List of created source sets.
struct oxr_source_set *src_set_list; struct oxr_action_set_attachment *src_set_list;
//! Has xrAttachSessionActionSets been called? //! Has xrAttachSessionActionSets been called?
bool actionsAttached; bool actionsAttached;
@ -1273,7 +1281,10 @@ struct oxr_binding
}; };
/*! /*!
* To carry around a sementic selection of sub action paths. * A parsed equivalent of a list of sub-action paths.
*
* If @p any is true, then no paths were provided, which typically means any
* input is acceptable.
*/ */
struct oxr_sub_paths struct oxr_sub_paths
{ {
@ -1287,12 +1298,13 @@ struct oxr_sub_paths
}; };
/*! /*!
* Session input source. * The data associated with the attachment of an Action Set (@ref
* oxr_action_set) to as Session (@ref oxr_session).
* *
* @see oxr_action_set * @see oxr_action_set
* @extends oxr_handle_base * @extends oxr_handle_base
*/ */
struct oxr_source_set struct oxr_action_set_attachment
{ {
/*! /*!
* While this isn't an OpenXR handle type, we're using the handle base * While this isn't an OpenXR handle type, we're using the handle base
@ -1307,15 +1319,28 @@ struct oxr_source_set
struct oxr_sub_paths requested_sub_paths; struct oxr_sub_paths requested_sub_paths;
//! Next source set on this session. //! Next source set on this session.
struct oxr_source_set *next; struct oxr_action_set_attachment *next;
}; };
/*! /*!
* The state of a action input source. * De-initialize an action set attachment and its action attachments.
* *
* @see oxr_source * Frees the action attachments, but does not de-allocate the action set
* attachment.
*
* @public @memberof oxr_action_set_attachment
*/ */
struct oxr_source_state void
oxr_action_set_attachment_teardown(
struct oxr_action_set_attachment *act_set_attached);
/*!
* The state of a action input.
*
* @see oxr_action_attachment
*/
struct oxr_action_state
{ {
/*! /*!
* The actual value - must interpret using action type * The actual value - must interpret using action type
@ -1333,24 +1358,24 @@ struct oxr_source_state
}; };
/*! /*!
* A input source pair of a @ref xrt_input and a @ref xrt_device. * A input action pair of a @ref xrt_input and a @ref xrt_device.
* *
* @see xrt_device * @see xrt_device
* @see xrt_input * @see xrt_input
*/ */
struct oxr_source_input struct oxr_action_input
{ {
struct xrt_device *xdev; struct xrt_device *xdev;
struct xrt_input *input; struct xrt_input *input;
}; };
/*! /*!
* A output source pair of a @ref xrt_output_name and a @ref xrt_device. * A output action pair of a @ref xrt_output_name and a @ref xrt_device.
* *
* @see xrt_device * @see xrt_device
* @see xrt_output_name * @see xrt_output_name
*/ */
struct oxr_source_output struct oxr_action_output
{ {
struct xrt_device *xdev; struct xrt_device *xdev;
enum xrt_output_name name; enum xrt_output_name name;
@ -1359,29 +1384,32 @@ struct oxr_source_output
/*! /*!
* A set of inputs for a single sub action path. * A set of inputs for a single sub action path.
* *
* @see oxr_source * @see oxr_action_attachment
*/ */
struct oxr_source_cache struct oxr_source_cache
{ {
struct oxr_source_state current; struct oxr_action_state current;
size_t num_inputs; size_t num_inputs;
struct oxr_source_input *inputs; struct oxr_action_input *inputs;
int64_t stop_output_time; int64_t stop_output_time;
size_t num_outputs; size_t num_outputs;
struct oxr_source_output *outputs; struct oxr_action_output *outputs;
enum xrt_source_value_redirect redirect; enum xrt_source_value_redirect redirect;
}; };
/*! /*!
* Session input source. * Data associated with an Action that has been attached to a Session.
*
* More information on the action vs action attachment and action set vs action
* set attachment parallel is in the docs for @ref oxr_action_set_attachment.
* *
* @see oxr_action * @see oxr_action
* @extends oxr_handle_base * @see oxr_action_set_attachment
*/ */
struct oxr_source struct oxr_action_attachment
{ {
/*! /*!
* While this isn't an OpenXR handle type, we're using the handle base * While this isn't an OpenXR handle type, we're using the handle base
@ -1392,7 +1420,7 @@ struct oxr_source
//! Type the action this source was created from is. //! Type the action this source was created from is.
XrActionType action_type; XrActionType action_type;
struct oxr_source_state any_state; struct oxr_action_state any_state;
struct oxr_source_cache user; struct oxr_source_cache user;
struct oxr_source_cache head; struct oxr_source_cache head;

View file

@ -197,7 +197,7 @@ oxr_space_action_relation(struct oxr_logger *log,
XrTime at_time, XrTime at_time,
struct xrt_space_relation *out_relation) struct xrt_space_relation *out_relation)
{ {
struct oxr_source_input *input = NULL; struct oxr_action_input *input = NULL;
struct oxr_space *act_spc, *ref_spc = NULL; struct oxr_space *act_spc, *ref_spc = NULL;
uint64_t timestamp = 0; uint64_t timestamp = 0;
bool invert = false; bool invert = false;