diff --git a/input/input_driver.h b/input/input_driver.h index b3169021ec..1ac166478b 100644 --- a/input/input_driver.h +++ b/input/input_driver.h @@ -59,6 +59,7 @@ enum input_toggle_type INPUT_TOGGLE_START_SELECT, INPUT_TOGGLE_L3_R, INPUT_TOGGLE_L_R, + INPUT_TOGGLE_HOLD_START, INPUT_TOGGLE_LAST }; diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index a31e28f937..cc95c33a76 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -7848,3 +7848,5 @@ MSG_HASH( ) MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_SAVE_POSITION, "Remember Window Position and Size") +MSG_HASH(MENU_ENUM_LABEL_VALUE_HOLD_START, + "Hold Start (2 seconds)") diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 8b7c30f7c0..61aca46d12 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -1819,6 +1819,9 @@ static void setting_get_string_representation_toggle_gamepad_combo( case INPUT_TOGGLE_L_R: strlcpy(s, "L + R", len); break; + case INPUT_TOGGLE_HOLD_START: + strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_HOLD_START), len); + break; } } diff --git a/msg_hash.h b/msg_hash.h index 5cb184c924..c2af72b219 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -2186,6 +2186,8 @@ enum msg_hash_enums MENU_ENUM_SUBLABEL_SWITCH_CPU_PROFILE, #endif + MENU_ENUM_LABEL_VALUE_HOLD_START, + MSG_LAST }; diff --git a/retroarch.c b/retroarch.c index 49d35b45bb..60c5826557 100644 --- a/retroarch.c +++ b/retroarch.c @@ -140,6 +140,7 @@ #endif #define SHADER_FILE_WATCH_DELAY_MSEC 500 +#define HOLD_START_DELAY_SEC 2 /* Descriptive names for options without short variant. * @@ -2507,6 +2508,39 @@ static bool input_driver_toggle_button_combo( if (!BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_R)) return false; break; + case INPUT_TOGGLE_HOLD_START: + { + uint64_t frame_count = 0; + bool is_alive = false; + bool is_focused = false; + static rarch_timer_t timer = {0}; + + if (!BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_START)) + { + /* timer only runs while start is held down */ + rarch_timer_end(&timer); + return false; + } + + video_driver_get_status(&frame_count, &is_alive, &is_focused); + + if (!rarch_timer_is_running(&timer)) + { + /* user started holding down the start button, start the timer */ + rarch_timer_begin(&timer, HOLD_START_DELAY_SEC); + } + + rarch_timer_tick(&timer); + + if (!timer.timer_end && rarch_timer_has_expired(&timer)) + { + /* start has been held down long enough, stop timer and enter menu */ + rarch_timer_end(&timer); + return true; + } + + return false; + } default: case INPUT_TOGGLE_NONE: return false;