The open source OpenXR runtime

a/bindings: Remove xrt_[input|output]_name_string functions

These were buggy anyways as inputs and outputs not referred to by the
json wouldn't be listed, for instance all the PS Sense inputs. Replace
usage with u_str_xrt_input_name instead.

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

authored by

Jakob Bornecrantz and committed by
Marge Bot
57a269a1 c95beed6

+7 -42
-17
src/xrt/auxiliary/bindings/b_generated_bindings_helpers.c.template
··· 14 15 // clang-format off 16 17 - const char * 18 - xrt_input_name_string(enum xrt_input_name input) { 19 - switch(input) 20 - { 21 - $xrt_input_name_string_switch 22 - } 23 - } 24 - 25 enum xrt_input_name 26 xrt_input_name_enum(const char *input) 27 { 28 $xrt_input_name_enum_content 29 - } 30 - 31 - const char * 32 - xrt_output_name_string(enum xrt_output_name output) 33 - { 34 - switch(output) 35 - { 36 - $xrt_output_name_string_switch 37 - } 38 } 39 40 enum xrt_output_name
··· 14 15 // clang-format off 16 17 enum xrt_input_name 18 xrt_input_name_enum(const char *input) 19 { 20 $xrt_input_name_enum_content 21 } 22 23 enum xrt_output_name
-6
src/xrt/auxiliary/bindings/b_generated_bindings_helpers.h
··· 17 extern "C" { 18 #endif 19 20 - const char * 21 - xrt_input_name_string(enum xrt_input_name input); 22 - 23 enum xrt_input_name 24 xrt_input_name_enum(const char *input); 25 - 26 - const char * 27 - xrt_output_name_string(enum xrt_output_name output); 28 29 enum xrt_output_name 30 xrt_output_name_enum(const char *output);
··· 17 extern "C" { 18 #endif 19 20 enum xrt_input_name 21 xrt_input_name_enum(const char *input); 22 23 enum xrt_output_name 24 xrt_output_name_enum(const char *output);
-12
src/xrt/auxiliary/bindings/bindings.py
··· 588 inputs.add("XRT_INPUT_HT_CONFORMING_RIGHT") 589 inputs.add("XRT_INPUT_GENERIC_TRACKER_POSE") 590 591 - xrt_input_name_string_switch = '\n'.join( 592 - [(f'\tcase {input}: return "{input}";') for input in sorted(inputs)] 593 - ) 594 - xrt_input_name_string_switch += (f'\n\tdefault: return "UNKNOWN";') 595 - 596 xrt_input_name_enum_content = '\n'.join( 597 [f'\tif(strcmp("{input}", input) == 0) return {input};' for input in sorted(inputs)] 598 ) 599 xrt_input_name_enum_content += f'\n\treturn XRT_INPUT_GENERIC_TRACKER_POSE;' 600 601 - xrt_output_name_string_switch = '\n'.join( 602 - [(f'\tcase {output}: return "{output}";') for output in sorted(outputs)] 603 - ) 604 - xrt_output_name_string_switch+= f'\n\tdefault: return "UNKNOWN";' 605 - 606 xrt_output_name_enum_content = '\n'.join( 607 [f'\tif(strcmp("{output}", output) == 0) return {output};' for output in sorted(outputs)] 608 ) ··· 614 615 with open(file, "w") as f: 616 filled = src.substitute( 617 - xrt_input_name_string_switch=xrt_input_name_string_switch, 618 xrt_input_name_enum_content=xrt_input_name_enum_content, 619 - xrt_output_name_string_switch=xrt_output_name_string_switch, 620 xrt_output_name_enum_content=xrt_output_name_enum_content 621 ) 622 f.write(filled)
··· 588 inputs.add("XRT_INPUT_HT_CONFORMING_RIGHT") 589 inputs.add("XRT_INPUT_GENERIC_TRACKER_POSE") 590 591 xrt_input_name_enum_content = '\n'.join( 592 [f'\tif(strcmp("{input}", input) == 0) return {input};' for input in sorted(inputs)] 593 ) 594 xrt_input_name_enum_content += f'\n\treturn XRT_INPUT_GENERIC_TRACKER_POSE;' 595 596 xrt_output_name_enum_content = '\n'.join( 597 [f'\tif(strcmp("{output}", output) == 0) return {output};' for output in sorted(outputs)] 598 ) ··· 604 605 with open(file, "w") as f: 606 filled = src.substitute( 607 xrt_input_name_enum_content=xrt_input_name_enum_content, 608 xrt_output_name_enum_content=xrt_output_name_enum_content 609 ) 610 f.write(filled)
+2 -1
src/xrt/auxiliary/util/u_config_json.c
··· 14 #include "util/u_file.h" 15 #include "util/u_json.h" 16 #include "util/u_debug.h" 17 18 #include "u_config_json.h" 19 ··· 504 505 cJSON_AddItemToObject(entry, "offset", make_pose(&overrides[i].offset)); 506 507 - const char *input_name_string = xrt_input_name_string(overrides[i].input_name); 508 cJSON_AddStringToObject(entry, "xrt_input_name", input_name_string); 509 510 cJSON_AddItemToArray(o, entry);
··· 14 #include "util/u_file.h" 15 #include "util/u_json.h" 16 #include "util/u_debug.h" 17 + #include "util/u_pretty_print.h" 18 19 #include "u_config_json.h" 20 ··· 505 506 cJSON_AddItemToObject(entry, "offset", make_pose(&overrides[i].offset)); 507 508 + const char *input_name_string = u_str_xrt_input_name(overrides[i].input_name); 509 cJSON_AddStringToObject(entry, "xrt_input_name", input_name_string); 510 511 cJSON_AddItemToArray(o, entry);
+2 -2
src/xrt/state_trackers/gui/gui_scene_tracking_overrides.c
··· 11 #include "util/u_misc.h" 12 #include "util/u_format.h" 13 #include "util/u_logging.h" 14 15 #include "util/u_config_json.h" 16 ··· 23 #include "gui_common.h" 24 #include "gui_imgui.h" 25 26 - #include "bindings/b_generated_bindings_helpers.h" 27 28 struct gui_tracking_overrides 29 { ··· 243 continue; 244 } 245 246 - const char *name_str = xrt_input_name_string(input_name); 247 bool selected = o->input_name == input_name; 248 if (igCheckbox(name_str, &selected)) { 249 o->input_name = input_name;
··· 11 #include "util/u_misc.h" 12 #include "util/u_format.h" 13 #include "util/u_logging.h" 14 + #include "util/u_pretty_print.h" 15 16 #include "util/u_config_json.h" 17 ··· 24 #include "gui_common.h" 25 #include "gui_imgui.h" 26 27 28 struct gui_tracking_overrides 29 { ··· 243 continue; 244 } 245 246 + const char *name_str = u_str_xrt_input_name(input_name); 247 bool selected = o->input_name == input_name; 248 if (igCheckbox(name_str, &selected)) { 249 o->input_name = input_name;
+3 -4
src/xrt/state_trackers/oxr/oxr_input.c
··· 9 * @ingroup oxr_main 10 */ 11 12 - #include "b_generated_bindings_helpers.h" 13 #include "oxr_bindings/b_oxr_generated_bindings.h" 14 #include "util/u_debug.h" 15 #include "util/u_time.h" ··· 771 if (found) { 772 if (xbp == NULL) { 773 oxr_slog(slog, "\t\t\t\tBound (xdev '%s'): %s!\n", xdev->str, 774 - xrt_input_name_string(binding_points[i]->input)); 775 } else { 776 oxr_slog(slog, "\t\t\t\tBound (xbp)!\n"); 777 } ··· 1626 // Only add the input if we can find a transform. 1627 1628 oxr_slog(slog, "\t\tFinding transforms for '%s' to action '%s' of type '%s'\n", 1629 - xrt_input_name_string(inputs[i].input->name), act_ref->name, 1630 xr_action_type_to_str(act_ref->action_type)); 1631 1632 enum oxr_dpad_region dpad_region; ··· 1667 struct xrt_input *input = cache->inputs[i].input; 1668 enum xrt_input_type t = XRT_GET_INPUT_TYPE(input->name); 1669 bool active = input->active; 1670 - oxr_slog(slog, "\t\t\t'%s' ('%s') on '%s' (%s)\n", xrt_input_name_string(input->name), 1671 xrt_input_type_to_str(t), cache->inputs[i].xdev->str, 1672 active ? "active" : "inactive"); 1673 }
··· 9 * @ingroup oxr_main 10 */ 11 12 #include "oxr_bindings/b_oxr_generated_bindings.h" 13 #include "util/u_debug.h" 14 #include "util/u_time.h" ··· 770 if (found) { 771 if (xbp == NULL) { 772 oxr_slog(slog, "\t\t\t\tBound (xdev '%s'): %s!\n", xdev->str, 773 + u_str_xrt_input_name(binding_points[i]->input)); 774 } else { 775 oxr_slog(slog, "\t\t\t\tBound (xbp)!\n"); 776 } ··· 1625 // Only add the input if we can find a transform. 1626 1627 oxr_slog(slog, "\t\tFinding transforms for '%s' to action '%s' of type '%s'\n", 1628 + u_str_xrt_input_name(inputs[i].input->name), act_ref->name, 1629 xr_action_type_to_str(act_ref->action_type)); 1630 1631 enum oxr_dpad_region dpad_region; ··· 1666 struct xrt_input *input = cache->inputs[i].input; 1667 enum xrt_input_type t = XRT_GET_INPUT_TYPE(input->name); 1668 bool active = input->active; 1669 + oxr_slog(slog, "\t\t\t'%s' ('%s') on '%s' (%s)\n", u_str_xrt_input_name(input->name), 1670 xrt_input_type_to_str(t), cache->inputs[i].xdev->str, 1671 active ? "active" : "inactive"); 1672 }