mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-03 07:22:15 +00:00
(Menu) Add Bind Mode option
This commit is contained in:
parent
e3f89a77ac
commit
380041f974
@ -123,8 +123,6 @@ typedef struct
|
||||
bool display;
|
||||
} keyboard;
|
||||
|
||||
bool bind_mode_keyboard;
|
||||
|
||||
rarch_setting_t *list_mainmenu;
|
||||
rarch_setting_t *list_settings;
|
||||
} menu_handle_t;
|
||||
|
@ -1089,23 +1089,6 @@ static int disk_options_disk_idx_toggle(unsigned type, const char *label,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int custom_bind_mode_toggle(unsigned type, const char *label,
|
||||
unsigned action)
|
||||
{
|
||||
if (!driver.menu)
|
||||
return -1;
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case MENU_ACTION_LEFT:
|
||||
case MENU_ACTION_RIGHT:
|
||||
driver.menu->bind_mode_keyboard = !driver.menu->bind_mode_keyboard;
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int deferred_push_core_list_deferred(void *data, void *userdata,
|
||||
const char *path, const char *label, unsigned type)
|
||||
{
|
||||
@ -1420,28 +1403,6 @@ static int deferred_push_category(void *data, void *userdata,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int deferred_push_input_options(void *data, void *userdata,
|
||||
const char *path, const char *label, unsigned type)
|
||||
{
|
||||
file_list_t *list = (file_list_t*)data;
|
||||
file_list_t *menu_list = (file_list_t*)userdata;
|
||||
|
||||
if (!list || !menu_list)
|
||||
return -1;
|
||||
|
||||
settings_list_free(driver.menu->list_settings);
|
||||
driver.menu->list_settings = (rarch_setting_t *)setting_data_new(SL_FLAG_ALL_SETTINGS);
|
||||
|
||||
menu_list_clear(list);
|
||||
menu_list_push(list, "Bind Mode", "",
|
||||
MENU_SETTINGS_CUSTOM_BIND_MODE, 0);
|
||||
|
||||
if (driver.menu_ctx && driver.menu_ctx->populate_entries)
|
||||
driver.menu_ctx->populate_entries(driver.menu, path, label, type);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int deferred_push_shader_options(void *data, void *userdata,
|
||||
const char *path, const char *label, unsigned type)
|
||||
{
|
||||
@ -2022,9 +1983,6 @@ static void menu_entries_cbs_init_bind_toggle(menu_file_list_cbs_t *cbs,
|
||||
case MENU_SETTINGS_CORE_DISK_OPTIONS_DISK_INDEX:
|
||||
cbs->action_toggle = disk_options_disk_idx_toggle;
|
||||
break;
|
||||
case MENU_SETTINGS_CUSTOM_BIND_MODE:
|
||||
cbs->action_toggle = custom_bind_mode_toggle;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
@ -2047,8 +2005,6 @@ static void menu_entries_cbs_init_bind_deferred_push(menu_file_list_cbs_t *cbs,
|
||||
cbs->action_deferred_push = deferred_push_category;
|
||||
else if (!strcmp(label, "deferred_core_list"))
|
||||
cbs->action_deferred_push = deferred_push_core_list_deferred;
|
||||
else if (!strcmp(label, "Input Options"))
|
||||
cbs->action_deferred_push = deferred_push_input_options;
|
||||
else if (!strcmp(label, "Shader Options"))
|
||||
cbs->action_deferred_push = deferred_push_shader_options;
|
||||
else if (!strcmp(label, "core_information"))
|
||||
|
@ -611,6 +611,7 @@ struct global
|
||||
struct
|
||||
{
|
||||
struct retro_system_info info;
|
||||
bool bind_mode_keyboard;
|
||||
} menu;
|
||||
#endif
|
||||
|
||||
|
@ -846,12 +846,12 @@ static int setting_data_action_ok_bind_all(void *data, unsigned action)
|
||||
driver.menu->menu_list,
|
||||
"",
|
||||
"",
|
||||
driver.menu->bind_mode_keyboard ?
|
||||
g_extern.menu.bind_mode_keyboard ?
|
||||
MENU_SETTINGS_CUSTOM_BIND_KEYBOARD :
|
||||
MENU_SETTINGS_CUSTOM_BIND,
|
||||
driver.menu->selection_ptr);
|
||||
|
||||
if (driver.menu->bind_mode_keyboard)
|
||||
if (g_extern.menu.bind_mode_keyboard)
|
||||
{
|
||||
driver.menu->binds.timeout_end =
|
||||
rarch_get_time_usec() +
|
||||
@ -891,7 +891,7 @@ static int setting_data_action_ok_bind_defaults(void *data, unsigned action)
|
||||
for (i = MENU_SETTINGS_BIND_BEGIN;
|
||||
i <= MENU_SETTINGS_BIND_LAST; i++, target++)
|
||||
{
|
||||
if (driver.menu->bind_mode_keyboard)
|
||||
if (g_extern.menu.bind_mode_keyboard)
|
||||
target->key = def_binds[i - MENU_SETTINGS_BIND_BEGIN].key;
|
||||
else
|
||||
{
|
||||
@ -1395,7 +1395,7 @@ static int setting_data_bind_action_start(void *data)
|
||||
if (!keybind)
|
||||
return -1;
|
||||
|
||||
if (!driver.menu->bind_mode_keyboard)
|
||||
if (!g_extern.menu.bind_mode_keyboard)
|
||||
{
|
||||
keybind->joykey = NO_BTN;
|
||||
keybind->joyaxis = AXIS_NONE;
|
||||
@ -1437,11 +1437,11 @@ static int setting_data_bind_action_ok(void *data, unsigned action)
|
||||
driver.menu->menu_list,
|
||||
"",
|
||||
"",
|
||||
driver.menu->bind_mode_keyboard ?
|
||||
g_extern.menu.bind_mode_keyboard ?
|
||||
MENU_SETTINGS_CUSTOM_BIND_KEYBOARD : MENU_SETTINGS_CUSTOM_BIND,
|
||||
driver.menu->selection_ptr);
|
||||
|
||||
if (driver.menu->bind_mode_keyboard)
|
||||
if (g_extern.menu.bind_mode_keyboard)
|
||||
{
|
||||
driver.menu->binds.timeout_end = rarch_get_time_usec() +
|
||||
MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000;
|
||||
@ -2454,10 +2454,6 @@ static int get_fallback_label(char *type_str,
|
||||
case MENU_SETTINGS_CUSTOM_BIND_DEFAULT_ALL:
|
||||
strlcpy(type_str, "...", type_str_size);
|
||||
break;
|
||||
case MENU_SETTINGS_CUSTOM_BIND_MODE:
|
||||
strlcpy(type_str, driver.menu->bind_mode_keyboard ?
|
||||
"RetroKeyboard" : "RetroPad", type_str_size);
|
||||
break;
|
||||
case MENU_SETTINGS_CORE_DISK_OPTIONS_DISK_INDEX:
|
||||
{
|
||||
const struct retro_disk_control_callback *control =
|
||||
@ -4448,6 +4444,18 @@ static bool setting_data_append_list_input_options(
|
||||
group_info.name,
|
||||
subgroup_info);
|
||||
|
||||
CONFIG_BOOL(
|
||||
g_extern.menu.bind_mode_keyboard,
|
||||
"input_bind_mode",
|
||||
"Bind Mode",
|
||||
false,
|
||||
"RetroPad",
|
||||
"RetroKeyboard",
|
||||
group_info.name,
|
||||
subgroup_info.name,
|
||||
general_write_handler,
|
||||
general_read_handler);
|
||||
|
||||
/* TODO: input_libretro_device_p%u */
|
||||
for (player = 0; player < MAX_PLAYERS; player ++)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user