diff --git a/configuration.c b/configuration.c index 0ab83424d4..49feb25290 100644 --- a/configuration.c +++ b/configuration.c @@ -1636,6 +1636,9 @@ static struct config_uint_setting *populate_settings_uint(settings_t *settings, SETTING_UINT("audio_latency", &settings->uints.audio_latency, false, 0 /* TODO */, false); SETTING_UINT("audio_resampler_quality", &settings->uints.audio_resampler_quality, true, audio_resampler_quality_level, false); SETTING_UINT("audio_block_frames", &settings->uints.audio_block_frames, true, 0, false); +#ifdef ANDROID + SETTING_UINT("input_block_timeout", &settings->uints.input_block_timeout, true, 1, false); +#endif SETTING_UINT("rewind_granularity", &settings->uints.rewind_granularity, true, rewind_granularity, false); SETTING_UINT("rewind_buffer_size_step", &settings->uints.rewind_buffer_size_step, true, rewind_buffer_size_step, false); SETTING_UINT("autosave_interval", &settings->uints.autosave_interval, true, autosave_interval, false); diff --git a/configuration.h b/configuration.h index 2e72e25072..78774c1b92 100644 --- a/configuration.h +++ b/configuration.h @@ -357,6 +357,8 @@ typedef struct settings unsigned audio_block_frames; unsigned audio_latency; + unsigned input_block_timeout; + unsigned audio_resampler_quality; unsigned input_turbo_period; diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index 51e7fda5d1..e95c8b13bf 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -42,6 +42,8 @@ #include "../../tasks/tasks_internal.h" #include "../../performance_counters.h" +#include "../../configuration.h" + #define MAX_TOUCH 16 #define MAX_NUM_KEYBOARDS 3 @@ -1337,13 +1339,14 @@ static bool android_input_key_pressed(void *data, int key) */ static void android_input_poll(void *data) { + settings_t *settings = config_get_ptr(); int ident; unsigned key = RARCH_PAUSE_TOGGLE; struct android_app *android_app = (struct android_app*)g_android; while ((ident = ALooper_pollAll((android_input_key_pressed(data, key)) - ? -1 : 1, + ? -1 : settings->uints.input_block_timeout, NULL, NULL, NULL)) >= 0) { switch (ident) diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index e2110d7a7f..5ea2874473 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -529,6 +529,8 @@ MSG_HASH(MENU_ENUM_LABEL_INPUT_BIND_TIMEOUT, "input_bind_timeout") MSG_HASH(MENU_ENUM_LABEL_INPUT_BIND_HOLD, "input_bind_hold") +MSG_HASH(MENU_ENUM_LABEL_INPUT_BLOCK_TIMEOUT, + "input_block_timeout") MSG_HASH(MENU_ENUM_LABEL_INPUT_DESCRIPTOR_HIDE_UNBOUND, "input_descriptor_hide_unbound") MSG_HASH(MENU_ENUM_LABEL_INPUT_DESCRIPTOR_LABEL_SHOW, diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 3011feb887..c6a19a232e 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -1077,6 +1077,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_INPUT_BIND_HOLD, "Bind Hold" ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_INPUT_BLOCK_TIMEOUT, + "Input Block Timeout" + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_INPUT_DESCRIPTOR_HIDE_UNBOUND, "Hide Unbound Core Input Descriptors" @@ -5239,6 +5243,10 @@ MSG_HASH( MENU_ENUM_SUBLABEL_RUN_AHEAD_FRAMES, "The number of frames to run ahead. Causes gameplay issues such as jitter if you exceed the number of lag frames internal to the game." ) +MSG_HASH( + MENU_ENUM_SUBLABEL_INPUT_BLOCK_TIMEOUT, + "The number of milliseconds to wait to get a complete input sample, use it if you have issues with simultaneous button presses (Android only)." + ) MSG_HASH( MENU_ENUM_SUBLABEL_RUN_AHEAD_SECONDARY_INSTANCE, "Use a second instance of the RetroArch core to run ahead. Prevents audio problems due to loading state." diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index daaccec4f8..4b7cc6ff04 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -225,6 +225,7 @@ default_sublabel_macro(action_bind_sublabel_run_ahead_enabled, MENU_ default_sublabel_macro(action_bind_sublabel_run_ahead_secondary_instance, MENU_ENUM_SUBLABEL_RUN_AHEAD_SECONDARY_INSTANCE) default_sublabel_macro(action_bind_sublabel_run_ahead_hide_warnings, MENU_ENUM_SUBLABEL_RUN_AHEAD_HIDE_WARNINGS) default_sublabel_macro(action_bind_sublabel_run_ahead_frames, MENU_ENUM_SUBLABEL_RUN_AHEAD_FRAMES) +default_sublabel_macro(action_bind_sublabel_input_block_timeout, MENU_ENUM_SUBLABEL_INPUT_BLOCK_TIMEOUT) default_sublabel_macro(action_bind_sublabel_rewind, MENU_ENUM_SUBLABEL_REWIND_ENABLE) default_sublabel_macro(action_bind_sublabel_cheat_apply_after_toggle, MENU_ENUM_SUBLABEL_CHEAT_APPLY_AFTER_TOGGLE) default_sublabel_macro(action_bind_sublabel_cheat_apply_after_load, MENU_ENUM_SUBLABEL_CHEAT_APPLY_AFTER_LOAD) @@ -1702,6 +1703,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_RUN_AHEAD_FRAMES: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_run_ahead_frames); break; + case MENU_ENUM_LABEL_INPUT_BLOCK_TIMEOUT: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_input_block_timeout); + break; case MENU_ENUM_LABEL_FASTFORWARD_RATIO: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_fastforward_ratio); break; diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index ea826ea13f..3fbf5563a2 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -7090,7 +7090,12 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist MENU_ENUM_LABEL_RUN_AHEAD_HIDE_WARNINGS, PARSE_ONLY_BOOL, false) == 0) count++; - +#ifdef ANDROID + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_INPUT_BLOCK_TIMEOUT, + PARSE_ONLY_UINT, false) == 0) + count++; +#endif if (count == 0) menu_entries_append_enum(info->list, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_SETTINGS_FOUND), diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 486eeb3e66..afc6cf603c 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -7386,6 +7386,21 @@ static bool setting_append_list( SD_FLAG_ADVANCED ); + CONFIG_UINT( + list, list_info, + &settings->uints.input_block_timeout, + MENU_ENUM_LABEL_INPUT_BLOCK_TIMEOUT, + MENU_ENUM_LABEL_VALUE_INPUT_BLOCK_TIMEOUT, + 1, + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler); + (*list)[list_info->index - 1].action_ok = &setting_action_ok_uint; + (*list)[list_info->index - 1].offset_by = 1; + menu_settings_list_current_add_range(list, list_info, 0, 4, 1, true, true); + CONFIG_BOOL( list, list_info, &settings->bools.menu_throttle_framerate, diff --git a/msg_hash.h b/msg_hash.h index 77ccddc701..0f8c83f856 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1478,6 +1478,7 @@ enum msg_hash_enums MENU_LABEL(RUN_AHEAD_SECONDARY_INSTANCE), MENU_LABEL(RUN_AHEAD_HIDE_WARNINGS), MENU_LABEL(RUN_AHEAD_FRAMES), + MENU_LABEL(INPUT_BLOCK_TIMEOUT), MENU_LABEL(TURBO), /* Privacy settings */