Create MENU_INPUT_CTL_START_LINE

This commit is contained in:
twinaphex 2016-02-25 18:36:29 +01:00
parent 27b5617cd9
commit b870aaf2fa
4 changed files with 69 additions and 39 deletions

View File

@ -937,24 +937,48 @@ static int action_ok_cheevos(const char *path,
static int action_ok_cheat(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
menu_input_key_start_line("Input Cheat",
label, type, idx, menu_input_st_cheat_cb);
menu_input_ctx_line_t line;
line.label = "Input Cheat";
line.label_setting = label;
line.type = type;
line.idx = idx;
line.cb = menu_input_st_cheat_cb;
if (!menu_input_ctl(MENU_INPUT_CTL_START_LINE, &line))
return -1;
return 0;
}
static int action_ok_shader_preset_save_as(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
menu_input_key_start_line("Preset Filename",
label, type, idx, menu_input_st_string_cb);
menu_input_ctx_line_t line;
line.label = "Preset Filename";
line.label_setting = label;
line.type = type;
line.idx = idx;
line.cb = menu_input_st_string_cb;
if (!menu_input_ctl(MENU_INPUT_CTL_START_LINE, &line))
return -1;
return 0;
}
static int action_ok_cheat_file_save_as(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
menu_input_key_start_line("Cheat Filename",
label, type, idx, menu_input_st_string_cb);
menu_input_ctx_line_t line;
line.label = "Cheat Filename";
line.label_setting = label;
line.type = type;
line.idx = idx;
line.cb = menu_input_st_string_cb;
if (!menu_input_ctl(MENU_INPUT_CTL_START_LINE, &line))
return -1;
return 0;
}

View File

@ -785,6 +785,25 @@ bool menu_input_ctl(enum menu_input_ctl_state state, void *data)
return menu_input_key_bind_iterate(bind->s, bind->len);
}
break;
case MENU_INPUT_CTL_START_LINE:
{
bool keyboard_display = true;
menu_handle_t *menu = NULL;
menu_input_ctx_line_t *line = (menu_input_ctx_line_t*)data;
if (!menu_input || !line)
return false;
if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu))
return false;
menu_input_ctl(MENU_INPUT_CTL_SET_KEYBOARD_DISPLAY, &keyboard_display);
menu_input_ctl(MENU_INPUT_CTL_SET_KEYBOARD_LABEL, &line->label);
menu_input_ctl(MENU_INPUT_CTL_SET_KEYBOARD_LABEL_SETTING, &line->label_setting);
menu_input->keyboard.type = line->type;
menu_input->keyboard.idx = line->idx;
menu_input->keyboard.buffer = input_keyboard_start_line(menu, line->cb);
}
break;
default:
case MENU_INPUT_CTL_NONE:
break;
@ -793,31 +812,6 @@ bool menu_input_ctl(enum menu_input_ctl_state state, void *data)
return true;
}
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 = NULL;
menu_input_t *menu_input = menu_input_get_ptr();
if (!menu_input)
return;
if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu))
return;
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);
}
void menu_input_key_bind_set_min_max(unsigned min, unsigned max)
{
menu_input_t *menu_input = menu_input_get_ptr();
@ -829,7 +823,6 @@ void menu_input_key_bind_set_min_max(unsigned min, unsigned max)
menu_input->binds.last = max;
}
static int menu_input_mouse(unsigned *action)
{
video_viewport_t vp;

View File

@ -93,7 +93,8 @@ enum menu_input_ctl_state
MENU_INPUT_CTL_BIND_NONE,
MENU_INPUT_CTL_BIND_SINGLE,
MENU_INPUT_CTL_BIND_ALL,
MENU_INPUT_CTL_BIND_ITERATE
MENU_INPUT_CTL_BIND_ITERATE,
MENU_INPUT_CTL_START_LINE
};
typedef struct menu_input_ctx_hitbox
@ -110,16 +111,21 @@ typedef struct menu_input_ctx_bind
size_t len;
} menu_input_ctx_bind_t;
typedef struct menu_input_ctx_line
{
const char *label;
const char *label_setting;
unsigned type;
unsigned idx;
input_keyboard_line_complete_t cb;
} menu_input_ctx_line_t;
/* 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);
void menu_input_key_start_line(const char *label,
const char *label_setting, unsigned type, unsigned idx,
input_keyboard_line_complete_t cb);
void menu_input_key_bind_set_min_max(unsigned min, unsigned max);
unsigned menu_input_frame_retropad(retro_input_t input, retro_input_t trigger_state);

View File

@ -2632,6 +2632,7 @@ static int setting_action_ok_video_refresh_rate_auto(void *data, bool wraparound
static int setting_generic_action_ok_linefeed(void *data, bool wraparound)
{
menu_input_ctx_line_t line;
input_keyboard_line_complete_t cb = NULL;
rarch_setting_t *setting = (rarch_setting_t*)data;
const char *short_description = menu_setting_get_short_description(setting);
@ -2657,8 +2658,14 @@ static int setting_generic_action_ok_linefeed(void *data, bool wraparound)
break;
}
menu_input_key_start_line(short_description,
setting->name, 0, 0, cb);
line.label = short_description;
line.label_setting = setting->name;
line.type = 0;
line.idx = 0;
line.cb = cb;
if (!menu_input_ctl(MENU_INPUT_CTL_START_LINE, &line))
return -1;
return 0;
}