mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-08 01:56:21 +00:00
Add discord RPC
This commit is contained in:
parent
16e2768df0
commit
f2b64e892b
5 changed files with 68 additions and 1 deletions
37
src/discord.cpp
Normal file
37
src/discord.cpp
Normal file
|
@ -0,0 +1,37 @@
|
|||
#include "discord.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
|
||||
void Discord::RPC::init() {
|
||||
DiscordEventHandlers handlers{};
|
||||
Discord_Initialize("1138176975865909360", &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 = "pand";
|
||||
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();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue