2014-04-14 02:32:54 +02:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
|
|
|
* Copyright (C) 2011-2014 - Daniel De Matteis
|
|
|
|
*
|
|
|
|
* 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 <stdint.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <ctype.h>
|
2014-10-02 11:36:52 +02:00
|
|
|
#include "../menu_common.h"
|
2014-10-22 00:23:06 +02:00
|
|
|
#include <file/file_path.h>
|
2014-10-02 11:36:52 +02:00
|
|
|
#include "../../../settings_data.h"
|
2014-09-16 00:52:07 +02:00
|
|
|
#include "menu_backend.h"
|
2014-10-17 20:44:22 +02:00
|
|
|
#include "../menu_list.h"
|
2014-08-31 18:36:26 +02:00
|
|
|
#include "../menu_entries.h"
|
2014-10-12 00:45:42 +02:00
|
|
|
#include "../menu_entries_cbs.h"
|
2014-04-26 02:40:38 +02:00
|
|
|
#include "../menu_input_line_cb.h"
|
2014-04-14 02:32:54 +02:00
|
|
|
|
2014-10-26 01:53:13 +02:00
|
|
|
#include "../../../input/input_autodetect.h"
|
2014-04-26 02:40:38 +02:00
|
|
|
#include "../../../config.def.h"
|
2014-09-24 07:56:47 +02:00
|
|
|
|
2014-09-12 22:12:41 +02:00
|
|
|
#ifdef GEKKO
|
|
|
|
extern unsigned menu_gx_resolutions[GX_RESOLUTIONS_LAST][2];
|
|
|
|
extern unsigned menu_current_gx_resolution;
|
|
|
|
#endif
|
|
|
|
|
2014-09-19 20:31:53 +02:00
|
|
|
static int menu_message_toggle(unsigned action)
|
|
|
|
{
|
|
|
|
if (driver.video_data && driver.menu_ctx
|
|
|
|
&& driver.menu_ctx->render_messagebox)
|
|
|
|
driver.menu_ctx->render_messagebox(driver.menu->message_contents);
|
2014-10-08 02:45:26 +02:00
|
|
|
|
2014-09-19 20:31:53 +02:00
|
|
|
if (action == MENU_ACTION_OK)
|
2014-10-18 01:44:06 +02:00
|
|
|
menu_list_pop_stack(driver.menu->menu_list);
|
2014-09-19 20:31:53 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-08-30 01:56:12 +02:00
|
|
|
static int menu_info_screen_iterate(unsigned action)
|
2014-05-31 05:14:04 +02:00
|
|
|
{
|
2014-07-27 04:30:06 +02:00
|
|
|
char msg[PATH_MAX];
|
2014-09-05 04:21:46 +02:00
|
|
|
char needle[PATH_MAX];
|
|
|
|
unsigned info_type = 0;
|
2014-08-27 15:13:10 +02:00
|
|
|
rarch_setting_t *current_setting = NULL;
|
2014-10-18 01:17:00 +02:00
|
|
|
file_list_t *list = (file_list_t*)driver.menu->menu_list->selection_buf;
|
2014-05-31 05:14:04 +02:00
|
|
|
|
2014-10-13 02:56:14 +02:00
|
|
|
if (!driver.menu)
|
2014-05-31 05:14:04 +02:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render)
|
|
|
|
driver.menu_ctx->render();
|
|
|
|
|
2014-10-11 15:49:38 +02:00
|
|
|
current_setting = (rarch_setting_t*)setting_data_find_setting(
|
2014-10-12 18:59:28 +02:00
|
|
|
driver.menu->list_settings,
|
|
|
|
list->list[driver.menu->selection_ptr].label);
|
2014-08-16 06:41:07 +02:00
|
|
|
|
|
|
|
if (current_setting)
|
2014-09-05 04:21:46 +02:00
|
|
|
strlcpy(needle, current_setting->name, sizeof(needle));
|
2014-10-11 15:49:38 +02:00
|
|
|
else if ((current_setting = (rarch_setting_t*)setting_data_find_setting(
|
2014-10-12 18:59:28 +02:00
|
|
|
driver.menu->list_mainmenu,
|
|
|
|
list->list[driver.menu->selection_ptr].label)))
|
2014-09-05 04:21:46 +02:00
|
|
|
{
|
2014-09-11 20:10:43 -04:00
|
|
|
if (current_setting)
|
|
|
|
strlcpy(needle, current_setting->name, sizeof(needle));
|
2014-09-05 04:21:46 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-10-12 18:01:07 +02:00
|
|
|
const char *label = NULL;
|
2014-10-18 01:17:00 +02:00
|
|
|
menu_list_get_at_offset(driver.menu->menu_list->selection_buf,
|
2014-10-12 18:01:07 +02:00
|
|
|
driver.menu->selection_ptr, NULL, &label,
|
|
|
|
&info_type);
|
2014-09-01 23:45:08 +02:00
|
|
|
|
2014-10-12 18:01:07 +02:00
|
|
|
if (label)
|
|
|
|
strlcpy(needle, label, sizeof(needle));
|
2014-09-05 04:21:46 +02:00
|
|
|
}
|
2014-09-08 06:12:43 +02:00
|
|
|
|
2014-09-08 22:12:22 +02:00
|
|
|
setting_data_get_description(needle, msg, sizeof(msg));
|
2014-05-31 05:14:04 +02:00
|
|
|
|
2014-09-01 16:52:54 +02:00
|
|
|
if (driver.video_data && driver.menu_ctx &&
|
|
|
|
driver.menu_ctx->render_messagebox)
|
2014-07-27 04:30:06 +02:00
|
|
|
{
|
|
|
|
if (*msg && msg[0] != '\0')
|
|
|
|
driver.menu_ctx->render_messagebox(msg);
|
|
|
|
}
|
2014-05-31 05:14:04 +02:00
|
|
|
|
2014-06-10 01:42:26 +02:00
|
|
|
if (action == MENU_ACTION_OK)
|
2014-10-18 01:44:06 +02:00
|
|
|
menu_list_pop_stack(driver.menu->menu_list);
|
2014-08-27 15:08:21 +02:00
|
|
|
|
2014-05-31 05:14:04 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-10-13 02:15:45 +02:00
|
|
|
static int menu_action_ok(menu_file_list_cbs_t *cbs)
|
2014-10-12 17:46:08 +02:00
|
|
|
{
|
|
|
|
const char *label = NULL;
|
|
|
|
const char *path = NULL;
|
|
|
|
unsigned type = 0;
|
|
|
|
|
2014-10-18 02:32:59 +02:00
|
|
|
if (menu_list_get_size(driver.menu->menu_list) == 0)
|
2014-10-12 17:46:08 +02:00
|
|
|
return 0;
|
|
|
|
|
2014-10-18 01:17:00 +02:00
|
|
|
menu_list_get_at_offset(driver.menu->menu_list->selection_buf,
|
2014-10-12 17:46:08 +02:00
|
|
|
driver.menu->selection_ptr, &path, &label, &type);
|
|
|
|
|
|
|
|
if (cbs && cbs->action_ok)
|
|
|
|
return cbs->action_ok(path, label, type, driver.menu->selection_ptr);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-05-30 20:23:20 +02:00
|
|
|
static int menu_start_screen_iterate(unsigned action)
|
2014-04-14 02:32:54 +02:00
|
|
|
{
|
|
|
|
unsigned i;
|
2014-10-12 05:24:52 +02:00
|
|
|
char msg[PATH_MAX];
|
2014-05-30 20:23:20 +02:00
|
|
|
|
2014-05-31 22:20:27 +02:00
|
|
|
if (!driver.menu)
|
2014-05-30 20:23:20 +02:00
|
|
|
return 0;
|
2014-04-14 02:32:54 +02:00
|
|
|
|
|
|
|
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render)
|
2014-05-30 21:51:12 +02:00
|
|
|
driver.menu_ctx->render();
|
2014-04-14 02:32:54 +02:00
|
|
|
|
|
|
|
static const unsigned binds[] = {
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_UP,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_DOWN,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_A,
|
|
|
|
RETRO_DEVICE_ID_JOYPAD_B,
|
2014-05-31 05:14:04 +02:00
|
|
|
RETRO_DEVICE_ID_JOYPAD_SELECT,
|
2014-04-14 02:32:54 +02:00
|
|
|
RARCH_MENU_TOGGLE,
|
|
|
|
RARCH_QUIT_KEY,
|
|
|
|
};
|
2014-05-31 14:36:49 +02:00
|
|
|
char desc[ARRAY_SIZE(binds)][64];
|
2014-04-14 02:32:54 +02:00
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(binds); i++)
|
|
|
|
{
|
2014-10-20 23:41:01 +02:00
|
|
|
const struct retro_keybind *keybind = (const struct retro_keybind*)
|
2014-09-01 16:52:54 +02:00
|
|
|
&g_settings.input.binds[0][binds[i]];
|
|
|
|
const struct retro_keybind *auto_bind = (const struct retro_keybind*)
|
|
|
|
input_get_auto_bind(0, binds[i]);
|
2014-08-14 00:49:28 +02:00
|
|
|
|
2014-10-20 23:41:01 +02:00
|
|
|
input_get_bind_string(desc[i], keybind, auto_bind, sizeof(desc[i]));
|
2014-04-14 02:32:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
snprintf(msg, sizeof(msg),
|
2014-06-10 02:44:19 +02:00
|
|
|
"-- Welcome to RetroArch --\n"
|
2014-04-14 02:32:54 +02:00
|
|
|
" \n" // strtok_r doesn't split empty strings.
|
|
|
|
|
2014-06-10 02:44:19 +02:00
|
|
|
"Basic Menu controls:\n"
|
2014-04-14 02:32:54 +02:00
|
|
|
" Scroll (Up): %-20s\n"
|
|
|
|
" Scroll (Down): %-20s\n"
|
|
|
|
" Accept/OK: %-20s\n"
|
|
|
|
" Back: %-20s\n"
|
2014-05-31 05:14:04 +02:00
|
|
|
" Info: %-20s\n"
|
2014-06-10 02:44:19 +02:00
|
|
|
"Enter/Exit Menu: %-20s\n"
|
2014-04-14 02:32:54 +02:00
|
|
|
" Exit RetroArch: %-20s\n"
|
|
|
|
" \n"
|
|
|
|
|
|
|
|
"To run content:\n"
|
|
|
|
"Load a libretro core (Core).\n"
|
|
|
|
"Load a content file (Load Content). \n"
|
|
|
|
" \n"
|
|
|
|
|
|
|
|
"See Path Options to set directories\n"
|
|
|
|
"for faster access to files.\n"
|
|
|
|
" \n"
|
|
|
|
|
|
|
|
"Press Accept/OK to continue.",
|
2014-10-12 18:01:07 +02:00
|
|
|
desc[0], desc[1], desc[2], desc[3], desc[4], desc[5], desc[6]);
|
2014-04-14 02:32:54 +02:00
|
|
|
|
|
|
|
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render_messagebox)
|
2014-05-30 21:51:12 +02:00
|
|
|
driver.menu_ctx->render_messagebox(msg);
|
2014-04-14 02:32:54 +02:00
|
|
|
|
2014-06-10 01:42:26 +02:00
|
|
|
if (action == MENU_ACTION_OK)
|
2014-10-18 01:44:06 +02:00
|
|
|
menu_list_pop_stack(driver.menu->menu_list);
|
2014-08-27 15:08:21 +02:00
|
|
|
|
2014-04-14 02:32:54 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-10-26 18:06:57 +01:00
|
|
|
static int mouse_iterate(unsigned action)
|
|
|
|
{
|
|
|
|
const struct retro_keybind *binds[MAX_PLAYERS];
|
|
|
|
|
|
|
|
if (!driver.menu->mouse.enable)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
driver.menu->mouse.dx = driver.input->input_state(driver.input_data,
|
|
|
|
binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_X);
|
|
|
|
driver.menu->mouse.dy = driver.input->input_state(driver.input_data,
|
|
|
|
binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_Y);
|
|
|
|
|
|
|
|
driver.menu->mouse.x += driver.menu->mouse.dx;
|
|
|
|
driver.menu->mouse.y += driver.menu->mouse.dy;
|
|
|
|
|
|
|
|
if (driver.menu->mouse.x < 5)
|
|
|
|
driver.menu->mouse.x = 5;
|
|
|
|
if (driver.menu->mouse.y < 5)
|
|
|
|
driver.menu->mouse.y = 5;
|
|
|
|
if (driver.menu->mouse.x > driver.menu->width - 5)
|
|
|
|
driver.menu->mouse.x = driver.menu->width - 5;
|
|
|
|
if (driver.menu->mouse.y > driver.menu->height - 5)
|
|
|
|
driver.menu->mouse.y = driver.menu->height - 5;
|
|
|
|
|
|
|
|
driver.menu->mouse.left = driver.input->input_state(driver.input_data,
|
|
|
|
binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_LEFT);
|
|
|
|
|
|
|
|
driver.menu->mouse.right = driver.input->input_state(driver.input_data,
|
|
|
|
binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_RIGHT);
|
|
|
|
|
2014-10-26 22:31:53 +01:00
|
|
|
driver.menu->mouse.wheelup = driver.input->input_state(driver.input_data,
|
|
|
|
binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_WHEELUP)
|
|
|
|
|| driver.menu->mouse.y == 5;
|
|
|
|
|
|
|
|
driver.menu->mouse.wheeldown = driver.input->input_state(driver.input_data,
|
|
|
|
binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_WHEELDOWN)
|
|
|
|
|| driver.menu->mouse.y == driver.menu->height - 5;
|
|
|
|
|
2014-10-26 18:06:57 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mouse_post_iterate(menu_file_list_cbs_t *cbs, unsigned action)
|
|
|
|
{
|
|
|
|
if (!driver.menu->mouse.enable)
|
|
|
|
return 0;
|
|
|
|
|
2014-10-27 00:55:14 +01:00
|
|
|
if (driver.menu->mouse.ptr <= menu_list_get_size(driver.menu->menu_list)-1)
|
|
|
|
menu_navigation_set(driver.menu, driver.menu->mouse.ptr, false);
|
2014-10-26 18:06:57 +01:00
|
|
|
|
|
|
|
if (driver.menu->mouse.left)
|
|
|
|
{
|
|
|
|
if (!driver.menu->mouse.oldleft)
|
|
|
|
{
|
|
|
|
driver.menu->mouse.oldleft = true;
|
|
|
|
return menu_action_ok(cbs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
driver.menu->mouse.oldleft = false;
|
|
|
|
|
|
|
|
if (driver.menu->mouse.right)
|
|
|
|
{
|
|
|
|
if (!driver.menu->mouse.oldright)
|
|
|
|
{
|
|
|
|
driver.menu->mouse.oldright = true;
|
|
|
|
menu_list_pop_stack(driver.menu->menu_list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
driver.menu->mouse.oldright = false;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-08-31 04:34:51 +02:00
|
|
|
static int menu_viewport_iterate(unsigned action)
|
2014-05-22 03:12:56 +02:00
|
|
|
{
|
2014-08-31 04:34:51 +02:00
|
|
|
int stride_x = 1, stride_y = 1;
|
2014-10-12 05:24:52 +02:00
|
|
|
char msg[PATH_MAX];
|
2014-08-31 04:34:51 +02:00
|
|
|
struct retro_game_geometry *geom = NULL;
|
|
|
|
const char *base_msg = NULL;
|
|
|
|
const char *label = NULL;
|
2014-10-16 03:55:03 +02:00
|
|
|
unsigned type = 0;
|
2014-08-31 04:34:51 +02:00
|
|
|
rarch_viewport_t *custom = (rarch_viewport_t*)
|
|
|
|
&g_extern.console.screen.viewports.custom_vp;
|
2014-05-22 03:12:56 +02:00
|
|
|
|
2014-10-18 01:59:16 +02:00
|
|
|
menu_list_get_last_stack(driver.menu->menu_list, NULL, &label, &type);
|
2014-08-31 04:34:51 +02:00
|
|
|
|
|
|
|
geom = (struct retro_game_geometry*)&g_extern.system.av_info.geometry;
|
|
|
|
|
|
|
|
if (g_settings.video.scale_integer)
|
2014-07-26 05:58:52 +02:00
|
|
|
{
|
2014-08-31 04:34:51 +02:00
|
|
|
stride_x = geom->base_width;
|
|
|
|
stride_y = geom->base_height;
|
2014-07-26 05:58:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (action)
|
|
|
|
{
|
2014-08-31 04:34:51 +02:00
|
|
|
case MENU_ACTION_UP:
|
2014-10-16 03:55:03 +02:00
|
|
|
if (type == MENU_SETTINGS_CUSTOM_VIEWPORT)
|
2014-08-31 04:34:51 +02:00
|
|
|
{
|
|
|
|
custom->y -= stride_y;
|
|
|
|
custom->height += stride_y;
|
|
|
|
}
|
|
|
|
else if (custom->height >= (unsigned)stride_y)
|
|
|
|
custom->height -= stride_y;
|
|
|
|
|
|
|
|
rarch_main_command(RARCH_CMD_VIDEO_APPLY_STATE_CHANGES);
|
2014-07-26 05:58:52 +02:00
|
|
|
break;
|
|
|
|
|
2014-08-31 04:34:51 +02:00
|
|
|
case MENU_ACTION_DOWN:
|
2014-10-16 03:55:03 +02:00
|
|
|
if (type == MENU_SETTINGS_CUSTOM_VIEWPORT)
|
2014-08-31 04:34:51 +02:00
|
|
|
{
|
|
|
|
custom->y += stride_y;
|
|
|
|
if (custom->height >= (unsigned)stride_y)
|
|
|
|
custom->height -= stride_y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
custom->height += stride_y;
|
2014-07-26 05:58:52 +02:00
|
|
|
|
2014-08-31 04:34:51 +02:00
|
|
|
rarch_main_command(RARCH_CMD_VIDEO_APPLY_STATE_CHANGES);
|
2014-08-02 15:16:56 +02:00
|
|
|
break;
|
|
|
|
|
2014-08-31 04:34:51 +02:00
|
|
|
case MENU_ACTION_LEFT:
|
2014-10-16 03:55:03 +02:00
|
|
|
if (type == MENU_SETTINGS_CUSTOM_VIEWPORT)
|
2014-08-31 04:34:51 +02:00
|
|
|
{
|
|
|
|
custom->x -= stride_x;
|
|
|
|
custom->width += stride_x;
|
|
|
|
}
|
|
|
|
else if (custom->width >= (unsigned)stride_x)
|
|
|
|
custom->width -= stride_x;
|
2014-08-02 15:16:56 +02:00
|
|
|
|
2014-08-31 04:34:51 +02:00
|
|
|
rarch_main_command(RARCH_CMD_VIDEO_APPLY_STATE_CHANGES);
|
|
|
|
break;
|
2014-08-27 18:07:45 +02:00
|
|
|
|
2014-08-31 04:34:51 +02:00
|
|
|
case MENU_ACTION_RIGHT:
|
2014-10-16 03:55:03 +02:00
|
|
|
if (type == MENU_SETTINGS_CUSTOM_VIEWPORT)
|
2014-08-27 18:07:45 +02:00
|
|
|
{
|
2014-08-31 04:34:51 +02:00
|
|
|
custom->x += stride_x;
|
|
|
|
if (custom->width >= (unsigned)stride_x)
|
|
|
|
custom->width -= stride_x;
|
2014-08-27 18:07:45 +02:00
|
|
|
}
|
2014-08-18 12:14:53 +02:00
|
|
|
else
|
2014-08-31 04:34:51 +02:00
|
|
|
custom->width += stride_x;
|
2014-07-26 05:58:52 +02:00
|
|
|
|
2014-08-31 04:34:51 +02:00
|
|
|
rarch_main_command(RARCH_CMD_VIDEO_APPLY_STATE_CHANGES);
|
|
|
|
break;
|
2014-07-26 05:58:52 +02:00
|
|
|
|
2014-08-31 04:34:51 +02:00
|
|
|
case MENU_ACTION_CANCEL:
|
2014-10-18 01:44:06 +02:00
|
|
|
menu_list_pop_stack(driver.menu->menu_list);
|
|
|
|
|
2014-09-01 00:37:21 +02:00
|
|
|
if (!strcmp(label, "custom_viewport_2"))
|
2014-08-31 04:34:51 +02:00
|
|
|
{
|
2014-10-18 01:24:37 +02:00
|
|
|
menu_list_push_stack(driver.menu->menu_list, "", "",
|
2014-08-31 04:34:51 +02:00
|
|
|
MENU_SETTINGS_CUSTOM_VIEWPORT,
|
|
|
|
driver.menu->selection_ptr);
|
|
|
|
}
|
|
|
|
break;
|
2014-07-26 05:58:52 +02:00
|
|
|
|
2014-08-31 04:34:51 +02:00
|
|
|
case MENU_ACTION_OK:
|
2014-10-18 01:44:06 +02:00
|
|
|
menu_list_pop_stack(driver.menu->menu_list);
|
|
|
|
|
2014-10-16 03:55:03 +02:00
|
|
|
if (type == MENU_SETTINGS_CUSTOM_VIEWPORT
|
2014-08-31 04:34:51 +02:00
|
|
|
&& !g_settings.video.scale_integer)
|
|
|
|
{
|
2014-10-18 01:24:37 +02:00
|
|
|
menu_list_push_stack(driver.menu->menu_list, "",
|
2014-09-01 00:37:21 +02:00
|
|
|
"custom_viewport_2", 0, driver.menu->selection_ptr);
|
2014-08-31 04:34:51 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MENU_ACTION_START:
|
|
|
|
if (!g_settings.video.scale_integer)
|
|
|
|
{
|
|
|
|
rarch_viewport_t vp;
|
|
|
|
|
2014-09-01 16:52:54 +02:00
|
|
|
if (driver.video_data && driver.video &&
|
|
|
|
driver.video->viewport_info)
|
2014-08-31 04:34:51 +02:00
|
|
|
driver.video->viewport_info(driver.video_data, &vp);
|
|
|
|
|
2014-10-16 03:55:03 +02:00
|
|
|
if (type == MENU_SETTINGS_CUSTOM_VIEWPORT)
|
2014-08-18 12:14:53 +02:00
|
|
|
{
|
2014-08-31 04:34:51 +02:00
|
|
|
custom->width += custom->x;
|
|
|
|
custom->height += custom->y;
|
|
|
|
custom->x = 0;
|
|
|
|
custom->y = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
custom->width = vp.full_width - custom->x;
|
|
|
|
custom->height = vp.full_height - custom->y;
|
2014-08-18 12:14:53 +02:00
|
|
|
}
|
2014-07-26 05:58:52 +02:00
|
|
|
|
2014-08-31 04:34:51 +02:00
|
|
|
rarch_main_command(RARCH_CMD_VIDEO_APPLY_STATE_CHANGES);
|
|
|
|
}
|
|
|
|
break;
|
2014-07-26 05:58:52 +02:00
|
|
|
|
2014-08-31 04:34:51 +02:00
|
|
|
case MENU_ACTION_MESSAGE:
|
|
|
|
driver.menu->msg_force = true;
|
|
|
|
break;
|
2014-07-26 05:58:52 +02:00
|
|
|
|
2014-08-31 04:34:51 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2014-07-26 05:58:52 +02:00
|
|
|
|
2014-10-18 01:59:16 +02:00
|
|
|
menu_list_get_last_stack(driver.menu->menu_list, NULL, &label, &type);
|
2014-07-26 05:58:52 +02:00
|
|
|
|
2014-08-31 04:34:51 +02:00
|
|
|
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render)
|
|
|
|
driver.menu_ctx->render();
|
2014-07-26 05:58:52 +02:00
|
|
|
|
2014-08-31 04:34:51 +02:00
|
|
|
if (g_settings.video.scale_integer)
|
|
|
|
{
|
|
|
|
custom->x = 0;
|
|
|
|
custom->y = 0;
|
2014-09-01 16:52:54 +02:00
|
|
|
custom->width = ((custom->width + geom->base_width - 1) /
|
|
|
|
geom->base_width) * geom->base_width;
|
|
|
|
custom->height = ((custom->height + geom->base_height - 1) /
|
|
|
|
geom->base_height) * geom->base_height;
|
2014-08-27 15:08:21 +02:00
|
|
|
|
2014-08-31 04:34:51 +02:00
|
|
|
base_msg = "Set scale";
|
|
|
|
snprintf(msg, sizeof(msg), "%s (%4ux%4u, %u x %u scale)",
|
|
|
|
base_msg,
|
|
|
|
custom->width, custom->height,
|
|
|
|
custom->width / geom->base_width,
|
|
|
|
custom->height / geom->base_height);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-10-16 03:55:03 +02:00
|
|
|
if (type == MENU_SETTINGS_CUSTOM_VIEWPORT)
|
2014-08-31 04:34:51 +02:00
|
|
|
base_msg = "Set Upper-Left Corner";
|
2014-09-01 00:37:21 +02:00
|
|
|
else if (!strcmp(label, "custom_viewport_2"))
|
2014-08-31 04:34:51 +02:00
|
|
|
base_msg = "Set Bottom-Right Corner";
|
2014-07-26 05:58:52 +02:00
|
|
|
|
2014-08-31 04:34:51 +02:00
|
|
|
snprintf(msg, sizeof(msg), "%s (%d, %d : %4ux%4u)",
|
|
|
|
base_msg, custom->x, custom->y, custom->width, custom->height);
|
|
|
|
}
|
2014-08-01 07:00:32 +02:00
|
|
|
|
2014-09-01 16:52:54 +02:00
|
|
|
if (driver.video_data && driver.menu_ctx &&
|
|
|
|
driver.menu_ctx->render_messagebox)
|
2014-08-31 04:34:51 +02:00
|
|
|
driver.menu_ctx->render_messagebox(msg);
|
2014-07-26 05:58:52 +02:00
|
|
|
|
2014-08-31 04:34:51 +02:00
|
|
|
if (!custom->width)
|
|
|
|
custom->width = stride_x;
|
|
|
|
if (!custom->height)
|
|
|
|
custom->height = stride_y;
|
2014-07-26 05:58:52 +02:00
|
|
|
|
2014-08-31 04:34:51 +02:00
|
|
|
aspectratio_lut[ASPECT_RATIO_CUSTOM].value =
|
|
|
|
(float)custom->width / custom->height;
|
2014-07-26 06:06:27 +02:00
|
|
|
|
2014-08-31 04:34:51 +02:00
|
|
|
rarch_main_command(RARCH_CMD_VIDEO_APPLY_STATE_CHANGES);
|
|
|
|
|
|
|
|
return 0;
|
2014-07-26 06:06:27 +02:00
|
|
|
}
|
|
|
|
|
2014-09-11 01:23:20 +02:00
|
|
|
static void menu_common_load_content(void)
|
|
|
|
{
|
|
|
|
rarch_main_command(RARCH_CMD_LOAD_CONTENT);
|
2014-10-18 01:39:05 +02:00
|
|
|
menu_list_flush_stack(driver.menu->menu_list, MENU_SETTINGS);
|
2014-09-11 01:23:20 +02:00
|
|
|
driver.menu->msg_force = true;
|
|
|
|
}
|
2014-09-05 03:24:06 +02:00
|
|
|
|
2014-09-20 20:07:26 +02:00
|
|
|
static int menu_load_or_open_zip_iterate(unsigned action)
|
|
|
|
{
|
|
|
|
char msg[PATH_MAX];
|
2014-10-12 05:24:52 +02:00
|
|
|
const char *menu_path = NULL;
|
|
|
|
const char *menu_label = NULL;
|
|
|
|
const char* path = NULL;
|
2014-10-16 03:55:03 +02:00
|
|
|
unsigned int type = 0;
|
2014-10-12 05:24:52 +02:00
|
|
|
|
2014-09-20 20:07:26 +02:00
|
|
|
snprintf(msg, sizeof(msg), "Opening compressed file\n"
|
|
|
|
" \n"
|
|
|
|
|
|
|
|
" - OK to open as Folder\n"
|
|
|
|
" - Cancel/Back to Load \n");
|
|
|
|
|
|
|
|
if (driver.video_data && driver.menu_ctx
|
|
|
|
&& driver.menu_ctx->render_messagebox)
|
|
|
|
{
|
|
|
|
if (*msg && msg[0] != '\0')
|
|
|
|
driver.menu_ctx->render_messagebox(msg);
|
|
|
|
}
|
|
|
|
|
2014-10-16 06:52:25 +02:00
|
|
|
switch (action)
|
2014-09-20 20:07:26 +02:00
|
|
|
{
|
2014-10-16 06:52:25 +02:00
|
|
|
case MENU_ACTION_OK:
|
|
|
|
case MENU_ACTION_CANCEL:
|
2014-10-18 01:44:06 +02:00
|
|
|
menu_list_pop_stack(driver.menu->menu_list);
|
2014-09-20 20:07:26 +02:00
|
|
|
|
2014-10-18 01:59:16 +02:00
|
|
|
menu_list_get_last_stack(driver.menu->menu_list,
|
2014-10-17 22:53:30 +02:00
|
|
|
&menu_path, &menu_label, NULL);
|
2014-09-20 20:07:26 +02:00
|
|
|
|
2014-10-18 02:32:59 +02:00
|
|
|
if (menu_list_get_size(driver.menu->menu_list) == 0)
|
2014-10-16 06:52:25 +02:00
|
|
|
return 0;
|
2014-09-20 20:07:26 +02:00
|
|
|
|
2014-10-18 01:17:00 +02:00
|
|
|
menu_list_get_at_offset(driver.menu->menu_list->selection_buf,
|
2014-10-16 06:52:25 +02:00
|
|
|
driver.menu->selection_ptr, &path, NULL, &type);
|
|
|
|
break;
|
2014-10-12 17:53:01 +02:00
|
|
|
}
|
|
|
|
|
2014-10-16 06:52:25 +02:00
|
|
|
switch (action)
|
2014-10-12 17:53:01 +02:00
|
|
|
{
|
2014-10-16 06:52:25 +02:00
|
|
|
case MENU_ACTION_OK:
|
|
|
|
{
|
|
|
|
char cat_path[PATH_MAX];
|
2014-09-20 20:07:26 +02:00
|
|
|
|
2014-10-16 06:52:25 +02:00
|
|
|
fill_pathname_join(cat_path, menu_path, path, sizeof(cat_path));
|
2014-10-17 22:29:59 +02:00
|
|
|
menu_list_push_stack_refresh(
|
2014-10-18 01:24:37 +02:00
|
|
|
driver.menu->menu_list,
|
2014-10-17 22:25:23 +02:00
|
|
|
cat_path,
|
|
|
|
menu_label,
|
|
|
|
type,
|
2014-10-16 06:52:25 +02:00
|
|
|
driver.menu->selection_ptr);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MENU_ACTION_CANCEL:
|
|
|
|
{
|
|
|
|
int ret = rarch_defer_core(g_extern.core_info, menu_path, path,
|
|
|
|
driver.menu->deferred_path, sizeof(driver.menu->deferred_path));
|
2014-09-20 20:07:26 +02:00
|
|
|
|
2014-10-16 06:52:25 +02:00
|
|
|
if (ret == -1)
|
|
|
|
{
|
|
|
|
rarch_main_command(RARCH_CMD_LOAD_CORE);
|
|
|
|
menu_common_load_content();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else if (ret == 0)
|
2014-10-17 22:29:59 +02:00
|
|
|
menu_list_push_stack_refresh(
|
2014-10-18 01:24:37 +02:00
|
|
|
driver.menu->menu_list,
|
2014-10-17 22:25:23 +02:00
|
|
|
g_settings.libretro_directory,
|
|
|
|
"deferred_core_list",
|
|
|
|
0,
|
2014-10-16 06:52:25 +02:00
|
|
|
driver.menu->selection_ptr);
|
|
|
|
}
|
|
|
|
break;
|
2014-09-20 20:07:26 +02:00
|
|
|
}
|
2014-10-16 06:52:25 +02:00
|
|
|
|
2014-09-20 20:07:26 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-10-26 17:49:46 +01:00
|
|
|
|
|
|
|
static int menu_common_iterate(unsigned action)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
unsigned type = 0;
|
2014-10-27 21:01:30 +01:00
|
|
|
unsigned type_offset = 0;
|
2014-10-26 17:49:46 +01:00
|
|
|
const char *label = NULL;
|
2014-10-27 21:01:30 +01:00
|
|
|
const char *label_offset = NULL;
|
|
|
|
const char *path_offset = NULL;
|
2014-10-26 17:49:46 +01:00
|
|
|
unsigned scroll_speed = 0, fast_scroll_speed = 0;
|
2014-10-27 21:01:30 +01:00
|
|
|
bool is_category = false;
|
2014-10-26 17:49:46 +01:00
|
|
|
menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*)
|
|
|
|
menu_list_get_actiondata_at_offset(driver.menu->menu_list->selection_buf,
|
|
|
|
driver.menu->selection_ptr);
|
|
|
|
|
|
|
|
menu_list_get_last_stack(driver.menu->menu_list, NULL, &label, &type);
|
|
|
|
|
|
|
|
mouse_iterate(action);
|
|
|
|
|
2014-08-31 04:34:51 +02:00
|
|
|
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->set_texture)
|
|
|
|
driver.menu_ctx->set_texture(driver.menu);
|
2014-04-26 02:40:38 +02:00
|
|
|
|
2014-10-27 21:01:30 +01:00
|
|
|
is_category = menu_common_type_is(label, type) == MENU_SETTINGS;
|
|
|
|
|
2014-10-16 03:55:03 +02:00
|
|
|
if (!strcmp(label, "help"))
|
2014-08-31 04:34:51 +02:00
|
|
|
return menu_start_screen_iterate(action);
|
2014-10-16 03:55:03 +02:00
|
|
|
else if (!strcmp(label, "message"))
|
2014-09-19 20:31:53 +02:00
|
|
|
return menu_message_toggle(action);
|
2014-10-16 03:55:03 +02:00
|
|
|
else if (!strcmp(label, "load_open_zip"))
|
2014-09-20 19:10:05 +02:00
|
|
|
return menu_load_or_open_zip_iterate(action);
|
2014-10-16 03:55:03 +02:00
|
|
|
else if (!strcmp(label, "info_screen"))
|
2014-08-31 04:34:51 +02:00
|
|
|
return menu_info_screen_iterate(action);
|
2014-09-01 16:52:54 +02:00
|
|
|
else if (
|
2014-10-16 03:55:03 +02:00
|
|
|
type == MENU_SETTINGS_CUSTOM_VIEWPORT ||
|
|
|
|
!strcmp(label, "custom_viewport_2")
|
2014-09-01 16:52:54 +02:00
|
|
|
)
|
2014-08-31 04:34:51 +02:00
|
|
|
return menu_viewport_iterate(action);
|
2014-10-16 03:55:03 +02:00
|
|
|
else if (type == MENU_SETTINGS_CUSTOM_BIND)
|
2014-09-24 06:43:42 +02:00
|
|
|
{
|
|
|
|
if (menu_input_bind_iterate(driver.menu))
|
2014-10-18 01:44:06 +02:00
|
|
|
menu_list_pop_stack(driver.menu->menu_list);
|
2014-09-24 06:43:42 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2014-10-16 03:55:03 +02:00
|
|
|
else if (type == MENU_SETTINGS_CUSTOM_BIND_KEYBOARD)
|
2014-09-24 06:43:42 +02:00
|
|
|
{
|
|
|
|
if (menu_input_bind_iterate_keyboard(driver.menu))
|
2014-10-18 01:44:06 +02:00
|
|
|
menu_list_pop_stack(driver.menu->menu_list);
|
2014-09-24 06:43:42 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2014-08-27 23:44:23 +02:00
|
|
|
|
2014-10-27 21:01:30 +01:00
|
|
|
menu_list_get_at_offset(driver.menu->menu_list->selection_buf,
|
|
|
|
driver.menu->selection_ptr, &path_offset, &label_offset, &type_offset);
|
|
|
|
|
2014-08-31 04:34:51 +02:00
|
|
|
if (driver.menu->need_refresh && action != MENU_ACTION_MESSAGE)
|
2014-10-11 23:54:29 +02:00
|
|
|
action = MENU_ACTION_REFRESH;
|
2014-08-27 23:44:23 +02:00
|
|
|
|
2014-09-24 06:35:57 +02:00
|
|
|
scroll_speed = (max(driver.menu->scroll_accel, 2) - 2) / 4 + 1;
|
|
|
|
fast_scroll_speed = 4 + 4 * scroll_speed;
|
2014-08-09 02:34:56 +02:00
|
|
|
|
2014-08-31 04:34:51 +02:00
|
|
|
switch (action)
|
2014-06-01 19:59:38 +02:00
|
|
|
{
|
2014-08-31 04:34:51 +02:00
|
|
|
case MENU_ACTION_UP:
|
|
|
|
if (driver.menu->selection_ptr >= scroll_speed)
|
2014-10-17 21:25:33 +02:00
|
|
|
menu_navigation_set(driver.menu,
|
2014-10-26 22:31:53 +01:00
|
|
|
driver.menu->selection_ptr - scroll_speed, true);
|
2014-08-31 04:34:51 +02:00
|
|
|
else
|
2014-10-17 21:25:33 +02:00
|
|
|
menu_navigation_set(driver.menu,
|
2014-10-26 22:31:53 +01:00
|
|
|
menu_list_get_size(driver.menu->menu_list) - 1, true);
|
2014-08-31 04:34:51 +02:00
|
|
|
break;
|
2014-06-01 19:59:38 +02:00
|
|
|
|
2014-08-31 04:34:51 +02:00
|
|
|
case MENU_ACTION_DOWN:
|
2014-10-18 02:32:59 +02:00
|
|
|
if (driver.menu->selection_ptr + scroll_speed < (menu_list_get_size(driver.menu->menu_list)))
|
2014-10-17 21:25:33 +02:00
|
|
|
menu_navigation_set(driver.menu,
|
2014-10-26 22:31:53 +01:00
|
|
|
driver.menu->selection_ptr + scroll_speed, true);
|
2014-08-31 04:34:51 +02:00
|
|
|
else
|
2014-10-17 21:25:33 +02:00
|
|
|
menu_navigation_clear(driver.menu, false);
|
2014-08-31 04:34:51 +02:00
|
|
|
break;
|
2014-08-14 00:49:28 +02:00
|
|
|
|
2014-08-31 04:34:51 +02:00
|
|
|
|
|
|
|
case MENU_ACTION_SCROLL_UP:
|
2014-10-17 21:25:33 +02:00
|
|
|
menu_navigation_descend_alphabet(driver.menu, &driver.menu->selection_ptr);
|
2014-08-31 04:34:51 +02:00
|
|
|
break;
|
|
|
|
case MENU_ACTION_SCROLL_DOWN:
|
2014-10-17 21:25:33 +02:00
|
|
|
menu_navigation_ascend_alphabet(driver.menu, &driver.menu->selection_ptr);
|
2014-08-31 04:34:51 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MENU_ACTION_CANCEL:
|
2014-10-27 21:01:30 +01:00
|
|
|
apply_deferred_settings();
|
2014-10-18 01:44:06 +02:00
|
|
|
menu_list_pop_stack(driver.menu->menu_list);
|
2014-08-31 04:34:51 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MENU_ACTION_OK:
|
2014-10-27 21:01:30 +01:00
|
|
|
if (is_category)
|
|
|
|
{
|
|
|
|
if (cbs && cbs->action_ok)
|
|
|
|
return cbs->action_ok(path_offset, label_offset, type_offset, driver.menu->selection_ptr);
|
|
|
|
/* fall-through */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ret = menu_action_ok(cbs);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case MENU_ACTION_START:
|
|
|
|
if (is_category)
|
|
|
|
{
|
|
|
|
if (cbs && cbs->action_start)
|
|
|
|
return cbs->action_start(type_offset, label_offset, action);
|
|
|
|
/* fall-through */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
case MENU_ACTION_LEFT:
|
|
|
|
if (is_category)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
if (cbs && cbs->action_toggle)
|
|
|
|
ret = cbs->action_toggle(type_offset, label_offset, action);
|
|
|
|
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (driver.menu->selection_ptr > fast_scroll_speed)
|
|
|
|
menu_navigation_set(driver.menu,
|
|
|
|
driver.menu->selection_ptr - fast_scroll_speed, true);
|
|
|
|
else
|
|
|
|
menu_navigation_clear(driver.menu, false);
|
|
|
|
|
|
|
|
}
|
2014-08-31 04:34:51 +02:00
|
|
|
break;
|
2014-10-27 21:01:30 +01:00
|
|
|
case MENU_ACTION_RIGHT:
|
|
|
|
if (is_category)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
2014-08-31 04:34:51 +02:00
|
|
|
|
2014-10-27 21:01:30 +01:00
|
|
|
if (cbs && cbs->action_toggle)
|
|
|
|
ret = cbs->action_toggle(type_offset, label_offset, action);
|
|
|
|
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (driver.menu->selection_ptr + fast_scroll_speed < (menu_list_get_size(driver.menu->menu_list)))
|
|
|
|
menu_navigation_set(driver.menu,
|
|
|
|
driver.menu->selection_ptr + fast_scroll_speed, true);
|
|
|
|
else
|
|
|
|
menu_navigation_set_last(driver.menu);
|
|
|
|
}
|
|
|
|
break;
|
2014-10-16 06:49:09 +02:00
|
|
|
case MENU_ACTION_SELECT:
|
2014-10-18 01:24:37 +02:00
|
|
|
menu_list_push_stack(driver.menu->menu_list, "", "info_screen",
|
2014-10-16 06:49:09 +02:00
|
|
|
0, driver.menu->selection_ptr);
|
|
|
|
break;
|
|
|
|
|
2014-08-31 04:34:51 +02:00
|
|
|
case MENU_ACTION_REFRESH:
|
2014-10-18 01:17:00 +02:00
|
|
|
menu_entries_deferred_push(driver.menu->menu_list->selection_buf,
|
|
|
|
driver.menu->menu_list->menu_stack);
|
2014-10-11 23:54:29 +02:00
|
|
|
|
|
|
|
driver.menu->need_refresh = false;
|
2014-08-31 04:34:51 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MENU_ACTION_MESSAGE:
|
|
|
|
driver.menu->msg_force = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2014-06-01 19:59:38 +02:00
|
|
|
}
|
2014-08-09 03:00:52 +02:00
|
|
|
|
2014-10-26 17:49:46 +01:00
|
|
|
ret = mouse_post_iterate(cbs, action);
|
2014-08-27 23:44:23 +02:00
|
|
|
|
2014-08-31 04:34:51 +02:00
|
|
|
if (driver.menu_ctx && driver.menu_ctx->iterate)
|
|
|
|
driver.menu_ctx->iterate(driver.menu, action);
|
2014-08-27 23:44:23 +02:00
|
|
|
|
2014-08-31 04:34:51 +02:00
|
|
|
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render)
|
|
|
|
driver.menu_ctx->render();
|
2014-08-27 23:44:23 +02:00
|
|
|
|
2014-10-27 21:01:30 +01:00
|
|
|
/* Have to defer it so we let settings refresh. */
|
|
|
|
if (driver.menu->push_start_screen)
|
|
|
|
{
|
|
|
|
menu_list_push_stack(driver.menu->menu_list, "", "help", 0, 0);
|
|
|
|
driver.menu->push_start_screen = false;
|
|
|
|
}
|
|
|
|
|
2014-08-31 04:34:51 +02:00
|
|
|
return ret;
|
|
|
|
}
|
2014-08-09 03:00:52 +02:00
|
|
|
|
2014-09-11 07:06:20 +02:00
|
|
|
menu_ctx_driver_backend_t menu_ctx_backend_common = {
|
2014-04-14 02:32:54 +02:00
|
|
|
menu_common_iterate,
|
2014-10-12 00:10:44 +02:00
|
|
|
|
2014-04-14 02:32:54 +02:00
|
|
|
"menu_common",
|
|
|
|
};
|