mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-26 04:36:01 +00:00
855 lines
28 KiB
C
855 lines
28 KiB
C
/* RetroArch - A frontend for libretro.
|
|
* Copyright (C) 2010-2013 - Hans-Kristian Arntzen
|
|
* Copyright (C) 2011-2013 - Daniel De Matteis
|
|
* Copyright (C) 2012-2013 - Michael Lelli
|
|
*
|
|
* 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 <string.h>
|
|
#include "menu_common.h"
|
|
|
|
#ifdef GEKKO
|
|
#define MAX_GAMMA_SETTING 2
|
|
#else
|
|
#define MAX_GAMMA_SETTING 1
|
|
#endif
|
|
|
|
const unsigned rgui_controller_lut[] = {
|
|
RETRO_DEVICE_ID_JOYPAD_UP,
|
|
RETRO_DEVICE_ID_JOYPAD_DOWN,
|
|
RETRO_DEVICE_ID_JOYPAD_LEFT,
|
|
RETRO_DEVICE_ID_JOYPAD_RIGHT,
|
|
RETRO_DEVICE_ID_JOYPAD_A,
|
|
RETRO_DEVICE_ID_JOYPAD_B,
|
|
RETRO_DEVICE_ID_JOYPAD_X,
|
|
RETRO_DEVICE_ID_JOYPAD_Y,
|
|
RETRO_DEVICE_ID_JOYPAD_START,
|
|
RETRO_DEVICE_ID_JOYPAD_SELECT,
|
|
RETRO_DEVICE_ID_JOYPAD_L,
|
|
RETRO_DEVICE_ID_JOYPAD_R,
|
|
RETRO_DEVICE_ID_JOYPAD_L2,
|
|
RETRO_DEVICE_ID_JOYPAD_R2,
|
|
RETRO_DEVICE_ID_JOYPAD_L3,
|
|
RETRO_DEVICE_ID_JOYPAD_R3,
|
|
};
|
|
|
|
int menu_set_settings(unsigned setting, unsigned action)
|
|
{
|
|
unsigned port = rgui->current_pad;
|
|
|
|
switch (setting)
|
|
{
|
|
case RGUI_SETTINGS_REWIND_ENABLE:
|
|
if (action == RGUI_ACTION_OK ||
|
|
action == RGUI_ACTION_LEFT ||
|
|
action == RGUI_ACTION_RIGHT)
|
|
{
|
|
settings_set(1ULL << S_REWIND);
|
|
if (g_settings.rewind_enable)
|
|
rarch_init_rewind();
|
|
else
|
|
rarch_deinit_rewind();
|
|
}
|
|
else if (action == RGUI_ACTION_START)
|
|
{
|
|
g_settings.rewind_enable = false;
|
|
rarch_deinit_rewind();
|
|
}
|
|
break;
|
|
#ifdef HAVE_SCREENSHOTS
|
|
case RGUI_SETTINGS_GPU_SCREENSHOT:
|
|
if (action == RGUI_ACTION_OK ||
|
|
action == RGUI_ACTION_LEFT ||
|
|
action == RGUI_ACTION_RIGHT)
|
|
g_settings.video.gpu_screenshot = !g_settings.video.gpu_screenshot;
|
|
else if (action == RGUI_ACTION_START)
|
|
g_settings.video.gpu_screenshot = true;
|
|
break;
|
|
#endif
|
|
case RGUI_SETTINGS_REWIND_GRANULARITY:
|
|
if (action == RGUI_ACTION_OK || action == RGUI_ACTION_RIGHT)
|
|
settings_set(1ULL << S_REWIND_GRANULARITY_INCREMENT);
|
|
else if (action == RGUI_ACTION_LEFT)
|
|
settings_set(1ULL << S_REWIND_GRANULARITY_DECREMENT);
|
|
else if (action == RGUI_ACTION_START)
|
|
settings_set(1ULL << S_DEF_REWIND_GRANULARITY);
|
|
break;
|
|
case RGUI_SETTINGS_CONFIG_SAVE_ON_EXIT:
|
|
if (action == RGUI_ACTION_OK || action == RGUI_ACTION_RIGHT
|
|
|| action == RGUI_ACTION_LEFT)
|
|
{
|
|
g_extern.config_save_on_exit = !g_extern.config_save_on_exit;
|
|
}
|
|
else if (action == RGUI_ACTION_START)
|
|
g_extern.config_save_on_exit = true;
|
|
break;
|
|
#if defined(HAVE_THREADS) && !defined(RARCH_CONSOLE)
|
|
case RGUI_SETTINGS_SRAM_AUTOSAVE:
|
|
if (action == RGUI_ACTION_OK || action == RGUI_ACTION_RIGHT || action == RGUI_ACTION_LEFT)
|
|
{
|
|
rarch_deinit_autosave();
|
|
g_settings.autosave_interval = (!g_settings.autosave_interval) * 10;
|
|
if (g_settings.autosave_interval)
|
|
rarch_init_autosave();
|
|
}
|
|
else if (action == RGUI_ACTION_START)
|
|
{
|
|
rarch_deinit_autosave();
|
|
g_settings.autosave_interval = 0;
|
|
}
|
|
break;
|
|
#endif
|
|
case RGUI_SETTINGS_SAVESTATE_SAVE:
|
|
case RGUI_SETTINGS_SAVESTATE_LOAD:
|
|
if (action == RGUI_ACTION_OK)
|
|
{
|
|
if (setting == RGUI_SETTINGS_SAVESTATE_SAVE)
|
|
rarch_save_state();
|
|
else
|
|
rarch_load_state();
|
|
g_extern.lifecycle_mode_state |= (1ULL << MODE_GAME);
|
|
#ifdef HAVE_RMENU
|
|
g_extern.lifecycle_mode_state |= (1ULL << MODE_MENU_INGAME_EXIT);
|
|
#endif
|
|
return -1;
|
|
}
|
|
else if (action == RGUI_ACTION_START)
|
|
settings_set(1ULL << S_DEF_SAVE_STATE);
|
|
else if (action == RGUI_ACTION_LEFT)
|
|
settings_set(1ULL << S_SAVESTATE_DECREMENT);
|
|
else if (action == RGUI_ACTION_RIGHT)
|
|
settings_set(1ULL << S_SAVESTATE_INCREMENT);
|
|
break;
|
|
#ifdef HAVE_SCREENSHOTS
|
|
case RGUI_SETTINGS_SCREENSHOT:
|
|
if (action == RGUI_ACTION_OK)
|
|
rarch_take_screenshot();
|
|
break;
|
|
#endif
|
|
case RGUI_SETTINGS_RESTART_GAME:
|
|
if (action == RGUI_ACTION_OK)
|
|
{
|
|
rarch_game_reset();
|
|
g_extern.lifecycle_mode_state |= (1ULL << MODE_GAME);
|
|
return -1;
|
|
}
|
|
break;
|
|
case RGUI_SETTINGS_AUDIO_MUTE:
|
|
if (action == RGUI_ACTION_START)
|
|
settings_set(1ULL << S_DEF_AUDIO_MUTE);
|
|
else
|
|
settings_set(1ULL << S_AUDIO_MUTE);
|
|
break;
|
|
case RGUI_SETTINGS_AUDIO_CONTROL_RATE_DELTA:
|
|
if (action == RGUI_ACTION_START)
|
|
settings_set(1ULL << S_DEF_AUDIO_CONTROL_RATE);
|
|
else if (action == RGUI_ACTION_LEFT)
|
|
settings_set(1ULL << S_AUDIO_CONTROL_RATE_DECREMENT);
|
|
else if (action == RGUI_ACTION_RIGHT)
|
|
settings_set(1ULL << S_AUDIO_CONTROL_RATE_INCREMENT);
|
|
break;
|
|
case RGUI_SETTINGS_DEBUG_TEXT:
|
|
if (action == RGUI_ACTION_START || action == RGUI_ACTION_LEFT)
|
|
g_extern.lifecycle_mode_state &= ~(1ULL << MODE_FPS_DRAW);
|
|
else if (action == RGUI_ACTION_RIGHT)
|
|
g_extern.lifecycle_mode_state |= (1ULL << MODE_FPS_DRAW);
|
|
break;
|
|
case RGUI_SETTINGS_DISK_INDEX:
|
|
{
|
|
const struct retro_disk_control_callback *control = &g_extern.system.disk_control;
|
|
|
|
unsigned num_disks = control->get_num_images();
|
|
unsigned current = control->get_image_index();
|
|
|
|
int step = 0;
|
|
if (action == RGUI_ACTION_RIGHT || action == RGUI_ACTION_OK)
|
|
step = 1;
|
|
else if (action == RGUI_ACTION_LEFT)
|
|
step = -1;
|
|
|
|
if (step)
|
|
{
|
|
unsigned next_index = (current + num_disks + 1 + step) % (num_disks + 1);
|
|
rarch_disk_control_set_eject(true, false);
|
|
rarch_disk_control_set_index(next_index);
|
|
rarch_disk_control_set_eject(false, false);
|
|
}
|
|
|
|
break;
|
|
}
|
|
case RGUI_SETTINGS_RESTART_EMULATOR:
|
|
if (action == RGUI_ACTION_OK)
|
|
{
|
|
#if defined(GEKKO) && defined(HW_RVL)
|
|
fill_pathname_join(g_extern.fullpath, default_paths.core_dir, SALAMANDER_FILE,
|
|
sizeof(g_extern.fullpath));
|
|
#endif
|
|
g_extern.lifecycle_mode_state &= ~(1ULL << MODE_GAME);
|
|
g_extern.lifecycle_mode_state |= (1ULL << MODE_EXITSPAWN);
|
|
return -1;
|
|
}
|
|
break;
|
|
case RGUI_SETTINGS_RESUME_GAME:
|
|
if (action == RGUI_ACTION_OK && (g_extern.main_is_init))
|
|
{
|
|
g_extern.lifecycle_mode_state |= (1ULL << MODE_GAME);
|
|
#ifdef HAVE_RMENU
|
|
g_extern.lifecycle_mode_state |= (1ULL << MODE_MENU_INGAME_EXIT);
|
|
#endif
|
|
return -1;
|
|
}
|
|
break;
|
|
case RGUI_SETTINGS_QUIT_RARCH:
|
|
if (action == RGUI_ACTION_OK)
|
|
{
|
|
g_extern.lifecycle_mode_state &= ~(1ULL << MODE_GAME);
|
|
#ifdef HAVE_RMENU
|
|
g_extern.lifecycle_mode_state |= (1ULL << MODE_MENU_INGAME_EXIT);
|
|
#endif
|
|
return -1;
|
|
}
|
|
break;
|
|
case RGUI_SETTINGS_SAVE_CONFIG:
|
|
if (action == RGUI_ACTION_OK)
|
|
menu_save_new_config();
|
|
break;
|
|
#ifdef HAVE_OVERLAY
|
|
case RGUI_SETTINGS_OVERLAY_PRESET:
|
|
switch (action)
|
|
{
|
|
case RGUI_ACTION_OK:
|
|
rgui_list_push(rgui->menu_stack, g_extern.overlay_dir, setting, rgui->selection_ptr);
|
|
rgui->selection_ptr = 0;
|
|
rgui->need_refresh = true;
|
|
break;
|
|
|
|
#ifndef __QNX__ // FIXME: Why ifndef QNX?
|
|
case RGUI_ACTION_START:
|
|
if (driver.overlay)
|
|
input_overlay_free(driver.overlay);
|
|
driver.overlay = NULL;
|
|
*g_settings.input.overlay = '\0';
|
|
break;
|
|
#endif
|
|
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
|
|
case RGUI_SETTINGS_OVERLAY_OPACITY:
|
|
{
|
|
bool changed = true;
|
|
switch (action)
|
|
{
|
|
case RGUI_ACTION_LEFT:
|
|
settings_set(1ULL << S_INPUT_OVERLAY_OPACITY_DECREMENT);
|
|
break;
|
|
|
|
case RGUI_ACTION_RIGHT:
|
|
case RGUI_ACTION_OK:
|
|
settings_set(1ULL << S_INPUT_OVERLAY_OPACITY_INCREMENT);
|
|
break;
|
|
|
|
case RGUI_ACTION_START:
|
|
settings_set(1ULL << S_DEF_INPUT_OVERLAY_OPACITY);
|
|
break;
|
|
|
|
default:
|
|
changed = false;
|
|
break;
|
|
}
|
|
|
|
if (changed && driver.overlay)
|
|
input_overlay_set_alpha_mod(driver.overlay,
|
|
g_settings.input.overlay_opacity);
|
|
break;
|
|
}
|
|
|
|
case RGUI_SETTINGS_OVERLAY_SCALE:
|
|
{
|
|
bool changed = true;
|
|
switch (action)
|
|
{
|
|
case RGUI_ACTION_LEFT:
|
|
settings_set(1ULL << S_INPUT_OVERLAY_SCALE_DECREMENT);
|
|
break;
|
|
|
|
case RGUI_ACTION_RIGHT:
|
|
case RGUI_ACTION_OK:
|
|
settings_set(1ULL << S_INPUT_OVERLAY_SCALE_INCREMENT);
|
|
break;
|
|
|
|
case RGUI_ACTION_START:
|
|
settings_set(1ULL << S_DEF_INPUT_OVERLAY_SCALE);
|
|
break;
|
|
|
|
default:
|
|
changed = false;
|
|
break;
|
|
}
|
|
|
|
if (changed && driver.overlay)
|
|
input_overlay_set_scale_factor(driver.overlay,
|
|
g_settings.input.overlay_scale);
|
|
break;
|
|
}
|
|
#endif
|
|
// controllers
|
|
case RGUI_SETTINGS_BIND_PLAYER:
|
|
if (action == RGUI_ACTION_START)
|
|
rgui->current_pad = 0;
|
|
else if (action == RGUI_ACTION_LEFT)
|
|
{
|
|
if (rgui->current_pad != 0)
|
|
rgui->current_pad--;
|
|
}
|
|
else if (action == RGUI_ACTION_RIGHT)
|
|
{
|
|
if (rgui->current_pad < MAX_PLAYERS - 1)
|
|
rgui->current_pad++;
|
|
}
|
|
|
|
port = rgui->current_pad;
|
|
break;
|
|
case RGUI_SETTINGS_BIND_DEVICE:
|
|
// If set_keybinds is supported, we do it more fancy, and scroll through
|
|
// a list of supported devices directly.
|
|
if (driver.input->set_keybinds)
|
|
{
|
|
g_settings.input.device[port] += DEVICE_LAST;
|
|
if (action == RGUI_ACTION_START)
|
|
g_settings.input.device[port] = 0;
|
|
else if (action == RGUI_ACTION_LEFT)
|
|
g_settings.input.device[port]--;
|
|
else if (action == RGUI_ACTION_RIGHT)
|
|
g_settings.input.device[port]++;
|
|
|
|
// DEVICE_LAST can be 0, avoid modulo.
|
|
if (g_settings.input.device[port] >= DEVICE_LAST)
|
|
g_settings.input.device[port] -= DEVICE_LAST;
|
|
|
|
unsigned keybind_action = (1ULL << KEYBINDS_ACTION_SET_DEFAULT_BINDS);
|
|
|
|
switch (g_settings.input.dpad_emulation[port])
|
|
{
|
|
case ANALOG_DPAD_LSTICK:
|
|
keybind_action |= (1ULL << KEYBINDS_ACTION_SET_ANALOG_DPAD_LSTICK);
|
|
break;
|
|
case ANALOG_DPAD_RSTICK:
|
|
keybind_action |= (1ULL << KEYBINDS_ACTION_SET_ANALOG_DPAD_RSTICK);
|
|
break;
|
|
case ANALOG_DPAD_NONE:
|
|
keybind_action |= (1ULL << KEYBINDS_ACTION_SET_ANALOG_DPAD_NONE);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
driver.input->set_keybinds(driver.input_data, g_settings.input.device[port], port, 0,
|
|
keybind_action);
|
|
}
|
|
else
|
|
{
|
|
// When only straight g_settings.input.joypad_map[] style
|
|
// mapping is supported.
|
|
int *p = &g_settings.input.joypad_map[port];
|
|
if (action == RGUI_ACTION_START)
|
|
*p = port;
|
|
else if (action == RGUI_ACTION_LEFT)
|
|
(*p)--;
|
|
else if (action == RGUI_ACTION_RIGHT)
|
|
(*p)++;
|
|
|
|
if (*p < -1)
|
|
*p = -1;
|
|
else if (*p >= MAX_PLAYERS)
|
|
*p = MAX_PLAYERS - 1;
|
|
}
|
|
break;
|
|
case RGUI_SETTINGS_BIND_DEVICE_TYPE:
|
|
{
|
|
static const unsigned device_types[] = {
|
|
RETRO_DEVICE_NONE,
|
|
RETRO_DEVICE_JOYPAD,
|
|
RETRO_DEVICE_ANALOG,
|
|
RETRO_DEVICE_MOUSE,
|
|
RETRO_DEVICE_JOYPAD_MULTITAP,
|
|
RETRO_DEVICE_LIGHTGUN_SUPER_SCOPE,
|
|
RETRO_DEVICE_LIGHTGUN_JUSTIFIER,
|
|
RETRO_DEVICE_LIGHTGUN_JUSTIFIERS,
|
|
};
|
|
|
|
unsigned current_device = g_settings.input.libretro_device[port];
|
|
unsigned current_index = 0;
|
|
for (unsigned i = 0; i < ARRAY_SIZE(device_types); i++)
|
|
{
|
|
if (current_device == device_types[i])
|
|
{
|
|
current_index = i;
|
|
break;
|
|
}
|
|
}
|
|
|
|
bool updated = true;
|
|
switch (action)
|
|
{
|
|
case RGUI_ACTION_START:
|
|
current_device = RETRO_DEVICE_JOYPAD;
|
|
break;
|
|
|
|
case RGUI_ACTION_LEFT:
|
|
current_device = device_types[(current_index + ARRAY_SIZE(device_types) - 1) % ARRAY_SIZE(device_types)];
|
|
break;
|
|
|
|
case RGUI_ACTION_RIGHT:
|
|
case RGUI_ACTION_OK:
|
|
current_device = device_types[(current_index + 1) % ARRAY_SIZE(device_types)];
|
|
break;
|
|
|
|
default:
|
|
updated = false;
|
|
}
|
|
|
|
if (updated)
|
|
{
|
|
g_settings.input.libretro_device[port] = current_device;
|
|
pretro_set_controller_port_device(port, current_device);
|
|
}
|
|
|
|
break;
|
|
}
|
|
case RGUI_SETTINGS_BIND_DPAD_EMULATION:
|
|
g_settings.input.dpad_emulation[port] += ANALOG_DPAD_LAST;
|
|
if (action == RGUI_ACTION_START)
|
|
g_settings.input.dpad_emulation[port] = ANALOG_DPAD_LSTICK;
|
|
else if (action == RGUI_ACTION_LEFT)
|
|
g_settings.input.dpad_emulation[port]--;
|
|
else if (action == RGUI_ACTION_RIGHT)
|
|
g_settings.input.dpad_emulation[port]++;
|
|
g_settings.input.dpad_emulation[port] %= ANALOG_DPAD_LAST;
|
|
|
|
if (driver.input->set_keybinds)
|
|
{
|
|
unsigned keybind_action = 0;
|
|
|
|
switch (g_settings.input.dpad_emulation[port])
|
|
{
|
|
case ANALOG_DPAD_LSTICK:
|
|
keybind_action = (1ULL << KEYBINDS_ACTION_SET_ANALOG_DPAD_LSTICK);
|
|
break;
|
|
case ANALOG_DPAD_RSTICK:
|
|
keybind_action = (1ULL << KEYBINDS_ACTION_SET_ANALOG_DPAD_RSTICK);
|
|
break;
|
|
case ANALOG_DPAD_NONE:
|
|
keybind_action = (1ULL << KEYBINDS_ACTION_SET_ANALOG_DPAD_NONE);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
if (keybind_action)
|
|
driver.input->set_keybinds(driver.input_data, g_settings.input.device[port], port, 0,
|
|
keybind_action);
|
|
}
|
|
break;
|
|
case RGUI_SETTINGS_BIND_UP:
|
|
case RGUI_SETTINGS_BIND_DOWN:
|
|
case RGUI_SETTINGS_BIND_LEFT:
|
|
case RGUI_SETTINGS_BIND_RIGHT:
|
|
case RGUI_SETTINGS_BIND_A:
|
|
case RGUI_SETTINGS_BIND_B:
|
|
case RGUI_SETTINGS_BIND_X:
|
|
case RGUI_SETTINGS_BIND_Y:
|
|
case RGUI_SETTINGS_BIND_START:
|
|
case RGUI_SETTINGS_BIND_SELECT:
|
|
case RGUI_SETTINGS_BIND_L:
|
|
case RGUI_SETTINGS_BIND_R:
|
|
case RGUI_SETTINGS_BIND_L2:
|
|
case RGUI_SETTINGS_BIND_R2:
|
|
case RGUI_SETTINGS_BIND_L3:
|
|
case RGUI_SETTINGS_BIND_R3:
|
|
if (driver.input->set_keybinds)
|
|
{
|
|
unsigned keybind_action = KEYBINDS_ACTION_NONE;
|
|
|
|
if (action == RGUI_ACTION_START)
|
|
keybind_action = (1ULL << KEYBINDS_ACTION_SET_DEFAULT_BIND);
|
|
else if (action == RGUI_ACTION_LEFT)
|
|
keybind_action = (1ULL << KEYBINDS_ACTION_DECREMENT_BIND);
|
|
else if (action == RGUI_ACTION_RIGHT)
|
|
keybind_action = (1ULL << KEYBINDS_ACTION_INCREMENT_BIND);
|
|
|
|
if (keybind_action != KEYBINDS_ACTION_NONE)
|
|
driver.input->set_keybinds(driver.input_data, g_settings.input.device[setting - RGUI_SETTINGS_BIND_UP], port,
|
|
rgui_controller_lut[setting - RGUI_SETTINGS_BIND_UP], keybind_action);
|
|
}
|
|
case RGUI_BROWSER_DIR_PATH:
|
|
if (action == RGUI_ACTION_START)
|
|
{
|
|
*g_settings.rgui_browser_directory = '\0';
|
|
*rgui->base_path = '\0';
|
|
}
|
|
break;
|
|
#ifdef HAVE_SCREENSHOTS
|
|
case RGUI_SCREENSHOT_DIR_PATH:
|
|
if (action == RGUI_ACTION_START)
|
|
*g_settings.screenshot_directory = '\0';
|
|
break;
|
|
#endif
|
|
case RGUI_SAVEFILE_DIR_PATH:
|
|
if (action == RGUI_ACTION_START)
|
|
*g_extern.savefile_dir = '\0';
|
|
break;
|
|
#ifdef HAVE_OVERLAY
|
|
case RGUI_OVERLAY_DIR_PATH:
|
|
if (action == RGUI_ACTION_START)
|
|
*g_extern.overlay_dir = '\0';
|
|
break;
|
|
#endif
|
|
case RGUI_SAVESTATE_DIR_PATH:
|
|
if (action == RGUI_ACTION_START)
|
|
*g_extern.savestate_dir = '\0';
|
|
break;
|
|
#ifdef HAVE_DYNAMIC
|
|
case RGUI_LIBRETRO_DIR_PATH:
|
|
if (action == RGUI_ACTION_START)
|
|
*rgui->libretro_dir = '\0';
|
|
break;
|
|
#endif
|
|
case RGUI_CONFIG_DIR_PATH:
|
|
if (action == RGUI_ACTION_START)
|
|
*g_settings.rgui_config_directory = '\0';
|
|
break;
|
|
case RGUI_SHADER_DIR_PATH:
|
|
if (action == RGUI_ACTION_START)
|
|
*g_settings.video.shader_dir = '\0';
|
|
break;
|
|
case RGUI_SYSTEM_DIR_PATH:
|
|
if (action == RGUI_ACTION_START)
|
|
*g_settings.system_directory = '\0';
|
|
break;
|
|
case RGUI_SETTINGS_VIDEO_ROTATION:
|
|
if (action == RGUI_ACTION_START)
|
|
{
|
|
settings_set(1ULL << S_DEF_ROTATION);
|
|
video_set_rotation_func((g_settings.video.rotation + g_extern.system.rotation) % 4);
|
|
}
|
|
else if (action == RGUI_ACTION_LEFT)
|
|
{
|
|
settings_set(1ULL << S_ROTATION_DECREMENT);
|
|
video_set_rotation_func((g_settings.video.rotation + g_extern.system.rotation) % 4);
|
|
}
|
|
else if (action == RGUI_ACTION_RIGHT)
|
|
{
|
|
settings_set(1ULL << S_ROTATION_INCREMENT);
|
|
video_set_rotation_func((g_settings.video.rotation + g_extern.system.rotation) % 4);
|
|
}
|
|
break;
|
|
|
|
case RGUI_SETTINGS_VIDEO_FILTER:
|
|
if (action == RGUI_ACTION_START)
|
|
settings_set(1ULL << S_DEF_HW_TEXTURE_FILTER);
|
|
else
|
|
settings_set(1ULL << S_HW_TEXTURE_FILTER);
|
|
|
|
if (driver.video_poke->set_filtering)
|
|
driver.video_poke->set_filtering(driver.video_data, 1, g_settings.video.smooth);
|
|
break;
|
|
|
|
case RGUI_SETTINGS_VIDEO_GAMMA:
|
|
if (action == RGUI_ACTION_START)
|
|
{
|
|
g_extern.console.screen.gamma_correction = 0;
|
|
if (driver.video_poke->apply_state_changes)
|
|
driver.video_poke->apply_state_changes(driver.video_data);
|
|
}
|
|
else if (action == RGUI_ACTION_LEFT)
|
|
{
|
|
if(g_extern.console.screen.gamma_correction > 0)
|
|
{
|
|
g_extern.console.screen.gamma_correction--;
|
|
if (driver.video_poke->apply_state_changes)
|
|
driver.video_poke->apply_state_changes(driver.video_data);
|
|
}
|
|
}
|
|
else if (action == RGUI_ACTION_RIGHT)
|
|
{
|
|
if(g_extern.console.screen.gamma_correction < MAX_GAMMA_SETTING)
|
|
{
|
|
g_extern.console.screen.gamma_correction++;
|
|
if (driver.video_poke->apply_state_changes)
|
|
driver.video_poke->apply_state_changes(driver.video_data);
|
|
}
|
|
}
|
|
break;
|
|
|
|
case RGUI_SETTINGS_VIDEO_INTEGER_SCALE:
|
|
if (action == RGUI_ACTION_START)
|
|
settings_set(1ULL << S_DEF_SCALE_INTEGER);
|
|
else if (action == RGUI_ACTION_LEFT ||
|
|
action == RGUI_ACTION_RIGHT ||
|
|
action == RGUI_ACTION_OK)
|
|
settings_set(1ULL << S_SCALE_INTEGER_TOGGLE);
|
|
|
|
if (driver.video_poke->apply_state_changes)
|
|
driver.video_poke->apply_state_changes(driver.video_data);
|
|
break;
|
|
|
|
case RGUI_SETTINGS_VIDEO_ASPECT_RATIO:
|
|
if (action == RGUI_ACTION_START)
|
|
settings_set(1ULL << S_DEF_ASPECT_RATIO);
|
|
else if (action == RGUI_ACTION_LEFT)
|
|
settings_set(1ULL << S_ASPECT_RATIO_DECREMENT);
|
|
else if (action == RGUI_ACTION_RIGHT)
|
|
settings_set(1ULL << S_ASPECT_RATIO_INCREMENT);
|
|
|
|
if (driver.video_poke->set_aspect_ratio)
|
|
driver.video_poke->set_aspect_ratio(driver.video_data, g_settings.video.aspect_ratio_idx);
|
|
break;
|
|
|
|
case RGUI_SETTINGS_TOGGLE_FULLSCREEN:
|
|
if (action == RGUI_ACTION_OK)
|
|
rarch_set_fullscreen(!g_settings.video.fullscreen);
|
|
break;
|
|
|
|
#ifdef GEKKO
|
|
case RGUI_SETTINGS_VIDEO_RESOLUTION:
|
|
if (action == RGUI_ACTION_LEFT)
|
|
{
|
|
if(rgui_current_gx_resolution > 0)
|
|
{
|
|
rgui_current_gx_resolution--;
|
|
gx_set_video_mode(rgui_gx_resolutions[rgui_current_gx_resolution][0], rgui_gx_resolutions[rgui_current_gx_resolution][1]);
|
|
}
|
|
}
|
|
else if (action == RGUI_ACTION_RIGHT)
|
|
{
|
|
if (rgui_current_gx_resolution < GX_RESOLUTIONS_LAST - 1)
|
|
{
|
|
#ifdef HW_RVL
|
|
if ((rgui_current_gx_resolution + 1) > GX_RESOLUTIONS_640_480)
|
|
if (CONF_GetVideo() != CONF_VIDEO_PAL)
|
|
return 0;
|
|
#endif
|
|
|
|
rgui_current_gx_resolution++;
|
|
gx_set_video_mode(rgui_gx_resolutions[rgui_current_gx_resolution][0],
|
|
rgui_gx_resolutions[rgui_current_gx_resolution][1]);
|
|
}
|
|
}
|
|
break;
|
|
#endif
|
|
#ifdef HW_RVL
|
|
case RGUI_SETTINGS_VIDEO_SOFT_FILTER:
|
|
if (g_extern.lifecycle_mode_state & (1ULL << MODE_VIDEO_SOFT_FILTER_ENABLE))
|
|
g_extern.lifecycle_mode_state &= ~(1ULL << MODE_VIDEO_SOFT_FILTER_ENABLE);
|
|
else
|
|
g_extern.lifecycle_mode_state |= (1ULL << MODE_VIDEO_SOFT_FILTER_ENABLE);
|
|
|
|
if (driver.video_poke->apply_state_changes)
|
|
driver.video_poke->apply_state_changes(driver.video_data);
|
|
break;
|
|
#endif
|
|
|
|
case RGUI_SETTINGS_VIDEO_VSYNC:
|
|
switch (action)
|
|
{
|
|
case RGUI_ACTION_START:
|
|
settings_set(1ULL << S_DEF_VIDEO_VSYNC);
|
|
break;
|
|
|
|
case RGUI_ACTION_LEFT:
|
|
case RGUI_ACTION_RIGHT:
|
|
case RGUI_ACTION_OK:
|
|
settings_set(1ULL << S_VIDEO_VSYNC_TOGGLE);
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
|
|
case RGUI_SETTINGS_VIDEO_HARD_SYNC:
|
|
switch (action)
|
|
{
|
|
case RGUI_ACTION_START:
|
|
g_settings.video.hard_sync = false;
|
|
break;
|
|
|
|
case RGUI_ACTION_LEFT:
|
|
case RGUI_ACTION_RIGHT:
|
|
case RGUI_ACTION_OK:
|
|
g_settings.video.hard_sync = !g_settings.video.hard_sync;
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
|
|
case RGUI_SETTINGS_VIDEO_BLACK_FRAME_INSERTION:
|
|
switch (action)
|
|
{
|
|
case RGUI_ACTION_START:
|
|
g_settings.video.black_frame_insertion = false;
|
|
break;
|
|
|
|
case RGUI_ACTION_LEFT:
|
|
case RGUI_ACTION_RIGHT:
|
|
case RGUI_ACTION_OK:
|
|
g_settings.video.black_frame_insertion = !g_settings.video.black_frame_insertion;
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
|
|
case RGUI_SETTINGS_VIDEO_CROP_OVERSCAN:
|
|
switch (action)
|
|
{
|
|
case RGUI_ACTION_START:
|
|
g_settings.video.crop_overscan = true;
|
|
break;
|
|
|
|
case RGUI_ACTION_LEFT:
|
|
case RGUI_ACTION_RIGHT:
|
|
case RGUI_ACTION_OK:
|
|
g_settings.video.crop_overscan = !g_settings.video.crop_overscan;
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
|
|
case RGUI_SETTINGS_VIDEO_WINDOW_SCALE_X:
|
|
case RGUI_SETTINGS_VIDEO_WINDOW_SCALE_Y:
|
|
{
|
|
float *scale = setting == RGUI_SETTINGS_VIDEO_WINDOW_SCALE_X ? &g_settings.video.xscale : &g_settings.video.yscale;
|
|
float old_scale = *scale;
|
|
|
|
switch (action)
|
|
{
|
|
case RGUI_ACTION_START:
|
|
*scale = 3.0f;
|
|
break;
|
|
|
|
case RGUI_ACTION_LEFT:
|
|
*scale -= 1.0f;
|
|
break;
|
|
|
|
case RGUI_ACTION_RIGHT:
|
|
*scale += 1.0f;
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
|
|
*scale = roundf(*scale);
|
|
*scale = max(*scale, 1.0f);
|
|
|
|
if (old_scale != *scale && !g_settings.video.fullscreen)
|
|
rarch_set_fullscreen(g_settings.video.fullscreen); // Reinit video driver.
|
|
|
|
break;
|
|
}
|
|
|
|
case RGUI_SETTINGS_VIDEO_SWAP_INTERVAL:
|
|
{
|
|
unsigned old = g_settings.video.swap_interval;
|
|
switch (action)
|
|
{
|
|
case RGUI_ACTION_START:
|
|
g_settings.video.swap_interval = 1;
|
|
break;
|
|
|
|
case RGUI_ACTION_LEFT:
|
|
g_settings.video.swap_interval--;
|
|
break;
|
|
|
|
case RGUI_ACTION_RIGHT:
|
|
case RGUI_ACTION_OK:
|
|
g_settings.video.swap_interval++;
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
|
|
g_settings.video.swap_interval = min(g_settings.video.swap_interval, 4);
|
|
g_settings.video.swap_interval = max(g_settings.video.swap_interval, 1);
|
|
if (old != g_settings.video.swap_interval && driver.video && driver.video_data)
|
|
video_set_nonblock_state_func(false); // This will update the current swap interval. Since we're in RGUI now, always apply VSync.
|
|
|
|
break;
|
|
}
|
|
|
|
case RGUI_SETTINGS_VIDEO_HARD_SYNC_FRAMES:
|
|
switch (action)
|
|
{
|
|
case RGUI_ACTION_START:
|
|
g_settings.video.hard_sync_frames = 0;
|
|
break;
|
|
|
|
case RGUI_ACTION_LEFT:
|
|
if (g_settings.video.hard_sync_frames > 0)
|
|
g_settings.video.hard_sync_frames--;
|
|
break;
|
|
|
|
case RGUI_ACTION_RIGHT:
|
|
case RGUI_ACTION_OK:
|
|
if (g_settings.video.hard_sync_frames < 3)
|
|
g_settings.video.hard_sync_frames++;
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
|
|
case RGUI_SETTINGS_VIDEO_REFRESH_RATE_AUTO:
|
|
switch (action)
|
|
{
|
|
case RGUI_ACTION_START:
|
|
g_extern.measure_data.frame_time_samples_count = 0;
|
|
break;
|
|
|
|
case RGUI_ACTION_OK:
|
|
{
|
|
double refresh_rate = 0.0;
|
|
double deviation = 0.0;
|
|
unsigned sample_points = 0;
|
|
if (driver_monitor_fps_statistics(&refresh_rate, &deviation, &sample_points))
|
|
{
|
|
driver_set_monitor_refresh_rate(refresh_rate);
|
|
// Incase refresh rate update forced non-block video.
|
|
video_set_nonblock_state_func(false);
|
|
}
|
|
break;
|
|
}
|
|
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return 0;
|
|
}
|