mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-04 06:06:17 +00:00
aux/bindings: Split function to convert input/output enums into two
xrt_input_name and xrt_output_name are actual different types.
This commit is contained in:
parent
d36123927d
commit
153280607f
|
@ -221,6 +221,7 @@ def generate_bindings_c(file, p):
|
||||||
f.write('}; // /array of profile_template\n\n')
|
f.write('}; // /array of profile_template\n\n')
|
||||||
|
|
||||||
inputs = set()
|
inputs = set()
|
||||||
|
outputs = set()
|
||||||
for profile in p.profiles:
|
for profile in p.profiles:
|
||||||
feature: Feature
|
feature: Feature
|
||||||
for idx, feature in enumerate(profile.features):
|
for idx, feature in enumerate(profile.features):
|
||||||
|
@ -228,7 +229,11 @@ def generate_bindings_c(file, p):
|
||||||
if feature_str not in sp_obj["monado_bindings"]:
|
if feature_str not in sp_obj["monado_bindings"]:
|
||||||
continue
|
continue
|
||||||
monado_binding = sp_obj["monado_bindings"][feature_str]
|
monado_binding = sp_obj["monado_bindings"][feature_str]
|
||||||
inputs.add(monado_binding)
|
|
||||||
|
if sp_obj["type"] == "vibration":
|
||||||
|
outputs.add(monado_binding)
|
||||||
|
else:
|
||||||
|
inputs.add(monado_binding)
|
||||||
|
|
||||||
# special cased bindings that are never directly used in the input profiles
|
# special cased bindings that are never directly used in the input profiles
|
||||||
inputs.add("XRT_INPUT_GENERIC_HEAD_POSE")
|
inputs.add("XRT_INPUT_GENERIC_HEAD_POSE")
|
||||||
|
@ -256,6 +261,25 @@ def generate_bindings_c(file, p):
|
||||||
f.write(f'\treturn XRT_INPUT_GENERIC_TRACKER_POSE;\n')
|
f.write(f'\treturn XRT_INPUT_GENERIC_TRACKER_POSE;\n')
|
||||||
f.write('}\n')
|
f.write('}\n')
|
||||||
|
|
||||||
|
f.write('const char *\n')
|
||||||
|
f.write('xrt_output_name_string(enum xrt_output_name output)\n')
|
||||||
|
f.write('{\n')
|
||||||
|
f.write('\tswitch(output)\n')
|
||||||
|
f.write('\t{\n')
|
||||||
|
for output in outputs:
|
||||||
|
f.write(f'\tcase {output}: return "{output}";\n')
|
||||||
|
f.write(f'\tdefault: return "UNKNOWN";\n')
|
||||||
|
f.write('\t}\n')
|
||||||
|
f.write('}\n')
|
||||||
|
|
||||||
|
f.write('enum xrt_output_name\n')
|
||||||
|
f.write('xrt_output_name_enum(const char *output)\n')
|
||||||
|
f.write('{\n')
|
||||||
|
for output in outputs:
|
||||||
|
f.write(f'\tif(strcmp("{output}", output) == 0) return {output};\n')
|
||||||
|
f.write(f'\treturn XRT_OUTPUT_NAME_SIMPLE_VIBRATION;\n')
|
||||||
|
f.write('}\n')
|
||||||
|
|
||||||
f.write("\n// clang-format on\n")
|
f.write("\n// clang-format on\n")
|
||||||
|
|
||||||
f.close()
|
f.close()
|
||||||
|
@ -315,6 +339,12 @@ extern struct profile_template profile_templates[NUM_PROFILE_TEMPLATES];
|
||||||
f.write('enum xrt_input_name\n')
|
f.write('enum xrt_input_name\n')
|
||||||
f.write('xrt_input_name_enum(const char *input);\n\n')
|
f.write('xrt_input_name_enum(const char *input);\n\n')
|
||||||
|
|
||||||
|
f.write('const char *\n')
|
||||||
|
f.write('xrt_output_name_string(enum xrt_output_name output);\n\n')
|
||||||
|
|
||||||
|
f.write('enum xrt_output_name\n')
|
||||||
|
f.write('xrt_output_name_enum(const char *output);\n\n')
|
||||||
|
|
||||||
f.write("\n// clang-format on\n")
|
f.write("\n// clang-format on\n")
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue