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