mirror of
https://github.com/libretro/RetroArch
synced 2025-04-04 22:20:25 +00:00
commit
1b7362838e
@ -31,7 +31,7 @@ Latest binaries are currently hosted on the [buildbot](http://buildbot.libretro.
|
|||||||
|
|
||||||
## Support
|
## Support
|
||||||
|
|
||||||
To reach developers, either make an issue here on GitHub, make a thread on the [forum](http://www.libretro.com/forums/), chat on [Discord](https://discord.gg/C4amCeV), or visit our IRC channel: #retroarch @ irc.freenode.org.
|
To reach developers, either make an issue here on GitHub, make a thread on the [forum](http://www.libretro.com/forums/), chat on [discord](https://discord.gg/C4amCeV), or visit our IRC channel: #retroarch @ irc.freenode.org.
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
|
@ -55,6 +55,8 @@
|
|||||||
#include <file/file_path.h>
|
#include <file/file_path.h>
|
||||||
#include "../file_path_special.h"
|
#include "../file_path_special.h"
|
||||||
|
|
||||||
|
#include <features/features_cpu.h>
|
||||||
|
|
||||||
static int64_t start_time = 0;
|
static int64_t start_time = 0;
|
||||||
static int64_t pause_time = 0;
|
static int64_t pause_time = 0;
|
||||||
static int64_t ellapsed_time = 0;
|
static int64_t ellapsed_time = 0;
|
||||||
@ -65,12 +67,21 @@ static unsigned discord_status = 0;
|
|||||||
|
|
||||||
struct netplay_room *room;
|
struct netplay_room *room;
|
||||||
|
|
||||||
static char user_id[128];
|
/* The discord API specifies these variables:
|
||||||
static char user_name[128];
|
- userId --------- char[24] - the userId of the player asking to join
|
||||||
static char party_name[128];
|
- username ------- char[344] - the username of the player asking to join
|
||||||
static char client_party_name[128];
|
- discriminator -- char[8] - the discriminator of the player asking to join
|
||||||
static char user_avatar[PATH_MAX_LENGTH];
|
- spectateSecret - char[128] - secret used for spectatin matches
|
||||||
|
- joinSecret - char[128] - secret used to join matches
|
||||||
|
- partyId - char[128] - the party you would be joining
|
||||||
|
*/
|
||||||
|
|
||||||
|
static char user_id[24];
|
||||||
|
static char user_name[344];
|
||||||
|
static char self_party_id[128];
|
||||||
|
static char peer_party_id[128];
|
||||||
|
|
||||||
|
static char user_avatar[PATH_MAX_LENGTH];
|
||||||
static bool connecting = false;
|
static bool connecting = false;
|
||||||
|
|
||||||
static char cdn_url[] = "https://cdn.discordapp.com/avatars";
|
static char cdn_url[] = "https://cdn.discordapp.com/avatars";
|
||||||
@ -119,6 +130,8 @@ static bool discord_download_avatar(
|
|||||||
|
|
||||||
file_transfer_t *transf = NULL;
|
file_transfer_t *transf = NULL;
|
||||||
|
|
||||||
|
RARCH_LOG("[discord] user avatar id: %s\n", user_id);
|
||||||
|
|
||||||
fill_pathname_application_special(buf,
|
fill_pathname_application_special(buf,
|
||||||
sizeof(buf),
|
sizeof(buf),
|
||||||
APPLICATION_SPECIAL_DIRECTORY_THUMBNAILS_DISCORD_AVATARS);
|
APPLICATION_SPECIAL_DIRECTORY_THUMBNAILS_DISCORD_AVATARS);
|
||||||
@ -139,7 +152,7 @@ static bool discord_download_avatar(
|
|||||||
transf->enum_idx = MENU_ENUM_LABEL_CB_DISCORD_AVATAR;
|
transf->enum_idx = MENU_ENUM_LABEL_CB_DISCORD_AVATAR;
|
||||||
strlcpy(transf->path, buf, sizeof(transf->path));
|
strlcpy(transf->path, buf, sizeof(transf->path));
|
||||||
|
|
||||||
RARCH_LOG("[Discord] downloading avatar from: %s\n", url_encoded);
|
RARCH_LOG("[discord] downloading avatar from: %s\n", url_encoded);
|
||||||
task_push_http_transfer(url_encoded, true, NULL, cb_generic_download, transf);
|
task_push_http_transfer(url_encoded, true, NULL, cb_generic_download, transf);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -149,14 +162,11 @@ static bool discord_download_avatar(
|
|||||||
static void handle_discord_ready(const DiscordUser* connectedUser)
|
static void handle_discord_ready(const DiscordUser* connectedUser)
|
||||||
{
|
{
|
||||||
strlcpy(user_name, connectedUser->username, sizeof(user_name));
|
strlcpy(user_name, connectedUser->username, sizeof(user_name));
|
||||||
strlcpy(party_name, connectedUser->username, sizeof(user_name));
|
|
||||||
strlcat(party_name, "|", sizeof(party_name));
|
|
||||||
strlcat(party_name, connectedUser->discriminator, sizeof(party_name));
|
|
||||||
|
|
||||||
RARCH_LOG("[Discord] connected to user: %s#%s - avatar id: %s\n",
|
RARCH_LOG("[discord] connected to user: %s#%s\n",
|
||||||
connectedUser->username,
|
connectedUser->username,
|
||||||
connectedUser->discriminator,
|
connectedUser->discriminator);
|
||||||
connectedUser->userId);
|
|
||||||
#ifdef HAVE_MENU
|
#ifdef HAVE_MENU
|
||||||
discord_download_avatar(connectedUser->userId, connectedUser->avatar);
|
discord_download_avatar(connectedUser->userId, connectedUser->avatar);
|
||||||
#endif
|
#endif
|
||||||
@ -164,18 +174,18 @@ static void handle_discord_ready(const DiscordUser* connectedUser)
|
|||||||
|
|
||||||
static void handle_discord_disconnected(int errcode, const char* message)
|
static void handle_discord_disconnected(int errcode, const char* message)
|
||||||
{
|
{
|
||||||
RARCH_LOG("[Discord] disconnected (%d: %s)\n", errcode, message);
|
RARCH_LOG("[discord] disconnected (%d: %s)\n", errcode, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_discord_error(int errcode, const char* message)
|
static void handle_discord_error(int errcode, const char* message)
|
||||||
{
|
{
|
||||||
RARCH_LOG("[Discord] error (%d: %s)\n", errcode, message);
|
RARCH_LOG("[discord] error (%d: %s)\n", errcode, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_discord_join_cb(retro_task_t *task, void *task_data, void *user_data, const char *err)
|
static void handle_discord_join_cb(retro_task_t *task, void *task_data, void *user_data, const char *err)
|
||||||
{
|
{
|
||||||
struct netplay_room *room;
|
struct netplay_room *room;
|
||||||
char tmp_hostname[32];
|
char join_hostname[PATH_MAX_LENGTH];
|
||||||
|
|
||||||
http_transfer_data_t *data = (http_transfer_data_t*)task_data;
|
http_transfer_data_t *data = (http_transfer_data_t*)task_data;
|
||||||
|
|
||||||
@ -194,13 +204,13 @@ static void handle_discord_join_cb(retro_task_t *task, void *task_data, void *us
|
|||||||
deinit_netplay();
|
deinit_netplay();
|
||||||
netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_CLIENT, NULL);
|
netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_CLIENT, NULL);
|
||||||
|
|
||||||
snprintf(tmp_hostname, sizeof(tmp_hostname), "%s|%d",
|
snprintf(join_hostname, sizeof(join_hostname), "%s|%d",
|
||||||
room->host_method == NETPLAY_HOST_METHOD_MITM ? room->mitm_address : room->address,
|
room->host_method == NETPLAY_HOST_METHOD_MITM ? room->mitm_address : room->address,
|
||||||
room->host_method == NETPLAY_HOST_METHOD_MITM ? room->mitm_port : room->port);
|
room->host_method == NETPLAY_HOST_METHOD_MITM ? room->mitm_port : room->port);
|
||||||
|
|
||||||
RARCH_LOG("[Discord] joining lobby at: %s\n", tmp_hostname);
|
RARCH_LOG("[discord] joining lobby at: %s\n", join_hostname);
|
||||||
task_push_netplay_crc_scan(room->gamecrc,
|
task_push_netplay_crc_scan(room->gamecrc,
|
||||||
room->gamename, tmp_hostname, room->corename, room->subsystem_name);
|
room->gamename, join_hostname, room->corename, room->subsystem_name);
|
||||||
connecting = true;
|
connecting = true;
|
||||||
discord_update(DISCORD_PRESENCE_NETPLAY_CLIENT);
|
discord_update(DISCORD_PRESENCE_NETPLAY_CLIENT);
|
||||||
}
|
}
|
||||||
@ -224,30 +234,22 @@ finish:
|
|||||||
static void handle_discord_join(const char* secret)
|
static void handle_discord_join(const char* secret)
|
||||||
{
|
{
|
||||||
char url [2048] = "http://lobby.libretro.com/";
|
char url [2048] = "http://lobby.libretro.com/";
|
||||||
char tmp_hostname[32];
|
|
||||||
static struct string_list *list = NULL;
|
static struct string_list *list = NULL;
|
||||||
|
|
||||||
RARCH_LOG("[Discord] join secret: (%s)\n", secret);
|
RARCH_LOG("[discord] join secret: (%s)\n", secret);
|
||||||
list = string_split(secret, "|");
|
list = string_split(secret, "|");
|
||||||
|
|
||||||
strlcpy(client_party_name, list->elems[1].data, sizeof(client_party_name));
|
strlcpy(peer_party_id, list->elems[0].data, sizeof(peer_party_id));
|
||||||
strlcat(client_party_name, "|", sizeof(client_party_name));
|
strlcat(url, peer_party_id, sizeof(url));
|
||||||
strlcat(client_party_name, list->elems[2].data, sizeof(client_party_name));
|
|
||||||
|
|
||||||
strlcat(url, list->elems[0].data, sizeof(url));
|
|
||||||
strlcat(url, "/", sizeof(url));
|
strlcat(url, "/", sizeof(url));
|
||||||
RARCH_LOG("[Discord] querying lobby id: %s at %s\n", list->elems[0].data, url);
|
|
||||||
|
|
||||||
snprintf(tmp_hostname,
|
|
||||||
sizeof(tmp_hostname),
|
|
||||||
"%s|%s", list->elems[0].data, list->elems[1].data);
|
|
||||||
|
|
||||||
|
RARCH_LOG("[discord] querying lobby id: %s at %s\n", peer_party_id, url);
|
||||||
task_push_http_transfer(url, true, NULL, handle_discord_join_cb, NULL);
|
task_push_http_transfer(url, true, NULL, handle_discord_join_cb, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_discord_spectate(const char* secret)
|
static void handle_discord_spectate(const char* secret)
|
||||||
{
|
{
|
||||||
RARCH_LOG("[Discord] spectate (%s)\n", secret);
|
RARCH_LOG("[discord] spectate (%s)\n", secret);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_discord_join_response(void *ignore, const char *line)
|
static void handle_discord_join_response(void *ignore, const char *line)
|
||||||
@ -273,7 +275,7 @@ static void handle_discord_join_request(const DiscordUser* request)
|
|||||||
menu_input_ctx_line_t line;
|
menu_input_ctx_line_t line;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RARCH_LOG("[Discord] join request from %s#%s - %s %s\n",
|
RARCH_LOG("[discord] join request from %s#%s - %s %s\n",
|
||||||
request->username,
|
request->username,
|
||||||
request->discriminator,
|
request->discriminator,
|
||||||
request->userId,
|
request->userId,
|
||||||
@ -315,7 +317,7 @@ void discord_update(enum discord_presence presence)
|
|||||||
if (!connecting && (presence == DISCORD_PRESENCE_NONE || presence == DISCORD_PRESENCE_MENU))
|
if (!connecting && (presence == DISCORD_PRESENCE_NONE || presence == DISCORD_PRESENCE_MENU))
|
||||||
{
|
{
|
||||||
memset(&discord_presence, 0, sizeof(discord_presence));
|
memset(&discord_presence, 0, sizeof(discord_presence));
|
||||||
client_party_name[0] = '\0';
|
peer_party_id[0] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (presence)
|
switch (presence)
|
||||||
@ -351,8 +353,8 @@ void discord_update(enum discord_presence presence)
|
|||||||
if (!label)
|
if (!label)
|
||||||
label = (char *)path_basename(path_get(RARCH_PATH_BASENAME));
|
label = (char *)path_basename(path_get(RARCH_PATH_BASENAME));
|
||||||
#if 0
|
#if 0
|
||||||
RARCH_LOG("[Discord] current core: %s\n", system_id);
|
RARCH_LOG("[discord] current core: %s\n", system_id);
|
||||||
RARCH_LOG("[Discord] current content: %s\n", label);
|
RARCH_LOG("[discord] current content: %s\n", label);
|
||||||
#endif
|
#endif
|
||||||
discord_presence.largeImageKey = system_id;
|
discord_presence.largeImageKey = system_id;
|
||||||
|
|
||||||
@ -378,7 +380,7 @@ void discord_update(enum discord_presence presence)
|
|||||||
|
|
||||||
if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL))
|
if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL))
|
||||||
{
|
{
|
||||||
client_party_name[0] = '\0';
|
peer_party_id[0] = '\0';
|
||||||
discord_presence.partyId = NULL;
|
discord_presence.partyId = NULL;
|
||||||
discord_presence.partyMax = 0;
|
discord_presence.partyMax = 0;
|
||||||
discord_presence.partySize = 0;
|
discord_presence.partySize = 0;
|
||||||
@ -391,34 +393,36 @@ void discord_update(enum discord_presence presence)
|
|||||||
if (room->id == 0)
|
if (room->id == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
RARCH_LOG("[Discord] netplay room details: id=%d, nick=%s IP=%s port=%d\n",
|
RARCH_LOG("[discord] netplay room details: id=%d, nick=%s IP=%s port=%d\n",
|
||||||
room->id, room->nickname,
|
room->id, room->nickname,
|
||||||
room->host_method == NETPLAY_HOST_METHOD_MITM ? room->mitm_address : room->address,
|
room->host_method == NETPLAY_HOST_METHOD_MITM ? room->mitm_address : room->address,
|
||||||
room->host_method == NETPLAY_HOST_METHOD_MITM ? room->mitm_port : room->port);
|
room->host_method == NETPLAY_HOST_METHOD_MITM ? room->mitm_port : room->port);
|
||||||
|
|
||||||
{
|
{
|
||||||
char join_secret[128];
|
char join_secret[128];
|
||||||
snprintf(join_secret, sizeof(join_secret), "%d|%s", room->id, party_name);
|
|
||||||
|
snprintf(self_party_id, sizeof(self_party_id), "%d", room->id);
|
||||||
|
snprintf(join_secret, sizeof(join_secret), "%d|%" PRId64, room->id, cpu_features_get_time_usec());
|
||||||
discord_presence.joinSecret = strdup(join_secret);
|
discord_presence.joinSecret = strdup(join_secret);
|
||||||
/* discord_presence.spectateSecret = "SPECSPECSPEC"; */
|
/* discord_presence.spectateSecret = "SPECSPECSPEC"; */
|
||||||
discord_presence.partyId = strdup(party_name);
|
discord_presence.partyId = strdup(self_party_id);
|
||||||
discord_presence.partyMax = 2;
|
discord_presence.partyMax = 2;
|
||||||
discord_presence.partySize = 1;
|
discord_presence.partySize = 1;
|
||||||
|
|
||||||
RARCH_LOG("[Discord] join secret: %s\n", join_secret);
|
RARCH_LOG("[discord] join secret: %s\n", join_secret);
|
||||||
RARCH_LOG("[Discord] party id: %s\n", party_name);
|
RARCH_LOG("[discord] party id: %s\n", self_party_id);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DISCORD_PRESENCE_NETPLAY_CLIENT:
|
case DISCORD_PRESENCE_NETPLAY_CLIENT:
|
||||||
RARCH_LOG("[Discord] party id: %s\n", client_party_name);
|
RARCH_LOG("[discord] party id: %s\n", peer_party_id);
|
||||||
discord_presence.partyId = strdup(client_party_name);
|
discord_presence.partyId = strdup(peer_party_id);
|
||||||
break;
|
break;
|
||||||
case DISCORD_PRESENCE_NETPLAY_NETPLAY_STOPPED:
|
case DISCORD_PRESENCE_NETPLAY_NETPLAY_STOPPED:
|
||||||
{
|
{
|
||||||
if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL) &&
|
if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL) &&
|
||||||
!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_CONNECTED, NULL))
|
!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_CONNECTED, NULL))
|
||||||
{
|
{
|
||||||
client_party_name[0] = '\0';
|
peer_party_id[0] = '\0';
|
||||||
discord_presence.partyId = NULL;
|
discord_presence.partyId = NULL;
|
||||||
discord_presence.partyMax = 0;
|
discord_presence.partyMax = 0;
|
||||||
discord_presence.partySize = 0;
|
discord_presence.partySize = 0;
|
||||||
@ -435,7 +439,7 @@ void discord_update(enum discord_presence presence)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
RARCH_LOG("[Discord] updating (%d)\n", presence);
|
RARCH_LOG("[discord] updating (%d)\n", presence);
|
||||||
|
|
||||||
Discord_UpdatePresence(&discord_presence);
|
Discord_UpdatePresence(&discord_presence);
|
||||||
discord_status = presence;
|
discord_status = presence;
|
||||||
@ -448,7 +452,7 @@ void discord_init(void)
|
|||||||
|
|
||||||
DiscordEventHandlers handlers;
|
DiscordEventHandlers handlers;
|
||||||
|
|
||||||
RARCH_LOG("[Discord] initializing ..\n");
|
RARCH_LOG("[discord] initializing ..\n");
|
||||||
start_time = time(0);
|
start_time = time(0);
|
||||||
|
|
||||||
memset(&handlers, 0, sizeof(handlers));
|
memset(&handlers, 0, sizeof(handlers));
|
||||||
@ -467,14 +471,14 @@ void discord_init(void)
|
|||||||
snprintf(command, sizeof(command), "sh -c %s", get_retroarch_launch_arguments());
|
snprintf(command, sizeof(command), "sh -c %s", get_retroarch_launch_arguments());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RARCH_LOG("[Discord] registering startup command: %s\n", command);
|
RARCH_LOG("[discord] registering startup command: %s\n", command);
|
||||||
Discord_Register(settings->arrays.discord_app_id, command);
|
Discord_Register(settings->arrays.discord_app_id, command);
|
||||||
discord_ready = true;
|
discord_ready = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void discord_shutdown(void)
|
void discord_shutdown(void)
|
||||||
{
|
{
|
||||||
RARCH_LOG("[Discord] shutting down ..\n");
|
RARCH_LOG("[discord] shutting down ..\n");
|
||||||
Discord_ClearPresence();
|
Discord_ClearPresence();
|
||||||
Discord_Shutdown();
|
Discord_Shutdown();
|
||||||
discord_ready = false;
|
discord_ready = false;
|
||||||
|
@ -66,15 +66,15 @@ enum netplay_host_method
|
|||||||
struct netplay_room
|
struct netplay_room
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
char nickname [PATH_MAX_LENGTH];
|
char nickname [2048];
|
||||||
char address [PATH_MAX_LENGTH];
|
char address [2048];
|
||||||
char mitm_address[PATH_MAX_LENGTH];
|
char mitm_address[2048];
|
||||||
int port;
|
int port;
|
||||||
int mitm_port;
|
int mitm_port;
|
||||||
char corename [PATH_MAX_LENGTH];
|
char corename [2048];
|
||||||
char frontend [PATH_MAX_LENGTH];
|
char frontend [2048];
|
||||||
char coreversion [PATH_MAX_LENGTH];
|
char coreversion [2048];
|
||||||
char gamename [PATH_MAX_LENGTH];
|
char gamename [2048];
|
||||||
int gamecrc;
|
int gamecrc;
|
||||||
int timestamp;
|
int timestamp;
|
||||||
int host_method;
|
int host_method;
|
||||||
@ -82,9 +82,9 @@ struct netplay_room
|
|||||||
bool has_spectate_password;
|
bool has_spectate_password;
|
||||||
bool lan;
|
bool lan;
|
||||||
bool fixed;
|
bool fixed;
|
||||||
char retroarch_version[PATH_MAX_LENGTH];
|
char retroarch_version [2048];
|
||||||
char subsystem_name[PATH_MAX_LENGTH];
|
char subsystem_name [2048];
|
||||||
char country[PATH_MAX_LENGTH];
|
char country[2048];
|
||||||
struct netplay_room *next;
|
struct netplay_room *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user