mirror of
https://github.com/libretro/RetroArch
synced 2025-03-02 19:13:34 +00:00
Add option for pause on controller disconnect (#14601)
This commit is contained in:
parent
6083ab14e5
commit
68401205f2
@ -1198,13 +1198,17 @@ static const bool audio_enable_menu_bgm = false;
|
||||
/* How many frames to rewind at a time. */
|
||||
#define DEFAULT_REWIND_GRANULARITY 1
|
||||
#endif
|
||||
/* Pause gameplay when gameplay loses focus. */
|
||||
|
||||
/* Pause gameplay when window loses focus. */
|
||||
#if defined(EMSCRIPTEN)
|
||||
#define DEFAULT_PAUSE_NONACTIVE false
|
||||
#else
|
||||
#define DEFAULT_PAUSE_NONACTIVE true
|
||||
#endif
|
||||
|
||||
/* Pause gameplay when controller disconnects. */
|
||||
#define DEFAULT_PAUSE_ON_DISCONNECT true
|
||||
|
||||
/* Saves non-volatile SRAM at a regular interval.
|
||||
* It is measured in seconds. A value of 0 disables autosave. */
|
||||
#if defined(__i386__) || defined(__i486__) || defined(__i686__) || defined(__x86_64__) || defined(_M_X64) || defined(_WIN32) || defined(OSX) || defined(ANDROID) || defined(IOS) || defined(DINGUX)
|
||||
|
@ -1704,6 +1704,7 @@ static struct config_bool_setting *populate_settings_bool(
|
||||
SETTING_BOOL("video_waitable_swapchains", &settings->bools.video_waitable_swapchains, true, DEFAULT_WAITABLE_SWAPCHAINS, false);
|
||||
SETTING_BOOL("video_disable_composition", &settings->bools.video_disable_composition, true, DEFAULT_DISABLE_COMPOSITION, false);
|
||||
SETTING_BOOL("pause_nonactive", &settings->bools.pause_nonactive, true, DEFAULT_PAUSE_NONACTIVE, false);
|
||||
SETTING_BOOL("pause_on_disconnect", &settings->bools.pause_on_disconnect, true, DEFAULT_PAUSE_ON_DISCONNECT, false);
|
||||
SETTING_BOOL("video_gpu_screenshot", &settings->bools.video_gpu_screenshot, true, DEFAULT_GPU_SCREENSHOT, false);
|
||||
SETTING_BOOL("video_post_filter_record", &settings->bools.video_post_filter_record, true, DEFAULT_POST_FILTER_RECORD, false);
|
||||
SETTING_BOOL("video_notch_write_over_enable", &settings->bools.video_notch_write_over_enable, true, DEFAULT_NOTCH_WRITE_OVER_ENABLE, false);
|
||||
|
@ -868,6 +868,7 @@ typedef struct settings
|
||||
bool run_ahead_secondary_instance;
|
||||
bool run_ahead_hide_warnings;
|
||||
bool pause_nonactive;
|
||||
bool pause_on_disconnect;
|
||||
bool block_sram_overwrite;
|
||||
bool savestate_auto_index;
|
||||
bool savestate_auto_save;
|
||||
|
@ -2414,6 +2414,10 @@ MSG_HASH(
|
||||
MENU_ENUM_LABEL_PAUSE_NONACTIVE,
|
||||
"pause_nonactive"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_PAUSE_ON_DISCONNECT,
|
||||
"pause_on_disconnect"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_MENU_SCREENSAVER_TIMEOUT,
|
||||
"menu_screensaver_timeout"
|
||||
|
@ -2508,6 +2508,14 @@ MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_AUTO_GAME_FOCUS_DETECT,
|
||||
"Detect"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_PAUSE_ON_DISCONNECT,
|
||||
"Pause Content When Controller Disconnects"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_PAUSE_ON_DISCONNECT,
|
||||
"Pause content when any controller is disconnected."
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_BUTTON_AXIS_THRESHOLD,
|
||||
"Input Button Axis Threshold"
|
||||
@ -11691,10 +11699,6 @@ MSG_HASH(
|
||||
MSG_NATIVE,
|
||||
"Native"
|
||||
)
|
||||
MSG_HASH(
|
||||
MSG_DEVICE_DISCONNECTED_FROM_PORT,
|
||||
"Device disconnected from port"
|
||||
)
|
||||
MSG_HASH(
|
||||
MSG_UNKNOWN_NETPLAY_COMMAND_RECEIVED,
|
||||
"Unknown netplay command received"
|
||||
@ -12908,6 +12912,14 @@ MSG_HASH(
|
||||
MSG_AUTOLOADING_SAVESTATE_SUCCEEDED,
|
||||
"Auto-loading save state from \"%s\" succeeded."
|
||||
)
|
||||
MSG_HASH(
|
||||
MSG_DEVICE_CONFIGURED_IN_PORT,
|
||||
"configured in port"
|
||||
)
|
||||
MSG_HASH(
|
||||
MSG_DEVICE_DISCONNECTED_FROM_PORT,
|
||||
"disconnected from port"
|
||||
)
|
||||
MSG_HASH(
|
||||
MSG_DEVICE_NOT_CONFIGURED,
|
||||
"not configured"
|
||||
@ -13112,10 +13124,6 @@ MSG_HASH(
|
||||
MSG_CHEAT_DELETE_SUCCESS,
|
||||
"Cheat deleted."
|
||||
)
|
||||
MSG_HASH(
|
||||
MSG_DEVICE_CONFIGURED_IN_PORT,
|
||||
"Configured in port:"
|
||||
)
|
||||
MSG_HASH(
|
||||
MSG_FAILED_TO_SET_DISK,
|
||||
"Failed to set disc"
|
||||
|
@ -507,6 +507,7 @@ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_audio_enable_menu, MENU_
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_menu_sounds, MENU_ENUM_SUBLABEL_MENU_SOUNDS)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_audio_max_timing_skew, MENU_ENUM_SUBLABEL_AUDIO_MAX_TIMING_SKEW)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_pause_nonactive, MENU_ENUM_SUBLABEL_PAUSE_NONACTIVE)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_pause_on_disconnect, MENU_ENUM_SUBLABEL_PAUSE_ON_DISCONNECT)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_video_disable_composition, MENU_ENUM_SUBLABEL_VIDEO_DISABLE_COMPOSITION)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_video_smooth, MENU_ENUM_SUBLABEL_VIDEO_SMOOTH)
|
||||
#ifdef HAVE_ODROIDGO2
|
||||
@ -4665,6 +4666,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
|
||||
case MENU_ENUM_LABEL_PAUSE_NONACTIVE:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_pause_nonactive);
|
||||
break;
|
||||
case MENU_ENUM_LABEL_PAUSE_ON_DISCONNECT:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_pause_on_disconnect);
|
||||
break;
|
||||
case MENU_ENUM_LABEL_VIDEO_DISABLE_COMPOSITION:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_video_disable_composition);
|
||||
break;
|
||||
|
@ -7055,6 +7055,10 @@ unsigned menu_displaylist_build_list(
|
||||
MENU_ENUM_LABEL_INPUT_AUTODETECT_ENABLE,
|
||||
PARSE_ONLY_BOOL, false) == 0)
|
||||
count++;
|
||||
if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list,
|
||||
MENU_ENUM_LABEL_PAUSE_ON_DISCONNECT,
|
||||
PARSE_ONLY_BOOL, false) == 0)
|
||||
count++;
|
||||
if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list,
|
||||
MENU_ENUM_LABEL_INPUT_DESCRIPTOR_LABEL_SHOW,
|
||||
PARSE_ONLY_BOOL, false) == 0)
|
||||
@ -7104,12 +7108,12 @@ unsigned menu_displaylist_build_list(
|
||||
count++;
|
||||
#endif
|
||||
if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list,
|
||||
MENU_ENUM_LABEL_INPUT_SENSORS_ENABLE,
|
||||
MENU_ENUM_LABEL_INPUT_AUTO_MOUSE_GRAB,
|
||||
PARSE_ONLY_BOOL, false) == 0)
|
||||
count++;
|
||||
if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list,
|
||||
MENU_ENUM_LABEL_INPUT_AUTO_MOUSE_GRAB,
|
||||
PARSE_ONLY_BOOL, false) == 0)
|
||||
MENU_ENUM_LABEL_INPUT_AUTO_GAME_FOCUS,
|
||||
PARSE_ONLY_UINT, false) == 0)
|
||||
count++;
|
||||
#ifdef ANDROID
|
||||
if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list,
|
||||
@ -7118,8 +7122,8 @@ unsigned menu_displaylist_build_list(
|
||||
count++;
|
||||
#endif
|
||||
if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list,
|
||||
MENU_ENUM_LABEL_INPUT_AUTO_GAME_FOCUS,
|
||||
PARSE_ONLY_UINT, false) == 0)
|
||||
MENU_ENUM_LABEL_INPUT_SENSORS_ENABLE,
|
||||
PARSE_ONLY_BOOL, false) == 0)
|
||||
count++;
|
||||
if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list,
|
||||
MENU_ENUM_LABEL_INPUT_HAPTIC_FEEDBACK_SETTINGS,
|
||||
@ -8389,6 +8393,7 @@ unsigned menu_displaylist_build_list(
|
||||
{MENU_ENUM_LABEL_NAVIGATION_WRAPAROUND, PARSE_ONLY_BOOL, true},
|
||||
{MENU_ENUM_LABEL_PAUSE_LIBRETRO, PARSE_ONLY_BOOL, true},
|
||||
{MENU_ENUM_LABEL_PAUSE_NONACTIVE, PARSE_ONLY_BOOL, true},
|
||||
{MENU_ENUM_LABEL_PAUSE_ON_DISCONNECT, PARSE_ONLY_BOOL, true},
|
||||
{MENU_ENUM_LABEL_MENU_SAVESTATE_RESUME, PARSE_ONLY_BOOL, true},
|
||||
{MENU_ENUM_LABEL_MENU_INSERT_DISK_RESUME, PARSE_ONLY_BOOL, true},
|
||||
{MENU_ENUM_LABEL_QUIT_ON_CLOSE_CONTENT, PARSE_ONLY_UINT, true},
|
||||
|
@ -13887,6 +13887,22 @@ static bool setting_append_list(
|
||||
(*list)[list_info->index - 1].get_string_representation =
|
||||
&setting_get_string_representation_uint_input_auto_game_focus;
|
||||
menu_settings_list_current_add_range(list, list_info, 0, AUTO_GAME_FOCUS_LAST-1, 1, true, true);
|
||||
|
||||
CONFIG_BOOL(
|
||||
list, list_info,
|
||||
&settings->bools.pause_on_disconnect,
|
||||
MENU_ENUM_LABEL_PAUSE_ON_DISCONNECT,
|
||||
MENU_ENUM_LABEL_VALUE_PAUSE_ON_DISCONNECT,
|
||||
DEFAULT_PAUSE_ON_DISCONNECT,
|
||||
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);
|
||||
|
||||
#if 0
|
||||
CONFIG_BOOL(
|
||||
list, list_info,
|
||||
|
@ -1225,6 +1225,7 @@ enum msg_hash_enums
|
||||
MENU_LABEL(MENU_WALLPAPER),
|
||||
MENU_LABEL(DYNAMIC_WALLPAPER),
|
||||
MENU_LABEL(PAUSE_NONACTIVE),
|
||||
MENU_LABEL(PAUSE_ON_DISCONNECT),
|
||||
MENU_LABEL(MENU_SCREENSAVER_TIMEOUT),
|
||||
MENU_LABEL(MENU_SCREENSAVER_ANIMATION),
|
||||
MENU_LABEL(MENU_SCREENSAVER_ANIMATION_SPEED),
|
||||
|
@ -958,6 +958,9 @@
|
||||
# Pause gameplay when window focus is lost.
|
||||
# pause_nonactive = true
|
||||
|
||||
# Pause gameplay when controller disconnects.
|
||||
# pause_on_disconnect = true
|
||||
|
||||
# Autosaves the non-volatile SRAM at a regular interval. This is disabled by default unless set otherwise.
|
||||
# The interval is measured in seconds. A value of 0 disables autosave.
|
||||
# autosave_interval =
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "../file_path_special.h"
|
||||
#include "../list_special.h"
|
||||
#include "../retroarch.h"
|
||||
#include "../verbosity.h"
|
||||
#include "../input/input_driver.h"
|
||||
#include "../input/input_remapping.h"
|
||||
|
||||
@ -37,6 +38,10 @@
|
||||
#include "../input/include/blissbox.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
#include "../menu/menu_driver.h"
|
||||
#endif
|
||||
|
||||
enum autoconfig_handle_flags
|
||||
{
|
||||
AUTOCONF_FLAG_AUTOCONFIG_ENABLED = (1 << 0),
|
||||
@ -578,7 +583,10 @@ static void input_autoconfigure_connect_handler(retro_task_t *task)
|
||||
/* Update task title */
|
||||
task_free_title(task);
|
||||
if (!string_is_empty(task_title))
|
||||
{
|
||||
task_set_title(task, strdup(task_title));
|
||||
RARCH_LOG("[Autoconf]: %s.\n", task_title);
|
||||
}
|
||||
|
||||
task_finished:
|
||||
|
||||
@ -798,6 +806,7 @@ static void input_autoconfigure_disconnect_handler(retro_task_t *task)
|
||||
{
|
||||
size_t _len;
|
||||
autoconfig_handle_t *autoconfig_handle = NULL;
|
||||
const char *device_display_name = NULL;
|
||||
char task_title[NAME_MAX_LENGTH + 16];
|
||||
|
||||
task_title[0] = '\0';
|
||||
@ -808,28 +817,31 @@ static void input_autoconfigure_disconnect_handler(retro_task_t *task)
|
||||
if (!(autoconfig_handle = (autoconfig_handle_t*)task->state))
|
||||
goto task_finished;
|
||||
|
||||
/* Get display name for task status message */
|
||||
device_display_name = autoconfig_handle->device_info.display_name;
|
||||
if (string_is_empty(device_display_name))
|
||||
device_display_name = autoconfig_handle->device_info.name;
|
||||
if (string_is_empty(device_display_name))
|
||||
device_display_name = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE);
|
||||
|
||||
/* Set task title */
|
||||
_len = strlcpy(task_title,
|
||||
_len = strlcpy(task_title,
|
||||
device_display_name, sizeof(task_title));
|
||||
task_title[_len ] = ' ';
|
||||
task_title[++_len] = '\0';
|
||||
_len = strlcat(task_title,
|
||||
msg_hash_to_str(MSG_DEVICE_DISCONNECTED_FROM_PORT),
|
||||
sizeof(task_title));
|
||||
task_title[_len ] = ' ';
|
||||
task_title[++_len] = '\0';
|
||||
_len += snprintf(task_title + _len,
|
||||
sizeof(task_title) - _len, "%u",
|
||||
task_title[_len ] = ' ';
|
||||
task_title[++_len] = '\0';
|
||||
snprintf(task_title + _len, sizeof(task_title) - _len, "%u",
|
||||
autoconfig_handle->port + 1);
|
||||
if (!string_is_empty(autoconfig_handle->device_info.name))
|
||||
{
|
||||
task_title[_len ] = ':';
|
||||
task_title[_len+1] = ' ';
|
||||
task_title[_len+2] = '\0';
|
||||
_len = strlcat(task_title,
|
||||
autoconfig_handle->device_info.name,
|
||||
sizeof(task_title));
|
||||
}
|
||||
|
||||
task_free_title(task);
|
||||
if (!(autoconfig_handle->flags & AUTOCONF_FLAG_SUPPRESS_NOTIFICATIONS))
|
||||
task_set_title(task, strdup(task_title));
|
||||
if (!string_is_empty(task_title))
|
||||
RARCH_LOG("[Autoconf]: %s.\n", task_title);
|
||||
|
||||
task_finished:
|
||||
|
||||
@ -871,8 +883,9 @@ bool input_autoconfigure_disconnect(unsigned port, const char *name)
|
||||
task_finder_data_t find_data;
|
||||
settings_t *settings = config_get_ptr();
|
||||
input_driver_state_t *input_st = input_state_get_ptr();
|
||||
bool notification_show_autoconfig = settings ?
|
||||
settings->bools.notification_show_autoconfig : true;
|
||||
bool notification_show_autoconfig = settings ? settings->bools.notification_show_autoconfig : true;
|
||||
bool pause_on_disconnect = settings ? settings->bools.pause_on_disconnect : true;
|
||||
bool core_is_running = runloop_state_get_ptr()->flags & RUNLOOP_FLAG_CORE_RUNNING;
|
||||
|
||||
if (port >= MAX_INPUT_DEVICES)
|
||||
goto error;
|
||||
@ -917,6 +930,21 @@ bool input_autoconfigure_disconnect(unsigned port, const char *name)
|
||||
|
||||
task_queue_push(task);
|
||||
|
||||
if (pause_on_disconnect && core_is_running)
|
||||
{
|
||||
#ifdef HAVE_MENU
|
||||
bool menu_pause_libretro = settings->bools.menu_pause_libretro;
|
||||
bool menu_is_alive = menu_state_get_ptr()->flags & MENU_ST_FLAG_ALIVE;
|
||||
|
||||
if (menu_pause_libretro && !menu_is_alive)
|
||||
command_event(CMD_EVENT_MENU_TOGGLE, NULL);
|
||||
else if (!menu_pause_libretro)
|
||||
command_event(CMD_EVENT_PAUSE, NULL);
|
||||
#else
|
||||
command_event(CMD_EVENT_PAUSE, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
error:
|
||||
|
Loading…
x
Reference in New Issue
Block a user