mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 12:32:52 +00:00
Get rid of menu_hash_calculate dependencies for menu keyboard
callback functions for settings
This commit is contained in:
parent
27ef0cf9c7
commit
69503880f5
@ -969,6 +969,30 @@ static int action_ok_cheat(const char *path,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void menu_input_st_string_cb_save_preset(void *userdata, const char *str)
|
||||
{
|
||||
if (str && *str)
|
||||
{
|
||||
rarch_setting_t *setting = NULL;
|
||||
const char *label = NULL;
|
||||
|
||||
menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_LABEL_SETTING, &label);
|
||||
|
||||
if (!string_is_empty(label))
|
||||
setting = menu_setting_find(label);
|
||||
|
||||
if (setting)
|
||||
{
|
||||
menu_setting_set_with_string_representation(setting, str);
|
||||
menu_setting_generic(setting, false);
|
||||
}
|
||||
else if (!string_is_empty(label))
|
||||
menu_shader_manager_save_preset(str, false);
|
||||
}
|
||||
|
||||
menu_input_key_end_line();
|
||||
}
|
||||
|
||||
static int action_ok_shader_preset_save_as(const char *path,
|
||||
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
||||
{
|
||||
@ -978,13 +1002,37 @@ static int action_ok_shader_preset_save_as(const char *path,
|
||||
line.label_setting = label;
|
||||
line.type = type;
|
||||
line.idx = idx;
|
||||
line.cb = menu_input_st_string_cb;
|
||||
line.cb = menu_input_st_string_cb_save_preset;
|
||||
|
||||
if (!menu_input_ctl(MENU_INPUT_CTL_START_LINE, &line))
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void menu_input_st_string_cb_cheat_file_save_as(void *userdata, const char *str)
|
||||
{
|
||||
if (str && *str)
|
||||
{
|
||||
rarch_setting_t *setting = NULL;
|
||||
const char *label = NULL;
|
||||
|
||||
menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_LABEL_SETTING, &label);
|
||||
|
||||
if (!string_is_empty(label))
|
||||
setting = menu_setting_find(label);
|
||||
|
||||
if (setting)
|
||||
{
|
||||
menu_setting_set_with_string_representation(setting, str);
|
||||
menu_setting_generic(setting, false);
|
||||
}
|
||||
else if (!string_is_empty(label))
|
||||
cheat_manager_save(str);
|
||||
}
|
||||
|
||||
menu_input_key_end_line();
|
||||
}
|
||||
|
||||
static int action_ok_cheat_file_save_as(const char *path,
|
||||
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
||||
{
|
||||
@ -994,7 +1042,7 @@ static int action_ok_cheat_file_save_as(const char *path,
|
||||
line.label_setting = label;
|
||||
line.type = type;
|
||||
line.idx = idx;
|
||||
line.cb = menu_input_st_string_cb;
|
||||
line.cb = menu_input_st_string_cb_cheat_file_save_as;
|
||||
|
||||
if (!menu_input_ctl(MENU_INPUT_CTL_START_LINE, &line))
|
||||
return -1;
|
||||
|
@ -134,7 +134,7 @@ static menu_input_t *menu_input_get_ptr(void)
|
||||
return &menu_input_state;
|
||||
}
|
||||
|
||||
static void menu_input_key_end_line(void)
|
||||
void menu_input_key_end_line(void)
|
||||
{
|
||||
bool keyboard_display = false;
|
||||
|
||||
@ -204,43 +204,6 @@ void menu_input_st_hex_cb(void *userdata, const char *str)
|
||||
menu_input_key_end_line();
|
||||
}
|
||||
|
||||
|
||||
void menu_input_st_string_cb(void *userdata, const char *str)
|
||||
{
|
||||
if (str && *str)
|
||||
{
|
||||
rarch_setting_t *setting = NULL;
|
||||
const char *label = NULL;
|
||||
|
||||
menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_LABEL_SETTING, &label);
|
||||
|
||||
if (!string_is_empty(label))
|
||||
setting = menu_setting_find(label);
|
||||
|
||||
if (setting)
|
||||
{
|
||||
menu_setting_set_with_string_representation(setting, str);
|
||||
menu_setting_generic(setting, false);
|
||||
}
|
||||
else if (!string_is_empty(label))
|
||||
{
|
||||
uint32_t hash_label = menu_hash_calculate(label);
|
||||
|
||||
switch (hash_label)
|
||||
{
|
||||
case MENU_LABEL_VIDEO_SHADER_PRESET_SAVE_AS:
|
||||
menu_shader_manager_save_preset(str, false);
|
||||
break;
|
||||
case MENU_LABEL_CHEAT_FILE_SAVE_AS:
|
||||
cheat_manager_save(str);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
menu_input_key_end_line();
|
||||
}
|
||||
|
||||
void menu_input_st_cheat_cb(void *userdata, const char *str)
|
||||
{
|
||||
menu_input_t *menu_input = menu_input_get_ptr();
|
||||
|
@ -128,7 +128,6 @@ typedef struct menu_input_ctx_bind_limits
|
||||
/* Keyboard input callbacks */
|
||||
void menu_input_st_uint_cb (void *userdata, const char *str);
|
||||
void menu_input_st_hex_cb (void *userdata, const char *str);
|
||||
void menu_input_st_string_cb(void *userdata, const char *str);
|
||||
void menu_input_st_cheat_cb (void *userdata, const char *str);
|
||||
|
||||
unsigned menu_input_frame_retropad(retro_input_t input, retro_input_t trigger_state);
|
||||
@ -139,6 +138,8 @@ int16_t menu_input_pointer_state(enum menu_input_pointer_state state);
|
||||
|
||||
int16_t menu_input_mouse_state(enum menu_input_mouse_state state);
|
||||
|
||||
void menu_input_key_end_line(void);
|
||||
|
||||
bool menu_input_ctl(enum menu_input_ctl_state state, void *data);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
@ -2768,6 +2768,28 @@ static int setting_action_ok_video_refresh_rate_auto(void *data, bool wraparound
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void menu_input_st_string_cb(void *userdata, const char *str)
|
||||
{
|
||||
if (str && *str)
|
||||
{
|
||||
rarch_setting_t *setting = NULL;
|
||||
const char *label = NULL;
|
||||
|
||||
menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_LABEL_SETTING, &label);
|
||||
|
||||
if (!string_is_empty(label))
|
||||
setting = menu_setting_find(label);
|
||||
|
||||
if (setting)
|
||||
{
|
||||
menu_setting_set_with_string_representation(setting, str);
|
||||
menu_setting_generic(setting, false);
|
||||
}
|
||||
}
|
||||
|
||||
menu_input_key_end_line();
|
||||
}
|
||||
|
||||
static int setting_generic_action_ok_linefeed(void *data, bool wraparound)
|
||||
{
|
||||
menu_input_ctx_line_t line;
|
||||
|
Loading…
x
Reference in New Issue
Block a user