| 1 | // Copyright 2018-2020,2023 Collabora, Ltd.cxx . . $ `<file>/src/xrt/state_trackers/oxr/oxr_binding.c`/ |
| 2 | // SPDX-License-Identifier: BSL-1.0 |
| 3 | /*! |
| 4 | * @file |
| 5 | * @brief Holds binding related functions. |
| 6 | * @author Jakob Bornecrantz <[email protected]> |
| 7 | * @author Korcan Hussein <[email protected]> |
| 8 | * @ingroup oxr_main |
| 9 | */ |
| 10 | |
| 11 | #include "util/u_misc.h"cxx . . $ `<file>/src/xrt/auxiliary/util/u_misc.h`/ |
| 12 | |
| 13 | #include "xrt/xrt_compiler.h"cxx . . $ `<file>/src/xrt/include/xrt/xrt_compiler.h`/ |
| 14 | #include "bindings/b_generated_bindings.h"cxx . . $ `<file>/build/src/xrt/auxiliary/bindings/b_generated_bindings.h`/ |
| 15 | |
| 16 | #include "oxr_objects.h"cxx . . $ `<file>/src/xrt/state_trackers/oxr/oxr_objects.h`/ |
| 17 | #include "oxr_logger.h"cxx . . $ `<file>/src/xrt/state_trackers/oxr/oxr_logger.h`/ |
| 18 | #include "oxr_two_call.h"cxx . . $ `<file>/src/xrt/state_trackers/oxr/oxr_two_call.h`/ |
| 19 | #include "oxr_subaction.h"cxx . . $ `<file>/src/xrt/state_trackers/oxr/oxr_subaction.h`/ |
| 20 | |
| 21 | #include <stdio.h> |
| 22 | |
| 23 | |
| 24 | static void |
| 25 | setup_pathscxx . . $ setup_paths(d6f1170c07958d10).(struct oxr_loggercxx . . $ oxr_logger# *log, |
| 26 | struct oxr_instancecxx . . $ oxr_instance# *inst, |
| 27 | const char **src_paths, |
| 28 | XrPathcxx . . $ XrPath# **dest_paths, |
| 29 | uint32_tcxx . . $ uint32_t# *dest_path_count) |
| 30 | { |
| 31 | uint32_tcxx . . $ uint32_t# count = 0; |
| 32 | while (src_paths[count] != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 33 | assertcxx . . $ `/usr/include/assert.h:118:11`!(count != UINT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:118:10`!); |
| 34 | count++; |
| 35 | } |
| 36 | |
| 37 | *dest_path_count = count; |
| 38 | *dest_paths = U_TYPED_ARRAY_CALLOCcxx . . $ `src/xrt/auxiliary/util/u_misc.h:58:9`!(XrPath, count); |
| 39 | |
| 40 | for (size_t x = 0; x < *dest_path_count; x++) { |
| 41 | const char *str = src_paths[x]; |
| 42 | size_t len = strlencxx . . $ strlen(751346f8406fd082).(str); |
| 43 | oxr_path_get_or_createcxx . . $ oxr_path_get_or_create(ae436ac1536ffc4f).(log, inst, str, len, &(*dest_paths)[x]); |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! |
| 48 | interaction_profile_find_in_arraycxx . . $ interaction_profile_find_in_array(d40c3d1846c92c94).(struct oxr_loggercxx . . $ oxr_logger# *log, |
| 49 | const size_t profile_count, |
| 50 | struct oxr_interaction_profilecxx . . $ oxr_interaction_profile# **profiles, |
| 51 | XrPathcxx . . $ XrPath# path, |
| 52 | struct oxr_interaction_profilecxx . . $ oxr_interaction_profile# **out_p) |
| 53 | { |
| 54 | if (profiles == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 55 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 56 | for (size_t x = 0; x < profile_count; x++) { |
| 57 | struct oxr_interaction_profilecxx . . $ oxr_interaction_profile# *p = profiles[x]; |
| 58 | if (p->pathcxx . . $ oxr_interaction_profile#path. != path) { |
| 59 | continue; |
| 60 | } |
| 61 | |
| 62 | *out_p = p; |
| 63 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 64 | } |
| 65 | |
| 66 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 67 | } |
| 68 | |
| 69 | static inline boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! |
| 70 | interaction_profile_find_in_instancecxx . . $ interaction_profile_find_in_instance(df0f331d350e9062).(struct oxr_loggercxx . . $ oxr_logger# *log, |
| 71 | struct oxr_instancecxx . . $ oxr_instance# *inst, |
| 72 | XrPathcxx . . $ XrPath# path, |
| 73 | struct oxr_interaction_profilecxx . . $ oxr_interaction_profile# **out_p) |
| 74 | { |
| 75 | if (interaction_profile_find_in_arraycxx . . $ interaction_profile_find_in_array(d40c3d1846c92c94).( // |
| 76 | log, // |
| 77 | inst->profile_countcxx . . $ oxr_instance#profile_count., // |
| 78 | inst->profilescxx . . $ oxr_instance#profiles., // |
| 79 | path, // |
| 80 | out_p)) { |
| 81 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 82 | } |
| 83 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 84 | } |
| 85 | |
| 86 | static inline boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! |
| 87 | interaction_profile_find_in_sessioncxx . . $ interaction_profile_find_in_session(d1b13e7cd69a6c43).(struct oxr_loggercxx . . $ oxr_logger# *log, |
| 88 | struct oxr_sessioncxx . . $ oxr_session# *sess, |
| 89 | XrPathcxx . . $ XrPath# path, |
| 90 | struct oxr_interaction_profilecxx . . $ oxr_interaction_profile# **out_p) |
| 91 | { |
| 92 | return interaction_profile_find_in_arraycxx . . $ interaction_profile_find_in_array(d40c3d1846c92c94).( // |
| 93 | log, // |
| 94 | sess->profiles_on_attachment_sizecxx . . $ oxr_session#profiles_on_attachment_size., // |
| 95 | sess->profiles_on_attachmentcxx . . $ oxr_session#profiles_on_attachment., // |
| 96 | path, // |
| 97 | out_p); // |
| 98 | } |
| 99 | |
| 100 | static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! |
| 101 | get_subaction_path_from_pathcxx . . $ get_subaction_path_from_path(3fe54d38dfb1ce34).(struct oxr_loggercxx . . $ oxr_logger# *log, |
| 102 | struct oxr_instancecxx . . $ oxr_instance# *inst, |
| 103 | XrPathcxx . . $ XrPath# path, |
| 104 | enum oxr_subaction_pathcxx . . $ oxr_subaction_path# *out_subaction_path); |
| 105 | |
| 106 | static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! |
| 107 | interaction_profile_find_or_create_in_instancecxx . . $ interaction_profile_find_or_create_in_instance(df0f331d350e9062).(struct oxr_loggercxx . . $ oxr_logger# *log, |
| 108 | struct oxr_instancecxx . . $ oxr_instance# *inst, |
| 109 | XrPathcxx . . $ XrPath# path, |
| 110 | struct oxr_interaction_profilecxx . . $ oxr_interaction_profile# **out_p) |
| 111 | { |
| 112 | if (interaction_profile_find_in_instancecxx . . $ interaction_profile_find_in_instance(df0f331d350e9062).(log, inst, path, out_p)) { |
| 113 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 114 | } |
| 115 | |
| 116 | struct profile_templatecxx . . $ profile_template# *templ = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 117 | |
| 118 | for (size_t x = 0; x < OXR_BINDINGS_PROFILE_TEMPLATE_COUNTcxx . . $ `build/src/xrt/auxiliary/bindings/b_generated_bindings.h:23:9`!; x++) { |
| 119 | XrPathcxx . . $ XrPath# t_path = XR_NULL_PATHcxx . . $ `src/external/openxr_includes/openxr/openxr.h:53:9`!; |
| 120 | |
| 121 | oxr_path_get_or_createcxx . . $ oxr_path_get_or_create(ae436ac1536ffc4f).(log, inst, profile_templatescxx . . $ profile_templates.[x].pathcxx . . $ profile_template#path., strlencxx . . $ strlen(751346f8406fd082).(profile_templatescxx . . $ profile_templates.[x].pathcxx . . $ profile_template#path.), |
| 122 | &t_path); |
| 123 | if (t_path == path) { |
| 124 | templ = &profile_templatescxx . . $ profile_templates.[x]; |
| 125 | break; |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | if (templ == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 130 | *out_p = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 131 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 132 | } |
| 133 | |
| 134 | struct oxr_interaction_profilecxx . . $ oxr_interaction_profile# *p = U_TYPED_CALLOCcxx . . $ `src/xrt/auxiliary/util/u_misc.h:47:9`!(struct oxr_interaction_profile); |
| 135 | |
| 136 | p->xnamecxx . . $ oxr_interaction_profile#xname. = templ->namecxx . . $ profile_template#name.; |
| 137 | p->binding_countcxx . . $ oxr_interaction_profile#binding_count. = templ->binding_countcxx . . $ profile_template#binding_count.; |
| 138 | p->bindingscxx . . $ oxr_interaction_profile#bindings. = U_TYPED_ARRAY_CALLOCcxx . . $ `src/xrt/auxiliary/util/u_misc.h:58:9`!(struct oxr_binding, p->binding_count); |
| 139 | p->dpad_countcxx . . $ oxr_interaction_profile#dpad_count. = templ->dpad_countcxx . . $ profile_template#dpad_count.; |
| 140 | p->dpadscxx . . $ oxr_interaction_profile#dpads. = U_TYPED_ARRAY_CALLOCcxx . . $ `src/xrt/auxiliary/util/u_misc.h:58:9`!(struct oxr_dpad_emulation, p->dpad_count); |
| 141 | p->pathcxx . . $ oxr_interaction_profile#path. = path; |
| 142 | p->localized_namecxx . . $ oxr_interaction_profile#localized_name. = templ->localized_namecxx . . $ profile_template#localized_name.; |
| 143 | |
| 144 | for (size_t x = 0; x < templ->binding_countcxx . . $ profile_template#binding_count.; x++) { |
| 145 | struct binding_templatecxx . . $ binding_template# *t = &templ->bindingscxx . . $ profile_template#bindings.[x]; |
| 146 | struct oxr_bindingcxx . . $ oxr_binding# *b = &p->bindingscxx . . $ oxr_interaction_profile#bindings.[x]; |
| 147 | |
| 148 | XrPathcxx . . $ XrPath# subaction_path; |
| 149 | XrResultcxx . . $ XrResult# r = |
| 150 | oxr_path_get_or_createcxx . . $ oxr_path_get_or_create(ae436ac1536ffc4f).(log, inst, t->subaction_pathcxx . . $ binding_template#subaction_path., strlencxx . . $ strlen(751346f8406fd082).(t->subaction_pathcxx . . $ binding_template#subaction_path.), &subaction_path); |
| 151 | if (r != XR_SUCCESScxx . . $ XR_SUCCESS.) { |
| 152 | oxr_logcxx . . $ oxr_log(53d77e502024c659).(log, "Couldn't get subaction path %s\n", t->subaction_pathcxx . . $ binding_template#subaction_path.); |
| 153 | } |
| 154 | |
| 155 | if (!get_subaction_path_from_pathcxx . . $ get_subaction_path_from_path(3fe54d38dfb1ce34).(log, inst, subaction_path, &b->subaction_pathcxx . . $ oxr_binding#subaction_path.)) { |
| 156 | oxr_logcxx . . $ oxr_log(53d77e502024c659).(log, "Invalid subaction path %s\n", t->subaction_pathcxx . . $ binding_template#subaction_path.); |
| 157 | } |
| 158 | |
| 159 | b->localized_namecxx . . $ oxr_binding#localized_name. = t->localized_namecxx . . $ binding_template#localized_name.; |
| 160 | setup_pathscxx . . $ setup_paths(d6f1170c07958d10).(log, inst, t->pathscxx . . $ binding_template#paths., &b->pathscxx . . $ oxr_binding#paths., &b->path_countcxx . . $ oxr_binding#path_count.); |
| 161 | b->inputcxx . . $ oxr_binding#input. = t->inputcxx . . $ binding_template#input.; |
| 162 | b->dpad_activatecxx . . $ oxr_binding#dpad_activate. = t->dpad_activatecxx . . $ binding_template#dpad_activate.; |
| 163 | b->outputcxx . . $ oxr_binding#output. = t->outputcxx . . $ binding_template#output.; |
| 164 | } |
| 165 | |
| 166 | for (size_t x = 0; x < templ->dpad_countcxx . . $ profile_template#dpad_count.; x++) { |
| 167 | struct dpad_emulationcxx . . $ dpad_emulation# *t = &templ->dpadscxx . . $ profile_template#dpads.[x]; |
| 168 | struct oxr_dpad_emulationcxx . . $ oxr_dpad_emulation# *d = &p->dpadscxx . . $ oxr_interaction_profile#dpads.[x]; |
| 169 | |
| 170 | XrPathcxx . . $ XrPath# subaction_path; |
| 171 | XrResultcxx . . $ XrResult# r = |
| 172 | oxr_path_get_or_createcxx . . $ oxr_path_get_or_create(ae436ac1536ffc4f).(log, inst, t->subaction_pathcxx . . $ dpad_emulation#subaction_path., strlencxx . . $ strlen(751346f8406fd082).(t->subaction_pathcxx . . $ dpad_emulation#subaction_path.), &subaction_path); |
| 173 | if (r != XR_SUCCESScxx . . $ XR_SUCCESS.) { |
| 174 | oxr_logcxx . . $ oxr_log(53d77e502024c659).(log, "Couldn't get subaction path %s\n", t->subaction_pathcxx . . $ dpad_emulation#subaction_path.); |
| 175 | } |
| 176 | |
| 177 | if (!get_subaction_path_from_pathcxx . . $ get_subaction_path_from_path(3fe54d38dfb1ce34).(log, inst, subaction_path, &d->subaction_pathcxx . . $ oxr_dpad_emulation#subaction_path.)) { |
| 178 | oxr_logcxx . . $ oxr_log(53d77e502024c659).(log, "Invalid subaction path %s\n", t->subaction_pathcxx . . $ dpad_emulation#subaction_path.); |
| 179 | } |
| 180 | |
| 181 | setup_pathscxx . . $ setup_paths(d6f1170c07958d10).(log, inst, t->pathscxx . . $ dpad_emulation#paths., &d->pathscxx . . $ oxr_dpad_emulation#paths., &d->path_countcxx . . $ oxr_dpad_emulation#path_count.); |
| 182 | d->positioncxx . . $ oxr_dpad_emulation#position. = t->positioncxx . . $ dpad_emulation#position.; |
| 183 | d->activatecxx . . $ oxr_dpad_emulation#activate. = t->activatecxx . . $ dpad_emulation#activate.; |
| 184 | } |
| 185 | |
| 186 | // Add to the list of currently created interaction profiles. |
| 187 | U_ARRAY_REALLOC_OR_FREEcxx . . $ `src/xrt/auxiliary/util/u_misc.h:117:9`!(inst->profiles, struct oxr_interaction_profile *, (inst->profile_count + 1)); |
| 188 | inst->profilescxx . . $ oxr_instance#profiles.[inst->profile_countcxx . . $ oxr_instance#profile_count.++] = p; |
| 189 | |
| 190 | *out_p = p; |
| 191 | |
| 192 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 193 | } |
| 194 | |
| 195 | static void |
| 196 | reset_binding_keyscxx . . $ reset_binding_keys(edf9a567c927190f).(struct oxr_bindingcxx . . $ oxr_binding# *binding) |
| 197 | { |
| 198 | freecxx . . $ free(5d22bdacc48458e8).(binding->keyscxx . . $ oxr_binding#keys.); |
| 199 | freecxx . . $ free(5d22bdacc48458e8).(binding->preferred_binding_path_indexcxx . . $ oxr_binding#preferred_binding_path_index.); |
| 200 | binding->keyscxx . . $ oxr_binding#keys. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 201 | binding->preferred_binding_path_indexcxx . . $ oxr_binding#preferred_binding_path_index. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 202 | binding->key_countcxx . . $ oxr_binding#key_count. = 0; |
| 203 | } |
| 204 | |
| 205 | static void |
| 206 | reset_all_keyscxx . . $ reset_all_keys(3634e99448f7efff).(struct oxr_bindingcxx . . $ oxr_binding# *bindings, size_t binding_count) |
| 207 | { |
| 208 | for (size_t x = 0; x < binding_count; x++) { |
| 209 | reset_binding_keyscxx . . $ reset_binding_keys(edf9a567c927190f).(&bindings[x]); |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | static void |
| 214 | add_key_to_matching_bindingscxx . . $ add_key_to_matching_bindings(b004911ceaad2010).(struct oxr_bindingcxx . . $ oxr_binding# *bindings, size_t binding_count, XrPathcxx . . $ XrPath# path, uint32_tcxx . . $ uint32_t# key) |
| 215 | { |
| 216 | for (size_t x = 0; x < binding_count; x++) { |
| 217 | struct oxr_bindingcxx . . $ oxr_binding# *b = &bindings[x]; |
| 218 | |
| 219 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! found = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 220 | uint32_tcxx . . $ uint32_t# preferred_path_index; |
| 221 | for (uint32_tcxx . . $ uint32_t# y = 0; y < b->path_countcxx . . $ oxr_binding#path_count.; y++) { |
| 222 | if (b->pathscxx . . $ oxr_binding#paths.[y] == path) { |
| 223 | found = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 224 | preferred_path_index = y; |
| 225 | break; |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | if (!found) { |
| 230 | continue; |
| 231 | } |
| 232 | |
| 233 | U_ARRAY_REALLOC_OR_FREEcxx . . $ `src/xrt/auxiliary/util/u_misc.h:117:9`!(b->keys, uint32_t, (b->key_count + 1)); |
| 234 | U_ARRAY_REALLOC_OR_FREEcxx . . $ `src/xrt/auxiliary/util/u_misc.h:117:9`!(b->preferred_binding_path_index, uint32_t, (b->key_count + 1)); |
| 235 | b->preferred_binding_path_indexcxx . . $ oxr_binding#preferred_binding_path_index.[b->key_countcxx . . $ oxr_binding#key_count.] = preferred_path_index; |
| 236 | b->keyscxx . . $ oxr_binding#keys.[b->key_countcxx . . $ oxr_binding#key_count.++] = key; |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | static void |
| 241 | add_stringcxx . . $ add_string(cb62ad2ee4d1c54b).(char *temp, size_t max, ssize_tcxx . . $ ssize_t# *current, const char *str) |
| 242 | { |
| 243 | if (*current > 0) { |
| 244 | temp[(*current)++] = ' '; |
| 245 | } |
| 246 | |
| 247 | ssize_tcxx . . $ ssize_t# len = snprintfcxx . . $ snprintf(ea502d73e74c754c).(temp + *current, max - *current, "%s", str); |
| 248 | if (len > 0) { |
| 249 | *current += len; |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! |
| 254 | get_subaction_path_from_pathcxx . . $ get_subaction_path_from_path(3fe54d38dfb1ce34).(struct oxr_loggercxx . . $ oxr_logger# *log, |
| 255 | struct oxr_instancecxx . . $ oxr_instance# *inst, |
| 256 | XrPathcxx . . $ XrPath# path, |
| 257 | enum oxr_subaction_pathcxx . . $ oxr_subaction_path# *out_subaction_path) |
| 258 | { |
| 259 | const char *str = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 260 | size_t length = 0; |
| 261 | XrResultcxx . . $ XrResult# ret; |
| 262 | |
| 263 | ret = oxr_path_get_stringcxx . . $ oxr_path_get_string(aa55199e18d2d48b).(log, inst, path, &str, &length); |
| 264 | if (ret != XR_SUCCESScxx . . $ XR_SUCCESS.) { |
| 265 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 266 | } |
| 267 | |
| 268 | if (length >= 10 && strncmpcxx . . $ strncmp(fd278af2f295fa2e).("/user/head", str, 10) == 0) { |
| 269 | *out_subaction_path = OXR_SUB_ACTION_PATH_HEADcxx . . $ OXR_SUB_ACTION_PATH_HEAD.; |
| 270 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 271 | } |
| 272 | if (length >= 15 && strncmpcxx . . $ strncmp(fd278af2f295fa2e).("/user/hand/left", str, 15) == 0) { |
| 273 | *out_subaction_path = OXR_SUB_ACTION_PATH_LEFTcxx . . $ OXR_SUB_ACTION_PATH_LEFT.; |
| 274 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 275 | } |
| 276 | if (length >= 16 && strncmpcxx . . $ strncmp(fd278af2f295fa2e).("/user/hand/right", str, 16) == 0) { |
| 277 | *out_subaction_path = OXR_SUB_ACTION_PATH_RIGHTcxx . . $ OXR_SUB_ACTION_PATH_RIGHT.; |
| 278 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 279 | } |
| 280 | if (length >= 13 && strncmpcxx . . $ strncmp(fd278af2f295fa2e).("/user/gamepad", str, 13) == 0) { |
| 281 | *out_subaction_path = OXR_SUB_ACTION_PATH_GAMEPADcxx . . $ OXR_SUB_ACTION_PATH_GAMEPAD.; |
| 282 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 283 | } |
| 284 | if (length >= 14 && strncmpcxx . . $ strncmp(fd278af2f295fa2e).("/user/eyes_ext", str, 14) == 0) { |
| 285 | *out_subaction_path = OXR_SUB_ACTION_PATH_EYEScxx . . $ OXR_SUB_ACTION_PATH_EYES.; |
| 286 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 287 | } |
| 288 | |
| 289 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 290 | } |
| 291 | |
| 292 | static const char * |
| 293 | get_subaction_path_strcxx . . $ get_subaction_path_str(71f6732158f6cb9).(enum oxr_subaction_pathcxx . . $ oxr_subaction_path# subaction_path) |
| 294 | { |
| 295 | switch (subaction_path) { |
| 296 | case OXR_SUB_ACTION_PATH_HEADcxx . . $ OXR_SUB_ACTION_PATH_HEAD.: return "Head"; |
| 297 | case OXR_SUB_ACTION_PATH_LEFTcxx . . $ OXR_SUB_ACTION_PATH_LEFT.: return "Left"; |
| 298 | case OXR_SUB_ACTION_PATH_RIGHTcxx . . $ OXR_SUB_ACTION_PATH_RIGHT.: return "Right"; |
| 299 | case OXR_SUB_ACTION_PATH_GAMEPADcxx . . $ OXR_SUB_ACTION_PATH_GAMEPAD.: return "Gameped"; |
| 300 | default: return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 301 | } |
| 302 | } |
| 303 | |
| 304 | static XrPathcxx . . $ XrPath# |
| 305 | get_interaction_bound_to_sub_pathcxx . . $ get_interaction_bound_to_sub_path(badd374e22a8dc2b).(struct oxr_sessioncxx . . $ oxr_session# *sess, enum oxr_subaction_pathcxx . . $ oxr_subaction_path# subaction_path) |
| 306 | { |
| 307 | switch (subaction_path) { |
| 308 | #define OXR_PATH_MEMBERcxx . . $ `src/xrt/state_trackers/oxr/oxr_binding.c:308:9`!(lower, CAP, _) \ |
| 309 | case OXR_SUB_ACTION_PATH_##CAP: return sess->lower; |
| 310 | |
| 311 | OXR_FOR_EACH_VALID_SUBACTION_PATH_DETAILEDcxx . . $ `src/xrt/state_trackers/oxr/oxr_subaction.h:56:9`!(OXR_PATH_MEMBERcxx . . $ `src/xrt/state_trackers/oxr/oxr_binding.c:308:9`!) |
| 312 | #undef OXR_PATH_MEMBERcxx . . $ `src/xrt/state_trackers/oxr/oxr_binding.c:308:9`! |
| 313 | default: return XR_NULL_PATHcxx . . $ `src/external/openxr_includes/openxr/openxr.h:53:9`!; |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | static const char * |
| 318 | get_identifier_str_in_profilecxx . . $ get_identifier_str_in_profile(a82d3d1254cb8634).(struct oxr_loggercxx . . $ oxr_logger# *log, |
| 319 | struct oxr_instancecxx . . $ oxr_instance# *inst, |
| 320 | XrPathcxx . . $ XrPath# path, |
| 321 | struct oxr_interaction_profilecxx . . $ oxr_interaction_profile# *oip) |
| 322 | { |
| 323 | const char *str = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 324 | size_t length = 0; |
| 325 | XrResultcxx . . $ XrResult# ret; |
| 326 | |
| 327 | ret = oxr_path_get_stringcxx . . $ oxr_path_get_string(aa55199e18d2d48b).(log, inst, path, &str, &length); |
| 328 | if (ret != XR_SUCCESScxx . . $ XR_SUCCESS.) { |
| 329 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 330 | } |
| 331 | |
| 332 | for (size_t i = 0; i < oip->binding_countcxx . . $ oxr_interaction_profile#binding_count.; i++) { |
| 333 | struct oxr_bindingcxx . . $ oxr_binding# *binding = &oip->bindingscxx . . $ oxr_interaction_profile#bindings.[i]; |
| 334 | |
| 335 | for (size_t k = 0; k < binding->path_countcxx . . $ oxr_binding#path_count.; k++) { |
| 336 | if (binding->pathscxx . . $ oxr_binding#paths.[k] != path) { |
| 337 | continue; |
| 338 | } |
| 339 | str = binding->localized_namecxx . . $ oxr_binding#localized_name.; |
| 340 | i = oip->binding_countcxx . . $ oxr_interaction_profile#binding_count.; // Break the outer loop as well. |
| 341 | break; |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | return str; |
| 346 | } |
| 347 | |
| 348 | void |
| 349 | oxr_get_profile_for_device_namecxx . . $ oxr_get_profile_for_device_name(2fa4c6c203ca16b).(struct oxr_loggercxx . . $ oxr_logger# *log, |
| 350 | struct oxr_sessioncxx . . $ oxr_session# *sess, |
| 351 | enum xrt_device_namecxx . . $ xrt_device_name# name, |
| 352 | struct oxr_interaction_profilecxx . . $ oxr_interaction_profile# **out_p) |
| 353 | { |
| 354 | /* |
| 355 | * Map xrt_device_name to an interaction profile XrPath. |
| 356 | * Set *out_p to an oxr_interaction_profile if bindings for that interaction profile XrPath have been suggested. |
| 357 | */ |
| 358 | for (uint32_tcxx . . $ uint32_t# i = 0; i < ARRAY_SIZEcxx . . $ `src/xrt/include/xrt/xrt_compiler.h:30:9`!(profile_templates); i++) { |
| 359 | if (name == profile_templatescxx . . $ profile_templates.[i].namecxx . . $ profile_template#name.) { |
| 360 | interaction_profile_find_in_sessioncxx . . $ interaction_profile_find_in_session(d1b13e7cd69a6c43).(log, sess, profile_templatescxx . . $ profile_templates.[i].path_cachecxx . . $ profile_template#path_cache., out_p); |
| 361 | return; |
| 362 | } |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | |
| 367 | /* |
| 368 | * |
| 369 | * 'Exported' functions. |
| 370 | * |
| 371 | */ |
| 372 | |
| 373 | void |
| 374 | oxr_find_profile_for_devicecxx . . $ oxr_find_profile_for_device(4870fd0550d972ee).(struct oxr_loggercxx . . $ oxr_logger# *log, |
| 375 | struct oxr_sessioncxx . . $ oxr_session# *sess, |
| 376 | struct xrt_devicecxx . . $ xrt_device# *xdev, |
| 377 | struct oxr_interaction_profilecxx . . $ oxr_interaction_profile# **out_p) |
| 378 | { |
| 379 | if (xdev == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 380 | return; |
| 381 | } |
| 382 | |
| 383 | // Have bindings for this device's interaction profile been suggested? |
| 384 | oxr_get_profile_for_device_namecxx . . $ oxr_get_profile_for_device_name(2fa4c6c203ca16b).(log, sess, xdev->namecxx . . $ xrt_device#name., out_p); |
| 385 | if (*out_p != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 386 | return; |
| 387 | } |
| 388 | |
| 389 | // Check if bindings for any of this device's alternative interaction profiles have been suggested. |
| 390 | for (size_t i = 0; i < xdev->binding_profile_countcxx . . $ xrt_device#binding_profile_count.; i++) { |
| 391 | struct xrt_binding_profilecxx . . $ xrt_binding_profile# *xbp = &xdev->binding_profilescxx . . $ xrt_device#binding_profiles.[i]; |
| 392 | oxr_get_profile_for_device_namecxx . . $ oxr_get_profile_for_device_name(2fa4c6c203ca16b).(log, sess, xbp->namecxx . . $ xrt_binding_profile#name., out_p); |
| 393 | if (*out_p != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 394 | return; |
| 395 | } |
| 396 | } |
| 397 | } |
| 398 | |
| 399 | void |
| 400 | oxr_binding_find_bindings_from_keycxx . . $ oxr_binding_find_bindings_from_key(c273df57d83dc3b3).(struct oxr_loggercxx . . $ oxr_logger# *log, |
| 401 | struct oxr_interaction_profilecxx . . $ oxr_interaction_profile# *p, |
| 402 | uint32_tcxx . . $ uint32_t# key, |
| 403 | size_t max_bounding_count, |
| 404 | struct oxr_bindingcxx . . $ oxr_binding# **bindings, |
| 405 | size_t *out_binding_count) |
| 406 | { |
| 407 | if (p == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 408 | *out_binding_count = 0; |
| 409 | return; |
| 410 | } |
| 411 | |
| 412 | // How many bindings are we returning? |
| 413 | size_t binding_count = 0; |
| 414 | |
| 415 | /* |
| 416 | * Loop over all app provided bindings for this profile |
| 417 | * and return those matching the action. |
| 418 | */ |
| 419 | for (size_t y = 0; y < p->binding_countcxx . . $ oxr_interaction_profile#binding_count.; y++) { |
| 420 | struct oxr_bindingcxx . . $ oxr_binding# *b = &p->bindingscxx . . $ oxr_interaction_profile#bindings.[y]; |
| 421 | |
| 422 | for (size_t z = 0; z < b->key_countcxx . . $ oxr_binding#key_count.; z++) { |
| 423 | if (b->keyscxx . . $ oxr_binding#keys.[z] == key) { |
| 424 | bindings[binding_count++] = b; |
| 425 | break; |
| 426 | } |
| 427 | } |
| 428 | |
| 429 | //! @todo Should return total count instead of fixed max. |
| 430 | if (binding_count >= max_bounding_count) { |
| 431 | oxr_warncxx . . $ oxr_warn(53d77e502024c659).(log, "Internal limit reached, action has too many bindings!"); |
| 432 | break; |
| 433 | } |
| 434 | } |
| 435 | |
| 436 | assertcxx . . $ `/usr/include/assert.h:118:11`!(binding_count <= max_bounding_count); |
| 437 | |
| 438 | *out_binding_count = binding_count; |
| 439 | } |
| 440 | |
| 441 | struct oxr_interaction_profilecxx . . $ oxr_interaction_profile# * |
| 442 | oxr_clone_profilecxx . . $ oxr_clone_profile(c4a988a5ba0c6ec6).(const struct oxr_interaction_profilecxx . . $ oxr_interaction_profile# *src_profile) |
| 443 | { |
| 444 | if (src_profile == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 445 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 446 | |
| 447 | struct oxr_interaction_profilecxx . . $ oxr_interaction_profile# *dst_profile = U_TYPED_CALLOCcxx . . $ `src/xrt/auxiliary/util/u_misc.h:47:9`!(struct oxr_interaction_profile); |
| 448 | |
| 449 | *dst_profile = *src_profile; |
| 450 | |
| 451 | dst_profile->binding_countcxx . . $ oxr_interaction_profile#binding_count. = 0; |
| 452 | dst_profile->bindingscxx . . $ oxr_interaction_profile#bindings. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 453 | if (src_profile->bindingscxx . . $ oxr_interaction_profile#bindings. && src_profile->binding_countcxx . . $ oxr_interaction_profile#binding_count. > 0) { |
| 454 | |
| 455 | dst_profile->binding_countcxx . . $ oxr_interaction_profile#binding_count. = src_profile->binding_countcxx . . $ oxr_interaction_profile#binding_count.; |
| 456 | dst_profile->bindingscxx . . $ oxr_interaction_profile#bindings. = U_TYPED_ARRAY_CALLOCcxx . . $ `src/xrt/auxiliary/util/u_misc.h:58:9`!(struct oxr_binding, src_profile->binding_count); |
| 457 | |
| 458 | for (size_t binding_idx = 0; binding_idx < src_profile->binding_countcxx . . $ oxr_interaction_profile#binding_count.; ++binding_idx) { |
| 459 | struct oxr_bindingcxx . . $ oxr_binding# *dst_binding = dst_profile->bindingscxx . . $ oxr_interaction_profile#bindings. + binding_idx; |
| 460 | const struct oxr_bindingcxx . . $ oxr_binding# *src_binding = src_profile->bindingscxx . . $ oxr_interaction_profile#bindings. + binding_idx; |
| 461 | |
| 462 | *dst_binding = *src_binding; |
| 463 | |
| 464 | dst_binding->path_countcxx . . $ oxr_binding#path_count. = 0; |
| 465 | dst_binding->pathscxx . . $ oxr_binding#paths. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 466 | if (src_binding->pathscxx . . $ oxr_binding#paths. && src_binding->path_countcxx . . $ oxr_binding#path_count. > 0) { |
| 467 | dst_binding->path_countcxx . . $ oxr_binding#path_count. = src_binding->path_countcxx . . $ oxr_binding#path_count.; |
| 468 | dst_binding->pathscxx . . $ oxr_binding#paths. = U_TYPED_ARRAY_CALLOCcxx . . $ `src/xrt/auxiliary/util/u_misc.h:58:9`!(XrPath, src_binding->path_count); |
| 469 | memcpycxx . . $ memcpy(cc817cb175f282d).(dst_binding->pathscxx . . $ oxr_binding#paths., src_binding->pathscxx . . $ oxr_binding#paths., |
| 470 | sizeof(XrPathcxx . . $ XrPath#) * src_binding->path_countcxx . . $ oxr_binding#path_count.); |
| 471 | } |
| 472 | |
| 473 | dst_binding->key_countcxx . . $ oxr_binding#key_count. = 0; |
| 474 | dst_binding->keyscxx . . $ oxr_binding#keys. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 475 | dst_binding->preferred_binding_path_indexcxx . . $ oxr_binding#preferred_binding_path_index. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 476 | if (src_binding->keyscxx . . $ oxr_binding#keys. && src_binding->key_countcxx . . $ oxr_binding#key_count. > 0) { |
| 477 | dst_binding->key_countcxx . . $ oxr_binding#key_count. = src_binding->key_countcxx . . $ oxr_binding#key_count.; |
| 478 | dst_binding->keyscxx . . $ oxr_binding#keys. = U_TYPED_ARRAY_CALLOCcxx . . $ `src/xrt/auxiliary/util/u_misc.h:58:9`!(uint32_t, src_binding->key_count); |
| 479 | memcpycxx . . $ memcpy(cc817cb175f282d).(dst_binding->keyscxx . . $ oxr_binding#keys., src_binding->keyscxx . . $ oxr_binding#keys., sizeof(uint32_tcxx . . $ uint32_t#) * src_binding->key_countcxx . . $ oxr_binding#key_count.); |
| 480 | } |
| 481 | if (src_binding->preferred_binding_path_indexcxx . . $ oxr_binding#preferred_binding_path_index. && src_binding->key_countcxx . . $ oxr_binding#key_count. > 0) { |
| 482 | assertcxx . . $ `/usr/include/assert.h:118:11`!(dst_binding->key_count == src_binding->key_count); |
| 483 | dst_binding->preferred_binding_path_indexcxx . . $ oxr_binding#preferred_binding_path_index. = |
| 484 | U_TYPED_ARRAY_CALLOCcxx . . $ `src/xrt/auxiliary/util/u_misc.h:58:9`!(uint32_t, src_binding->key_count); |
| 485 | memcpycxx . . $ memcpy(cc817cb175f282d).(dst_binding->preferred_binding_path_indexcxx . . $ oxr_binding#preferred_binding_path_index., |
| 486 | src_binding->preferred_binding_path_indexcxx . . $ oxr_binding#preferred_binding_path_index., |
| 487 | sizeof(uint32_tcxx . . $ uint32_t#) * src_binding->key_countcxx . . $ oxr_binding#key_count.); |
| 488 | } |
| 489 | } |
| 490 | } |
| 491 | |
| 492 | dst_profile->dpad_countcxx . . $ oxr_interaction_profile#dpad_count. = 0; |
| 493 | dst_profile->dpadscxx . . $ oxr_interaction_profile#dpads. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 494 | if (src_profile->dpadscxx . . $ oxr_interaction_profile#dpads. && src_profile->dpad_countcxx . . $ oxr_interaction_profile#dpad_count. > 0) { |
| 495 | |
| 496 | dst_profile->dpad_countcxx . . $ oxr_interaction_profile#dpad_count. = src_profile->dpad_countcxx . . $ oxr_interaction_profile#dpad_count.; |
| 497 | dst_profile->dpadscxx . . $ oxr_interaction_profile#dpads. = U_TYPED_ARRAY_CALLOCcxx . . $ `src/xrt/auxiliary/util/u_misc.h:58:9`!(struct oxr_dpad_emulation, src_profile->dpad_count); |
| 498 | |
| 499 | for (size_t dpad_index = 0; dpad_index < src_profile->dpad_countcxx . . $ oxr_interaction_profile#dpad_count.; ++dpad_index) { |
| 500 | struct oxr_dpad_emulationcxx . . $ oxr_dpad_emulation# *dst_dpad = dst_profile->dpadscxx . . $ oxr_interaction_profile#dpads. + dpad_index; |
| 501 | const struct oxr_dpad_emulationcxx . . $ oxr_dpad_emulation# *src_dpad = src_profile->dpadscxx . . $ oxr_interaction_profile#dpads. + dpad_index; |
| 502 | |
| 503 | *dst_dpad = *src_dpad; |
| 504 | |
| 505 | dst_dpad->path_countcxx . . $ oxr_dpad_emulation#path_count. = 0; |
| 506 | dst_dpad->pathscxx . . $ oxr_dpad_emulation#paths. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 507 | if (src_dpad->pathscxx . . $ oxr_dpad_emulation#paths. && src_dpad->path_countcxx . . $ oxr_dpad_emulation#path_count. > 0) { |
| 508 | dst_dpad->path_countcxx . . $ oxr_dpad_emulation#path_count. = src_dpad->path_countcxx . . $ oxr_dpad_emulation#path_count.; |
| 509 | dst_dpad->pathscxx . . $ oxr_dpad_emulation#paths. = U_TYPED_ARRAY_CALLOCcxx . . $ `src/xrt/auxiliary/util/u_misc.h:58:9`!(XrPath, src_dpad->path_count); |
| 510 | memcpycxx . . $ memcpy(cc817cb175f282d).(dst_dpad->pathscxx . . $ oxr_dpad_emulation#paths., src_dpad->pathscxx . . $ oxr_dpad_emulation#paths., sizeof(XrPathcxx . . $ XrPath#) * src_dpad->path_countcxx . . $ oxr_dpad_emulation#path_count.); |
| 511 | } |
| 512 | } |
| 513 | } |
| 514 | |
| 515 | const struct oxr_dpad_statecxx . . $ oxr_dpad_state# empty_dpad_state = {.uhi = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!}; |
| 516 | dst_profile->dpad_statecxx . . $ oxr_interaction_profile#dpad_state. = empty_dpad_state; |
| 517 | oxr_dpad_state_clonecxx . . $ oxr_dpad_state_clone(7d605ac16f515010).(&dst_profile->dpad_statecxx . . $ oxr_interaction_profile#dpad_state., &src_profile->dpad_statecxx . . $ oxr_interaction_profile#dpad_state.); |
| 518 | |
| 519 | return dst_profile; |
| 520 | } |
| 521 | |
| 522 | static void |
| 523 | oxr_destroy_profilescxx . . $ oxr_destroy_profiles(c0afc69fc6a4dcc7).(struct oxr_interaction_profilecxx . . $ oxr_interaction_profile# **profiles, const size_t profile_count) |
| 524 | { |
| 525 | if (profiles == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 526 | return; |
| 527 | |
| 528 | for (size_t x = 0; x < profile_count; x++) { |
| 529 | struct oxr_interaction_profilecxx . . $ oxr_interaction_profile# *p = profiles[x]; |
| 530 | |
| 531 | for (size_t y = 0; y < p->binding_countcxx . . $ oxr_interaction_profile#binding_count.; y++) { |
| 532 | struct oxr_bindingcxx . . $ oxr_binding# *b = &p->bindingscxx . . $ oxr_interaction_profile#bindings.[y]; |
| 533 | |
| 534 | reset_binding_keyscxx . . $ reset_binding_keys(edf9a567c927190f).(b); |
| 535 | freecxx . . $ free(5d22bdacc48458e8).(b->pathscxx . . $ oxr_binding#paths.); |
| 536 | b->pathscxx . . $ oxr_binding#paths. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 537 | b->path_countcxx . . $ oxr_binding#path_count. = 0; |
| 538 | b->inputcxx . . $ oxr_binding#input. = 0; |
| 539 | b->outputcxx . . $ oxr_binding#output. = 0; |
| 540 | } |
| 541 | |
| 542 | for (size_t y = 0; y < p->dpad_countcxx . . $ oxr_interaction_profile#dpad_count.; ++y) { |
| 543 | struct oxr_dpad_emulationcxx . . $ oxr_dpad_emulation# *d = &p->dpadscxx . . $ oxr_interaction_profile#dpads.[y]; |
| 544 | freecxx . . $ free(5d22bdacc48458e8).(d->pathscxx . . $ oxr_dpad_emulation#paths.); |
| 545 | } |
| 546 | |
| 547 | freecxx . . $ free(5d22bdacc48458e8).(p->bindingscxx . . $ oxr_interaction_profile#bindings.); |
| 548 | p->bindingscxx . . $ oxr_interaction_profile#bindings. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 549 | p->binding_countcxx . . $ oxr_interaction_profile#binding_count. = 0; |
| 550 | |
| 551 | freecxx . . $ free(5d22bdacc48458e8).(p->dpadscxx . . $ oxr_interaction_profile#dpads.); |
| 552 | |
| 553 | oxr_dpad_state_deinitcxx . . $ oxr_dpad_state_deinit(9969bde19770e251).(&p->dpad_statecxx . . $ oxr_interaction_profile#dpad_state.); |
| 554 | |
| 555 | freecxx . . $ free(5d22bdacc48458e8).(p); |
| 556 | } |
| 557 | |
| 558 | freecxx . . $ free(5d22bdacc48458e8).(profiles); |
| 559 | } |
| 560 | |
| 561 | void |
| 562 | oxr_binding_destroy_allcxx . . $ oxr_binding_destroy_all(5171e90bd7167858).(struct oxr_loggercxx . . $ oxr_logger# *log, struct oxr_instancecxx . . $ oxr_instance# *inst) |
| 563 | { |
| 564 | oxr_destroy_profilescxx . . $ oxr_destroy_profiles(c0afc69fc6a4dcc7).(inst->profilescxx . . $ oxr_instance#profiles., inst->profile_countcxx . . $ oxr_instance#profile_count.); |
| 565 | inst->profilescxx . . $ oxr_instance#profiles. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 566 | inst->profile_countcxx . . $ oxr_instance#profile_count. = 0; |
| 567 | } |
| 568 | |
| 569 | void |
| 570 | oxr_session_binding_destroy_allcxx . . $ oxr_session_binding_destroy_all(4784bce4ec530d28).(struct oxr_loggercxx . . $ oxr_logger# *log, struct oxr_sessioncxx . . $ oxr_session# *sess) |
| 571 | { |
| 572 | oxr_destroy_profilescxx . . $ oxr_destroy_profiles(c0afc69fc6a4dcc7).(sess->profiles_on_attachmentcxx . . $ oxr_session#profiles_on_attachment., sess->profiles_on_attachment_sizecxx . . $ oxr_session#profiles_on_attachment_size.); |
| 573 | sess->profiles_on_attachmentcxx . . $ oxr_session#profiles_on_attachment. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 574 | sess->profiles_on_attachment_sizecxx . . $ oxr_session#profiles_on_attachment_size. = 0; |
| 575 | } |
| 576 | |
| 577 | /* |
| 578 | * |
| 579 | * Client functions. |
| 580 | * |
| 581 | */ |
| 582 | |
| 583 | XrResultcxx . . $ XrResult# |
| 584 | oxr_action_suggest_interaction_profile_bindingscxx . . $ oxr_action_suggest_interaction_profile_bindings(9877a02207faa932).(struct oxr_loggercxx . . $ oxr_logger# *log, |
| 585 | struct oxr_instancecxx . . $ oxr_instance# *inst, |
| 586 | const XrInteractionProfileSuggestedBindingcxx . . $ XrInteractionProfileSuggestedBinding# *suggestedBindings, |
| 587 | struct oxr_dpad_statecxx . . $ oxr_dpad_state# *dpad_state) |
| 588 | { |
| 589 | struct oxr_interaction_profilecxx . . $ oxr_interaction_profile# *p = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 590 | |
| 591 | // Path already validated. |
| 592 | XrPathcxx . . $ XrPath# path = suggestedBindings->interactionProfilecxx . . $ XrInteractionProfileSuggestedBinding#interactionProfile.; |
| 593 | interaction_profile_find_or_create_in_instancecxx . . $ interaction_profile_find_or_create_in_instance(df0f331d350e9062).(log, inst, path, &p); |
| 594 | |
| 595 | // Valid path, but not used. |
| 596 | if (p == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 597 | goto out; |
| 598 | } |
| 599 | |
| 600 | struct oxr_bindingcxx . . $ oxr_binding# *bindings = p->bindingscxx . . $ oxr_interaction_profile#bindings.; |
| 601 | size_t binding_count = p->binding_countcxx . . $ oxr_interaction_profile#binding_count.; |
| 602 | |
| 603 | // Everything is now valid, reset the keys. |
| 604 | reset_all_keyscxx . . $ reset_all_keys(3634e99448f7efff).(bindings, binding_count); |
| 605 | // Transfer ownership of dpad state to profile |
| 606 | oxr_dpad_state_deinitcxx . . $ oxr_dpad_state_deinit(9969bde19770e251).(&p->dpad_statecxx . . $ oxr_interaction_profile#dpad_state.); |
| 607 | p->dpad_statecxx . . $ oxr_interaction_profile#dpad_state. = *dpad_state; |
| 608 | U_ZEROcxx . . $ `src/xrt/auxiliary/util/u_misc.h:68:9`!(dpad_state); |
| 609 | |
| 610 | for (size_t i = 0; i < suggestedBindings->countSuggestedBindingscxx . . $ XrInteractionProfileSuggestedBinding#countSuggestedBindings.; i++) { |
| 611 | const XrActionSuggestedBindingcxx . . $ XrActionSuggestedBinding# *s = &suggestedBindings->suggestedBindingscxx . . $ XrInteractionProfileSuggestedBinding#suggestedBindings.[i]; |
| 612 | struct oxr_actioncxx . . $ oxr_action# *act = XRT_CAST_OXR_HANDLE_TO_PTRcxx . . $ `src/xrt/state_trackers/oxr/oxr_objects.h:86:9`!(struct oxr_action *, s->action); |
| 613 | |
| 614 | add_key_to_matching_bindingscxx . . $ add_key_to_matching_bindings(b004911ceaad2010).(bindings, binding_count, s->bindingcxx . . $ XrActionSuggestedBinding#binding., act->act_keycxx . . $ oxr_action#act_key.); |
| 615 | } |
| 616 | |
| 617 | out: |
| 618 | oxr_dpad_state_deinitcxx . . $ oxr_dpad_state_deinit(9969bde19770e251).(dpad_state); // if it hasn't been moved |
| 619 | |
| 620 | return XR_SUCCESScxx . . $ XR_SUCCESS.; |
| 621 | } |
| 622 | |
| 623 | XrResultcxx . . $ XrResult# |
| 624 | oxr_action_get_current_interaction_profilecxx . . $ oxr_action_get_current_interaction_profile(1fe65a5e8179d809).(struct oxr_loggercxx . . $ oxr_logger# *log, |
| 625 | struct oxr_sessioncxx . . $ oxr_session# *sess, |
| 626 | XrPathcxx . . $ XrPath# topLevelUserPath, |
| 627 | XrInteractionProfileStatecxx . . $ XrInteractionProfileState# *interactionProfile) |
| 628 | { |
| 629 | struct oxr_instancecxx . . $ oxr_instance# *inst = sess->syscxx . . $ oxr_session#sys.->instcxx . . $ oxr_system#inst.; |
| 630 | |
| 631 | if (sess->act_set_attachmentscxx . . $ oxr_session#act_set_attachments. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 632 | return oxr_errorcxx . . $ oxr_error(1140daf53870d718).(log, XR_ERROR_ACTIONSET_NOT_ATTACHEDcxx . . $ XR_ERROR_ACTIONSET_NOT_ATTACHED., |
| 633 | "xrAttachSessionActionSets has not been " |
| 634 | "called on this session."); |
| 635 | } |
| 636 | #define IDENTIFY_TOP_LEVEL_PATHcxx . . $ `src/xrt/state_trackers/oxr/oxr_binding.c:636:9`!(X) \ |
| 637 | if (topLevelUserPath == inst->path_cache.X) { \ |
| 638 | interactionProfile->interactionProfile = sess->X; \ |
| 639 | } else |
| 640 | |
| 641 | OXR_FOR_EACH_VALID_SUBACTION_PATHcxx . . $ `src/xrt/state_trackers/oxr/oxr_subaction.h:23:9`!(IDENTIFY_TOP_LEVEL_PATHcxx . . $ `src/xrt/state_trackers/oxr/oxr_binding.c:636:9`!) |
| 642 | { |
| 643 | // else clause |
| 644 | return oxr_errorcxx . . $ oxr_error(1140daf53870d718).(log, XR_ERROR_RUNTIME_FAILUREcxx . . $ XR_ERROR_RUNTIME_FAILURE., "Top level path not handled?!"); |
| 645 | } |
| 646 | #undef IDENTIFY_TOP_LEVEL_PATHcxx . . $ `src/xrt/state_trackers/oxr/oxr_binding.c:636:9`! |
| 647 | return XR_SUCCESScxx . . $ XR_SUCCESS.; |
| 648 | } |
| 649 | |
| 650 | XrResultcxx . . $ XrResult# |
| 651 | oxr_action_get_input_source_localized_namecxx . . $ oxr_action_get_input_source_localized_name(6b1211d1b5c39675).(struct oxr_loggercxx . . $ oxr_logger# *log, |
| 652 | struct oxr_sessioncxx . . $ oxr_session# *sess, |
| 653 | const XrInputSourceLocalizedNameGetInfocxx . . $ XrInputSourceLocalizedNameGetInfo# *getInfo, |
| 654 | uint32_tcxx . . $ uint32_t# bufferCapacityInput, |
| 655 | uint32_tcxx . . $ uint32_t# *bufferCountOutput, |
| 656 | char *buffer) |
| 657 | { |
| 658 | char temp[1024] = {0}; |
| 659 | ssize_tcxx . . $ ssize_t# current = 0; |
| 660 | enum oxr_subaction_pathcxx . . $ oxr_subaction_path# subaction_path = 0; |
| 661 | |
| 662 | if (!get_subaction_path_from_pathcxx . . $ get_subaction_path_from_path(3fe54d38dfb1ce34).(log, sess->syscxx . . $ oxr_session#sys.->instcxx . . $ oxr_system#inst., getInfo->sourcePathcxx . . $ XrInputSourceLocalizedNameGetInfo#sourcePath., &subaction_path)) { |
| 663 | return oxr_errorcxx . . $ oxr_error(1140daf53870d718).(log, XR_ERROR_VALIDATION_FAILUREcxx . . $ XR_ERROR_VALIDATION_FAILURE., |
| 664 | "(getInfo->sourcePath) doesn't start with a " |
| 665 | "valid subaction_path"); |
| 666 | } |
| 667 | |
| 668 | // Get the interaction profile bound to this subaction_path. |
| 669 | XrPathcxx . . $ XrPath# path = get_interaction_bound_to_sub_pathcxx . . $ get_interaction_bound_to_sub_path(badd374e22a8dc2b).(sess, subaction_path); |
| 670 | if (path == XR_NULL_PATHcxx . . $ `src/external/openxr_includes/openxr/openxr.h:53:9`!) { |
| 671 | return oxr_errorcxx . . $ oxr_error(1140daf53870d718).(log, XR_ERROR_VALIDATION_FAILUREcxx . . $ XR_ERROR_VALIDATION_FAILURE., |
| 672 | "(getInfo->sourcePath) no interaction profile " |
| 673 | "bound to subaction path"); |
| 674 | } |
| 675 | |
| 676 | // Find the interaction profile. |
| 677 | struct oxr_interaction_profilecxx . . $ oxr_interaction_profile# *oip = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 678 | //! @todo: If we ever rebind a profile that has not been suggested by the client, it will not be found. |
| 679 | interaction_profile_find_in_sessioncxx . . $ interaction_profile_find_in_session(d1b13e7cd69a6c43).(log, sess, path, &oip); |
| 680 | if (oip == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 681 | return oxr_errorcxx . . $ oxr_error(1140daf53870d718).(log, XR_ERROR_RUNTIME_FAILUREcxx . . $ XR_ERROR_RUNTIME_FAILURE., "no interaction profile found"); |
| 682 | } |
| 683 | |
| 684 | // Add which hand to use. |
| 685 | if (getInfo->whichComponentscxx . . $ XrInputSourceLocalizedNameGetInfo#whichComponents. & XR_INPUT_SOURCE_LOCALIZED_NAME_USER_PATH_BITcxx . . $ XR_INPUT_SOURCE_LOCALIZED_NAME_USER_PATH_BIT.) { |
| 686 | add_stringcxx . . $ add_string(cb62ad2ee4d1c54b).(temp, sizeof(temp), ¤t, get_subaction_path_strcxx . . $ get_subaction_path_str(71f6732158f6cb9).(subaction_path)); |
| 687 | } |
| 688 | |
| 689 | // Add a human readable and localized name of the device. |
| 690 | if ((getInfo->whichComponentscxx . . $ XrInputSourceLocalizedNameGetInfo#whichComponents. & XR_INPUT_SOURCE_LOCALIZED_NAME_INTERACTION_PROFILE_BITcxx . . $ XR_INPUT_SOURCE_LOCALIZED_NAME_INTERACTION_PROFILE_BIT.) != 0) { |
| 691 | add_stringcxx . . $ add_string(cb62ad2ee4d1c54b).(temp, sizeof(temp), ¤t, oip->localized_namecxx . . $ oxr_interaction_profile#localized_name.); |
| 692 | } |
| 693 | |
| 694 | //! @todo This implementation is very very very inelegant. |
| 695 | if ((getInfo->whichComponentscxx . . $ XrInputSourceLocalizedNameGetInfo#whichComponents. & XR_INPUT_SOURCE_LOCALIZED_NAME_COMPONENT_BITcxx . . $ XR_INPUT_SOURCE_LOCALIZED_NAME_COMPONENT_BIT.) != 0) { |
| 696 | /* |
| 697 | * The preceding enum is misnamed: it should be called identifier |
| 698 | * instead of component. But, this is a spec bug. |
| 699 | */ |
| 700 | add_stringcxx . . $ add_string(cb62ad2ee4d1c54b).(temp, sizeof(temp), ¤t, |
| 701 | get_identifier_str_in_profilecxx . . $ get_identifier_str_in_profile(a82d3d1254cb8634).(log, sess->syscxx . . $ oxr_session#sys.->instcxx . . $ oxr_system#inst., getInfo->sourcePathcxx . . $ XrInputSourceLocalizedNameGetInfo#sourcePath., oip)); |
| 702 | } |
| 703 | |
| 704 | // Include the null character. |
| 705 | current += 1; |
| 706 | |
| 707 | OXR_TWO_CALL_HELPERcxx . . $ `src/xrt/state_trackers/oxr/oxr_two_call.h:18:9`!(log, bufferCapacityInput, bufferCountOutput, buffer, (size_t)current, temp, |
| 708 | oxr_session_success_result(sess)); |
| 709 | } |