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:
wheremyfoodat 2023-08-08 00:23:39 +03:00 committed by GitHub
parent 32ad43cb8e
commit 1c11e2df40
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 145 additions and 8 deletions

View file

@ -6,6 +6,7 @@
// Remember to initialize every field here to its default value otherwise bad things will happen
struct EmulatorConfig {
bool shaderJitEnabled = false;
bool discordRpcEnabled = false;
RendererType rendererType = RendererType::OpenGL;
EmulatorConfig(const std::filesystem::path& path);

23
include/discord_rpc.hpp Normal file
View file

@ -0,0 +1,23 @@
#pragma once
#ifdef PANDA3DS_ENABLE_DISCORD_RPC
#include <discord_rpc.h>
#include <cstdint>
#include <string>
namespace Discord {
enum class RPCStatus { Idling, Playing };
class RPC {
std::uint64_t startTimestamp;
bool enabled = false;
public:
void init();
void update(RPCStatus status, const std::string& title);
void stop();
};
} // namespace Discord
#endif

View file

@ -11,6 +11,7 @@
#include "config.hpp"
#include "cpu.hpp"
#include "crypto/aes_engine.hpp"
#include "discord_rpc.hpp"
#include "io_file.hpp"
#include "memory.hpp"
@ -64,6 +65,11 @@ class Emulator {
friend struct HttpServer;
#endif
#ifdef PANDA3DS_ENABLE_DISCORD_RPC
Discord::RPC discordRpc;
#endif
void updateDiscord();
// Keep the handle for the ROM here to reload when necessary and to prevent deleting it
// This is currently only used for ELFs, NCSDs use the IOFile API instead
std::ifstream loadedELF;