Skip to content

Commit

Permalink
start registering the application so it can be started from discord
Browse files Browse the repository at this point in the history
  • Loading branch information
radius committed Oct 14, 2018
1 parent 32c346a commit bf7c3f1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
10 changes: 5 additions & 5 deletions deps/discord-rpc/src/discord_register_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,22 @@ static void Discord_RegisterW(const wchar_t* applicationId, const wchar_t* comma
wchar_t openCommand[1024];

if (command && command[0]) {
StringCbPrintfW(openCommand, sizeof(openCommand), L"%s", command);
StringCbPrintfW(openCommand, sizeof(openCommand), L"%S", command);
}
else {
// StringCbCopyW(openCommand, sizeof(openCommand), exeFilePath);
StringCbPrintfW(openCommand, sizeof(openCommand), L"%s", exeFilePath);
StringCbPrintfW(openCommand, sizeof(openCommand), L"%S", exeFilePath);
}

wchar_t protocolName[64];
StringCbPrintfW(protocolName, sizeof(protocolName), L"discord-%s", applicationId);
StringCbPrintfW(protocolName, sizeof(protocolName), L"discord-%S", applicationId);
wchar_t protocolDescription[128];
StringCbPrintfW(
protocolDescription, sizeof(protocolDescription), L"URL:Run game %s protocol", applicationId);
protocolDescription, sizeof(protocolDescription), L"URL:Run game %S protocol", applicationId);
wchar_t urlProtocol = 0;

wchar_t keyName[256];
StringCbPrintfW(keyName, sizeof(keyName), L"Software\\Classes\\%s", protocolName);
StringCbPrintfW(keyName, sizeof(keyName), L"Software\\Classes\\%S", protocolName);
HKEY key;
auto status =
RegCreateKeyExW(HKEY_CURRENT_USER, keyName, 0, nullptr, 0, KEY_WRITE, nullptr, &key, nullptr);
Expand Down
7 changes: 6 additions & 1 deletion discord/discord.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <file/file_path.h>

#include "discord.h"
#include "discord_register.h"

#include "../retroarch.h"
#include "../configuration.h"
Expand Down Expand Up @@ -225,7 +226,11 @@ void discord_init(void)
handlers.spectateGame = handle_discord_spectate;
handlers.joinRequest = handle_discord_join_request;

Discord_Initialize(settings->arrays.discord_app_id, &handlers, 1, NULL);
/* To-Do: Add the arguments RetroArch was started with to the register URI*/
const char command[256] = "retroarch";

Discord_Initialize(settings->arrays.discord_app_id, &handlers, 0, NULL);
Discord_Register(settings->arrays.discord_app_id, NULL);

discord_ready = true;
}
Expand Down

0 comments on commit bf7c3f1

Please sign in to comment.