mirror of
https://github.com/libretro/RetroArch
synced 2025-04-03 01:21:10 +00:00
Merge pull request #11239 from jdgleaver/overlay-gamepad-hide
Add option to hide overlays when a gamepad is connected (Note: Restricted functionality on Android)
This commit is contained in:
commit
df245d4917
@ -356,6 +356,11 @@
|
||||
#define DEFAULT_SHOW_HIDDEN_FILES false
|
||||
|
||||
#define DEFAULT_OVERLAY_HIDE_IN_MENU true
|
||||
|
||||
/* Automatically disable overlays when a
|
||||
* controller is connected in port 1 */
|
||||
#define DEFAULT_OVERLAY_HIDE_WHEN_GAMEPAD_CONNECTED false
|
||||
|
||||
#define DEFAULT_OVERLAY_SHOW_MOUSE_CURSOR true
|
||||
|
||||
#define DEFAULT_DISPLAY_KEYBOARD_OVERLAY false
|
||||
|
@ -1670,6 +1670,7 @@ static struct config_bool_setting *populate_settings_bool(
|
||||
SETTING_BOOL("input_overlay_enable_autopreferred", &settings->bools.input_overlay_enable_autopreferred, true, DEFAULT_OVERLAY_ENABLE_AUTOPREFERRED, false);
|
||||
SETTING_BOOL("input_overlay_show_physical_inputs", &settings->bools.input_overlay_show_physical_inputs, true, DEFAULT_SHOW_PHYSICAL_INPUTS, false);
|
||||
SETTING_BOOL("input_overlay_hide_in_menu", &settings->bools.input_overlay_hide_in_menu, true, DEFAULT_OVERLAY_HIDE_IN_MENU, false);
|
||||
SETTING_BOOL("input_overlay_hide_when_gamepad_connected", &settings->bools.input_overlay_hide_when_gamepad_connected, true, DEFAULT_OVERLAY_HIDE_WHEN_GAMEPAD_CONNECTED, false);
|
||||
SETTING_BOOL("input_overlay_show_mouse_cursor", &settings->bools.input_overlay_show_mouse_cursor, true, DEFAULT_OVERLAY_SHOW_MOUSE_CURSOR, false);
|
||||
SETTING_BOOL("input_overlay_auto_rotate", &settings->bools.input_overlay_auto_rotate, true, DEFAULT_OVERLAY_AUTO_ROTATE, false);
|
||||
#endif
|
||||
|
@ -487,6 +487,7 @@ typedef struct settings
|
||||
bool input_overlay_enable;
|
||||
bool input_overlay_enable_autopreferred;
|
||||
bool input_overlay_hide_in_menu;
|
||||
bool input_overlay_hide_when_gamepad_connected;
|
||||
bool input_overlay_show_physical_inputs;
|
||||
bool input_overlay_show_mouse_cursor;
|
||||
bool input_overlay_auto_rotate;
|
||||
|
@ -198,15 +198,16 @@ typedef struct input_overlay input_overlay_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
bool hide_in_menu;
|
||||
bool overlay_enable;
|
||||
struct overlay *overlays;
|
||||
struct overlay *active;
|
||||
size_t size;
|
||||
float overlay_opacity;
|
||||
float overlay_scale;
|
||||
float overlay_center_x;
|
||||
float overlay_center_y;
|
||||
struct overlay *overlays;
|
||||
struct overlay *active;
|
||||
bool overlay_enable;
|
||||
bool hide_in_menu;
|
||||
bool hide_when_gamepad_connected;
|
||||
} overlay_task_data_t;
|
||||
|
||||
void input_overlay_free_overlay(struct overlay *overlay);
|
||||
|
@ -1392,6 +1392,10 @@ MSG_HASH(
|
||||
MENU_ENUM_LABEL_INPUT_OVERLAY_HIDE_IN_MENU,
|
||||
"overlay_hide_in_menu"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_INPUT_OVERLAY_HIDE_WHEN_GAMEPAD_CONNECTED,
|
||||
"overlay_hide_when_gamepad_connected"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS,
|
||||
"overlay_show_physical_inputs"
|
||||
|
@ -3240,6 +3240,20 @@ MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_INPUT_OVERLAY_HIDE_IN_MENU,
|
||||
"Hide the overlay while inside the menu, and show it again when exiting the menu."
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_OVERLAY_HIDE_WHEN_GAMEPAD_CONNECTED,
|
||||
"Hide Overlay When Gamepad is Connected"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_INPUT_OVERLAY_HIDE_WHEN_GAMEPAD_CONNECTED,
|
||||
"Hide the overlay when a physical gamepad is connected in port 1, and show it again when the gamepad is disconnected."
|
||||
)
|
||||
#if defined(ANDROID)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_INPUT_OVERLAY_HIDE_WHEN_GAMEPAD_CONNECTED_ANDROID,
|
||||
"Hide the overlay when a physical gamepad is connected in port 1. WARNING: Overlay will not be restored automatically when gamepad is disconnected."
|
||||
)
|
||||
#endif
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS,
|
||||
"Show Inputs on Overlay"
|
||||
|
@ -404,6 +404,11 @@ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_video_message_pos_x, MENU_
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_video_message_pos_y, MENU_ENUM_SUBLABEL_VIDEO_MESSAGE_POS_Y)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_video_font_size, MENU_ENUM_SUBLABEL_VIDEO_FONT_SIZE)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_overlay_hide_in_menu, MENU_ENUM_SUBLABEL_INPUT_OVERLAY_HIDE_IN_MENU)
|
||||
#if defined(ANDROID)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_overlay_hide_when_gamepad_connected_android, MENU_ENUM_SUBLABEL_INPUT_OVERLAY_HIDE_WHEN_GAMEPAD_CONNECTED_ANDROID)
|
||||
#else
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_overlay_hide_when_gamepad_connected, MENU_ENUM_SUBLABEL_INPUT_OVERLAY_HIDE_WHEN_GAMEPAD_CONNECTED)
|
||||
#endif
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_overlay_show_mouse_cursor, MENU_ENUM_SUBLABEL_INPUT_OVERLAY_SHOW_MOUSE_CURSOR)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_overlay_auto_rotate, MENU_ENUM_SUBLABEL_INPUT_OVERLAY_AUTO_ROTATE)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_content_collection_list, MENU_ENUM_SUBLABEL_PLAYLISTS_TAB)
|
||||
@ -3001,6 +3006,13 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
|
||||
case MENU_ENUM_LABEL_INPUT_OVERLAY_HIDE_IN_MENU:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_input_overlay_hide_in_menu);
|
||||
break;
|
||||
case MENU_ENUM_LABEL_INPUT_OVERLAY_HIDE_WHEN_GAMEPAD_CONNECTED:
|
||||
#if defined(ANDROID)
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_input_overlay_hide_when_gamepad_connected_android);
|
||||
#else
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_input_overlay_hide_when_gamepad_connected);
|
||||
#endif
|
||||
break;
|
||||
case MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_input_overlay_show_physical_inputs);
|
||||
break;
|
||||
|
@ -7540,8 +7540,9 @@ unsigned menu_displaylist_build_list(
|
||||
menu_displaylist_build_info_selective_t build_list[] = {
|
||||
{MENU_ENUM_LABEL_INPUT_OVERLAY_ENABLE, PARSE_ONLY_BOOL, true },
|
||||
{MENU_ENUM_LABEL_INPUT_OVERLAY_HIDE_IN_MENU, PARSE_ONLY_BOOL, false },
|
||||
{MENU_ENUM_LABEL_INPUT_OVERLAY_HIDE_WHEN_GAMEPAD_CONNECTED, PARSE_ONLY_BOOL, false },
|
||||
{MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS, PARSE_ONLY_BOOL, false },
|
||||
{MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS_PORT,PARSE_ONLY_BOOL, false },
|
||||
{MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS_PORT, PARSE_ONLY_BOOL, false },
|
||||
{MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_MOUSE_CURSOR, PARSE_ONLY_BOOL, false },
|
||||
{MENU_ENUM_LABEL_INPUT_OVERLAY_AUTO_ROTATE, PARSE_ONLY_BOOL, false },
|
||||
{MENU_ENUM_LABEL_OVERLAY_PRESET, PARSE_ONLY_PATH, false },
|
||||
@ -7556,6 +7557,7 @@ unsigned menu_displaylist_build_list(
|
||||
switch (build_list[i].enum_idx)
|
||||
{
|
||||
case MENU_ENUM_LABEL_INPUT_OVERLAY_HIDE_IN_MENU:
|
||||
case MENU_ENUM_LABEL_INPUT_OVERLAY_HIDE_WHEN_GAMEPAD_CONNECTED:
|
||||
case MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS:
|
||||
case MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS_PORT:
|
||||
case MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_MOUSE_CURSOR:
|
||||
|
@ -12959,6 +12959,23 @@ static bool setting_append_list(
|
||||
);
|
||||
(*list)[list_info->index - 1].change_handler = overlay_enable_toggle_change_handler;
|
||||
|
||||
CONFIG_BOOL(
|
||||
list, list_info,
|
||||
&settings->bools.input_overlay_hide_when_gamepad_connected,
|
||||
MENU_ENUM_LABEL_INPUT_OVERLAY_HIDE_WHEN_GAMEPAD_CONNECTED,
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_OVERLAY_HIDE_WHEN_GAMEPAD_CONNECTED,
|
||||
DEFAULT_OVERLAY_HIDE_WHEN_GAMEPAD_CONNECTED,
|
||||
MENU_ENUM_LABEL_VALUE_OFF,
|
||||
MENU_ENUM_LABEL_VALUE_ON,
|
||||
&group_info,
|
||||
&subgroup_info,
|
||||
parent_group,
|
||||
general_write_handler,
|
||||
general_read_handler,
|
||||
SD_FLAG_NONE
|
||||
);
|
||||
(*list)[list_info->index - 1].change_handler = overlay_enable_toggle_change_handler;
|
||||
|
||||
CONFIG_BOOL(
|
||||
list, list_info,
|
||||
&settings->bools.input_overlay_show_physical_inputs,
|
||||
|
@ -923,6 +923,10 @@ enum msg_hash_enums
|
||||
MENU_LABEL(INPUT_OSK_OVERLAY_ENABLE),
|
||||
MENU_LABEL(INPUT_MENU_ENUM_TOGGLE_GAMEPAD_COMBO),
|
||||
MENU_LABEL(INPUT_OVERLAY_HIDE_IN_MENU),
|
||||
MENU_LABEL(INPUT_OVERLAY_HIDE_WHEN_GAMEPAD_CONNECTED),
|
||||
#if defined(ANDROID)
|
||||
MENU_ENUM_SUBLABEL_INPUT_OVERLAY_HIDE_WHEN_GAMEPAD_CONNECTED_ANDROID,
|
||||
#endif
|
||||
MENU_LABEL(INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS),
|
||||
MENU_LABEL(INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS_PORT),
|
||||
MENU_LABEL(INPUT_OVERLAY_SHOW_MOUSE_CURSOR),
|
||||
|
38
retroarch.c
38
retroarch.c
@ -23241,14 +23241,20 @@ static void input_overlay_loaded(retro_task_t *task,
|
||||
if (err)
|
||||
return;
|
||||
|
||||
if (data->overlay_enable)
|
||||
{
|
||||
#ifdef HAVE_MENU
|
||||
/* We can't display when the menu is up */
|
||||
if (data->hide_in_menu && p_rarch->menu_driver_alive)
|
||||
{
|
||||
if (data->overlay_enable)
|
||||
goto abort_load;
|
||||
#endif
|
||||
|
||||
/* If 'hide_when_gamepad_connected' is enabled,
|
||||
* we can't display when a gamepad is connected */
|
||||
if (data->hide_when_gamepad_connected &&
|
||||
(input_config_get_device_name(0) != NULL))
|
||||
goto abort_load;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( !data->overlay_enable ||
|
||||
!video_driver_overlay_interface(&iface) ||
|
||||
@ -23520,6 +23526,7 @@ static void retroarch_overlay_init(struct rarch_state *p_rarch)
|
||||
#else
|
||||
bool overlay_hide_in_menu = false;
|
||||
#endif
|
||||
bool overlay_hide_when_gamepad_connected = settings->bools.input_overlay_hide_when_gamepad_connected;
|
||||
#if defined(GEKKO)
|
||||
/* Avoid a crash at startup or even when toggling overlay in rgui */
|
||||
uint64_t memory_free = frontend_driver_get_free_memory();
|
||||
@ -23536,10 +23543,16 @@ static void retroarch_overlay_init(struct rarch_state *p_rarch)
|
||||
load_enabled = load_enabled && !p_rarch->menu_driver_alive;
|
||||
#endif
|
||||
|
||||
/* Cancel load if 'hide_when_gamepad_connected' is
|
||||
* enabled and a gamepad is currently connected */
|
||||
if (overlay_hide_when_gamepad_connected)
|
||||
load_enabled = load_enabled && (input_config_get_device_name(0) == NULL);
|
||||
|
||||
if (load_enabled)
|
||||
task_push_overlay_load_default(input_overlay_loaded,
|
||||
path_overlay,
|
||||
overlay_hide_in_menu,
|
||||
overlay_hide_when_gamepad_connected,
|
||||
input_overlay_enable,
|
||||
overlay_opacity,
|
||||
overlay_scale,
|
||||
@ -38777,8 +38790,27 @@ static enum runloop_state runloop_check_state(
|
||||
static unsigned last_height = 0;
|
||||
bool check_next_rotation = true;
|
||||
bool input_overlay_hide_in_menu = settings->bools.input_overlay_hide_in_menu;
|
||||
bool input_overlay_hide_when_gamepad_connected = settings->bools.input_overlay_hide_when_gamepad_connected;
|
||||
bool input_overlay_auto_rotate = settings->bools.input_overlay_auto_rotate;
|
||||
|
||||
/* Check whether overlay should be hidden
|
||||
* when a gamepad is connected */
|
||||
if (input_overlay_hide_when_gamepad_connected)
|
||||
{
|
||||
static bool last_controller_connected = false;
|
||||
bool controller_connected = (input_config_get_device_name(0) != NULL);
|
||||
|
||||
if (controller_connected != last_controller_connected)
|
||||
{
|
||||
if (controller_connected)
|
||||
retroarch_overlay_deinit(p_rarch);
|
||||
else
|
||||
retroarch_overlay_init(p_rarch);
|
||||
|
||||
last_controller_connected = controller_connected;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check next overlay */
|
||||
HOTKEY_CHECK(RARCH_OVERLAY_NEXT, CMD_EVENT_OVERLAY_NEXT, true, &check_next_rotation);
|
||||
|
||||
|
@ -56,6 +56,7 @@ struct overlay_loader
|
||||
bool driver_rgba_support;
|
||||
bool overlay_enable;
|
||||
bool overlay_hide_in_menu;
|
||||
bool overlay_hide_when_gamepad_connected;
|
||||
};
|
||||
|
||||
static void task_overlay_image_done(struct overlay *overlay)
|
||||
@ -705,14 +706,15 @@ static void task_overlay_handler(retro_task_t *task)
|
||||
calloc(1, sizeof(*data));
|
||||
|
||||
data->overlays = loader->overlays;
|
||||
data->size = loader->size;
|
||||
data->active = loader->active;
|
||||
data->hide_in_menu = loader->overlay_hide_in_menu;
|
||||
data->overlay_enable = loader->overlay_enable;
|
||||
data->size = loader->size;
|
||||
data->overlay_opacity = loader->overlay_opacity;
|
||||
data->overlay_scale = loader->overlay_scale;
|
||||
data->overlay_center_x = loader->overlay_center_x;
|
||||
data->overlay_center_y = loader->overlay_center_y;
|
||||
data->overlay_enable = loader->overlay_enable;
|
||||
data->hide_in_menu = loader->overlay_hide_in_menu;
|
||||
data->hide_when_gamepad_connected = loader->overlay_hide_when_gamepad_connected;
|
||||
|
||||
task_set_data(task, data);
|
||||
}
|
||||
@ -739,6 +741,7 @@ bool task_push_overlay_load_default(
|
||||
retro_task_callback_t cb,
|
||||
const char *overlay_path,
|
||||
bool overlay_hide_in_menu,
|
||||
bool overlay_hide_when_gamepad_connected,
|
||||
bool input_overlay_enable,
|
||||
float input_overlay_opacity,
|
||||
float input_overlay_scale,
|
||||
@ -791,6 +794,7 @@ bool task_push_overlay_load_default(
|
||||
}
|
||||
|
||||
loader->overlay_hide_in_menu = overlay_hide_in_menu;
|
||||
loader->overlay_hide_when_gamepad_connected = overlay_hide_when_gamepad_connected;
|
||||
loader->overlay_enable = input_overlay_enable;
|
||||
loader->overlay_opacity = input_overlay_opacity;
|
||||
loader->overlay_scale = input_overlay_scale;
|
||||
|
@ -158,6 +158,7 @@ bool task_push_overlay_load_default(
|
||||
retro_task_callback_t cb,
|
||||
const char *overlay_path,
|
||||
bool overlay_hide_in_menu,
|
||||
bool overlay_hide_when_gamepad_connected,
|
||||
bool input_overlay_enable,
|
||||
float input_overlay_opacity,
|
||||
float input_overlay_scale,
|
||||
|
Loading…
x
Reference in New Issue
Block a user