[App] Add support for Discord rich presence.
This commit is contained in:
56
src/xenia/app/discord/discord_presence.cc
Normal file
56
src/xenia/app/discord/discord_presence.cc
Normal file
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2015 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "discord_presence.h"
|
||||
#include "third_party/discord-rpc/include/discord_rpc.h"
|
||||
#include "xenia/base/string.h"
|
||||
|
||||
namespace xe {
|
||||
namespace discord {
|
||||
|
||||
void HandleDiscordReady(const DiscordUser* request) {}
|
||||
void HandleDiscordError(int errorCode, const char* message) {}
|
||||
void HandleDiscordJoinGame(const char* joinSecret) {}
|
||||
void HandleDiscordJoinRequest(const DiscordUser* request) {}
|
||||
void HandleDiscordSpectateGame(const char* spectateSecret) {}
|
||||
|
||||
void DiscordPresence::InitializeDiscord() {
|
||||
DiscordEventHandlers handlers = {};
|
||||
handlers.ready = &HandleDiscordReady;
|
||||
handlers.errored = &HandleDiscordError;
|
||||
handlers.joinGame = &HandleDiscordJoinGame;
|
||||
handlers.joinRequest = &HandleDiscordJoinRequest;
|
||||
handlers.spectateGame = &HandleDiscordSpectateGame;
|
||||
Discord_Initialize("606840046649081857", &handlers, 0, "");
|
||||
}
|
||||
|
||||
void DiscordPresence::NotPlaying() {
|
||||
DiscordRichPresence discordPresence = {};
|
||||
discordPresence.state = "Idle";
|
||||
discordPresence.details = "Standby";
|
||||
discordPresence.largeImageKey = "default";
|
||||
discordPresence.instance = 1;
|
||||
Discord_UpdatePresence(&discordPresence);
|
||||
}
|
||||
|
||||
void DiscordPresence::PlayingTitle(std::wstring game_title) {
|
||||
auto discord_game_title = xe::to_string(game_title);
|
||||
DiscordRichPresence discordPresence = {};
|
||||
discordPresence.state = "In Game";
|
||||
discordPresence.details = discord_game_title.c_str();
|
||||
discordPresence.smallImageKey = "default";
|
||||
discordPresence.largeImageKey = "defaultgame";
|
||||
discordPresence.instance = 1;
|
||||
Discord_UpdatePresence(&discordPresence);
|
||||
}
|
||||
|
||||
void DiscordPresence::ShutdownDiscord() { Discord_Shutdown(); }
|
||||
|
||||
} // namespace discord
|
||||
} // namespace xe
|
||||
29
src/xenia/app/discord/discord_presence.h
Normal file
29
src/xenia/app/discord/discord_presence.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2015 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_DISCORD_DISCORD_PRESENCE_H_
|
||||
#define XENIA_DISCORD_DISCORD_PRESENCE_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace xe {
|
||||
namespace discord {
|
||||
|
||||
class DiscordPresence {
|
||||
public:
|
||||
static void InitializeDiscord();
|
||||
static void NotPlaying();
|
||||
static void PlayingTitle(std::wstring game_title);
|
||||
static void ShutdownDiscord();
|
||||
};
|
||||
|
||||
} // namespace discord
|
||||
} // namespace xe
|
||||
|
||||
#endif // XENIA_DISCORD_DISCORD_PRESENCE_H_
|
||||
20
src/xenia/app/discord/premake5.lua
Normal file
20
src/xenia/app/discord/premake5.lua
Normal file
@@ -0,0 +1,20 @@
|
||||
project_root = "../../../.."
|
||||
include(project_root.."/tools/build")
|
||||
|
||||
group("src")
|
||||
project("xenia-app-discord")
|
||||
uuid("d14c0885-22d2-40de-ab28-7b234ef2b949")
|
||||
kind("StaticLib")
|
||||
language("C++")
|
||||
links({
|
||||
"discord-rpc"
|
||||
})
|
||||
defines({
|
||||
})
|
||||
includedirs({
|
||||
project_root.."/third_party/discord-rpc/src"
|
||||
})
|
||||
files({
|
||||
"discord_presence.cc",
|
||||
"discord_presence.h"
|
||||
})
|
||||
Reference in New Issue
Block a user