Saving gamepad inputs to config file.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By 9BitStrider

I’m using the remap controls tutorial from the Godot website, but I’m having trouble getting it to save gamepad controls to the .cfg file.

var config =
	var err = config.load(CONFIG_FILE)
	if err: #Assuming that options.cfg doesn't exist.
		for action_name in INPUT_ACTIONS:
			var action_list = InputMap.get_action_list(action_name)
			# There could be multiple actions in the list, but we save the first one by default
			var scancode = OS.get_scancode_string(action_list[1].scancode)
			config.set_value("input", action_name, scancode)

I’ve changed the var scancode line to str(action_list)which saves the following to the config:


up="[[InputEventKey:43], [InputEventJoypadButton:44], [InputEventJoypadMotion:45]]"
down="[[InputEventKey:46], [InputEventJoypadButton:47], [InputEventJoypadMotion:48]]"
left="[[InputEventKey:49], [InputEventJoypadButton:50], [InputEventJoypadMotion:51]]"
right="[[InputEventKey:52], [InputEventJoypadButton:53], [InputEventJoypadMotion:54]]"
jump="[[InputEventKey:55], [InputEventJoypadButton:56]]"
fire="[[InputEventKey:57], [InputEventJoypadButton:58]]"
dash="[[InputEventKey:67], [InputEventJoypadButton:68]]"
prev="[[InputEventKey:61], [InputEventJoypadButton:62]]"
next="[[InputEventKey:59], [InputEventJoypadButton:60]]"
select="[[InputEventKey:63], [InputEventJoypadButton:64]]"
start="[[InputEventKey:65], [InputEventJoypadButton:66]]"

If anything, I just need an example of how to load these values into my InputMap without pulling my hair out. Thanks in advance.

:bust_in_silhouette: Reply From: 9BitStrider

Completely forgot that this had been answered. My bad.