2016-09-15 17:23:32 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2017-01-22 12:40:32 +00:00
|
|
|
* Copyright (C) 2011-2017 - Daniel De Matteis
|
2016-09-15 17:23:32 +00:00
|
|
|
*
|
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <compat/strl.h>
|
|
|
|
|
|
|
|
#include "menu_input_dialog.h"
|
|
|
|
|
|
|
|
#include "../menu_driver.h"
|
|
|
|
#include "../../input/input_driver.h"
|
|
|
|
|
|
|
|
static const char **menu_input_dialog_keyboard_buffer = {NULL};
|
|
|
|
static bool menu_input_dialog_keyboard_display = false;
|
|
|
|
static unsigned menu_input_dialog_keyboard_type = 0;
|
|
|
|
static unsigned menu_input_dialog_keyboard_idx = 0;
|
|
|
|
static char menu_input_dialog_keyboard_label_setting[256] = {0};
|
|
|
|
static char menu_input_dialog_keyboard_label[256] = {0};
|
|
|
|
|
|
|
|
static void menu_input_search_cb(void *userdata, const char *str)
|
|
|
|
{
|
|
|
|
size_t idx = 0;
|
|
|
|
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
|
|
|
|
|
|
|
|
if (!selection_buf)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (str && *str && file_list_search(selection_buf, str, &idx))
|
|
|
|
{
|
2017-04-23 12:31:49 +00:00
|
|
|
menu_navigation_set_selection(idx);
|
2017-05-15 05:56:22 +00:00
|
|
|
menu_driver_navigation_set(true);
|
2016-09-15 17:23:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
menu_input_dialog_end();
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *menu_input_dialog_get_label_buffer(void)
|
|
|
|
{
|
|
|
|
return menu_input_dialog_keyboard_label;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *menu_input_dialog_get_label_setting_buffer(void)
|
|
|
|
{
|
|
|
|
return menu_input_dialog_keyboard_label_setting;
|
|
|
|
}
|
|
|
|
|
|
|
|
void menu_input_dialog_end(void)
|
|
|
|
{
|
|
|
|
menu_input_dialog_keyboard_type = 0;
|
|
|
|
menu_input_dialog_keyboard_idx = 0;
|
2017-11-16 03:19:29 +00:00
|
|
|
menu_input_dialog_keyboard_display = false;
|
2016-09-15 17:23:32 +00:00
|
|
|
menu_input_dialog_keyboard_label[0] = '\0';
|
|
|
|
menu_input_dialog_keyboard_label_setting[0] = '\0';
|
|
|
|
|
2017-06-11 15:35:48 +00:00
|
|
|
/* Avoid triggering tates on pressing return. */
|
2016-09-15 17:23:32 +00:00
|
|
|
input_driver_set_flushing_input();
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *menu_input_dialog_get_buffer(void)
|
|
|
|
{
|
|
|
|
if (!(*menu_input_dialog_keyboard_buffer))
|
|
|
|
return "";
|
|
|
|
return *menu_input_dialog_keyboard_buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned menu_input_dialog_get_kb_type(void)
|
|
|
|
{
|
|
|
|
return menu_input_dialog_keyboard_type;
|
|
|
|
}
|
|
|
|
|
2016-09-23 12:45:07 +00:00
|
|
|
unsigned menu_input_dialog_get_kb_idx(void)
|
|
|
|
{
|
|
|
|
return menu_input_dialog_keyboard_idx;
|
|
|
|
}
|
|
|
|
|
2016-09-15 17:23:32 +00:00
|
|
|
bool menu_input_dialog_get_display_kb(void)
|
|
|
|
{
|
2017-11-16 03:19:29 +00:00
|
|
|
return menu_input_dialog_keyboard_display;
|
2016-09-15 17:23:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void menu_input_dialog_display_kb(void)
|
|
|
|
{
|
2017-11-16 03:19:29 +00:00
|
|
|
menu_input_dialog_keyboard_display = true;
|
2016-09-15 17:23:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void menu_input_dialog_hide_kb(void)
|
|
|
|
{
|
2017-11-16 03:19:29 +00:00
|
|
|
menu_input_dialog_keyboard_display = false;
|
2016-09-15 17:23:32 +00:00
|
|
|
}
|
|
|
|
|
2018-04-11 04:11:04 +00:00
|
|
|
bool menu_input_dialog_start_search(void)
|
2016-09-15 17:23:32 +00:00
|
|
|
{
|
2018-04-11 04:11:04 +00:00
|
|
|
menu_handle_t *menu = NULL;
|
2016-09-15 17:23:32 +00:00
|
|
|
|
2018-04-11 04:11:04 +00:00
|
|
|
if (!menu_driver_ctl(
|
|
|
|
RARCH_MENU_CTL_DRIVER_DATA_GET, &menu))
|
2016-09-15 17:23:32 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
menu_input_dialog_display_kb();
|
2018-04-11 04:11:04 +00:00
|
|
|
strlcpy(menu_input_dialog_keyboard_label, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SEARCH),
|
2016-09-15 17:23:32 +00:00
|
|
|
sizeof(menu_input_dialog_keyboard_label));
|
2017-06-11 15:35:48 +00:00
|
|
|
|
|
|
|
input_keyboard_ctl(RARCH_INPUT_KEYBOARD_CTL_LINE_FREE, NULL);
|
|
|
|
|
2016-09-15 17:23:32 +00:00
|
|
|
menu_input_dialog_keyboard_buffer =
|
|
|
|
input_keyboard_start_line(menu, menu_input_search_cb);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-04-11 04:10:51 +00:00
|
|
|
bool menu_input_dialog_start(menu_input_ctx_line_t *line)
|
2016-09-15 17:23:32 +00:00
|
|
|
{
|
2018-04-11 04:10:51 +00:00
|
|
|
menu_handle_t *menu = NULL;
|
2016-09-15 17:23:32 +00:00
|
|
|
if (!line)
|
|
|
|
return false;
|
2018-04-11 04:10:51 +00:00
|
|
|
if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu))
|
2016-09-15 17:23:32 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
menu_input_dialog_display_kb();
|
2017-11-16 03:19:29 +00:00
|
|
|
|
2017-11-28 16:43:32 +00:00
|
|
|
/* Only copy over the menu label and setting if they exist. */
|
2017-11-16 03:19:29 +00:00
|
|
|
if (line->label)
|
|
|
|
strlcpy(menu_input_dialog_keyboard_label, line->label,
|
|
|
|
sizeof(menu_input_dialog_keyboard_label));
|
|
|
|
if (line->label_setting)
|
|
|
|
strlcpy(menu_input_dialog_keyboard_label_setting,
|
2018-04-11 04:10:51 +00:00
|
|
|
line->label_setting, sizeof(menu_input_dialog_keyboard_label_setting));
|
2016-09-15 17:23:32 +00:00
|
|
|
|
|
|
|
menu_input_dialog_keyboard_type = line->type;
|
|
|
|
menu_input_dialog_keyboard_idx = line->idx;
|
2017-06-11 15:35:48 +00:00
|
|
|
|
|
|
|
input_keyboard_ctl(RARCH_INPUT_KEYBOARD_CTL_LINE_FREE, NULL);
|
|
|
|
|
2016-09-15 17:23:32 +00:00
|
|
|
menu_input_dialog_keyboard_buffer =
|
|
|
|
input_keyboard_start_line(menu, line->cb);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|