From b7f3bede61d25f9888f3447c195e235e5f72efb9 Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 19 Nov 2017 16:04:22 -0500 Subject: [PATCH 1/2] hook up touch callback --- menu/cbs/menu_cbs_select.c | 59 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/menu/cbs/menu_cbs_select.c b/menu/cbs/menu_cbs_select.c index 84132b7a01..74ca3ef2c8 100644 --- a/menu/cbs/menu_cbs_select.c +++ b/menu/cbs/menu_cbs_select.c @@ -23,6 +23,12 @@ #include "../widgets/menu_entry.h" #include "../menu_cbs.h" #include "../menu_setting.h" +#include "../../tasks/tasks_internal.h" + +#ifdef HAVE_NETWORKING +#include "../../network/netplay/netplay.h" +#include "../../network/netplay/netplay_discovery.h" +#endif #ifndef BIND_ACTION_SELECT #define BIND_ACTION_SELECT(cbs, name) \ @@ -148,6 +154,53 @@ static int action_select_input_desc_kbd(const char *path, const char *label, uns return action_right_input_desc_kbd(type, label, true); } +static int action_select_netplay_connect_room(const char *path, const char *label, unsigned type, + size_t idx) +{ +#ifdef HAVE_NETWORKING + char tmp_hostname[4115]; + + tmp_hostname[0] = '\0'; + + if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL)) + command_event(CMD_EVENT_NETPLAY_DEINIT, NULL); + netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_CLIENT, NULL); + + if (netplay_room_list[idx - 3].host_method == NETPLAY_HOST_METHOD_MITM) + { + snprintf(tmp_hostname, + sizeof(tmp_hostname), + "%s|%d", + netplay_room_list[idx - 3].mitm_address, + netplay_room_list[idx - 3].mitm_port); + } + else + { + snprintf(tmp_hostname, + sizeof(tmp_hostname), + "%s|%d", + netplay_room_list[idx - 3].address, + netplay_room_list[idx - 3].port); + } + +#if 0 + RARCH_LOG("[lobby] connecting to: %s with game: %s/%08x\n", + tmp_hostname, + netplay_room_list[idx - 3].gamename, + netplay_room_list[idx - 3].gamecrc); +#endif + + task_push_netplay_crc_scan(netplay_room_list[idx - 3].gamecrc, + netplay_room_list[idx - 3].gamename, + tmp_hostname, netplay_room_list[idx - 3].corename); + +#else + return -1; + +#endif + return 0; +} + static int menu_cbs_init_bind_select_compare_type( menu_file_list_cbs_t *cbs, unsigned type) { @@ -180,6 +233,12 @@ static int menu_cbs_init_bind_select_compare_type( BIND_ACTION_SELECT(cbs, action_select_input_desc_kbd); } #endif +#ifdef HAVE_NETWORKING + else if (type == MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM) + { + BIND_ACTION_SELECT(cbs, action_select_netplay_connect_room); + } +#endif else { switch (type) From 4a09dfdb30022b9a022b05999ea39cd5d143c956 Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 19 Nov 2017 16:47:34 -0500 Subject: [PATCH 2/2] fix netplay join with touch --- menu/cbs/menu_cbs_select.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/menu/cbs/menu_cbs_select.c b/menu/cbs/menu_cbs_select.c index 74ca3ef2c8..bdca580865 100644 --- a/menu/cbs/menu_cbs_select.c +++ b/menu/cbs/menu_cbs_select.c @@ -233,14 +233,9 @@ static int menu_cbs_init_bind_select_compare_type( BIND_ACTION_SELECT(cbs, action_select_input_desc_kbd); } #endif -#ifdef HAVE_NETWORKING - else if (type == MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM) - { - BIND_ACTION_SELECT(cbs, action_select_netplay_connect_room); - } -#endif else { + switch (type) { case FILE_TYPE_USE_DIRECTORY: @@ -268,6 +263,14 @@ int menu_cbs_init_bind_select(menu_file_list_cbs_t *cbs, BIND_ACTION_SELECT(cbs, action_select_default); +#ifdef HAVE_NETWORKING + if (cbs->enum_idx == MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM) + { + BIND_ACTION_SELECT(cbs, action_select_netplay_connect_room); + return 0; + } +#endif + if (cbs->setting) { uint64_t flags = cbs->setting->flags;