diff --git a/general.h b/general.h index 2c4c68eebc..4a7e28af40 100644 --- a/general.h +++ b/general.h @@ -67,7 +67,7 @@ #include "360/msvc_compat.h" #endif -#define MAX_PLAYERS 7 +#define MAX_PLAYERS 8 enum ssnes_shader_type { diff --git a/gfx/ext_gfx.c b/gfx/ext_gfx.c index 996c01d3cf..f97267e4d7 100644 --- a/gfx/ext_gfx.c +++ b/gfx/ext_gfx.c @@ -190,6 +190,7 @@ static bool video_ext_frame(void *data, const void *frame, unsigned width, unsig static void *setup_input(ext_t *ext, const ssnes_input_driver_t *driver) { + // TODO: Change external API to allow more players. Do be done in next major ABI break. int joypad_index[5]; for (unsigned i = 0; i < 5; i++) joypad_index[i] = g_settings.input.joypad_map[i] < 0 ? -1 : g_settings.input.joypad_map[i]; diff --git a/settings.c b/settings.c index 18d34ac082..8dc22daab1 100644 --- a/settings.c +++ b/settings.c @@ -212,11 +212,11 @@ void config_set_defaults(void) ssnes_assert(sizeof(g_settings.input.binds[0]) >= sizeof(snes_keybinds_1)); ssnes_assert(sizeof(g_settings.input.binds[1]) >= sizeof(snes_keybinds_rest)); memcpy(g_settings.input.binds[0], snes_keybinds_1, sizeof(snes_keybinds_1)); - for (unsigned i = 1; i < 5; i++) + for (unsigned i = 1; i < MAX_PLAYERS; i++) memcpy(g_settings.input.binds[i], snes_keybinds_rest, sizeof(snes_keybinds_rest)); // Verify that binds are in proper order. - for (unsigned i = 0; i < 5; i++) + for (unsigned i = 0; i < MAX_PLAYERS; i++) for (unsigned j = 0; j < SSNES_BIND_LIST_END; j++) if (g_settings.input.binds[i][j].valid) ssnes_assert(j == g_settings.input.binds[i][j].id); @@ -418,11 +418,13 @@ bool config_load_file(const char *path) 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.joypad_map[0], "input_player1_joypad_index"); - CONFIG_GET_INT(input.joypad_map[1], "input_player2_joypad_index"); - CONFIG_GET_INT(input.joypad_map[2], "input_player3_joypad_index"); - CONFIG_GET_INT(input.joypad_map[3], "input_player4_joypad_index"); - CONFIG_GET_INT(input.joypad_map[4], "input_player5_joypad_index"); + + for (unsigned i = 0; i < MAX_PLAYERS; i++) + { + char buf[64]; + snprintf(buf, sizeof(buf), "input_player%u_joypad_index", i); + CONFIG_GET_INT(input.joypad_map[i], buf); + } // Audio settings. CONFIG_GET_BOOL(audio.enable, "audio_enable"); @@ -563,6 +565,9 @@ static const struct bind_map bind_maps[MAX_PLAYERS][SSNES_BIND_LIST_END] = { DECL_PLAYER(3), DECL_PLAYER(4), DECL_PLAYER(5), + DECL_PLAYER(6), + DECL_PLAYER(7), + DECL_PLAYER(8), }; struct key_map diff --git a/ssnes.cfg b/ssnes.cfg index 576e66e0e5..cb7a6b6490 100644 --- a/ssnes.cfg +++ b/ssnes.cfg @@ -168,6 +168,10 @@ # input_player3_joypad_index = 2 # input_player4_joypad_index = 3 # input_player5_joypad_index = 4 +# Player 6-8 is not directly expected by libsnes API, but we'll futureproof it. +# input_player6_joypad_index = 5 +# input_player7_joypad_index = 6 +# input_player8_joypad_index = 7 # Joypad buttons. # Figure these out by using SSNES-Phoenix or ssnes-joyconfig. @@ -194,7 +198,7 @@ # input_player1_up_axis = # input_player1_down_axis = -# This goes all the way to player 5 (*_player2_*, *_player3_*, etc), but omitted for clarity. +# This goes all the way to player 8 (*_player2_*, *_player3_*, etc), but omitted for clarity. # Toggles fullscreen. # input_toggle_fullscreen = f