mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 12:32:52 +00:00
(menu_input.c) Refactors
This commit is contained in:
parent
bbc5bc9f6e
commit
0b9f16763f
@ -165,14 +165,12 @@ void menu_input_key_event(bool down, unsigned keycode,
|
||||
|
||||
static void menu_input_key_end_line(void)
|
||||
{
|
||||
bool keyboard_display = false;
|
||||
driver_t *driver = driver_get_ptr();
|
||||
menu_input_t *menu_input = menu_input_get_ptr();
|
||||
if (!menu_input)
|
||||
return;
|
||||
|
||||
menu_input->keyboard.display = false;
|
||||
menu_input->keyboard.label = NULL;
|
||||
menu_input->keyboard.label_setting = NULL;
|
||||
menu_input_ctl(MENU_INPUT_CTL_SET_KEYBOARD_DISPLAY, &keyboard_display);
|
||||
menu_input_ctl(MENU_INPUT_CTL_SET_KEYBOARD_LABEL, NULL);
|
||||
menu_input_ctl(MENU_INPUT_CTL_SET_KEYBOARD_LABEL_SETTING, NULL);
|
||||
|
||||
/* Avoid triggering states on pressing return. */
|
||||
driver->flushing_input = true;
|
||||
@ -260,6 +258,12 @@ bool menu_input_ctl(enum menu_input_ctl_state state, void *data)
|
||||
*ptr = menu_input->keyboard.display;
|
||||
}
|
||||
return true;
|
||||
case MENU_INPUT_CTL_SET_KEYBOARD_DISPLAY:
|
||||
{
|
||||
bool *ptr = (bool*)data;
|
||||
menu_input->keyboard.display = *ptr;
|
||||
}
|
||||
return true;
|
||||
case MENU_INPUT_CTL_KEYBOARD_BUFF_PTR:
|
||||
{
|
||||
const char **ptr = (const char**)data;
|
||||
@ -272,6 +276,24 @@ bool menu_input_ctl(enum menu_input_ctl_state state, void *data)
|
||||
*ptr = menu_input->keyboard.label;
|
||||
}
|
||||
return true;
|
||||
case MENU_INPUT_CTL_SET_KEYBOARD_LABEL:
|
||||
{
|
||||
const char *ptr = (const char*)data;
|
||||
menu_input->keyboard.label = ptr;
|
||||
}
|
||||
return true;
|
||||
case MENU_INPUT_CTL_KEYBOARD_LABEL_SETTING:
|
||||
{
|
||||
const char **ptr = (const char**)data;
|
||||
*ptr = menu_input->keyboard.label_setting;
|
||||
}
|
||||
return true;
|
||||
case MENU_INPUT_CTL_SET_KEYBOARD_LABEL_SETTING:
|
||||
{
|
||||
const char *ptr = (const char*)data;
|
||||
menu_input->keyboard.label_setting = ptr;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -281,14 +303,16 @@ void menu_input_key_start_line(const char *label,
|
||||
const char *label_setting, unsigned type, unsigned idx,
|
||||
input_keyboard_line_complete_t cb)
|
||||
{
|
||||
bool keyboard_display = true;
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
menu_input_t *menu_input = menu_input_get_ptr();
|
||||
if (!menu || !menu_input)
|
||||
return;
|
||||
|
||||
menu_input->keyboard.display = true;
|
||||
menu_input->keyboard.label = label;
|
||||
menu_input->keyboard.label_setting = label_setting;
|
||||
menu_input_ctl(MENU_INPUT_CTL_SET_KEYBOARD_DISPLAY, &keyboard_display);
|
||||
menu_input_ctl(MENU_INPUT_CTL_SET_KEYBOARD_LABEL, &label);
|
||||
menu_input_ctl(MENU_INPUT_CTL_SET_KEYBOARD_LABEL_SETTING, &label_setting);
|
||||
|
||||
menu_input->keyboard.type = type;
|
||||
menu_input->keyboard.idx = idx;
|
||||
menu_input->keyboard.buffer = input_keyboard_start_line(menu, cb);
|
||||
@ -306,7 +330,13 @@ void menu_input_st_uint_callback(void *userdata, const char *str)
|
||||
if (str && *str)
|
||||
{
|
||||
rarch_setting_t *current_setting = NULL;
|
||||
if ((current_setting = menu_setting_find(menu_input->keyboard.label_setting)))
|
||||
const char *label = NULL;
|
||||
|
||||
menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_LABEL_SETTING, &label);
|
||||
|
||||
current_setting = menu_setting_find(label);
|
||||
|
||||
if (current_setting)
|
||||
setting_set_with_string_representation(current_setting, str);
|
||||
}
|
||||
|
||||
@ -323,7 +353,13 @@ void menu_input_st_hex_callback(void *userdata, const char *str)
|
||||
if (str && *str)
|
||||
{
|
||||
rarch_setting_t *current_setting = NULL;
|
||||
if ((current_setting = menu_setting_find(menu_input->keyboard.label_setting)))
|
||||
const char *label = NULL;
|
||||
|
||||
menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_LABEL_SETTING, &label);
|
||||
|
||||
current_setting = menu_setting_find(label);
|
||||
|
||||
if (current_setting)
|
||||
if (str[0] == '#')
|
||||
str++;
|
||||
*current_setting->value.unsigned_integer = strtoul(str, NULL, 16);
|
||||
@ -342,8 +378,13 @@ void menu_input_st_string_callback(void *userdata, const char *str)
|
||||
|
||||
if (str && *str)
|
||||
{
|
||||
rarch_setting_t *current_setting = NULL;
|
||||
const char *label = NULL;
|
||||
global_t *global = global_get_ptr();
|
||||
rarch_setting_t *current_setting = menu_setting_find(menu_input->keyboard.label_setting);
|
||||
|
||||
menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_LABEL_SETTING, &label);
|
||||
|
||||
current_setting = menu_setting_find(label);
|
||||
|
||||
if (current_setting)
|
||||
{
|
||||
@ -352,7 +393,7 @@ void menu_input_st_string_callback(void *userdata, const char *str)
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t hash_label = menu_hash_calculate(menu_input->keyboard.label_setting);
|
||||
uint32_t hash_label = menu_hash_calculate(label);
|
||||
|
||||
switch (hash_label)
|
||||
{
|
||||
|
@ -68,8 +68,12 @@ enum menu_input_ctl_state
|
||||
MENU_INPUT_CTL_POINTER_ACCEL_WRITE,
|
||||
MENU_INPUT_CTL_POINTER_DRAGGING,
|
||||
MENU_INPUT_CTL_KEYBOARD_DISPLAY,
|
||||
MENU_INPUT_CTL_SET_KEYBOARD_DISPLAY,
|
||||
MENU_INPUT_CTL_KEYBOARD_BUFF_PTR,
|
||||
MENU_INPUT_CTL_KEYBOARD_LABEL,
|
||||
MENU_INPUT_CTL_SET_KEYBOARD_LABEL,
|
||||
MENU_INPUT_CTL_KEYBOARD_LABEL_SETTING,
|
||||
MENU_INPUT_CTL_SET_KEYBOARD_LABEL_SETTING,
|
||||
MENU_INPUT_CTL_SEARCH_START
|
||||
};
|
||||
|
||||
|
@ -281,10 +281,13 @@ int menu_iterate(bool render_this_frame, enum menu_action action)
|
||||
BIT64_SET(menu->state, MENU_STATE_POP_STACK);
|
||||
break;
|
||||
case ITERATE_TYPE_DEFAULT:
|
||||
/* Crappy hack, needed for mouse controls to not be completely broken
|
||||
* in case we press back. NOTE/FIXME: we need to fix this entire mess,
|
||||
* mouse controls should not rely on a hack like this in order to work. */
|
||||
/* FIXME: Crappy hack, needed for mouse controls to not be completely broken
|
||||
* in case we press back.
|
||||
*
|
||||
* We need to fix this entire mess, mouse controls should not rely on a
|
||||
* hack like this in order to work. */
|
||||
selection = max(min(selection, menu_list_get_size(menu_list)-1), 0);
|
||||
|
||||
menu_entry_get(&entry, selection, NULL, false);
|
||||
ret = menu_entry_action(&entry, selection, (enum menu_action)action);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user