mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-29 11:06:18 +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')
|
||||
|
||||
inputs = set()
|
||||
outputs = set()
|
||||
for profile in p.profiles:
|
||||
feature: Feature
|
||||
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"]:
|
||||
continue
|
||||
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
|
||||
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('}\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.close()
|
||||
|
@ -315,6 +339,12 @@ extern struct profile_template profile_templates[NUM_PROFILE_TEMPLATES];
|
|||
f.write('enum xrt_input_name\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.close()
|
||||
|
||||
|
|
Loading…
Reference in a new issue