From dc1d9b674a7ceed04d86b1a26c45c413198a3ace Mon Sep 17 00:00:00 2001 From: Themaister Date: Wed, 29 Feb 2012 19:07:25 +0100 Subject: [PATCH] config_save_keybinds takes a pathname directly. --- general.h | 2 +- settings.c | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/general.h b/general.h index 59834c9f77..3f65ec620d 100644 --- a/general.h +++ b/general.h @@ -414,7 +414,7 @@ void config_set_defaults(void); #include "conf/config_file.h" bool config_load_file(const char *path); void config_read_keybinds(config_file_t *conf); -void config_save_keybinds(config_file_t *conf); +bool config_save_keybinds(const char *path); #endif void ssnes_game_reset(void); diff --git a/settings.c b/settings.c index 9fcaa3ce15..4e9ab0e7d2 100644 --- a/settings.c +++ b/settings.c @@ -895,10 +895,20 @@ static void save_keybinds_player(config_file_t *conf, unsigned i) save_keybind(conf, &bind_maps[i][j], &g_settings.input.binds[i][j]); } -void config_save_keybinds(config_file_t *conf) +bool config_save_keybinds(const char *path) { + config_file_t *conf = config_file_new(path); + if (!conf) + conf = config_file_new(NULL); + if (!conf) + return NULL; + for (unsigned i = 0; i < MAX_PLAYERS; i++) save_keybinds_player(conf, i); + + config_file_write(conf, path); + config_file_free(conf); + return true; } #endif