mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 06:44:27 +00:00
Merge pull request #4326 from GregorR/netplay-address-prompt
Server prompt when connecting to netplay host
This commit is contained in:
commit
b238f32cb7
42
command.c
42
command.c
@ -2395,48 +2395,58 @@ bool command_event(enum event_command cmd, void *data)
|
|||||||
command_event(CMD_EVENT_BSV_MOVIE_DEINIT, NULL);
|
command_event(CMD_EVENT_BSV_MOVIE_DEINIT, NULL);
|
||||||
bsv_movie_ctl(BSV_MOVIE_CTL_INIT, NULL);
|
bsv_movie_ctl(BSV_MOVIE_CTL_INIT, NULL);
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_NETPLAY_DEINIT:
|
|
||||||
#ifdef HAVE_NETWORKING
|
#ifdef HAVE_NETWORKING
|
||||||
|
case CMD_EVENT_NETPLAY_DEINIT:
|
||||||
deinit_netplay();
|
deinit_netplay();
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_NETWORK_DEINIT:
|
case CMD_EVENT_NETWORK_DEINIT:
|
||||||
#ifdef HAVE_NETWORKING
|
|
||||||
network_deinit();
|
network_deinit();
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_NETWORK_INIT:
|
case CMD_EVENT_NETWORK_INIT:
|
||||||
#ifdef HAVE_NETWORKING
|
|
||||||
network_init();
|
network_init();
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_NETPLAY_INIT:
|
case CMD_EVENT_NETPLAY_INIT:
|
||||||
{
|
{
|
||||||
#ifdef HAVE_NETWORKING
|
char *hostname = (char *) data;
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
#endif
|
|
||||||
command_event(CMD_EVENT_NETPLAY_DEINIT, NULL);
|
command_event(CMD_EVENT_NETPLAY_DEINIT, NULL);
|
||||||
#ifdef HAVE_NETWORKING
|
|
||||||
if (!init_netplay(
|
if (!init_netplay(
|
||||||
data, settings->netplay.server,
|
NULL, hostname ? hostname : settings->netplay.server,
|
||||||
settings->netplay.port))
|
settings->netplay.port))
|
||||||
{
|
{
|
||||||
command_event(CMD_EVENT_NETPLAY_DEINIT, NULL);
|
command_event(CMD_EVENT_NETPLAY_DEINIT, NULL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
}
|
||||||
|
break;
|
||||||
|
case CMD_EVENT_NETPLAY_INIT_DIRECT:
|
||||||
|
{
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
|
command_event(CMD_EVENT_NETPLAY_DEINIT, NULL);
|
||||||
|
if (!init_netplay(
|
||||||
|
data, NULL, settings->netplay.port))
|
||||||
|
{
|
||||||
|
command_event(CMD_EVENT_NETPLAY_DEINIT, NULL);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_NETPLAY_FLIP_PLAYERS:
|
case CMD_EVENT_NETPLAY_FLIP_PLAYERS:
|
||||||
#ifdef HAVE_NETWORKING
|
|
||||||
netplay_driver_ctl(RARCH_NETPLAY_CTL_FLIP_PLAYERS, NULL);
|
netplay_driver_ctl(RARCH_NETPLAY_CTL_FLIP_PLAYERS, NULL);
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_NETPLAY_GAME_WATCH:
|
case CMD_EVENT_NETPLAY_GAME_WATCH:
|
||||||
#ifdef HAVE_NETWORKING
|
|
||||||
netplay_driver_ctl(RARCH_NETPLAY_CTL_GAME_WATCH, NULL);
|
netplay_driver_ctl(RARCH_NETPLAY_CTL_GAME_WATCH, NULL);
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
|
#else
|
||||||
|
case CMD_EVENT_NETPLAY_DEINIT:
|
||||||
|
case CMD_EVENT_NETWORK_DEINIT:
|
||||||
|
case CMD_EVENT_NETWORK_INIT:
|
||||||
|
case CMD_EVENT_NETPLAY_INIT:
|
||||||
|
case CMD_EVENT_NETPLAY_INIT_DIRECT:
|
||||||
|
case CMD_EVENT_NETPLAY_FLIP_PLAYERS:
|
||||||
|
case CMD_EVENT_NETPLAY_GAME_WATCH:
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
case CMD_EVENT_FULLSCREEN_TOGGLE:
|
case CMD_EVENT_FULLSCREEN_TOGGLE:
|
||||||
{
|
{
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
|
@ -167,8 +167,10 @@ enum event_command
|
|||||||
CMD_EVENT_NETWORK_DEINIT,
|
CMD_EVENT_NETWORK_DEINIT,
|
||||||
/* Initializes network system. */
|
/* Initializes network system. */
|
||||||
CMD_EVENT_NETWORK_INIT,
|
CMD_EVENT_NETWORK_INIT,
|
||||||
/* Initializes netplay system. */
|
/* Initializes netplay system with a string or no host specified. */
|
||||||
CMD_EVENT_NETPLAY_INIT,
|
CMD_EVENT_NETPLAY_INIT,
|
||||||
|
/* Initializes netplay system with a direct host specified. */
|
||||||
|
CMD_EVENT_NETPLAY_INIT_DIRECT,
|
||||||
/* Deinitializes netplay system. */
|
/* Deinitializes netplay system. */
|
||||||
CMD_EVENT_NETPLAY_DEINIT,
|
CMD_EVENT_NETPLAY_DEINIT,
|
||||||
/* Flip netplay players. */
|
/* Flip netplay players. */
|
||||||
|
@ -3132,7 +3132,7 @@ static int action_ok_netplay_lan_scan(const char *path,
|
|||||||
netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_CLIENT, NULL);
|
netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_CLIENT, NULL);
|
||||||
|
|
||||||
/* Enable Netplay */
|
/* Enable Netplay */
|
||||||
if (!command_event(CMD_EVENT_NETPLAY_INIT, (void *) host))
|
if (!command_event(CMD_EVENT_NETPLAY_INIT_DIRECT, (void *) host))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return generic_action_ok_command(CMD_EVENT_RESUME);
|
return generic_action_ok_command(CMD_EVENT_RESUME);
|
||||||
@ -3597,6 +3597,19 @@ static int action_ok_netplay_enable_host(const char *path,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void action_ok_netplay_enable_client_hostname_cb(
|
||||||
|
void *ignore, const char *hostname)
|
||||||
|
{
|
||||||
|
char tmp_hostname[512];
|
||||||
|
strlcpy(tmp_hostname, hostname, sizeof(tmp_hostname));
|
||||||
|
if (hostname[0])
|
||||||
|
command_event(CMD_EVENT_NETPLAY_INIT, (void *) tmp_hostname);
|
||||||
|
menu_input_dialog_end();
|
||||||
|
|
||||||
|
/* Force the menu to close */
|
||||||
|
rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static int action_ok_netplay_enable_client(const char *path,
|
static int action_ok_netplay_enable_client(const char *path,
|
||||||
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
||||||
{
|
{
|
||||||
@ -3607,15 +3620,6 @@ static int action_ok_netplay_enable_client(const char *path,
|
|||||||
command_event(CMD_EVENT_NETPLAY_DEINIT, NULL);
|
command_event(CMD_EVENT_NETPLAY_DEINIT, NULL);
|
||||||
netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_CLIENT, NULL);
|
netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_CLIENT, NULL);
|
||||||
|
|
||||||
/* We can't do anything without a host specified */
|
|
||||||
if (!settings->netplay.server[0])
|
|
||||||
{
|
|
||||||
runloop_msg_queue_push(
|
|
||||||
"Please specify the Netplay server's IP address or hostname.",
|
|
||||||
1, 480, true);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If we haven't yet started, this will load on its own */
|
/* If we haven't yet started, this will load on its own */
|
||||||
if (!content_is_inited())
|
if (!content_is_inited())
|
||||||
{
|
{
|
||||||
@ -3625,6 +3629,19 @@ static int action_ok_netplay_enable_client(const char *path,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If no host was specified in the config, ask for one */
|
||||||
|
if (!settings->netplay.server[0])
|
||||||
|
{
|
||||||
|
menu_input_ctx_line_t line;
|
||||||
|
memset(&line, 0, sizeof(line));
|
||||||
|
line.label = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_IP_ADDRESS);
|
||||||
|
line.label_setting = "no_setting";
|
||||||
|
line.cb = action_ok_netplay_enable_client_hostname_cb;
|
||||||
|
if (!menu_input_dialog_start(&line))
|
||||||
|
return -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Enable Netplay itself */
|
/* Enable Netplay itself */
|
||||||
if (!command_event(CMD_EVENT_NETPLAY_INIT, NULL))
|
if (!command_event(CMD_EVENT_NETPLAY_INIT, NULL))
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user