mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-07-11 09:38:41 +12:00
Add Discord RPC (#161)
* Add discord-rpc submodule * Add Discord RPC * Fix up Discord status * Fix CMake because MacOS sucks * Slightly less hacky fix
This commit is contained in:
parent
32ad43cb8e
commit
1c11e2df40
9 changed files with 145 additions and 8 deletions
41
src/discord_rpc.cpp
Normal file
41
src/discord_rpc.cpp
Normal file
|
@ -0,0 +1,41 @@
|
|||
#ifdef PANDA3DS_ENABLE_DISCORD_RPC
|
||||
|
||||
#include "discord_rpc.hpp"
|
||||
|
||||
#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 = "Panda3DS is a 3DS emulator for Windows, MacOS and Linux";
|
||||
rpc.startTimestamp = startTimestamp;
|
||||
|
||||
Discord_UpdatePresence(&rpc);
|
||||
}
|
||||
|
||||
void Discord::RPC::stop() {
|
||||
if (enabled) {
|
||||
enabled = false;
|
||||
Discord_ClearPresence();
|
||||
Discord_Shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue