2023-08-11 17:22:26 +00:00
|
|
|
#include "discord.h"
|
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
#include <ctime>
|
|
|
|
|
|
|
|
void Discord::RPC::init() {
|
|
|
|
DiscordEventHandlers handlers{};
|
2023-08-12 15:47:37 +00:00
|
|
|
Discord_Initialize("1139939140494971051", &handlers, 1, nullptr);
|
2023-08-11 17:22:26 +00:00
|
|
|
|
|
|
|
startTimestamp = time(nullptr);
|
|
|
|
enabled = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Discord::RPC::update(Discord::RPCStatus status, const std::string& game) {
|
|
|
|
DiscordRichPresence rpc{};
|
|
|
|
|
|
|
|
if (status == Discord::RPCStatus::Playing) {
|
|
|
|
rpc.details = "Playing a game";
|
|
|
|
rpc.state = game.c_str();
|
|
|
|
} else {
|
|
|
|
rpc.details = "Idle";
|
|
|
|
}
|
|
|
|
|
2023-08-12 15:47:37 +00:00
|
|
|
rpc.largeImageKey = "shadps4";
|
2023-08-11 17:22:26 +00:00
|
|
|
rpc.largeImageText = "ShadPS4 is a PS4 emulator";
|
|
|
|
rpc.startTimestamp = startTimestamp;
|
|
|
|
|
|
|
|
Discord_UpdatePresence(&rpc);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Discord::RPC::stop() {
|
|
|
|
if (enabled) {
|
|
|
|
enabled = false;
|
|
|
|
Discord_ClearPresence();
|
|
|
|
Discord_Shutdown();
|
|
|
|
}
|
|
|
|
}
|