2015-05-10 08:55:20 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2014-2015 - Jay McCarthy
|
|
|
|
*
|
|
|
|
* 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 "menu.h"
|
2015-05-11 15:53:33 +00:00
|
|
|
#include "menu_display.h"
|
2015-05-10 09:00:05 +00:00
|
|
|
#include "menu_entry.h"
|
2015-05-10 08:55:20 +00:00
|
|
|
#include "menu_navigation.h"
|
|
|
|
#include "menu_setting.h"
|
|
|
|
#include "menu_input.h"
|
2015-05-17 11:10:55 +00:00
|
|
|
#include "../runloop_data.h"
|
2015-05-10 08:55:20 +00:00
|
|
|
|
2015-06-02 10:37:56 +00:00
|
|
|
/* This file provides an abstraction of the currently displayed
|
|
|
|
* menu.
|
|
|
|
*
|
|
|
|
* It is organized into event-system where the UI companion
|
|
|
|
* calls this functions and RetroArch responds by changing the global
|
|
|
|
* state (including arranging for these functions to return different
|
|
|
|
* values).
|
|
|
|
*
|
|
|
|
* Its only interaction back to the UI is to arrange for
|
|
|
|
* notify_list_loaded on the UI companion.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Returns the starting index of the menu entry list. */
|
2015-05-14 21:53:28 +00:00
|
|
|
size_t menu_entries_get_start(void)
|
2015-05-14 20:18:32 +00:00
|
|
|
{
|
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
|
|
|
|
|
|
|
if (!menu)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return menu->begin;
|
|
|
|
}
|
|
|
|
|
2015-06-02 10:37:56 +00:00
|
|
|
/* Returns the last index (+1) of the menu entry list. */
|
2015-05-14 21:53:28 +00:00
|
|
|
size_t menu_entries_get_end(void)
|
2015-05-14 20:18:32 +00:00
|
|
|
{
|
2015-05-14 23:02:58 +00:00
|
|
|
menu_list_t *menu_list = menu_list_get_ptr();
|
2015-05-14 20:18:32 +00:00
|
|
|
|
2015-05-14 23:02:58 +00:00
|
|
|
if (!menu_list)
|
2015-05-14 20:18:32 +00:00
|
|
|
return 0;
|
|
|
|
|
2015-05-14 23:02:58 +00:00
|
|
|
return menu_list_get_size(menu_list);
|
2015-05-14 20:18:32 +00:00
|
|
|
}
|
|
|
|
|
2015-06-01 09:55:03 +00:00
|
|
|
|
2015-06-02 10:37:56 +00:00
|
|
|
/* Sets title to what the name of the current menu should be. */
|
|
|
|
int menu_entries_get_title(char *s, size_t len)
|
2015-05-14 20:18:32 +00:00
|
|
|
{
|
2015-06-01 10:24:48 +00:00
|
|
|
const char *path = NULL;
|
2015-05-14 20:18:32 +00:00
|
|
|
const char *label = NULL;
|
|
|
|
unsigned menu_type = 0;
|
2015-06-01 10:24:48 +00:00
|
|
|
menu_file_list_cbs_t *cbs = NULL;
|
2015-05-14 23:01:27 +00:00
|
|
|
menu_list_t *menu_list = menu_list_get_ptr();
|
2015-05-14 20:18:32 +00:00
|
|
|
|
2015-05-14 23:01:27 +00:00
|
|
|
if (!menu_list)
|
2015-06-01 10:24:48 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
cbs = (menu_file_list_cbs_t*)menu_list_get_last_stack_actiondata(menu_list);
|
|
|
|
|
|
|
|
menu_list_get_last_stack(menu_list, &path, &label, &menu_type);
|
|
|
|
|
|
|
|
(void)cbs;
|
2015-05-14 20:18:32 +00:00
|
|
|
|
2015-06-01 10:24:48 +00:00
|
|
|
if (cbs && cbs->action_get_title)
|
2015-06-02 10:37:56 +00:00
|
|
|
return cbs->action_get_title(path, label, menu_type, s, len);
|
2015-06-01 10:24:48 +00:00
|
|
|
return 0;
|
2015-05-14 20:18:32 +00:00
|
|
|
}
|
|
|
|
|
2015-06-02 10:37:56 +00:00
|
|
|
/* Returns true if a Back button should be shown (i.e. we are at least
|
|
|
|
* one level deep in the menu hierarchy). */
|
|
|
|
bool menu_entries_show_back(void)
|
2015-05-14 20:18:32 +00:00
|
|
|
{
|
2015-05-14 23:01:27 +00:00
|
|
|
menu_list_t *menu_list = menu_list_get_ptr();
|
2015-06-01 14:50:09 +00:00
|
|
|
|
2015-05-14 23:01:27 +00:00
|
|
|
if (!menu_list)
|
2015-05-14 20:18:32 +00:00
|
|
|
return false;
|
|
|
|
|
2015-05-14 23:01:27 +00:00
|
|
|
return (menu_list_get_stack_size(menu_list) > 1);
|
2015-05-14 20:18:32 +00:00
|
|
|
}
|
|
|
|
|
2015-05-14 22:19:36 +00:00
|
|
|
/* Clicks the back button */
|
2015-06-01 14:50:09 +00:00
|
|
|
int menu_entry_go_back(void)
|
2015-05-14 20:18:32 +00:00
|
|
|
{
|
2015-06-01 14:50:09 +00:00
|
|
|
menu_list_t *menu_list = menu_list_get_ptr();
|
|
|
|
if (!menu_list)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
menu_setting_apply_deferred();
|
|
|
|
menu_list_pop_stack(menu_list);
|
|
|
|
|
|
|
|
if (menu_needs_refresh())
|
2015-05-15 20:31:16 +00:00
|
|
|
menu_do_refresh(MENU_ACTION_CANCEL);
|
2015-05-14 22:19:36 +00:00
|
|
|
|
2015-06-01 14:50:09 +00:00
|
|
|
rarch_main_data_iterate();
|
|
|
|
|
|
|
|
return 0;
|
2015-05-14 20:18:32 +00:00
|
|
|
}
|
|
|
|
|
2015-06-02 10:37:56 +00:00
|
|
|
/* Sets 's' to the name of the current core
|
|
|
|
* (shown at the top of the UI). */
|
|
|
|
void menu_entries_get_core_title(char *s, size_t len)
|
2015-05-09 23:30:11 +00:00
|
|
|
{
|
|
|
|
global_t *global = global_get_ptr();
|
|
|
|
const char *core_name = global->menu.info.library_name;
|
|
|
|
const char *core_version = global->menu.info.library_version;
|
2015-05-10 08:33:17 +00:00
|
|
|
|
2015-05-09 23:30:11 +00:00
|
|
|
if (!core_name)
|
2015-05-10 08:33:17 +00:00
|
|
|
core_name = global->system.info.library_name;
|
2015-05-09 23:30:11 +00:00
|
|
|
if (!core_name)
|
2015-05-10 08:33:17 +00:00
|
|
|
core_name = "No Core";
|
2015-05-09 23:30:11 +00:00
|
|
|
|
|
|
|
if (!core_version)
|
2015-05-10 08:33:17 +00:00
|
|
|
core_version = global->system.info.library_version;
|
2015-05-09 23:30:11 +00:00
|
|
|
if (!core_version)
|
2015-05-10 08:33:17 +00:00
|
|
|
core_version = "";
|
2015-05-09 23:30:11 +00:00
|
|
|
|
2015-06-02 10:37:56 +00:00
|
|
|
snprintf(s, len, "%s - %s %s", PACKAGE_VERSION,
|
2015-05-10 08:33:17 +00:00
|
|
|
core_name, core_version);
|
2015-05-09 23:30:11 +00:00
|
|
|
}
|
|
|
|
|
2015-06-01 14:54:48 +00:00
|
|
|
static rarch_setting_t *menu_entry_get_setting(uint32_t i)
|
2015-05-10 08:33:17 +00:00
|
|
|
{
|
|
|
|
const char *path = NULL, *entry_label = NULL;
|
|
|
|
unsigned type = 0;
|
|
|
|
const char *dir = NULL;
|
|
|
|
const char *label = NULL;
|
|
|
|
menu_list_t *menu_list = menu_list_get_ptr();
|
|
|
|
unsigned menu_type = 0;
|
|
|
|
|
|
|
|
menu_list_get_last_stack(menu_list, &dir, &label, &menu_type);
|
2015-05-09 23:30:11 +00:00
|
|
|
|
2015-05-10 08:33:17 +00:00
|
|
|
menu_list_get_at_offset(menu_list->selection_buf, i, &path,
|
|
|
|
&entry_label, &type);
|
2015-05-09 23:30:11 +00:00
|
|
|
|
2015-06-01 14:52:48 +00:00
|
|
|
return menu_setting_find(
|
2015-05-10 08:55:20 +00:00
|
|
|
menu_list->selection_buf->list[i].label);
|
2015-05-09 23:30:11 +00:00
|
|
|
}
|
|
|
|
|
2015-05-10 09:06:58 +00:00
|
|
|
enum menu_entry_type menu_entry_get_type(uint32_t i)
|
2015-05-10 08:33:17 +00:00
|
|
|
{
|
|
|
|
rarch_setting_t *setting;
|
|
|
|
const char *path = NULL, *entry_label = NULL;
|
|
|
|
unsigned type = 0;
|
|
|
|
const char *dir = NULL;
|
|
|
|
const char *label = NULL;
|
|
|
|
menu_list_t *menu_list = menu_list_get_ptr();
|
|
|
|
unsigned menu_type = 0;
|
|
|
|
|
|
|
|
menu_list_get_last_stack(menu_list, &dir, &label, &menu_type);
|
|
|
|
|
|
|
|
menu_list_get_at_offset(menu_list->selection_buf, i, &path,
|
|
|
|
&entry_label, &type);
|
|
|
|
|
2015-05-10 09:06:58 +00:00
|
|
|
setting = menu_entry_get_setting(i);
|
2015-05-10 08:33:17 +00:00
|
|
|
|
|
|
|
// XXX Really a special kind of ST_ACTION, but this should be
|
|
|
|
// changed
|
2015-06-03 19:27:47 +00:00
|
|
|
if (menu_setting_is_of_path_type(setting))
|
2015-05-10 08:33:17 +00:00
|
|
|
return MENU_ENTRY_PATH;
|
2015-06-06 19:36:58 +00:00
|
|
|
|
|
|
|
if (menu_setting_is_of_enum_type(setting))
|
2015-05-10 08:33:17 +00:00
|
|
|
return MENU_ENTRY_ENUM;
|
2015-06-06 19:36:58 +00:00
|
|
|
|
|
|
|
if (setting)
|
|
|
|
{
|
|
|
|
switch (setting->type)
|
|
|
|
{
|
|
|
|
case ST_BOOL:
|
|
|
|
return MENU_ENTRY_BOOL;
|
|
|
|
case ST_BIND:
|
|
|
|
return MENU_ENTRY_BIND;
|
|
|
|
case ST_INT:
|
|
|
|
return MENU_ENTRY_INT;
|
|
|
|
case ST_UINT:
|
|
|
|
return MENU_ENTRY_UINT;
|
|
|
|
case ST_FLOAT:
|
|
|
|
return MENU_ENTRY_FLOAT;
|
|
|
|
case ST_PATH:
|
|
|
|
return MENU_ENTRY_PATH;
|
|
|
|
case ST_DIR:
|
|
|
|
return MENU_ENTRY_DIR;
|
|
|
|
case ST_STRING:
|
|
|
|
return MENU_ENTRY_STRING;
|
|
|
|
case ST_HEX:
|
|
|
|
return MENU_ENTRY_HEX;
|
|
|
|
|
|
|
|
case ST_NONE:
|
|
|
|
case ST_ACTION:
|
|
|
|
case ST_GROUP:
|
|
|
|
case ST_SUB_GROUP:
|
|
|
|
case ST_END_GROUP:
|
|
|
|
case ST_END_SUB_GROUP:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-06-03 08:24:09 +00:00
|
|
|
|
|
|
|
return MENU_ENTRY_ACTION;
|
2015-05-09 23:30:11 +00:00
|
|
|
}
|
|
|
|
|
2015-06-01 13:16:54 +00:00
|
|
|
void menu_entry_get_path(uint32_t i, char *s, size_t len)
|
2015-05-10 08:33:17 +00:00
|
|
|
{
|
2015-06-06 11:02:23 +00:00
|
|
|
menu_entry_t entry = {{0}};
|
2015-05-10 10:45:53 +00:00
|
|
|
menu_entry_get(&entry, i, NULL, true);
|
2015-05-10 10:44:32 +00:00
|
|
|
|
2015-06-01 13:16:54 +00:00
|
|
|
strlcpy(s, entry.path, len);
|
2015-05-09 23:30:11 +00:00
|
|
|
}
|
2015-05-10 08:33:17 +00:00
|
|
|
|
2015-06-01 13:21:43 +00:00
|
|
|
void menu_entry_get_label(uint32_t i, char *s, size_t len)
|
|
|
|
{
|
2015-06-06 11:02:23 +00:00
|
|
|
menu_entry_t entry = {{0}};
|
2015-06-01 13:21:43 +00:00
|
|
|
menu_entry_get(&entry, i, NULL, true);
|
|
|
|
|
|
|
|
strlcpy(s, entry.label, len);
|
|
|
|
}
|
|
|
|
|
2015-06-01 13:13:49 +00:00
|
|
|
unsigned menu_entry_get_spacing(uint32_t i)
|
|
|
|
{
|
2015-06-06 11:02:23 +00:00
|
|
|
menu_entry_t entry = {{0}};
|
2015-06-01 13:13:49 +00:00
|
|
|
menu_entry_get(&entry, i, NULL, true);
|
|
|
|
|
|
|
|
return entry.spacing;
|
|
|
|
}
|
|
|
|
|
2015-06-01 13:21:43 +00:00
|
|
|
unsigned menu_entry_get_type_new(uint32_t i)
|
|
|
|
{
|
2015-06-06 11:02:23 +00:00
|
|
|
menu_entry_t entry = {{0}};
|
2015-06-01 13:21:43 +00:00
|
|
|
menu_entry_get(&entry, i, NULL, true);
|
|
|
|
|
|
|
|
return entry.type;
|
|
|
|
}
|
|
|
|
|
2015-05-10 09:12:50 +00:00
|
|
|
uint32_t menu_entry_get_bool_value(uint32_t i)
|
2015-05-10 08:33:17 +00:00
|
|
|
{
|
2015-05-10 09:06:58 +00:00
|
|
|
rarch_setting_t *setting = menu_entry_get_setting(i);
|
2015-05-10 08:33:17 +00:00
|
|
|
return *setting->value.boolean;
|
2015-05-09 23:30:11 +00:00
|
|
|
}
|
|
|
|
|
2015-06-02 12:10:36 +00:00
|
|
|
void menu_entry_set_bool_value(uint32_t i, bool value)
|
2015-05-10 08:33:17 +00:00
|
|
|
{
|
2015-05-10 09:06:58 +00:00
|
|
|
rarch_setting_t *setting = menu_entry_get_setting(i);
|
2015-06-03 09:19:26 +00:00
|
|
|
setting_set_with_string_representation(setting, value ? "true" : "false");
|
2015-05-09 23:30:11 +00:00
|
|
|
}
|
|
|
|
|
2015-05-10 08:33:17 +00:00
|
|
|
struct string_list *menu_entry_enum_values(uint32_t i)
|
|
|
|
{
|
2015-05-10 09:06:58 +00:00
|
|
|
rarch_setting_t *setting = menu_entry_get_setting(i);
|
2015-05-10 08:33:17 +00:00
|
|
|
return string_split(setting->values, "|");
|
2015-05-09 23:30:11 +00:00
|
|
|
}
|
|
|
|
|
2015-05-10 09:06:58 +00:00
|
|
|
void menu_entry_enum_set_value_with_string(uint32_t i, const char *s)
|
2015-05-10 08:33:17 +00:00
|
|
|
{
|
2015-05-10 09:06:58 +00:00
|
|
|
rarch_setting_t *setting = menu_entry_get_setting(i);
|
2015-05-10 08:33:17 +00:00
|
|
|
setting_set_with_string_representation(setting, s);
|
2015-05-09 23:30:11 +00:00
|
|
|
}
|
|
|
|
|
2015-05-10 08:33:17 +00:00
|
|
|
int32_t menu_entry_bind_index(uint32_t i)
|
|
|
|
{
|
2015-05-10 09:06:58 +00:00
|
|
|
rarch_setting_t *setting = menu_entry_get_setting(i);
|
2015-05-10 08:33:17 +00:00
|
|
|
if (setting->index)
|
|
|
|
return setting->index - 1;
|
|
|
|
return 0;
|
2015-05-09 23:30:11 +00:00
|
|
|
}
|
2015-05-10 08:33:17 +00:00
|
|
|
|
|
|
|
void menu_entry_bind_key_set(uint32_t i, int32_t value)
|
|
|
|
{
|
2015-05-10 09:06:58 +00:00
|
|
|
rarch_setting_t *setting = menu_entry_get_setting(i);
|
2015-05-20 00:50:27 +00:00
|
|
|
BINDFOR(*setting).key = (enum retro_key)value;
|
2015-05-09 23:30:11 +00:00
|
|
|
}
|
2015-05-10 08:33:17 +00:00
|
|
|
|
|
|
|
void menu_entry_bind_joykey_set(uint32_t i, int32_t value)
|
|
|
|
{
|
2015-05-10 09:06:58 +00:00
|
|
|
rarch_setting_t *setting = menu_entry_get_setting(i);
|
2015-05-10 08:33:17 +00:00
|
|
|
BINDFOR(*setting).joykey = value;
|
2015-05-09 23:30:11 +00:00
|
|
|
}
|
|
|
|
|
2015-05-10 08:33:17 +00:00
|
|
|
void menu_entry_bind_joyaxis_set(uint32_t i, int32_t value)
|
|
|
|
{
|
2015-05-10 09:06:58 +00:00
|
|
|
rarch_setting_t *setting = menu_entry_get_setting(i);
|
2015-05-10 08:33:17 +00:00
|
|
|
BINDFOR(*setting).joyaxis = value;
|
2015-05-09 23:30:11 +00:00
|
|
|
}
|
|
|
|
|
2015-05-10 08:33:17 +00:00
|
|
|
void menu_entry_pathdir_selected(uint32_t i)
|
|
|
|
{
|
2015-05-10 09:06:58 +00:00
|
|
|
rarch_setting_t *setting = menu_entry_get_setting(i);
|
2015-06-03 19:27:47 +00:00
|
|
|
if (menu_setting_is_of_path_type(setting))
|
2015-06-06 12:41:21 +00:00
|
|
|
setting->action_right(setting, false);
|
2015-05-09 23:30:11 +00:00
|
|
|
}
|
2015-05-10 08:33:17 +00:00
|
|
|
|
2015-06-02 12:07:47 +00:00
|
|
|
bool menu_entry_pathdir_allow_empty(uint32_t i)
|
2015-05-10 08:33:17 +00:00
|
|
|
{
|
2015-05-10 09:06:58 +00:00
|
|
|
rarch_setting_t *setting = menu_entry_get_setting(i);
|
2015-06-02 12:07:47 +00:00
|
|
|
if (!setting)
|
|
|
|
return false;
|
2015-05-10 08:33:17 +00:00
|
|
|
return setting->flags & SD_FLAG_ALLOW_EMPTY;
|
2015-05-09 23:30:11 +00:00
|
|
|
}
|
|
|
|
|
2015-05-10 08:33:17 +00:00
|
|
|
uint32_t menu_entry_pathdir_for_directory(uint32_t i)
|
|
|
|
{
|
2015-05-10 09:06:58 +00:00
|
|
|
rarch_setting_t *setting = menu_entry_get_setting(i);
|
2015-05-10 08:33:17 +00:00
|
|
|
return setting->flags & SD_FLAG_PATH_DIR;
|
2015-05-09 23:30:11 +00:00
|
|
|
}
|
2015-05-10 08:33:17 +00:00
|
|
|
|
2015-05-10 16:18:46 +00:00
|
|
|
void menu_entry_pathdir_get_value(uint32_t i, char *s, size_t len)
|
2015-05-10 08:33:17 +00:00
|
|
|
{
|
2015-06-06 11:02:23 +00:00
|
|
|
menu_entry_t entry = {{0}};
|
2015-05-10 16:18:46 +00:00
|
|
|
menu_entry_get(&entry, i, NULL, true);
|
|
|
|
strlcpy(s, entry.value, len);
|
2015-05-09 23:30:11 +00:00
|
|
|
}
|
2015-05-10 08:33:17 +00:00
|
|
|
|
2015-06-01 14:38:34 +00:00
|
|
|
int menu_entry_pathdir_set_value(uint32_t i, const char *s)
|
2015-05-10 08:33:17 +00:00
|
|
|
{
|
2015-06-01 14:38:34 +00:00
|
|
|
const char *menu_label = NULL;
|
|
|
|
const char *menu_path = NULL;
|
|
|
|
rarch_setting_t *setting = NULL;
|
|
|
|
menu_list_t *menu_list = menu_list_get_ptr();
|
|
|
|
|
|
|
|
menu_list_get_last_stack(menu_list,
|
|
|
|
&menu_path, &menu_label, NULL);
|
|
|
|
|
|
|
|
setting = menu_setting_find(menu_label);
|
|
|
|
|
|
|
|
if (!setting)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (setting->type != ST_DIR)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
(void)s;
|
2015-06-02 08:36:49 +00:00
|
|
|
setting_set_with_string_representation(setting, menu_path);
|
2015-06-01 14:38:34 +00:00
|
|
|
|
2015-06-06 14:26:55 +00:00
|
|
|
menu_setting_generic(setting, false);
|
2015-06-01 14:38:34 +00:00
|
|
|
|
|
|
|
menu_list_pop_stack_by_needle(menu_list, setting->name);
|
|
|
|
|
|
|
|
return 0;
|
2015-05-09 23:30:11 +00:00
|
|
|
}
|
|
|
|
|
2015-05-10 16:18:46 +00:00
|
|
|
void menu_entry_pathdir_extensions(uint32_t i, char *s, size_t len)
|
2015-05-10 08:33:17 +00:00
|
|
|
{
|
2015-05-10 09:06:58 +00:00
|
|
|
rarch_setting_t *setting = menu_entry_get_setting(i);
|
2015-06-01 14:42:55 +00:00
|
|
|
const char *extensions = setting ? setting->values : NULL;
|
|
|
|
if (setting && extensions)
|
|
|
|
strlcpy(s, extensions, len);
|
2015-05-09 23:30:11 +00:00
|
|
|
}
|
2015-05-10 08:33:17 +00:00
|
|
|
|
|
|
|
void menu_entry_reset(uint32_t i)
|
|
|
|
{
|
2015-06-06 11:02:23 +00:00
|
|
|
menu_entry_t entry = {{0}};
|
2015-05-14 22:58:06 +00:00
|
|
|
menu_entry_get(&entry, i, NULL, true);
|
|
|
|
|
|
|
|
menu_entry_action(&entry, i, MENU_ACTION_START);
|
2015-05-10 08:33:17 +00:00
|
|
|
}
|
|
|
|
|
2015-05-10 09:06:58 +00:00
|
|
|
void menu_entry_get_value(uint32_t i, char *s, size_t len)
|
2015-05-10 08:33:17 +00:00
|
|
|
{
|
2015-06-06 11:02:23 +00:00
|
|
|
menu_entry_t entry = {{0}};
|
2015-05-10 10:58:46 +00:00
|
|
|
menu_entry_get(&entry, i, NULL, true);
|
|
|
|
strlcpy(s, entry.value, len);
|
2015-05-09 23:30:11 +00:00
|
|
|
}
|
2015-05-10 08:33:17 +00:00
|
|
|
|
2015-05-10 09:06:58 +00:00
|
|
|
void menu_entry_set_value(uint32_t i, const char *s)
|
2015-05-10 08:33:17 +00:00
|
|
|
{
|
2015-05-10 09:06:58 +00:00
|
|
|
rarch_setting_t *setting = menu_entry_get_setting(i);
|
2015-05-10 08:33:17 +00:00
|
|
|
setting_set_with_string_representation(setting, s);
|
2015-05-09 23:30:11 +00:00
|
|
|
}
|
|
|
|
|
2015-05-10 08:33:17 +00:00
|
|
|
uint32_t menu_entry_num_has_range(uint32_t i)
|
|
|
|
{
|
2015-05-10 09:06:58 +00:00
|
|
|
rarch_setting_t *setting = menu_entry_get_setting(i);
|
2015-05-10 08:33:17 +00:00
|
|
|
return (setting->flags & SD_FLAG_HAS_RANGE);
|
2015-05-09 23:30:11 +00:00
|
|
|
}
|
|
|
|
|
2015-05-10 08:33:17 +00:00
|
|
|
float menu_entry_num_min(uint32_t i)
|
|
|
|
{
|
2015-05-10 09:06:58 +00:00
|
|
|
rarch_setting_t *setting = menu_entry_get_setting(i);
|
2015-05-10 08:33:17 +00:00
|
|
|
return setting->min;
|
2015-05-09 23:30:11 +00:00
|
|
|
}
|
2015-05-10 08:33:17 +00:00
|
|
|
|
|
|
|
float menu_entry_num_max(uint32_t i)
|
|
|
|
{
|
2015-05-10 09:06:58 +00:00
|
|
|
rarch_setting_t *setting = menu_entry_get_setting(i);
|
2015-05-10 08:33:17 +00:00
|
|
|
return setting->max;
|
2015-05-09 23:30:11 +00:00
|
|
|
}
|
|
|
|
|
2015-05-10 09:23:00 +00:00
|
|
|
void menu_entry_get(menu_entry_t *entry, size_t i,
|
|
|
|
void *userdata, bool use_representation)
|
|
|
|
{
|
|
|
|
const char *label = NULL;
|
|
|
|
const char *path = NULL;
|
|
|
|
const char *entry_label = NULL;
|
|
|
|
menu_file_list_cbs_t *cbs = NULL;
|
|
|
|
file_list_t *list = NULL;
|
|
|
|
menu_list_t *menu_list = menu_list_get_ptr();
|
|
|
|
|
|
|
|
if (!menu_list)
|
|
|
|
return;
|
|
|
|
|
|
|
|
menu_list_get_last_stack(menu_list, NULL, &label, NULL);
|
|
|
|
|
|
|
|
list = userdata ? (file_list_t*)userdata : menu_list->selection_buf;
|
|
|
|
|
|
|
|
if (!list)
|
|
|
|
return;
|
|
|
|
|
|
|
|
menu_list_get_at_offset(list, i, &path, &entry_label, &entry->type);
|
|
|
|
|
2015-05-17 11:23:27 +00:00
|
|
|
cbs = menu_list_get_actiondata_at_offset(list, i);
|
2015-05-10 09:23:00 +00:00
|
|
|
|
|
|
|
if (cbs && cbs->action_get_representation && use_representation)
|
|
|
|
cbs->action_get_representation(list,
|
|
|
|
&entry->spacing, entry->type, i, label,
|
|
|
|
entry->value, sizeof(entry->value),
|
|
|
|
entry_label, path,
|
|
|
|
entry->path, sizeof(entry->path));
|
|
|
|
|
|
|
|
entry->id = i;
|
|
|
|
|
2015-05-10 14:42:49 +00:00
|
|
|
if (path && !use_representation)
|
2015-05-10 09:23:00 +00:00
|
|
|
strlcpy(entry->path, path, sizeof(entry->path));
|
|
|
|
if (entry_label)
|
|
|
|
strlcpy(entry->label, entry_label, sizeof(entry->label));
|
|
|
|
}
|
|
|
|
|
2015-06-01 13:08:58 +00:00
|
|
|
bool menu_entry_is_currently_selected(unsigned id)
|
2015-05-10 09:23:00 +00:00
|
|
|
{
|
|
|
|
menu_navigation_t *nav = menu_navigation_get_ptr();
|
2015-06-01 13:08:58 +00:00
|
|
|
if (!nav)
|
2015-05-10 09:23:00 +00:00
|
|
|
return false;
|
2015-06-01 13:08:58 +00:00
|
|
|
return (id == nav->selection_ptr);
|
2015-05-10 09:23:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int menu_entry_get_current_id(bool use_representation)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
menu_list_t *menu_list = menu_list_get_ptr();
|
|
|
|
size_t end = menu_list_get_size(menu_list);
|
|
|
|
|
|
|
|
for (i = 0; i < end; i++)
|
|
|
|
{
|
2015-06-06 11:02:23 +00:00
|
|
|
menu_entry_t entry = {{0}};
|
2015-05-10 09:23:00 +00:00
|
|
|
menu_entry_get(&entry, i, NULL, use_representation);
|
|
|
|
|
2015-06-01 13:08:58 +00:00
|
|
|
if (menu_entry_is_currently_selected(entry.id))
|
2015-05-10 09:23:00 +00:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2015-06-02 12:17:37 +00:00
|
|
|
/* Performs whatever actions are associated with menu entry 'i'.
|
|
|
|
*
|
|
|
|
* This is the most important function because it does all the work
|
|
|
|
* associated with clicking on things in the UI.
|
|
|
|
*
|
|
|
|
* This includes loading cores and updating the
|
|
|
|
* currently displayed menu. */
|
2015-05-15 02:38:58 +00:00
|
|
|
int menu_entry_select(uint32_t i)
|
2015-05-09 23:30:11 +00:00
|
|
|
{
|
2015-06-06 11:02:23 +00:00
|
|
|
menu_entry_t entry = {{0}};
|
2015-06-01 05:49:49 +00:00
|
|
|
menu_navigation_t *nav = menu_navigation_get_ptr();
|
|
|
|
|
|
|
|
nav->selection_ptr = i;
|
2015-05-10 09:23:00 +00:00
|
|
|
menu_entry_get(&entry, i, NULL, false);
|
2015-05-10 08:33:17 +00:00
|
|
|
|
2015-06-01 05:38:59 +00:00
|
|
|
return menu_entry_action(&entry, i, MENU_ACTION_SELECT);
|
2015-05-09 23:30:11 +00:00
|
|
|
}
|
2015-05-10 23:27:00 +00:00
|
|
|
|
2015-05-11 15:53:33 +00:00
|
|
|
int menu_entry_iterate(unsigned action)
|
|
|
|
{
|
|
|
|
const char *label = NULL;
|
|
|
|
menu_file_list_cbs_t *cbs = NULL;
|
|
|
|
menu_list_t *menu_list = menu_list_get_ptr();
|
|
|
|
|
|
|
|
if (!menu_list)
|
|
|
|
return -1;
|
|
|
|
|
2015-05-15 20:06:42 +00:00
|
|
|
if (action != MENU_ACTION_NOOP || menu_needs_refresh() || menu_display_update_pending())
|
2015-05-18 21:14:56 +00:00
|
|
|
menu_display_fb_set_dirty();
|
2015-05-11 15:53:33 +00:00
|
|
|
|
2015-05-11 16:11:11 +00:00
|
|
|
cbs = (menu_file_list_cbs_t*)menu_list_get_last_stack_actiondata(menu_list);
|
2015-05-11 15:53:33 +00:00
|
|
|
|
|
|
|
menu_list_get_last_stack(menu_list, NULL, &label, NULL);
|
|
|
|
|
|
|
|
if (cbs && cbs->action_iterate)
|
|
|
|
return cbs->action_iterate(label, action);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2015-05-15 02:41:57 +00:00
|
|
|
int menu_entry_action(menu_entry_t *entry, unsigned i, enum menu_action action)
|
2015-05-10 23:27:00 +00:00
|
|
|
{
|
2015-05-18 15:58:21 +00:00
|
|
|
int ret = 0;
|
2015-05-10 23:27:00 +00:00
|
|
|
menu_navigation_t *nav = menu_navigation_get_ptr();
|
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
|
|
|
menu_list_t *menu_list = menu_list_get_ptr();
|
2015-05-17 11:23:27 +00:00
|
|
|
menu_file_list_cbs_t *cbs = menu_list_get_actiondata_at_offset(menu_list->selection_buf, i);
|
2015-05-10 23:27:00 +00:00
|
|
|
|
|
|
|
switch (action)
|
|
|
|
{
|
|
|
|
case MENU_ACTION_UP:
|
2015-05-18 13:31:53 +00:00
|
|
|
if (cbs && cbs->action_up)
|
2015-05-18 15:58:21 +00:00
|
|
|
ret = cbs->action_up(entry->type, entry->label);
|
2015-05-18 13:31:53 +00:00
|
|
|
break;
|
2015-05-10 23:27:00 +00:00
|
|
|
case MENU_ACTION_DOWN:
|
2015-05-18 13:31:53 +00:00
|
|
|
if (cbs && cbs->action_down)
|
2015-05-18 15:58:21 +00:00
|
|
|
ret = cbs->action_down(entry->type, entry->label);
|
2015-05-10 23:27:00 +00:00
|
|
|
break;
|
|
|
|
case MENU_ACTION_SCROLL_UP:
|
|
|
|
menu_navigation_descend_alphabet(nav, &nav->selection_ptr);
|
|
|
|
break;
|
|
|
|
case MENU_ACTION_SCROLL_DOWN:
|
|
|
|
menu_navigation_ascend_alphabet(nav, &nav->selection_ptr);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MENU_ACTION_CANCEL:
|
|
|
|
if (cbs && cbs->action_cancel)
|
2015-05-18 15:58:21 +00:00
|
|
|
ret = cbs->action_cancel(entry->path, entry->label, entry->type, i);
|
2015-05-10 23:27:00 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MENU_ACTION_OK:
|
|
|
|
if (cbs && cbs->action_ok)
|
2015-05-18 15:58:21 +00:00
|
|
|
ret = cbs->action_ok(entry->path, entry->label, entry->type, i);
|
2015-05-10 23:27:00 +00:00
|
|
|
break;
|
|
|
|
case MENU_ACTION_START:
|
|
|
|
if (cbs && cbs->action_start)
|
2015-05-18 15:58:21 +00:00
|
|
|
ret = cbs->action_start(entry->type, entry->label);
|
2015-05-10 23:27:00 +00:00
|
|
|
break;
|
|
|
|
case MENU_ACTION_LEFT:
|
2015-05-18 13:56:32 +00:00
|
|
|
if (cbs && cbs->action_left)
|
2015-05-18 15:58:21 +00:00
|
|
|
ret = cbs->action_left(entry->type, entry->label, false);
|
2015-05-18 13:56:32 +00:00
|
|
|
break;
|
2015-05-10 23:27:00 +00:00
|
|
|
case MENU_ACTION_RIGHT:
|
2015-05-18 13:56:32 +00:00
|
|
|
if (cbs && cbs->action_right)
|
2015-05-18 15:58:21 +00:00
|
|
|
ret = cbs->action_right(entry->type, entry->label, false);
|
2015-05-10 23:27:00 +00:00
|
|
|
break;
|
2015-06-01 05:21:00 +00:00
|
|
|
case MENU_ACTION_INFO:
|
2015-05-31 20:40:26 +00:00
|
|
|
if (cbs && cbs->action_info)
|
|
|
|
ret = cbs->action_info(entry->type, entry->label);
|
2015-05-10 23:27:00 +00:00
|
|
|
break;
|
2015-06-01 05:38:59 +00:00
|
|
|
case MENU_ACTION_SELECT:
|
|
|
|
if (cbs && cbs->action_select)
|
|
|
|
ret = cbs->action_select(entry->path, entry->label, entry->type, i);
|
|
|
|
break;
|
2015-05-10 23:27:00 +00:00
|
|
|
|
|
|
|
case MENU_ACTION_REFRESH:
|
|
|
|
if (cbs && cbs->action_refresh)
|
2015-05-16 16:15:35 +00:00
|
|
|
{
|
2015-05-18 15:58:21 +00:00
|
|
|
ret = cbs->action_refresh(menu_list->selection_buf, menu_list->menu_stack);
|
2015-05-16 16:15:35 +00:00
|
|
|
menu_unset_refresh();
|
|
|
|
}
|
2015-05-10 23:27:00 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MENU_ACTION_MESSAGE:
|
|
|
|
menu->msg_force = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MENU_ACTION_SEARCH:
|
|
|
|
menu_input_search_start();
|
|
|
|
break;
|
|
|
|
|
2015-05-25 23:10:27 +00:00
|
|
|
case MENU_ACTION_SCAN:
|
2015-05-27 04:57:01 +00:00
|
|
|
if (cbs && cbs->action_scan)
|
|
|
|
ret = cbs->action_scan(entry->path, entry->label, entry->type, i);
|
2015-05-10 23:27:00 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-05-18 15:58:21 +00:00
|
|
|
return ret;
|
2015-05-10 23:27:00 +00:00
|
|
|
}
|