0 votes

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 = ConfigFile.new()
    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.

in Engine by (230 points)

1 Answer

0 votes


Completely forgot that this had been answered. My bad.

by (230 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.