From 2bdd938338b75ab194030c2014605e456651d827 Mon Sep 17 00:00:00 2001 From: radius Date: Mon, 27 Feb 2017 18:10:35 -0500 Subject: [PATCH 1/2] after the first scan it will no longer scan because of this line --- menu/menu_displaylist.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index d1b8da8f3b..9febdea678 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -4941,8 +4941,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) if (!hosts || hosts->size == 0) { - if (!hosts) - task_push_netplay_lan_scan(); + task_push_netplay_lan_scan(); menu_entries_append_enum(info->list, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_NETPLAY_HOSTS_FOUND), From b719f30b8e1bc6d5470d419bdc097504414e1a7c Mon Sep 17 00:00:00 2001 From: radius Date: Mon, 27 Feb 2017 19:00:43 -0500 Subject: [PATCH 2/2] add lan games --- menu/cbs/menu_cbs_ok.c | 52 +++++++++++++++++++++++++++++++++-- tasks/task_netplay_lan_scan.c | 17 ++++++++++++ 2 files changed, 67 insertions(+), 2 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 916b575e45..be9b5f223e 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -3414,10 +3414,16 @@ finish: } else { - int i, j = 0; + int i = 0; + int j = 0; + int k = 0; char s[PATH_MAX_LENGTH]; static struct string_list *room_data = NULL; file_list_t *file_list = menu_entries_get_selection_buf_ptr(0); + struct netplay_host_list *lan_hosts; + + if (!netplay_discovery_driver_ctl(RARCH_NETPLAY_DISCOVERY_CTL_LAN_GET_RESPONSES, &lan_hosts)) + lan_hosts = NULL; menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, file_list); @@ -3428,7 +3434,8 @@ finish: netplay_room_count = (int)(room_data->size / 8); netplay_room_list = (struct netplay_room*) - malloc(sizeof(struct netplay_room) * netplay_room_count); + malloc(sizeof(struct netplay_room) * netplay_room_count + + lan_hosts->size); #if 0 for (int i = 0; i < room_data->size; i++) @@ -3504,6 +3511,46 @@ finish: MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM, MENU_ROOM, 0, 0); } + + struct netplay_host *host = &lan_hosts->hosts[k]; + for (; i < netplay_room_count + lan_hosts->size; i++) + { + strlcpy(netplay_room_list[i].nickname, + host->nick, + sizeof(netplay_room_list[i].nickname)); + /* to-do: get address fron host-> addr */ + strlcpy(netplay_room_list[i].address, + "", + sizeof(netplay_room_list[i].address)); + strlcpy(netplay_room_list[i].corename, + host->core, + sizeof(netplay_room_list[i].corename)); + strlcpy(netplay_room_list[i].coreversion, + host->core_version, + sizeof(netplay_room_list[i].coreversion)); + strlcpy(netplay_room_list[i].gamename, + host->content, + sizeof(netplay_room_list[i].coreversion)); + + /* to-do: this will only work with default port os + we should have a start LAN game entry that always + uses that port + */ + netplay_room_list[i].port = 55435; + /* to-do: lan announce doesn't announce CRC */ + netplay_room_list[i].gamecrc = 0; + netplay_room_list[i].timestamp = 0; + + snprintf(s, sizeof(s), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_ROOM_NICKNAME), + netplay_room_list[i].nickname); + + menu_entries_append_enum(file_list, + s, + msg_hash_to_str(MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM), + MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM, + MENU_ROOM, 0, 0); + k++; + } } } @@ -3526,6 +3573,7 @@ static int action_ok_push_netplay_refresh_rooms(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { char url [2048] = "http://lobby.libretro.com/raw/"; + task_push_netplay_lan_scan(); task_push_http_transfer(url, true, NULL, netplay_refresh_rooms_cb, NULL); return 0; } diff --git a/tasks/task_netplay_lan_scan.c b/tasks/task_netplay_lan_scan.c index c5d72baaaa..2842035f1d 100644 --- a/tasks/task_netplay_lan_scan.c +++ b/tasks/task_netplay_lan_scan.c @@ -107,3 +107,20 @@ bool task_push_netplay_lan_scan(void) return true; } + +bool task_push_netplay_lan_scan_rooms(void) +{ + retro_task_t *task = (retro_task_t*)calloc(1, sizeof(*task)); + + if (!task) + return false; + + task->type = TASK_TYPE_BLOCKING; + task->handler = task_netplay_lan_scan_handler; + task->callback = netplay_lan_scan_callback; + task->title = strdup(msg_hash_to_str(MSG_NETPLAY_LAN_SCANNING)); + + task_queue_ctl(TASK_QUEUE_CTL_PUSH, task); + + return true; +}