add option to toggle menu by holding down start button

This commit is contained in:
Brad Parker 2018-12-19 14:53:17 -05:00
parent fd93e5e26e
commit 458bb9fbb5
5 changed files with 42 additions and 0 deletions

View File

@ -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
};

View File

@ -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)")

View File

@ -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;
}
}

View File

@ -2186,6 +2186,8 @@ enum msg_hash_enums
MENU_ENUM_SUBLABEL_SWITCH_CPU_PROFILE,
#endif
MENU_ENUM_LABEL_VALUE_HOLD_START,
MSG_LAST
};

View File

@ -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;