fix generate_emu_config

fix two controller config related error when generating for appid 427520 and 1477940
This commit is contained in:
alex47exe 2024-10-19 22:47:56 +01:00
parent 766b685b62
commit 169d29e53d

View File

@ -1047,16 +1047,22 @@ def main():
cfg_user_account_steamid = cfg_user["user::general"]["account_steamid"]
cfg_user_language = cfg_user["user::general"]["language"]
config_found = 0
config_found = 0 # needed to skip showing "[ ] Found controller configs --- generating action sets..." again if already shown once
config_generated = 0 # used to avoid overwriting supported config by unsupported one
config_generated_not_sup = 0 # used to avoid overwriting prefered unsupported config if no supported config present
downloading_ctrl_vdf = 0 # needed to remove possible duplicate 'Found controller configs...'
valid_id = 0 # needed to skip showing "[ ] Found controller configs --- generating action sets..." if no valid is found in either "steamcontrollerconfigdetails" or "steamcontrollertouchconfigdetails"
if "config" in game_info:
if not SKIP_CONTROLLER and "steamcontrollerconfigdetails" in game_info["config"]:
controller_details = game_info["config"]["steamcontrollerconfigdetails"]
for id in controller_details:
# make sure the controller config id exists and is a numeric string
# fixes "TypeError: string indices must be integers, not 'str'" when generating for "Unknown 9: Awakening" (appid 1477940)
if id.isdigit():
if (downloading_ctrl_vdf == 0) and (valid_id == 0):
print(f"[ ] Found controller configs --- generating action sets...")
downloading_ctrl_vdf = 1
for id in controller_details:
valid_id = 1
details = controller_details[id]
controller_type = ""
enabled_branches = ""
@ -1065,6 +1071,8 @@ def main():
if "enabled_branches" in details:
enabled_branches = details["enabled_branches"]
out_vdf = None # initialize out_vdf, fixes "UnboundLocalError: cannot access local variable 'out_vdf' where it is not associated with a value" when generating for "Factorio" (appid 427520)
if (("default" in enabled_branches) or ("public" in enabled_branches)): # download only 'default' and 'public' branches to avoid multiple configs for same controller type
print(f'[ ] __ downloading config, file id = {id}, controller type = {controller_type}') # first noticed for Elden Ring, two 'controller_ps4' vdf configs are downloaded, but only one of them is converted to action sets
out_vdf = download_published_file(client, int(id), os.path.join(backup_dir, 'controller\\' + f'{controller_type}' + '_' + f'{id}'))
@ -1105,9 +1113,14 @@ def main():
if not SKIP_CONTROLLER and "steamcontrollertouchconfigdetails" in game_info["config"]:
controller_details = game_info["config"]["steamcontrollertouchconfigdetails"]
if downloading_ctrl_vdf == 0:
print(f"[ ] Found controller configs --- generating action sets...")
for id in controller_details:
# make sure the controller config id exists and is a numeric string
# fixes "TypeError: string indices must be integers, not 'str'" when generating for "Unknown 9: Awakening" (appid 1477940)
if id.isdigit():
if (downloading_ctrl_vdf == 0) and (valid_id == 0):
print(f"[ ] Found controller configs --- generating action sets...")
downloading_ctrl_vdf = 1
valid_id = 1
details = controller_details[id]
controller_type = ""
enabled_branches = ""
@ -1116,6 +1129,8 @@ def main():
if "enabled_branches" in details:
enabled_branches = details["enabled_branches"]
out_vdf = None # initialize out_vdf, fixes "UnboundLocalError: cannot access local variable 'out_vdf' where it is not associated with a value" when generating for "Factorio" (appid 427520)
if (("default" in enabled_branches) or ("public" in enabled_branches)): # download only 'default' and 'public' branches to avoid multiple configs for same controller type
print(f'[ ] __ downloading config, file id = {id}, controller type = {controller_type}') # first noticed for Elden Ring, two 'controller_ps4' vdf configs are downloaded, but only one of them is converted to action sets
out_vdf = download_published_file(client, int(id), os.path.join(backup_dir, 'controller\\' + f'{controller_type}' + '_' + f'{id}'))