mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-01-21 05:51:39 +00:00
38 lines
770 B
C++
38 lines
770 B
C++
#include "discord.h"
|
|
|
|
#include <cstring>
|
|
#include <ctime>
|
|
|
|
void Discord::RPC::init() {
|
|
DiscordEventHandlers handlers{};
|
|
Discord_Initialize("1139939140494971051", &handlers, 1, nullptr);
|
|
|
|
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";
|
|
}
|
|
|
|
rpc.largeImageKey = "shadps4";
|
|
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();
|
|
}
|
|
}
|