diff --git a/config.def.h b/config.def.h index 2310ac4d11..bada04590f 100644 --- a/config.def.h +++ b/config.def.h @@ -162,6 +162,9 @@ static const bool pause_nonactive = true; // Saves non-volatile SRAM at a regular interval. It is measured in seconds. A value of 0 disables autosave. static const unsigned autosave_interval = 0; +// When being client over netplay, use keybinds for player 1 rather than player 2. +static const bool netplay_client_swap_input = false; + //////////////////// // Keybinds, Joypad diff --git a/general.h b/general.h index 8ced5222f2..301f924897 100644 --- a/general.h +++ b/general.h @@ -89,6 +89,7 @@ struct settings struct snes_keybind binds[MAX_PLAYERS][MAX_BINDS]; float axis_threshold; unsigned joypad_map[MAX_PLAYERS]; + bool netplay_client_swap_input; } input; char libsnes[256]; diff --git a/netplay.c b/netplay.c index 9ae554d27d..ecc5d70d69 100644 --- a/netplay.c +++ b/netplay.c @@ -455,7 +455,7 @@ static bool get_self_input_state(netplay_t *handle) snes_input_state_t cb = handle->cbs.state_cb; for (int i = 0; i <= 11; i++) { - int16_t tmp = cb(!handle->port, SNES_DEVICE_JOYPAD, 0, i); + int16_t tmp = cb(g_settings.input.netplay_client_swap_input ? 0 : !handle->port, SNES_DEVICE_JOYPAD, 0, i); state |= tmp ? 1 << i : 0; } } diff --git a/settings.c b/settings.c index 37128bb3a6..a4ab99f190 100644 --- a/settings.c +++ b/settings.c @@ -145,8 +145,10 @@ static void set_defaults(void) memcpy(g_settings.input.binds[4], snes_keybinds_5, sizeof(snes_keybinds_5)); g_settings.input.axis_threshold = AXIS_THRESHOLD; + g_settings.input.netplay_client_swap_input = netplay_client_swap_input; for (int i = 0; i < MAX_PLAYERS; i++) g_settings.input.joypad_map[i] = i; + } #ifdef HAVE_CONFIGFILE @@ -291,6 +293,7 @@ static void parse_config_file(void) #endif CONFIG_GET_DOUBLE(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"); diff --git a/ssnes.cfg b/ssnes.cfg index b0f80f96bc..56feb2c220 100644 --- a/ssnes.cfg +++ b/ssnes.cfg @@ -219,3 +219,5 @@ # The interval is measured in seconds. A value of 0 disables autosave. # autosave_interval = +# When being client over netplay, use keybinds for player 1. +# netplay_client_swap_input = false