mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-29 18:08:29 +00:00
st/oxr: Validate xrSuggestInteractionProfileBindings better
This commit is contained in:
parent
6ff4b23a76
commit
f4fadc6f55
2
doc/changes/state_trackers/mr.359.16.md
Normal file
2
doc/changes/state_trackers/mr.359.16.md
Normal file
|
@ -0,0 +1,2 @@
|
|||
OpenXR: Validate the arguments for `xrSuggestInteractionProfileBindings` better
|
||||
so that it follows the spec better.
|
|
@ -7,8 +7,6 @@
|
|||
* @ingroup oxr_api
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "oxr_objects.h"
|
||||
#include "oxr_logger.h"
|
||||
#include "oxr_handle.h"
|
||||
|
@ -18,6 +16,9 @@
|
|||
#include "oxr_api_funcs.h"
|
||||
#include "oxr_api_verify.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
|
@ -98,12 +99,34 @@ oxr_xrSuggestInteractionProfileBindings(
|
|||
&log, suggestedBindings,
|
||||
XR_TYPE_INTERACTION_PROFILE_SUGGESTED_BINDING);
|
||||
|
||||
if (suggestedBindings->countSuggestedBindings == 0) {
|
||||
return oxr_error(&log, XR_ERROR_VALIDATION_FAILURE,
|
||||
"(suggestedBindings->countSuggestedBindings "
|
||||
"== 0) can not suggest 0 bindings");
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < suggestedBindings->countSuggestedBindings; i++) {
|
||||
const XrActionSuggestedBinding *s =
|
||||
&suggestedBindings->suggestedBindings[i];
|
||||
|
||||
struct oxr_action *dummy;
|
||||
OXR_VERIFY_ACTION_NOT_NULL(&log, s->action, dummy);
|
||||
struct oxr_action *act;
|
||||
OXR_VERIFY_ACTION_NOT_NULL(&log, s->action, act);
|
||||
|
||||
if (act->act_set->attached) {
|
||||
return oxr_error(
|
||||
&log, XR_ERROR_ACTIONSETS_ALREADY_ATTACHED,
|
||||
"(suggestedBindings->suggestedBindings[%zu]->"
|
||||
"action) action '%s/%s' has already been attached",
|
||||
i, act->act_set->name, act->name);
|
||||
}
|
||||
|
||||
if (!oxr_path_is_valid(&log, inst, s->binding)) {
|
||||
return oxr_error(
|
||||
&log, XR_ERROR_PATH_INVALID,
|
||||
"(suggestedBindings->suggestedBindings[%zu]->"
|
||||
"binding == %" PRIu64 ") is not a valid path",
|
||||
i, s->binding);
|
||||
}
|
||||
|
||||
//! @todo verify path (s->binding).
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue