Add Menu Toggle Joypad Combo

This commit is contained in:
twinaphex 2015-07-09 06:27:17 +02:00
parent 4cb5d57ede
commit c09cc19cfe
9 changed files with 108 additions and 1 deletions

View File

@ -519,6 +519,12 @@ static unsigned default_menu_btn_info = RETRO_DEVICE_ID_JOYPAD_SELECT;
static unsigned default_menu_btn_scroll_down = RETRO_DEVICE_ID_JOYPAD_R;
static unsigned default_menu_btn_scroll_up = RETRO_DEVICE_ID_JOYPAD_L;
#if defined(__CELLOS_LV2__)
static unsigned menu_toggle_gamepad_combo = 2;
#else
static unsigned menu_toggle_gamepad_combo = 0;
#endif
/* Crop overscanned frames. */
static const bool crop_overscan = true;

View File

@ -589,6 +589,7 @@ static void config_set_defaults(void)
settings->input.input_descriptor_hide_unbound = input_descriptor_hide_unbound;
settings->input.remap_binds_enable = true;
settings->input.max_users = input_max_users;
settings->input.menu_toggle_gamepad_combo = menu_toggle_gamepad_combo;
rarch_assert(sizeof(settings->input.binds[0]) >= sizeof(retro_keybinds_1));
rarch_assert(sizeof(settings->input.binds[1]) >= sizeof(retro_keybinds_rest));
@ -1394,6 +1395,7 @@ static bool config_load_file(const char *path, bool set_defaults)
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");
CONFIG_GET_INT_BASE(conf, settings, input.max_users, "input_max_users");
CONFIG_GET_INT_BASE(conf, settings, input.menu_toggle_gamepad_combo, "input_menu_toggle_gamepad_combo");
CONFIG_GET_BOOL_BASE(conf, settings, input.input_descriptor_label_show, "input_descriptor_label_show");
CONFIG_GET_BOOL_BASE(conf, settings, input.input_descriptor_hide_unbound, "input_descriptor_hide_unbound");
CONFIG_GET_BOOL_BASE(conf, settings, input.autoconfig_descriptor_label_show, "autoconfig_descriptor_label_show");
@ -2348,6 +2350,7 @@ bool config_save_file(const char *path)
RARCH_LOG("Saving config at path: \"%s\"\n", path);
config_set_int(conf, "input_max_users", settings->input.max_users);
config_set_int(conf, "input_menu_toggle_gamepad_combo", settings->input.menu_toggle_gamepad_combo);
config_set_float(conf, "input_axis_threshold",
settings->input.axis_threshold);
config_set_bool(conf, "ui_companion_start_on_boot", settings->ui.companion_start_on_boot);

View File

@ -242,6 +242,8 @@ typedef struct settings
bool input_descriptor_hide_unbound;
char remapping_path[PATH_MAX_LENGTH];
unsigned menu_toggle_gamepad_combo;
} input;
struct

View File

@ -528,6 +528,36 @@ static void menu_action_setting_disp_set_label_state(
strlcat(s, " (Auto)", len);
}
static void menu_action_setting_disp_set_label_menu_toggle_gamepad_combo(
file_list_t* list,
unsigned *w, unsigned type, unsigned i,
const char *label,
char *s, size_t len,
const char *entry_label,
const char *path,
char *s2, size_t len2)
{
settings_t *settings = config_get_ptr();
if (!settings)
return;
strlcpy(s2, path, len2);
*w = 16;
switch (settings->input.menu_toggle_gamepad_combo)
{
case 0:
snprintf(s, len, "%s", "None");
break;
case 1:
snprintf(s, len, "%s", "Down + L1 + R1 + Y");
break;
case 2:
snprintf(s, len, "%s", "L3 + R3");
break;
}
}
static void menu_action_setting_disp_set_label_menu_disk_index(
file_list_t* list,
@ -907,6 +937,10 @@ static int menu_cbs_init_bind_get_string_representation_compare_label(
cbs->action_get_value =
menu_action_setting_disp_set_label_state;
break;
case MENU_LABEL_INPUT_MENU_TOGGLE_GAMEPAD_COMBO:
cbs->action_get_value =
menu_action_setting_disp_set_label_menu_toggle_gamepad_combo;
break;
case MENU_LABEL_CHEAT_NUM_PASSES:
cbs->action_get_value =
menu_action_setting_disp_set_label_cheat_num_passes;

View File

@ -26,6 +26,8 @@ static const char *menu_hash_to_str_us_label(uint32_t hash)
{
switch (hash)
{
case MENU_LABEL_INPUT_MENU_TOGGLE_GAMEPAD_COMBO:
return "input_menu_toggle_gamepad_combo";
case MENU_LABEL_INPUT_OVERLAY_HIDE_IN_MENU:
return "overlay_hide_in_menu";
case MENU_LABEL_NO_PLAYLIST_ENTRIES_AVAILABLE:
@ -616,6 +618,8 @@ const char *menu_hash_to_str_us(uint32_t hash)
switch (hash)
{
case MENU_LABEL_VALUE_INPUT_MENU_TOGGLE_GAMEPAD_COMBO:
return "Menu Toggle Gamepad Combo";
case MENU_LABEL_VALUE_INPUT_OVERLAY_HIDE_IN_MENU:
return "Hide Overlay In Menu";
case MENU_VALUE_LANG_POLISH:

View File

@ -22,6 +22,9 @@
extern "C" {
#endif
#define MENU_LABEL_INPUT_MENU_TOGGLE_GAMEPAD_COMBO 0xc5b7aa47U
#define MENU_LABEL_VALUE_INPUT_MENU_TOGGLE_GAMEPAD_COMBO 0x0dedea3bU
#define MENU_LABEL_INPUT_OVERLAY_HIDE_IN_MENU 0xf09e230aU
#define MENU_LABEL_VALUE_INPUT_OVERLAY_HIDE_IN_MENU 0x39b5bd0dU

View File

@ -4257,6 +4257,18 @@ 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);
CONFIG_UINT(
settings->input.menu_toggle_gamepad_combo,
menu_hash_to_str(MENU_LABEL_INPUT_MENU_TOGGLE_GAMEPAD_COMBO),
menu_hash_to_str(MENU_LABEL_VALUE_INPUT_MENU_TOGGLE_GAMEPAD_COMBO),
menu_toggle_gamepad_combo,
group_info.name,
subgroup_info.name,
parent_group,
general_write_handler,
general_read_handler);
menu_settings_list_current_add_range(list, list_info, 0, 2, 1, true, true);
CONFIG_BOOL(
settings->input.remap_binds_enable,
menu_hash_to_str(MENU_LABEL_INPUT_REMAP_BINDS_ENABLE),

View File

@ -531,6 +531,7 @@
# On Unix-likes, SIGINT/SIGTERM allows a clean deinitialization.
# input_exit_emulator = escape
# Applies next and previous shader in directory.
# input_shader_next = m
# input_shader_prev = n
@ -595,6 +596,10 @@
# Toggles menu.
# input_menu_toggle = f1
# RetroPad button combination to toggle menu
# 0 = none, 1 = L + R + Y + D-Pad Down, 2 = L3 + R3
# input_menu_toggle_gamepad_combo = 0
# Toggles mouse grab. When mouse is grabbed, RetroArch hides the mouse,
# and keeps the mouse pointer inside the window to allow relative mouse input
# to work better.

View File

@ -986,6 +986,42 @@ bool rarch_main_is_idle(void)
return runloop->is_idle;
}
static bool rarch_main_cmd_get_state_menu_toggle_button_combo(
retro_input_t input, retro_input_t old_input,
retro_input_t trigger_input)
{
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
if (!settings)
return false;
switch (settings->input.menu_toggle_gamepad_combo)
{
case 0:
return false;
case 1:
if (!BIT64_GET(input, RETRO_DEVICE_ID_JOYPAD_DOWN))
return false;
if (!BIT64_GET(input, RETRO_DEVICE_ID_JOYPAD_Y))
return false;
if (!BIT64_GET(input, RETRO_DEVICE_ID_JOYPAD_L))
return false;
if (!BIT64_GET(input, RETRO_DEVICE_ID_JOYPAD_R))
return false;
break;
case 2:
if (!BIT64_GET(input, RETRO_DEVICE_ID_JOYPAD_L3))
return false;
if (!BIT64_GET(input, RETRO_DEVICE_ID_JOYPAD_R3))
return false;
break;
}
driver->flushing_input = true;
return true;
}
static void rarch_main_cmd_get_state(event_cmd_state_t *cmd,
retro_input_t input, retro_input_t old_input,
retro_input_t trigger_input)
@ -997,7 +1033,9 @@ static void rarch_main_cmd_get_state(event_cmd_state_t *cmd,
cmd->overlay_next_pressed = BIT64_GET(trigger_input, RARCH_OVERLAY_NEXT);
cmd->grab_mouse_pressed = BIT64_GET(trigger_input, RARCH_GRAB_MOUSE_TOGGLE);
#ifdef HAVE_MENU
cmd->menu_pressed = BIT64_GET(trigger_input, RARCH_MENU_TOGGLE);
cmd->menu_pressed = BIT64_GET(trigger_input, RARCH_MENU_TOGGLE) ||
rarch_main_cmd_get_state_menu_toggle_button_combo(input,
old_input, trigger_input);
#endif
cmd->quit_key_pressed = BIT64_GET(input, RARCH_QUIT_KEY);
cmd->screenshot_pressed = BIT64_GET(trigger_input, RARCH_SCREENSHOT);