Add setting 'Max Users'

This commit is contained in:
twinaphex 2015-01-05 01:45:57 +01:00
parent 9bc4ffb69b
commit 45cdb15de4
6 changed files with 32 additions and 13 deletions

View File

@ -362,6 +362,8 @@ struct settings
char keyboard_layout[64];
struct retro_keybind binds[MAX_PLAYERS][RARCH_BIND_LIST_END];
unsigned max_users;
/* Set by autoconfiguration in joypad_autoconfig_dir.
* Does not override main binds. */
struct retro_keybind autoconf_binds[MAX_PLAYERS][RARCH_BIND_LIST_END];

View File

@ -169,7 +169,7 @@ void menu_poll_bind_state(struct menu_bind_state *state)
if (joypad->poll)
joypad->poll();
for (i = 0; i < MAX_PLAYERS; i++)
for (i = 0; i < g_settings.input.max_users; i++)
{
for (b = 0; b < MENU_MAX_BUTTONS; b++)
state->state[i].buttons[b] = input_joypad_button_raw(joypad, i, b);
@ -206,7 +206,7 @@ void menu_poll_bind_get_rested_axes(struct menu_bind_state *state)
return;
}
for (i = 0; i < MAX_PLAYERS; i++)
for (i = 0; i < g_settings.input.max_users; i++)
for (a = 0; a < MENU_MAX_AXES; a++)
state->axis_state[i].rested_axes[a] =
input_joypad_axis_raw(joypad, i, a);
@ -290,7 +290,7 @@ bool menu_poll_find_trigger(struct menu_bind_state *state,
if (!state || !new_state)
return false;
for (i = 0; i < MAX_PLAYERS; i++)
for (i = 0; i < g_settings.input.max_users; i++)
{
if (menu_poll_find_trigger_pad(state, new_state, i))
{

View File

@ -308,6 +308,9 @@
# Joypad driver. (Valid: linuxraw, sdl, dinput)
# input_joypad_driver =
# Maximum amount of users supported by RetroArch.
# input_max_users = 16
# Keyboard layout for input driver if applicable (udev/evdev for now).
# Syntax is either just layout (e.g. "no"), or a layout and variant separated with colon ("no:nodeadkeys").
# input_keyboard_layout =

View File

@ -599,7 +599,7 @@ static inline retro_input_t input_keys_pressed(void)
(g_settings.input.analog_dpad_mode[0] == ANALOG_DPAD_NONE) ?
ANALOG_DPAD_LSTICK : g_settings.input.analog_dpad_mode[0]);
for (i = 0; i < MAX_PLAYERS; i++)
for (i = 0; i < g_settings.input.max_users; i++)
{
input_push_analog_dpad(g_settings.input.autoconf_binds[i],
g_settings.input.analog_dpad_mode[i]);
@ -635,7 +635,7 @@ static inline retro_input_t input_keys_pressed(void)
}
input_pop_analog_dpad((struct retro_keybind*)binds[0]);
for (i = 0; i < MAX_PLAYERS; i++)
for (i = 0; i < g_settings.input.max_users; i++)
input_pop_analog_dpad(g_settings.input.autoconf_binds[i]);
return ret;
@ -730,7 +730,7 @@ int rarch_main_iterate(void)
driver_camera_poll();
/* Update binds for analog dpad modes. */
for (i = 0; i < MAX_PLAYERS; i++)
for (i = 0; i < g_settings.input.max_users; i++)
{
if (!g_settings.input.analog_dpad_mode[i])
continue;
@ -748,7 +748,7 @@ int rarch_main_iterate(void)
/* Run libretro for one frame. */
pretro_run();
for (i = 0; i < MAX_PLAYERS; i++)
for (i = 0; i < g_settings.input.max_users; i++)
{
if (!g_settings.input.analog_dpad_mode[i])
continue;

View File

@ -445,6 +445,7 @@ static void config_set_defaults(void)
g_settings.input.autoconfig_descriptor_label_show = true;
g_settings.input.input_descriptor_label_show = input_descriptor_label_show;
g_settings.input.input_descriptor_hide_unbound = input_descriptor_hide_unbound;
g_settings.input.max_users = MAX_PLAYERS;
rarch_assert(sizeof(g_settings.input.binds[0]) >= sizeof(retro_keybinds_1));
rarch_assert(sizeof(g_settings.input.binds[1]) >= sizeof(retro_keybinds_rest));
@ -1005,6 +1006,7 @@ static bool config_load_file(const char *path, bool set_defaults)
CONFIG_GET_FLOAT(input.axis_threshold, "input_axis_threshold");
CONFIG_GET_BOOL(input.netplay_client_swap_input,
"netplay_client_swap_input");
CONFIG_GET_INT(input.max_users, "input_max_users");
CONFIG_GET_BOOL(input.input_descriptor_label_show,
"input_descriptor_label_show");
CONFIG_GET_BOOL(input.input_descriptor_hide_unbound,
@ -1571,6 +1573,7 @@ bool config_save_file(const char *path)
RARCH_LOG("Saving config at path: \"%s\"\n", path);
config_set_int(conf, "input_max_users", g_settings.input.max_users);
config_set_float(conf, "input_axis_threshold",
g_settings.input.axis_threshold);
config_set_bool(conf, "netplay_client_swap_input",

View File

@ -589,13 +589,13 @@ static int setting_data_action_toggle_bind_device(void *data, unsigned action)
switch (action)
{
case MENU_ACTION_LEFT:
if ((*p) >= MAX_PLAYERS)
*p = MAX_PLAYERS - 1;
if ((*p) >= g_settings.input.max_users)
*p = g_settings.input.max_users - 1;
else if ((*p) > 0)
(*p)--;
break;
case MENU_ACTION_RIGHT:
if (*p < MAX_PLAYERS)
if (*p < g_settings.input.max_users)
(*p)++;
break;
}
@ -2282,7 +2282,7 @@ static void get_string_representation_bind_device(void * data, char *type_str,
map = g_settings.input.joypad_map[setting->index_offset];
if (map < MAX_PLAYERS)
if (map < g_settings.input.max_users)
{
const char *device_name =
g_settings.input.device_names[map];
@ -4285,6 +4285,17 @@ static bool setting_data_append_list_input_options(
START_GROUP(group_info, "Input Options");
START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info);
CONFIG_UINT(
g_settings.input.max_users,
"input_max_users",
"Max Users",
MAX_PLAYERS,
group_info.name,
subgroup_info.name,
general_write_handler,
general_read_handler);
settings_list_current_add_range(list, list_info, 1, MAX_PLAYERS, 1, true, true);
CONFIG_BOOL(
g_settings.input.autodetect_enable,
"input_autodetect_enable",
@ -4354,7 +4365,7 @@ static bool setting_data_append_list_input_options(
general_write_handler,
general_read_handler);
for (user = 0; user < MAX_PLAYERS; user ++)
for (user = 0; user < g_settings.input.max_users; user ++)
{
/* These constants match the string lengths.
* Keep them up to date or you'll get some really obvious bugs.
@ -4520,7 +4531,7 @@ static bool setting_data_append_list_input_options(
}
END_SUB_GROUP(list, list_info);
for (user = 0; user < MAX_PLAYERS; user++)
for (user = 0; user < g_settings.input.max_users; user++)
{
/* This constants matches the string length.
* Keep it up to date or you'll get some really obvious bugs.