2014-09-12 03:54:58 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2015-01-07 16:46:50 +00:00
|
|
|
* Copyright (C) 2011-2015 - Daniel De Matteis
|
2014-09-12 03:54:58 +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/>.
|
|
|
|
*/
|
|
|
|
|
2015-02-14 00:51:28 +00:00
|
|
|
#include "menu_setting.h"
|
2014-09-24 05:56:47 +00:00
|
|
|
#include "menu_entries.h"
|
2015-01-11 00:34:08 +00:00
|
|
|
#include "../retroarch.h"
|
2014-09-12 03:54:58 +00:00
|
|
|
|
2015-02-14 00:51:28 +00:00
|
|
|
int menu_setting_generic(rarch_setting_t *setting)
|
2014-09-14 22:34:00 +00:00
|
|
|
{
|
2014-10-28 21:32:00 +00:00
|
|
|
if (!setting)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (setting->cmd_trigger.idx != RARCH_CMD_NONE)
|
|
|
|
setting->cmd_trigger.triggered = true;
|
2014-10-15 03:51:00 +00:00
|
|
|
|
2014-09-14 22:34:00 +00:00
|
|
|
if (setting->change_handler)
|
|
|
|
setting->change_handler(setting);
|
|
|
|
|
|
|
|
if (setting->flags & SD_FLAG_EXIT
|
|
|
|
&& setting->cmd_trigger.triggered)
|
|
|
|
{
|
|
|
|
setting->cmd_trigger.triggered = false;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-02-14 00:51:28 +00:00
|
|
|
static void setting_handler(rarch_setting_t *setting, unsigned action)
|
2014-10-14 23:14:35 +00:00
|
|
|
{
|
2014-10-28 21:32:00 +00:00
|
|
|
if (!setting)
|
|
|
|
return;
|
2014-10-15 03:51:00 +00:00
|
|
|
|
2014-10-28 21:32:00 +00:00
|
|
|
switch (action)
|
2014-10-15 03:51:00 +00:00
|
|
|
{
|
2015-01-22 22:52:02 +00:00
|
|
|
case MENU_ACTION_UP:
|
|
|
|
case MENU_ACTION_DOWN:
|
|
|
|
if (setting->action_up_or_down)
|
|
|
|
setting->action_up_or_down(setting, action);
|
|
|
|
break;
|
2014-10-28 21:32:00 +00:00
|
|
|
case MENU_ACTION_LEFT:
|
|
|
|
case MENU_ACTION_RIGHT:
|
|
|
|
if (setting->action_toggle)
|
2015-03-09 13:32:58 +00:00
|
|
|
setting->action_toggle(setting, action, true);
|
2014-10-28 21:32:00 +00:00
|
|
|
break;
|
|
|
|
case MENU_ACTION_OK:
|
|
|
|
if (setting->action_ok)
|
|
|
|
setting->action_ok(setting, action);
|
|
|
|
break;
|
2015-01-09 03:43:24 +00:00
|
|
|
case MENU_ACTION_CANCEL:
|
|
|
|
if (setting->action_cancel)
|
|
|
|
setting->action_cancel(setting, action);
|
|
|
|
break;
|
2014-10-28 21:32:00 +00:00
|
|
|
case MENU_ACTION_START:
|
|
|
|
if (setting->action_start)
|
|
|
|
setting->action_start(setting);
|
|
|
|
break;
|
2014-10-15 03:51:00 +00:00
|
|
|
}
|
2014-10-28 21:32:00 +00:00
|
|
|
}
|
2014-10-15 03:51:00 +00:00
|
|
|
|
2015-02-14 00:51:28 +00:00
|
|
|
int menu_setting_handler(rarch_setting_t *setting, unsigned action)
|
2014-10-28 21:32:00 +00:00
|
|
|
{
|
2015-02-14 00:51:28 +00:00
|
|
|
setting_handler(setting, action);
|
2014-10-28 21:32:00 +00:00
|
|
|
|
2015-02-14 00:51:28 +00:00
|
|
|
return menu_setting_generic(setting);
|
2014-10-14 23:14:35 +00:00
|
|
|
}
|
2014-09-24 05:56:47 +00:00
|
|
|
|
2015-01-27 00:58:48 +00:00
|
|
|
static int menu_action_handle_setting(rarch_setting_t *setting,
|
2015-03-09 03:18:47 +00:00
|
|
|
unsigned type, unsigned action, bool wraparound)
|
2014-09-24 05:56:47 +00:00
|
|
|
{
|
2014-10-14 23:23:13 +00:00
|
|
|
if (!setting)
|
|
|
|
return -1;
|
|
|
|
|
2014-10-16 15:19:48 +00:00
|
|
|
switch (setting->type)
|
2014-09-24 05:56:47 +00:00
|
|
|
{
|
2014-10-28 19:12:21 +00:00
|
|
|
case ST_PATH:
|
|
|
|
if (action == MENU_ACTION_OK)
|
2014-10-28 21:32:00 +00:00
|
|
|
menu_list_push_stack_refresh(
|
|
|
|
driver.menu->menu_list,
|
|
|
|
setting->default_value.string,
|
|
|
|
setting->name,
|
|
|
|
type,
|
2015-02-13 23:47:42 +00:00
|
|
|
driver.menu->navigation.selection_ptr);
|
2014-10-28 21:32:00 +00:00
|
|
|
/* fall-through. */
|
2014-10-16 15:19:48 +00:00
|
|
|
case ST_BOOL:
|
2014-10-18 02:20:52 +00:00
|
|
|
case ST_INT:
|
2014-10-16 15:19:48 +00:00
|
|
|
case ST_UINT:
|
|
|
|
case ST_FLOAT:
|
2014-10-16 23:37:17 +00:00
|
|
|
case ST_STRING:
|
2014-10-17 00:02:23 +00:00
|
|
|
case ST_DIR:
|
2014-10-17 05:11:51 +00:00
|
|
|
case ST_BIND:
|
2014-10-22 22:10:58 +00:00
|
|
|
case ST_ACTION:
|
2015-02-14 00:51:28 +00:00
|
|
|
setting_handler(setting, action);
|
2014-10-28 21:32:00 +00:00
|
|
|
break;
|
2014-10-16 15:19:48 +00:00
|
|
|
default:
|
|
|
|
break;
|
2014-09-24 05:56:47 +00:00
|
|
|
}
|
|
|
|
|
2015-02-14 00:51:28 +00:00
|
|
|
return menu_setting_generic(setting);
|
2014-09-24 05:56:47 +00:00
|
|
|
}
|
|
|
|
|
2015-02-14 00:51:28 +00:00
|
|
|
rarch_setting_t *menu_setting_find(const char *label)
|
2014-09-24 05:56:47 +00:00
|
|
|
{
|
2015-01-25 04:49:39 +00:00
|
|
|
return (rarch_setting_t*)setting_data_find_setting(
|
|
|
|
driver.menu->list_settings, label);
|
2014-10-28 18:08:18 +00:00
|
|
|
}
|
2014-09-24 05:56:47 +00:00
|
|
|
|
2015-03-09 03:10:57 +00:00
|
|
|
int menu_setting_set(unsigned type, const char *label,
|
|
|
|
unsigned action, bool wraparound)
|
2014-10-28 18:08:18 +00:00
|
|
|
{
|
2015-02-14 00:51:28 +00:00
|
|
|
rarch_setting_t *setting = menu_setting_find(
|
2015-01-25 04:49:39 +00:00
|
|
|
driver.menu->menu_list->selection_buf->list
|
2015-02-13 23:47:42 +00:00
|
|
|
[driver.menu->navigation.selection_ptr].label);
|
2015-01-25 04:49:39 +00:00
|
|
|
|
2015-01-22 22:09:58 +00:00
|
|
|
if (!setting)
|
|
|
|
return 0;
|
2014-09-24 05:56:47 +00:00
|
|
|
|
2015-03-09 03:18:47 +00:00
|
|
|
return menu_action_handle_setting(setting,
|
|
|
|
type, action, wraparound);
|
2014-09-24 05:56:47 +00:00
|
|
|
}
|