Is there any built in way to save the InputMap?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By EIREXE
:warning: Old Version Published before Godot 3 was released.

I have made a settings menu, and I would like to save my InputMap from memory and then load it on top of the InputMap from engine.cfg.

Is there any built in way to do this?

:bust_in_silhouette: Reply From: kubecz3k

There is InputMap object that resides in global scope, so you are able to get it all the time by simply using it’s name(InputMap). It have some methods that allows you to modify mapping in runtime:

bool has_action( String action ) 
int get_action_id( String action ) 
String get_action_from_id( int id )
void add_action( String action )
void erase_action( String action )
bool action_has_event ( String action, InputEvent event )
void action_add_event ( String action, InputEvent event )
void action_erase_event ( String action, InputEvent event )

However you need to save state of input map to the file manually, and restore it each time when the game is started.
More informations:

Extras/Hint: You can take look into how Akien implement saving/loading inputs in his game DynaDungeons: https://github.com/akien-mga/dynadungeons/blob/master/scripts/global.gd#L93 Take a look at load_config() function.

Thanks for the answer, I also asked on the IRC and was told that there’s a simple implementation of remapping from file here: GitHub - akien-mga/dynadungeons: Bomberman clone using Godot Engine - Not actively developed since 2015.

EIREXE | 2016-04-13 13:10

Nice to know, I will add this as a hint to the answer for people that will look for this answer in the future :slight_smile:

kubecz3k | 2016-04-13 14:06