(Overlays) Add explicit overlay_enable option

This commit is contained in:
twinaphex 2014-06-12 22:15:32 +02:00
parent 9b6703b3ad
commit 5532babfd6
9 changed files with 42 additions and 18 deletions

View File

@ -332,6 +332,7 @@ static void menu_common_entries_init(void *data, unsigned menu_type)
break;
case MENU_SETTINGS_OVERLAY_OPTIONS:
file_list_clear(menu->selection_buf);
file_list_push(menu->selection_buf, "Overlay Enable", MENU_SETTINGS_OVERLAY_ENABLE, 0);
file_list_push(menu->selection_buf, "Overlay Preset", MENU_SETTINGS_OVERLAY_PRESET, 0);
file_list_push(menu->selection_buf, "Overlay Opacity", MENU_SETTINGS_OVERLAY_OPACITY, 0);
file_list_push(menu->selection_buf, "Overlay Scale", MENU_SETTINGS_OVERLAY_SCALE, 0);
@ -3752,6 +3753,12 @@ static int menu_common_setting_set(unsigned setting, unsigned action)
menu_save_new_config();
break;
#ifdef HAVE_OVERLAY
case MENU_SETTINGS_OVERLAY_ENABLE:
if (action == MENU_ACTION_OK)
g_settings.input.overlay_enable = !g_settings.input.overlay_enable;
else if (action == MENU_ACTION_START)
g_settings.input.overlay_enable = g_defaults.settings.input_overlay_enable;
break;
case MENU_SETTINGS_OVERLAY_PRESET:
switch (action)
{
@ -3760,16 +3767,12 @@ static int menu_common_setting_set(unsigned setting, unsigned action)
menu_clear_navigation(driver.menu);
driver.menu->need_refresh = true;
break;
#ifndef __QNX__ // FIXME: Why ifndef QNX?
case MENU_ACTION_START:
if (driver.overlay)
input_overlay_free(driver.overlay);
driver.overlay = NULL;
*g_settings.input.overlay = '\0';
break;
#endif
default:
break;
}
@ -5429,6 +5432,9 @@ static void menu_common_setting_set_label(char *type_str, size_t type_str_size,
snprintf(type_str, type_str_size, g_settings.osk.enable ? "ON" : "OFF");
break;
#endif
case MENU_SETTINGS_OVERLAY_ENABLE:
snprintf(type_str, type_str_size, g_settings.input.overlay_enable ? "ON" : "OFF");
break;
case MENU_SETTINGS_FONT_ENABLE:
snprintf(type_str, type_str_size, g_settings.video.font_enable ? "ON" : "OFF");
break;

View File

@ -167,6 +167,7 @@ typedef enum
MENU_SETTINGS_PRIVACY_CAMERA_ALLOW,
MENU_SETTINGS_PRIVACY_LOCATION_ALLOW,
MENU_SETTINGS_OVERLAY_ENABLE,
MENU_SETTINGS_OVERLAY_PRESET,
MENU_SETTINGS_OVERLAY_OPACITY,
MENU_SETTINGS_OVERLAY_SCALE,

View File

@ -142,6 +142,7 @@ struct defaults
struct
{
int out_latency;
bool input_overlay_enable;
} settings;
};
@ -286,6 +287,7 @@ struct settings
unsigned turbo_period;
unsigned turbo_duty_cycle;
bool overlay_enable;
char overlay[PATH_MAX];
float overlay_opacity;
float overlay_scale;

View File

@ -518,7 +518,7 @@ static void d3d_overlay_render(void *data, overlay_t *overlay)
{
d3d_video_t *d3d = (d3d_video_t*)data;
if (!overlay || !overlay->tex)
if (!overlay || !overlay->tex || !g_settings.input.overlay_enable)
return;
struct overlay_vertex

View File

@ -2773,6 +2773,9 @@ static void gl_render_overlay(void *data)
unsigned i, j;
gl_t *gl = (gl_t*)data;
if (!g_settings.input.overlay_enable)
return;
GLfloat white_color_mod[16] = {
1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f,

View File

@ -1214,6 +1214,9 @@ static void gx_render_overlay(void *data)
{
gx_video_t *gx = (gx_video_t*)data;
if (!g_settings.input.overlay_enable)
return;
GX_SetCurrentMtx(GX_PNMTX1);
GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT);

View File

@ -490,6 +490,9 @@ size_t audio_sample_batch(const int16_t *data, size_t frames)
#ifdef HAVE_OVERLAY
static inline void input_poll_overlay(void)
{
if (!g_settings.input.overlay_enable)
return;
input_overlay_state_t old_key_state;
memcpy(old_key_state.keys, driver.overlay_state.keys, sizeof(driver.overlay_state.keys));
memset(&driver.overlay_state, 0, sizeof(driver.overlay_state));
@ -592,7 +595,7 @@ void rarch_input_poll(void)
input_poll_func();
#ifdef HAVE_OVERLAY
if (driver.overlay) // Poll overlay state
if (driver.overlay)
input_poll_overlay();
#endif
@ -2682,7 +2685,7 @@ void rarch_check_block_hotkey(void)
#ifdef HAVE_OVERLAY
void rarch_check_overlay(void)
{
if (!driver.overlay)
if (!driver.overlay || !g_settings.input.overlay_enable)
return;
static bool old_pressed;

View File

@ -247,6 +247,20 @@
# Gain can be controlled in runtime with input_volume_up/input_volume_down.
# audio_volume = 0.0
#### Overlay
# Enable overlay.
# input_overlay_enable = false
# Path to input overlay
# input_overlay =
# Overlay opacity
# input_overlay_opacity = 1.0
# Overlay scale
# input_overlay_scale = 1.0
#### Input
# Input driver. Depending on video driver, it might force a different input driver.
@ -262,15 +276,6 @@
# Defines axis threshold. Possible values are [0.0, 1.0]
# input_axis_threshold = 0.5
# Path to input overlay
# input_overlay =
# Overlay opacity
# input_overlay_opacity = 1.0
# Overlay scale
# input_overlay_scale = 1.0
# Enable input auto-detection. Will attempt to autoconfigure
# joypads, Plug-and-Play style.
# input_autodetect_enable = true

View File

@ -380,6 +380,7 @@ void config_set_defaults(void)
g_settings.input.netplay_client_swap_input = netplay_client_swap_input;
g_settings.input.turbo_period = turbo_period;
g_settings.input.turbo_duty_cycle = turbo_duty_cycle;
g_settings.input.overlay_enable = false;
g_settings.input.overlay_opacity = 0.7f;
g_settings.input.overlay_scale = 1.0f;
g_settings.input.debug_enable = input_debug_enable;
@ -450,9 +451,7 @@ void config_set_defaults(void)
if (default_overlay_dir)
{
fill_pathname_expand_special(g_extern.overlay_dir, default_overlay_dir, sizeof(g_extern.overlay_dir));
#if defined(RARCH_MOBILE)
fill_pathname_join(g_settings.input.overlay, g_extern.overlay_dir, "gamepads/retropad/retropad.cfg", sizeof(g_settings.input.overlay));
#endif
}
#endif
@ -1042,6 +1041,7 @@ bool config_load_file(const char *path, bool set_defaults)
if (!strcmp(g_extern.overlay_dir, "default"))
*g_extern.overlay_dir = '\0';
CONFIG_GET_BOOL(input.overlay_enable, "input_overlay_enable");
CONFIG_GET_PATH(input.overlay, "input_overlay");
CONFIG_GET_FLOAT(input.overlay_opacity, "input_overlay_opacity");
CONFIG_GET_FLOAT(input.overlay_scale, "input_overlay_scale");
@ -1422,6 +1422,7 @@ bool config_save_file(const char *path)
#ifdef HAVE_OVERLAY
config_set_path(conf, "overlay_directory", *g_extern.overlay_dir ? g_extern.overlay_dir : "default");
config_set_path(conf, "input_overlay", g_settings.input.overlay);
config_set_bool(conf, "input_overlay_enable", g_settings.input.overlay_enable);
config_set_float(conf, "input_overlay_opacity", g_settings.input.overlay_opacity);
config_set_float(conf, "input_overlay_scale", g_settings.input.overlay_scale);
#endif