(Android) Implement 'Back As Menu Toggle Enable' setting

This commit is contained in:
twinaphex 2015-07-11 03:13:38 +02:00
parent 2ec593f3b4
commit 6f99b4d381
7 changed files with 39 additions and 2 deletions

View File

@ -525,6 +525,8 @@ static unsigned menu_toggle_gamepad_combo = 2;
static unsigned menu_toggle_gamepad_combo = 0;
#endif
static bool back_as_menu_toggle_enable = true;
/* Crop overscanned frames. */
static const bool crop_overscan = true;

View File

@ -585,6 +585,7 @@ static void config_set_defaults(void)
settings->camera.allow = false;
settings->input.autoconfig_descriptor_label_show = true;
settings->input.back_as_menu_toggle_enable = true;
settings->input.input_descriptor_label_show = input_descriptor_label_show;
settings->input.input_descriptor_hide_unbound = input_descriptor_hide_unbound;
settings->input.remap_binds_enable = true;
@ -1392,6 +1393,7 @@ static bool config_load_file(const char *path, bool set_defaults)
if (!strcmp(settings->audio.filter_dir, "default"))
*settings->audio.filter_dir = '\0';
CONFIG_GET_BOOL_BASE(conf, settings, input.back_as_menu_toggle_enable, "back_as_menu_toggle_enable");
CONFIG_GET_BOOL_BASE(conf, settings, input.remap_binds_enable, "input_remap_binds_enable");
CONFIG_GET_FLOAT_BASE(conf, settings, input.axis_threshold, "input_axis_threshold");
CONFIG_GET_BOOL_BASE(conf, settings, input.netplay_client_swap_input, "netplay_client_swap_input");
@ -2358,6 +2360,8 @@ bool config_save_file(const char *path)
config_set_bool(conf, "video_gpu_record", settings->video.gpu_record);
config_set_bool(conf, "input_remap_binds_enable",
settings->input.remap_binds_enable);
config_set_bool(conf, "back_as_menu_toggle_enable",
settings->input.back_as_menu_toggle_enable);
config_set_bool(conf, "netplay_client_swap_input",
settings->input.netplay_client_swap_input);
config_set_bool(conf, "input_descriptor_label_show",

View File

@ -244,6 +244,7 @@ typedef struct settings
char remapping_path[PATH_MAX_LENGTH];
unsigned menu_toggle_gamepad_combo;
bool back_as_menu_toggle_enable;
} input;
struct

View File

@ -565,7 +565,7 @@ static void handle_hotplug(android_input_t *android,
char name_buf[256] = {0};
int vendorId = 0;
int productId = 0;
bool autoconfigured = false;
bool back_mapped = false;
settings_t *settings = config_get_ptr();
if (*port > MAX_PADS)
@ -662,6 +662,7 @@ static void handle_hotplug(android_input_t *android,
if (settings->input.autodetect_enable)
{
unsigned autoconfigured = false;
autoconfig_params_t params = {{0}};
RARCH_LOG("Port %d: %s.\n", *port, name_buf);
@ -672,9 +673,16 @@ static void handle_hotplug(android_input_t *android,
params.pid = productId;
strlcpy(params.driver, android_joypad.ident, sizeof(params.driver));
autoconfigured = input_config_autoconfigure_joypad(&params);
if (autoconfigured)
{
if (settings->input.autoconf_binds[*port][RARCH_MENU_TOGGLE].joykey != 0)
back_mapped = true;
}
}
(void)autoconfigured;
if (!back_mapped && settings->input.back_as_menu_toggle_enable)
settings->input.autoconf_binds[*port][RARCH_MENU_TOGGLE].joykey = AKEYCODE_BACK;
*port = android->pads_connected;
android->pad_states[android->pads_connected].id = id;

View File

@ -26,6 +26,8 @@ static const char *menu_hash_to_str_us_label(uint32_t hash)
{
switch (hash)
{
case MENU_LABEL_INPUT_BACK_AS_MENU_TOGGLE_ENABLE:
return "back_as_menu_toggle_enable";
case MENU_LABEL_INPUT_MENU_TOGGLE_GAMEPAD_COMBO:
return "input_menu_toggle_gamepad_combo";
case MENU_LABEL_INPUT_OVERLAY_HIDE_IN_MENU:
@ -618,6 +620,8 @@ const char *menu_hash_to_str_us(uint32_t hash)
switch (hash)
{
case MENU_LABEL_VALUE_INPUT_BACK_AS_MENU_TOGGLE_ENABLE:
return "Back As Menu Toggle Enable";
case MENU_LABEL_VALUE_INPUT_MENU_TOGGLE_GAMEPAD_COMBO:
return "Menu Toggle Gamepad Combo";
case MENU_LABEL_VALUE_INPUT_OVERLAY_HIDE_IN_MENU:

View File

@ -22,6 +22,9 @@
extern "C" {
#endif
#define MENU_LABEL_VALUE_INPUT_BACK_AS_MENU_TOGGLE_ENABLE 0x1cf1e6a8U
#define MENU_LABEL_INPUT_BACK_AS_MENU_TOGGLE_ENABLE 0x60bacd04U
#define MENU_LABEL_INPUT_MENU_TOGGLE_GAMEPAD_COMBO 0xc5b7aa47U
#define MENU_LABEL_VALUE_INPUT_MENU_TOGGLE_GAMEPAD_COMBO 0x0dedea3bU

View File

@ -4257,6 +4257,21 @@ static bool setting_append_list_input_options(
general_read_handler);
menu_settings_list_current_add_range(list, list_info, 1, MAX_USERS, 1, true, true);
#ifdef ANDROID
CONFIG_BOOL(
settings->input.remap_binds_enable,
menu_hash_to_str(MENU_LABEL_INPUT_BACK_AS_MENU_TOGGLE_ENABLE),
menu_hash_to_str(MENU_LABEL_VALUE_INPUT_BACK_AS_MENU_TOGGLE_ENABLE),
back_as_menu_toggle_enable,
menu_hash_to_str(MENU_VALUE_OFF),
menu_hash_to_str(MENU_VALUE_ON),
group_info.name,
subgroup_info.name,
parent_group,
general_write_handler,
general_read_handler);
#endif
CONFIG_UINT(
settings->input.menu_toggle_gamepad_combo,
menu_hash_to_str(MENU_LABEL_INPUT_MENU_TOGGLE_GAMEPAD_COMBO),