Commit ef4fbfde authored by Christoph Haag's avatar Christoph Haag Committed by Jakob Bornecrantz

st/oxr: Find arbitrarily many bindings from key

This changes oxr_binding_find_bindings_from_key to the two-call paradigm.
parent 1867a34d
......@@ -293,20 +293,19 @@ oxr_find_profile_for_device(struct oxr_logger *log,
}
}
void
XrResult
oxr_binding_find_bindings_from_key(struct oxr_logger *log,
struct oxr_interaction_profile *p,
uint32_t key,
struct oxr_binding *bindings[32],
size_t *num_bindings)
uint32_t bindingsCapacityInput,
uint32_t *bindingsCountOutput,
struct oxr_binding ***bindings)
{
if (p == NULL) {
*num_bindings = 0;
return;
*bindingsCountOutput = 0;
return XR_SUCCESS;
}
//! @todo This function should be a two call function, or handle more
//! then 32 bindings.
size_t num = 0;
for (size_t y = 0; y < p->num_bindings; y++) {
......@@ -314,18 +313,19 @@ oxr_binding_find_bindings_from_key(struct oxr_logger *log,
for (size_t z = 0; z < b->num_keys; z++) {
if (b->keys[z] == key) {
bindings[num++] = b;
if (bindingsCapacityInput > 0) {
if (num > bindingsCapacityInput)
return XR_ERROR_SIZE_INSUFFICIENT;
(*bindings)[num] = b;
}
num++;
break;
}
}
if (num >= 32) {
*num_bindings = num;
return;
}
}
*num_bindings = num;
OXR_TWO_CALL_HELPER_DIRECT(log, bindingsCapacityInput,
bindingsCountOutput, num, XR_SUCCESS);
}
void
......
......@@ -340,7 +340,7 @@ get_binding(struct oxr_logger *log,
uint32_t *num_outputs)
{
struct xrt_device *xdev = NULL;
struct oxr_binding *bindings[32];
struct oxr_binding **bindings;
const char *profile_str;
const char *user_path_str;
size_t length;
......@@ -388,9 +388,14 @@ get_binding(struct oxr_logger *log,
oxr_slog(slog, "\t\tProfile: %s\n", profile_str);
size_t num = 0;
oxr_binding_find_bindings_from_key(log, profile, act->key, bindings,
&num);
uint32_t num = 0;
oxr_binding_find_bindings_from_key(log, profile, act->key, 0, &num,
NULL);
bindings = malloc(sizeof(struct oxr_binding *) * num);
oxr_binding_find_bindings_from_key(log, profile, act->key, num, &num,
&bindings);
if (num == 0) {
oxr_slog(slog, "\t\tNo bindings\n");
return;
......@@ -419,6 +424,8 @@ get_binding(struct oxr_logger *log,
oxr_slog(slog, "\t\t\t\tRejected! (NO XDEV MAPPING)\n");
}
}
free(bindings);
}
......
......@@ -368,14 +368,15 @@ void
oxr_binding_destroy_all(struct oxr_logger *log, struct oxr_instance *inst);
/*!
* Find all bindings that is the given action key is bound to.
* Find all bindings that the given action key is bound to.
*/
void
XrResult
oxr_binding_find_bindings_from_key(struct oxr_logger *log,
struct oxr_interaction_profile *profile,
struct oxr_interaction_profile *p,
uint32_t key,
struct oxr_binding *bindings[32],
size_t *num_bindings);
uint32_t bindingsCapacityInput,
uint32_t *bindingsCountOutput,
struct oxr_binding ***bindings);
XrResult
oxr_action_suggest_interaction_profile_bindings(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment