From 3c1c58cfc3cf8e5e5bbd80509e8bd6c94d0783f4 Mon Sep 17 00:00:00 2001 From: sonninnos Date: Tue, 27 Jun 2023 21:17:34 +0300 Subject: [PATCH] Fix keybind hat hotkey save --- configuration.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/configuration.c b/configuration.c index 9e13be11a9..e9ca597f4d 100644 --- a/configuration.c +++ b/configuration.c @@ -4558,37 +4558,34 @@ static void video_driver_save_settings(global_t *global, config_file_t *conf) static void save_keybind_hat(config_file_t *conf, const char *key, const struct retro_keybind *bind) { - size_t _len; char config[16]; - unsigned hat = (unsigned)GET_HAT(bind->joykey); + const char *hat = NULL; - config[0] = 'h'; - config[1] = '\0'; - - _len = snprintf(config + 1, sizeof(config) - 1, "%u", hat); + config[0] = '\0'; switch (GET_HAT_DIR(bind->joykey)) { case HAT_UP_MASK: - strlcpy(config + _len, "up", sizeof(config) - _len); + hat = "up"; break; case HAT_DOWN_MASK: - strlcpy(config + _len, "down", sizeof(config) - _len); + hat = "down"; break; case HAT_LEFT_MASK: - strlcpy(config + _len, "left", sizeof(config) - _len); + hat = "left"; break; case HAT_RIGHT_MASK: - strlcpy(config + _len, "right", sizeof(config) - _len); + hat = "right"; break; default: break; } + snprintf(config, sizeof(config), "h%u%s", GET_HAT(bind->joykey), hat); config_set_string(conf, key, config); }