2015-05-10 08:55:20 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2016-01-10 03:06:50 +00:00
|
|
|
* Copyright (C) 2011-2016 - Daniel De Matteis
|
2015-05-10 08:55:20 +00:00
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2015-06-13 17:12:10 +00:00
|
|
|
#include <compat/strl.h>
|
2016-03-20 13:53:54 +00:00
|
|
|
#include <lists/string_list.h>
|
2016-07-08 14:27:16 +00:00
|
|
|
#include <string/stdstring.h>
|
2015-06-13 17:12:10 +00:00
|
|
|
|
2015-12-06 16:55:27 +00:00
|
|
|
#include "menu_driver.h"
|
2015-09-25 23:23:10 +00:00
|
|
|
#include "menu_display.h"
|
2015-12-09 08:53:43 +00:00
|
|
|
#include "menu_navigation.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.
|
|
|
|
*
|
2015-06-12 14:07:12 +00:00
|
|
|
* It is organized into an event-based system where the UI companion
|
2015-06-02 10:37:56 +00:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
{
|
2015-10-18 18:21:12 +00:00
|
|
|
rarch_setting_t *setting = menu_entries_get_setting(i);
|
2015-05-10 08:33:17 +00:00
|
|
|
|
2015-06-26 16:35:35 +00:00
|
|
|
/* XXX Really a special kind of ST_ACTION, but this should be changed */
|
2016-03-18 21:23:51 +00:00
|
|
|
if (menu_setting_ctl(MENU_SETTING_CTL_IS_OF_PATH_TYPE, (void*)setting))
|
2015-05-10 08:33:17 +00:00
|
|
|
return MENU_ENTRY_PATH;
|
2015-06-06 19:36:58 +00:00
|
|
|
|
|
|
|
if (setting)
|
|
|
|
{
|
2016-02-14 16:22:01 +00:00
|
|
|
enum setting_type setting_type =
|
|
|
|
menu_setting_get_type(setting);
|
2015-09-26 00:22:01 +00:00
|
|
|
|
|
|
|
switch (setting_type)
|
2015-06-06 19:36:58 +00:00
|
|
|
{
|
|
|
|
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;
|
2015-10-11 21:07:43 +00:00
|
|
|
case ST_STRING_OPTIONS:
|
|
|
|
return MENU_ENTRY_ENUM;
|
2015-06-06 19:36:58 +00:00
|
|
|
case ST_STRING:
|
|
|
|
return MENU_ENTRY_STRING;
|
|
|
|
case ST_HEX:
|
|
|
|
return MENU_ENTRY_HEX;
|
2015-10-11 21:07:43 +00:00
|
|
|
|
|
|
|
default:
|
2015-06-06 19:36:58 +00:00
|
|
|
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-10-27 09:10:33 +00:00
|
|
|
menu_entry_get(&entry, 0, i, NULL, true);
|
2015-05-10 10:44:32 +00:00
|
|
|
|
2016-07-08 14:42:40 +00:00
|
|
|
strlcpy(s, entry.path, len);
|
2015-05-09 23:30:11 +00:00
|
|
|
}
|
2015-05-10 08:33:17 +00:00
|
|
|
|
2016-07-08 14:55:21 +00:00
|
|
|
void menu_entry_get_rich_label(uint32_t i, char *s, size_t len)
|
|
|
|
{
|
|
|
|
menu_entry_t entry = {{0}};
|
|
|
|
menu_entry_get(&entry, 0, i, NULL, true);
|
|
|
|
|
|
|
|
if (!string_is_empty(entry.rich_label))
|
|
|
|
strlcpy(s, entry.rich_label, len);
|
|
|
|
else
|
|
|
|
strlcpy(s, entry.path, len);
|
|
|
|
}
|
|
|
|
|
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-10-27 09:10:33 +00:00
|
|
|
menu_entry_get(&entry, 0, i, NULL, true);
|
2015-06-01 13:21:43 +00:00
|
|
|
|
2016-07-08 14:28:49 +00:00
|
|
|
strlcpy(s, entry.label, len);
|
2015-06-01 13:21:43 +00:00
|
|
|
}
|
|
|
|
|
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-10-27 09:10:33 +00:00
|
|
|
menu_entry_get(&entry, 0, i, NULL, true);
|
2015-06-01 13:13:49 +00:00
|
|
|
|
|
|
|
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-10-27 09:10:33 +00:00
|
|
|
menu_entry_get(&entry, 0, i, NULL, true);
|
2015-06-01 13:21:43 +00:00
|
|
|
|
|
|
|
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-10-18 18:21:12 +00:00
|
|
|
rarch_setting_t *setting = menu_entries_get_setting(i);
|
2015-10-11 15:17:05 +00:00
|
|
|
bool *ptr = (bool*)setting_get_ptr(setting);
|
2015-10-11 12:23:32 +00:00
|
|
|
if (!ptr)
|
|
|
|
return 0;
|
|
|
|
return *ptr;
|
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-10-18 18:21:12 +00:00
|
|
|
rarch_setting_t *setting = menu_entries_get_setting(i);
|
2015-09-28 00:02:54 +00:00
|
|
|
const char *values = menu_setting_get_values(setting);
|
|
|
|
|
|
|
|
if (!values)
|
|
|
|
return NULL;
|
|
|
|
return string_split(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-10-18 18:21:12 +00:00
|
|
|
rarch_setting_t *setting = menu_entries_get_setting(i);
|
2015-10-11 15:24:37 +00:00
|
|
|
menu_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-10-18 18:21:12 +00:00
|
|
|
rarch_setting_t *setting = menu_entries_get_setting(i);
|
2015-09-28 00:02:54 +00:00
|
|
|
uint32_t index = menu_setting_get_index(setting);
|
|
|
|
|
|
|
|
if (index)
|
|
|
|
return index - 1;
|
2015-05-10 08:33:17 +00:00
|
|
|
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-10-18 18:21:12 +00:00
|
|
|
rarch_setting_t *setting = menu_entries_get_setting(i);
|
2016-02-14 16:22:01 +00:00
|
|
|
struct retro_keybind *keybind = (struct retro_keybind*)
|
|
|
|
setting_get_ptr(setting);
|
2015-10-11 12:31:41 +00:00
|
|
|
if (keybind)
|
|
|
|
keybind->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-10-18 18:21:12 +00:00
|
|
|
rarch_setting_t *setting = menu_entries_get_setting(i);
|
2016-02-14 16:22:01 +00:00
|
|
|
struct retro_keybind *keybind = (struct retro_keybind*)
|
|
|
|
setting_get_ptr(setting);
|
2015-10-11 12:31:41 +00:00
|
|
|
if (keybind)
|
|
|
|
keybind->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-10-18 18:21:12 +00:00
|
|
|
rarch_setting_t *setting = menu_entries_get_setting(i);
|
2016-02-14 16:22:01 +00:00
|
|
|
struct retro_keybind *keybind = (struct retro_keybind*)
|
|
|
|
setting_get_ptr(setting);
|
2015-10-11 12:31:41 +00:00
|
|
|
if (keybind)
|
|
|
|
keybind->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-10-18 18:21:12 +00:00
|
|
|
rarch_setting_t *setting = menu_entries_get_setting(i);
|
2016-03-18 21:23:51 +00:00
|
|
|
|
|
|
|
if (menu_setting_ctl(MENU_SETTING_CTL_IS_OF_PATH_TYPE, (void*)setting))
|
2016-03-18 22:31:11 +00:00
|
|
|
menu_setting_ctl(MENU_SETTING_CTL_ACTION_RIGHT, setting);
|
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-10-18 18:21:12 +00:00
|
|
|
rarch_setting_t *setting = menu_entries_get_setting(i);
|
2015-09-28 00:02:54 +00:00
|
|
|
uint64_t flags = menu_setting_get_flags(setting);
|
|
|
|
|
|
|
|
return 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-10-18 18:21:12 +00:00
|
|
|
rarch_setting_t *setting = menu_entries_get_setting(i);
|
2015-09-28 00:02:54 +00:00
|
|
|
uint64_t flags = menu_setting_get_flags(setting);
|
|
|
|
|
|
|
|
return 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-10-27 09:10:33 +00:00
|
|
|
menu_entry_get(&entry, 0, i, NULL, true);
|
2015-05-10 16:18:46 +00:00
|
|
|
strlcpy(s, entry.value, len);
|
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_extensions(uint32_t i, char *s, size_t len)
|
2015-05-10 08:33:17 +00:00
|
|
|
{
|
2015-10-18 18:21:12 +00:00
|
|
|
rarch_setting_t *setting = menu_entries_get_setting(i);
|
2015-09-28 00:02:54 +00:00
|
|
|
const char *values = menu_setting_get_values(setting);
|
|
|
|
|
|
|
|
if (!values)
|
|
|
|
return;
|
|
|
|
|
|
|
|
strlcpy(s, values, 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-10-27 09:10:33 +00:00
|
|
|
menu_entry_get(&entry, 0, i, NULL, true);
|
2015-05-14 22:58:06 +00:00
|
|
|
|
|
|
|
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-10-27 09:10:33 +00:00
|
|
|
menu_entry_get(&entry, 0, i, NULL, true);
|
2015-05-10 10:58:46 +00:00
|
|
|
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-10-18 18:21:12 +00:00
|
|
|
rarch_setting_t *setting = menu_entries_get_setting(i);
|
2015-10-11 15:24:37 +00:00
|
|
|
menu_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-10-18 18:21:12 +00:00
|
|
|
rarch_setting_t *setting = menu_entries_get_setting(i);
|
2015-09-28 00:02:54 +00:00
|
|
|
uint64_t flags = menu_setting_get_flags(setting);
|
|
|
|
|
|
|
|
return (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-10-18 18:21:12 +00:00
|
|
|
rarch_setting_t *setting = menu_entries_get_setting(i);
|
2015-09-28 00:02:54 +00:00
|
|
|
double min = menu_setting_get_min(setting);
|
|
|
|
return (float)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-10-18 18:21:12 +00:00
|
|
|
rarch_setting_t *setting = menu_entries_get_setting(i);
|
2015-09-28 00:02:54 +00:00
|
|
|
double max = menu_setting_get_max(setting);
|
|
|
|
return (float)max;
|
2015-05-09 23:30:11 +00:00
|
|
|
}
|
|
|
|
|
2015-10-27 09:10:33 +00:00
|
|
|
void menu_entry_get(menu_entry_t *entry, size_t stack_idx,
|
|
|
|
size_t i, void *userdata, bool use_representation)
|
2015-05-10 09:23:00 +00:00
|
|
|
{
|
2015-10-17 15:51:40 +00:00
|
|
|
const char *path = NULL;
|
|
|
|
const char *entry_label = NULL;
|
|
|
|
menu_file_list_cbs_t *cbs = NULL;
|
2015-10-27 09:10:33 +00:00
|
|
|
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(stack_idx);
|
2015-10-27 06:56:32 +00:00
|
|
|
file_list_t *list = selection_buf;
|
2015-05-10 09:23:00 +00:00
|
|
|
|
2015-10-27 06:56:32 +00:00
|
|
|
if (userdata)
|
|
|
|
list = (file_list_t*)userdata;
|
2015-05-10 09:23:00 +00:00
|
|
|
|
|
|
|
if (!list)
|
|
|
|
return;
|
|
|
|
|
2015-10-18 19:54:20 +00:00
|
|
|
menu_entries_get_at_offset(list, i, &path, &entry_label, &entry->type,
|
|
|
|
&entry->entry_idx, NULL);
|
2015-05-10 09:23:00 +00:00
|
|
|
|
2015-10-19 14:32:51 +00:00
|
|
|
cbs = menu_entries_get_actiondata_at_offset(list, i);
|
2015-05-10 09:23:00 +00:00
|
|
|
|
2016-06-17 19:03:00 +00:00
|
|
|
if (cbs)
|
2015-08-17 23:58:18 +00:00
|
|
|
{
|
2016-07-09 11:49:31 +00:00
|
|
|
const char *label = NULL;
|
|
|
|
enum msg_hash_enums enum_idx = MSG_UNKNOWN;
|
|
|
|
|
2016-06-17 19:03:00 +00:00
|
|
|
entry->enum_idx = cbs->enum_idx;
|
|
|
|
|
2016-07-09 11:49:31 +00:00
|
|
|
menu_entries_get_last_stack(NULL, &label, NULL, &enum_idx, NULL);
|
2016-06-17 19:03:00 +00:00
|
|
|
|
2016-07-09 11:49:31 +00:00
|
|
|
if (cbs->action_get_value && use_representation)
|
2016-06-17 19:03:00 +00:00
|
|
|
cbs->action_get_value(list,
|
|
|
|
&entry->spacing, entry->type, i, label,
|
|
|
|
entry->value, sizeof(entry->value),
|
|
|
|
entry_label, path,
|
|
|
|
entry->path, sizeof(entry->path));
|
2016-07-08 14:24:05 +00:00
|
|
|
|
2016-07-08 14:42:40 +00:00
|
|
|
if (cbs->action_label)
|
2016-07-09 11:49:31 +00:00
|
|
|
cbs->action_label(list,
|
|
|
|
entry->type, i,
|
|
|
|
label, path,
|
|
|
|
entry->rich_label,
|
2016-07-08 14:24:05 +00:00
|
|
|
sizeof(entry->rich_label));
|
2015-08-17 23:58:18 +00:00
|
|
|
}
|
2015-05-10 09:23:00 +00:00
|
|
|
|
2015-06-10 21:00:38 +00:00
|
|
|
entry->idx = i;
|
2015-05-10 09:23:00 +00:00
|
|
|
|
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
|
|
|
{
|
2015-09-25 12:57:37 +00:00
|
|
|
size_t selection;
|
|
|
|
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
|
|
|
|
return false;
|
|
|
|
|
2015-09-06 00:06:02 +00:00
|
|
|
return (id == selection);
|
2015-05-10 09:23:00 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2015-09-25 13:59:23 +00:00
|
|
|
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &i);
|
|
|
|
|
2015-10-27 09:10:33 +00:00
|
|
|
menu_entry_get(&entry, 0, 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-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-10-17 15:51:40 +00:00
|
|
|
int ret = 0;
|
2016-02-14 16:22:01 +00:00
|
|
|
file_list_t *selection_buf =
|
|
|
|
menu_entries_get_selection_buf_ptr(0);
|
|
|
|
menu_file_list_cbs_t *cbs =
|
|
|
|
menu_entries_get_actiondata_at_offset(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:
|
2015-09-25 16:31:54 +00:00
|
|
|
menu_navigation_ctl(MENU_NAVIGATION_CTL_DESCEND_ALPHABET, NULL);
|
2015-05-10 23:27:00 +00:00
|
|
|
break;
|
|
|
|
case MENU_ACTION_SCROLL_DOWN:
|
2015-09-25 16:31:54 +00:00
|
|
|
menu_navigation_ctl(MENU_NAVIGATION_CTL_ASCEND_ALPHABET, NULL);
|
2015-05-10 23:27:00 +00:00
|
|
|
break;
|
|
|
|
case MENU_ACTION_CANCEL:
|
|
|
|
if (cbs && cbs->action_cancel)
|
2016-02-14 16:22:01 +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)
|
2016-02-14 16:22:01 +00:00
|
|
|
ret = cbs->action_ok(entry->path,
|
|
|
|
entry->label, entry->type, i, entry->entry_idx);
|
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)
|
2016-02-14 16:22:01 +00:00
|
|
|
ret = cbs->action_select(entry->path,
|
|
|
|
entry->label, entry->type, i);
|
2015-06-01 05:38:59 +00:00
|
|
|
break;
|
2015-05-10 23:27:00 +00:00
|
|
|
case MENU_ACTION_SEARCH:
|
2015-09-26 00:55:38 +00:00
|
|
|
menu_input_ctl(MENU_INPUT_CTL_SEARCH_START, NULL);
|
2015-05-10 23:27:00 +00:00
|
|
|
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)
|
2016-02-14 16:22:01 +00:00
|
|
|
ret = cbs->action_scan(entry->path,
|
|
|
|
entry->label, entry->type, i);
|
2015-05-10 23:27:00 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-10-19 14:32:51 +00:00
|
|
|
cbs = menu_entries_get_actiondata_at_offset(selection_buf, i);
|
2015-08-22 18:24:19 +00:00
|
|
|
|
2015-12-11 20:41:59 +00:00
|
|
|
if (menu_entries_ctl(MENU_ENTRIES_CTL_NEEDS_REFRESH, NULL))
|
2015-08-22 00:07:10 +00:00
|
|
|
{
|
|
|
|
if (cbs && cbs->action_refresh)
|
|
|
|
{
|
2015-12-12 01:14:50 +00:00
|
|
|
bool refresh = false;
|
2015-10-27 09:33:19 +00:00
|
|
|
file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0);
|
2015-10-17 15:51:40 +00:00
|
|
|
|
|
|
|
cbs->action_refresh(selection_buf, menu_stack);
|
2015-12-12 01:14:50 +00:00
|
|
|
menu_entries_ctl(MENU_ENTRIES_CTL_UNSET_REFRESH, &refresh);
|
2015-08-22 00:07:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-18 15:58:21 +00:00
|
|
|
return ret;
|
2015-05-10 23:27:00 +00:00
|
|
|
}
|