The open source OpenXR runtime

st/oxr: Fix regression caused by parent binding fix

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2476>

+19 -13
+19 -13
src/xrt/state_trackers/oxr/oxr_binding.c
··· 220 220 } 221 221 222 222 static bool 223 - add_by_component(struct oxr_logger *log, 224 - struct oxr_instance *inst, 225 - struct oxr_binding *bindings, 226 - size_t binding_count, 227 - XrPath path, 228 - struct oxr_action *act, 229 - const char **components, 230 - size_t component_count) 223 + try_add_by_component(struct oxr_logger *log, 224 + struct oxr_instance *inst, 225 + struct oxr_binding *bindings, 226 + size_t binding_count, 227 + XrPath path, 228 + struct oxr_action *act, 229 + const char **components, 230 + size_t component_count) 231 231 { 232 232 for (uint32_t component_index = 0; component_index < component_count; component_index++) { 233 233 // once we found everything for a component like click we don't want to keep going to add to a component ··· 275 275 return true; 276 276 } 277 277 } 278 - return true; 278 + return false; 279 279 } 280 280 281 281 static bool ··· 326 326 size_t len; 327 327 oxr_path_get_string(log, inst, path, &str, &len); 328 328 329 - // check if we need to select a child 329 + bool added = false; 330 + 331 + // check if we need to select a child, e.g. suggested str is */trigger for a bool action, or */trigger for a 332 + // float action 330 333 if (xr_act_type == XR_ACTION_TYPE_BOOLEAN_INPUT && !ends_with(str, "/click") && !ends_with(str, "/touch")) { 331 334 const char *components[2] = {"click", "value"}; 332 - add_by_component(log, inst, bindings, binding_count, path, act, components, 2); 335 + added = try_add_by_component(log, inst, bindings, binding_count, path, act, components, 2); 333 336 } else if (xr_act_type == XR_ACTION_TYPE_FLOAT_INPUT && !ends_with(str, "/value") && 334 337 !ends_with(str, "/click")) { 335 338 const char *components[2] = {"value", "click"}; 336 - add_by_component(log, inst, bindings, binding_count, path, act, components, 2); 337 - } else { 339 + added = try_add_by_component(log, inst, bindings, binding_count, path, act, components, 2); 340 + } 341 + 342 + // if the suggested str was not one of the ones that require us to select a child, fall back to the default case 343 + if (!added) { 338 344 add_direct(log, inst, bindings, binding_count, path, act); 339 345 } 340 346 }