mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-27 10:10:57 +00:00
menu: add press quit twice setting
This commit is contained in:
parent
0e66da3930
commit
6b6f9ae678
@ -432,6 +432,8 @@ static bool menu_swap_ok_cancel_buttons = true;
|
||||
static bool menu_swap_ok_cancel_buttons = false;
|
||||
#endif
|
||||
|
||||
static bool quit_press_twice = false;
|
||||
|
||||
/* Crop overscanned frames. */
|
||||
static const bool crop_overscan = true;
|
||||
|
||||
|
@ -1579,6 +1579,8 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings,
|
||||
SETTING_BOOL("playlist_show_core_name", &settings->bools.playlist_show_core_name, true, playlist_show_core_name, false);
|
||||
SETTING_BOOL("playlist_sort_alphabetical", &settings->bools.playlist_sort_alphabetical, true, playlist_sort_alphabetical, false);
|
||||
|
||||
SETTING_BOOL("quit_press_twice", &settings->bools.quit_press_twice, true, quit_press_twice, false);
|
||||
|
||||
*size = count;
|
||||
|
||||
return tmp;
|
||||
|
@ -313,6 +313,8 @@ typedef struct settings
|
||||
bool playlist_show_core_name;
|
||||
bool playlist_sort_alphabetical;
|
||||
bool playlist_show_sublabels;
|
||||
|
||||
bool quit_press_twice;
|
||||
} bools;
|
||||
|
||||
struct
|
||||
|
@ -1445,6 +1445,8 @@ MSG_HASH(MENU_ENUM_LABEL_SHADER_PIPELINE_SNOW,
|
||||
"shader_pipeline_snow")
|
||||
MSG_HASH(MENU_ENUM_LABEL_INPUT_UNIFIED_MENU_CONTROLS,
|
||||
"unified_menu_controls")
|
||||
MSG_HASH(MENU_ENUM_LABEL_QUIT_PRESS_TWICE,
|
||||
"quit_press_twice")
|
||||
MSG_HASH(MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR,
|
||||
"detect_core_list_push_dir")
|
||||
MSG_HASH(MENU_ENUM_LABEL_BATTERY_LEVEL_ENABLE,
|
||||
|
@ -4794,6 +4794,10 @@ MSG_HASH(
|
||||
MSG_SCREENSHOT_SAVED,
|
||||
"Screenshot saved"
|
||||
)
|
||||
MSG_HASH(
|
||||
MSG_PRESS_AGAIN_TO_QUIT,
|
||||
"Press again to quit..."
|
||||
)
|
||||
MSG_HASH(
|
||||
MSG_TO,
|
||||
"to"
|
||||
@ -5087,6 +5091,14 @@ MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_INPUT_UNIFIED_MENU_CONTROLS,
|
||||
"Use the same controls for both the menu and the game. Applies to the keyboard."
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_QUIT_PRESS_TWICE,
|
||||
"Press quit twice"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_QUIT_PRESS_TWICE,
|
||||
"Press the quit hotkey twice to exit RetroArch."
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_VIDEO_FONT_ENABLE,
|
||||
"Show onscreen messages."
|
||||
|
@ -185,6 +185,7 @@ default_sublabel_macro(action_bind_sublabel_video_smooth, MENU_
|
||||
default_sublabel_macro(action_bind_sublabel_history_list_enable, MENU_ENUM_SUBLABEL_HISTORY_LIST_ENABLE)
|
||||
default_sublabel_macro(action_bind_sublabel_content_history_size, MENU_ENUM_SUBLABEL_CONTENT_HISTORY_SIZE)
|
||||
default_sublabel_macro(action_bind_sublabel_menu_input_unified_controls, MENU_ENUM_SUBLABEL_INPUT_UNIFIED_MENU_CONTROLS)
|
||||
default_sublabel_macro(action_bind_sublabel_quit_press_twice, MENU_ENUM_SUBLABEL_QUIT_PRESS_TWICE)
|
||||
default_sublabel_macro(action_bind_sublabel_onscreen_notifications_enable, MENU_ENUM_SUBLABEL_VIDEO_FONT_ENABLE)
|
||||
default_sublabel_macro(action_bind_sublabel_video_crop_overscan, MENU_ENUM_SUBLABEL_VIDEO_CROP_OVERSCAN)
|
||||
default_sublabel_macro(action_bind_sublabel_video_filter, MENU_ENUM_SUBLABEL_VIDEO_FILTER)
|
||||
@ -1938,6 +1939,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
|
||||
case MENU_ENUM_LABEL_INPUT_UNIFIED_MENU_CONTROLS:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_input_unified_controls);
|
||||
break;
|
||||
case MENU_ENUM_LABEL_QUIT_PRESS_TWICE:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_quit_press_twice);
|
||||
break;
|
||||
case MENU_ENUM_LABEL_AUDIO_MAX_TIMING_SKEW:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_audio_max_timing_skew);
|
||||
break;
|
||||
|
@ -266,8 +266,7 @@ enum menu_action
|
||||
MENU_ACTION_SCROLL_UP,
|
||||
MENU_ACTION_TOGGLE,
|
||||
MENU_ACTION_POINTER_MOVED,
|
||||
MENU_ACTION_POINTER_PRESSED,
|
||||
MENU_ACTION_QUIT
|
||||
MENU_ACTION_POINTER_PRESSED
|
||||
};
|
||||
|
||||
enum menu_input_pointer_state
|
||||
|
@ -7075,6 +7075,9 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist
|
||||
ret = menu_displaylist_parse_settings_enum(menu, info,
|
||||
MENU_ENUM_LABEL_INPUT_UNIFIED_MENU_CONTROLS,
|
||||
PARSE_ONLY_BOOL, false);
|
||||
ret = menu_displaylist_parse_settings_enum(menu, info,
|
||||
MENU_ENUM_LABEL_QUIT_PRESS_TWICE,
|
||||
PARSE_ONLY_BOOL, false);
|
||||
if (menu_displaylist_parse_settings_enum(menu, info,
|
||||
MENU_ENUM_LABEL_INPUT_POLL_TYPE_BEHAVIOR,
|
||||
PARSE_ONLY_UINT, false) == 0)
|
||||
|
@ -336,9 +336,6 @@ unsigned menu_event(input_bits_t *p_input, input_bits_t *p_trigger_input)
|
||||
menu_event_kb_set_internal(RETROK_F11, 0);
|
||||
}
|
||||
|
||||
if (BIT256_GET_PTR(p_trigger_input, RARCH_QUIT_KEY))
|
||||
return MENU_ACTION_QUIT;
|
||||
|
||||
mouse_enabled = settings->bools.menu_mouse_enable;
|
||||
#ifdef HAVE_OVERLAY
|
||||
if (!mouse_enabled)
|
||||
|
@ -6858,6 +6858,22 @@ static bool setting_append_list(
|
||||
);
|
||||
settings_data_list_current_add_flags(list, list_info, SD_FLAG_LAKKA_ADVANCED);
|
||||
|
||||
CONFIG_BOOL(
|
||||
list, list_info,
|
||||
&settings->bools.quit_press_twice,
|
||||
MENU_ENUM_LABEL_QUIT_PRESS_TWICE,
|
||||
MENU_ENUM_LABEL_VALUE_QUIT_PRESS_TWICE,
|
||||
false,
|
||||
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
|
||||
);
|
||||
|
||||
CONFIG_UINT(
|
||||
list, list_info,
|
||||
&settings->uints.input_poll_type_behavior,
|
||||
|
@ -347,6 +347,7 @@ enum msg_hash_enums
|
||||
MSG_MOVIE_PLAYBACK_ENDED,
|
||||
MSG_TAKING_SCREENSHOT,
|
||||
MSG_SCREENSHOT_SAVED,
|
||||
MSG_PRESS_AGAIN_TO_QUIT,
|
||||
MSG_WIFI_SCAN_COMPLETE,
|
||||
MSG_SCANNING_WIRELESS_NETWORKS,
|
||||
MSG_FAILED_TO_TAKE_SCREENSHOT,
|
||||
@ -765,6 +766,8 @@ enum msg_hash_enums
|
||||
MENU_LABEL(INPUT_POLL_TYPE_BEHAVIOR),
|
||||
MENU_LABEL(INPUT_UNIFIED_MENU_CONTROLS),
|
||||
|
||||
MENU_LABEL(QUIT_PRESS_TWICE),
|
||||
|
||||
/* Video */
|
||||
MENU_LABEL(CRT_SWITCH_RESOLUTION),
|
||||
MENU_LABEL(CRT_SWITCH_RESOLUTION_SUPER),
|
||||
|
49
retroarch.c
49
retroarch.c
@ -147,6 +147,8 @@
|
||||
#define SHADER_FILE_WATCH_DELAY_MSEC 500
|
||||
#define HOLD_START_DELAY_SEC 2
|
||||
|
||||
#define QUIT_DELAY_USEC 3 * 1000000 /* 3 seconds */
|
||||
|
||||
/* Descriptive names for options without short variant.
|
||||
*
|
||||
* Please keep the name in sync with the option name.
|
||||
@ -2743,24 +2745,25 @@ static enum runloop_state runloop_check_state(
|
||||
#ifdef HAVE_MENU
|
||||
static input_bits_t last_input = {{0}};
|
||||
#endif
|
||||
static bool old_quit_key = false;
|
||||
static bool quit_key = false;
|
||||
static bool trig_quit_key = false;
|
||||
static bool runloop_exec = false;
|
||||
static bool old_focus = true;
|
||||
bool is_focused = false;
|
||||
bool is_alive = false;
|
||||
uint64_t frame_count = 0;
|
||||
bool focused = true;
|
||||
bool pause_nonactive = settings->bools.pause_nonactive;
|
||||
bool rarch_is_initialized = rarch_ctl(RARCH_CTL_IS_INITED, NULL);
|
||||
bool fs_toggle_triggered = false;
|
||||
static bool old_quit_key = false;
|
||||
static bool quit_key = false;
|
||||
static bool trig_quit_key = false;
|
||||
static retro_time_t quit_key_time = 0;
|
||||
static bool runloop_exec = false;
|
||||
static bool old_focus = true;
|
||||
bool is_focused = false;
|
||||
bool is_alive = false;
|
||||
uint64_t frame_count = 0;
|
||||
bool focused = true;
|
||||
bool pause_nonactive = settings->bools.pause_nonactive;
|
||||
bool rarch_is_initialized = rarch_ctl(RARCH_CTL_IS_INITED, NULL);
|
||||
bool fs_toggle_triggered = false;
|
||||
#ifdef HAVE_MENU
|
||||
bool menu_driver_binding_state = menu_driver_is_binding_state();
|
||||
bool menu_is_alive = menu_driver_is_alive();
|
||||
unsigned menu_toggle_gamepad_combo = settings->uints.input_menu_toggle_gamepad_combo;
|
||||
bool menu_driver_binding_state = menu_driver_is_binding_state();
|
||||
bool menu_is_alive = menu_driver_is_alive();
|
||||
unsigned menu_toggle_gamepad_combo = settings->uints.input_menu_toggle_gamepad_combo;
|
||||
#ifdef HAVE_EASTEREGG
|
||||
static uint64_t seq = 0;
|
||||
static uint64_t seq = 0;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -2889,6 +2892,17 @@ static enum runloop_state runloop_check_state(
|
||||
trig_quit_key = quit_key && !old_quit_key;
|
||||
old_quit_key = quit_key;
|
||||
|
||||
/* Check double press if enabled */
|
||||
if (trig_quit_key && settings->bools.quit_press_twice)
|
||||
{
|
||||
retro_time_t cur_time = cpu_features_get_time_usec();
|
||||
trig_quit_key = trig_quit_key && (cur_time - quit_key_time < QUIT_DELAY_USEC);
|
||||
quit_key_time = cur_time;
|
||||
|
||||
if (!trig_quit_key)
|
||||
runloop_msg_queue_push(msg_hash_to_str(MSG_PRESS_AGAIN_TO_QUIT), 1, QUIT_DELAY_USEC * 60 / 1000000, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
}
|
||||
|
||||
if (time_to_exit(trig_quit_key))
|
||||
{
|
||||
if ((runloop_max_frames != 0) && (frame_count >= runloop_max_frames))
|
||||
@ -3063,9 +3077,6 @@ static enum runloop_state runloop_check_state(
|
||||
if (!focused)
|
||||
return RUNLOOP_STATE_POLLED_AND_SLEEP;
|
||||
|
||||
if (action == MENU_ACTION_QUIT && !menu_driver_binding_state)
|
||||
return RUNLOOP_STATE_QUIT;
|
||||
|
||||
if (runloop_idle)
|
||||
return RUNLOOP_STATE_POLLED_AND_SLEEP;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user