mirror of
https://github.com/yuzu-emu/discord-rpc.git
synced 2024-12-22 22:55:38 +00:00
Let's just register in init
This commit is contained in:
parent
1f6fd05884
commit
f617f3b78d
|
@ -97,16 +97,13 @@ static void gameLoop()
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
/* This would typically be in an installer and/or wrapped to only run once */
|
|
||||||
Discord_Register(APPLICATION_ID);
|
|
||||||
|
|
||||||
DiscordEventHandlers handlers;
|
DiscordEventHandlers handlers;
|
||||||
memset(&handlers, 0, sizeof(handlers));
|
memset(&handlers, 0, sizeof(handlers));
|
||||||
handlers.ready = handleDiscordReady;
|
handlers.ready = handleDiscordReady;
|
||||||
handlers.disconnected = handleDiscordDisconnected;
|
handlers.disconnected = handleDiscordDisconnected;
|
||||||
handlers.errored = handleDiscordError;
|
handlers.errored = handleDiscordError;
|
||||||
handlers.presenceRequested = handleDiscordPresenceRequested;
|
handlers.presenceRequested = handleDiscordPresenceRequested;
|
||||||
Discord_Initialize(APPLICATION_ID, &handlers);
|
Discord_Initialize(APPLICATION_ID, &handlers, 1);
|
||||||
|
|
||||||
gameLoop();
|
gameLoop();
|
||||||
|
|
||||||
|
|
|
@ -5,12 +5,6 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Registration */
|
|
||||||
|
|
||||||
void Discord_Register(const char* applicationId);
|
|
||||||
|
|
||||||
/* RPC */
|
|
||||||
|
|
||||||
typedef struct DiscordRichPresence {
|
typedef struct DiscordRichPresence {
|
||||||
const char* state;
|
const char* state;
|
||||||
const char* details;
|
const char* details;
|
||||||
|
@ -38,7 +32,7 @@ typedef struct DiscordEventHandlers {
|
||||||
void (*spectateGame)(const char* spectateSecret);
|
void (*spectateGame)(const char* spectateSecret);
|
||||||
} DiscordEventHandlers;
|
} DiscordEventHandlers;
|
||||||
|
|
||||||
void Discord_Initialize(const char* applicationId, DiscordEventHandlers* handlers);
|
void Discord_Initialize(const char* applicationId, DiscordEventHandlers* handlers, int autoRegister);
|
||||||
void Discord_Shutdown();
|
void Discord_Shutdown();
|
||||||
|
|
||||||
/* checks for incoming messages, dispatches callbacks */
|
/* checks for incoming messages, dispatches callbacks */
|
||||||
|
|
4
src/discord-register.h
Normal file
4
src/discord-register.h
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
void Discord_Register(const char* applicationId);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "discord-rpc.h"
|
#include "discord-rpc.h"
|
||||||
|
|
||||||
#include "backoff.h"
|
#include "backoff.h"
|
||||||
|
#include "discord-register.h"
|
||||||
#include "rpc_connection.h"
|
#include "rpc_connection.h"
|
||||||
#include "serialization.h"
|
#include "serialization.h"
|
||||||
|
|
||||||
|
@ -179,8 +180,12 @@ bool RegisterForEvent(const char* evtName)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void Discord_Initialize(const char* applicationId, DiscordEventHandlers* handlers)
|
extern "C" void Discord_Initialize(const char* applicationId, DiscordEventHandlers* handlers, int autoRegister)
|
||||||
{
|
{
|
||||||
|
if (autoRegister) {
|
||||||
|
Discord_Register(applicationId);
|
||||||
|
}
|
||||||
|
|
||||||
Pid = GetProcessId();
|
Pid = GetProcessId();
|
||||||
|
|
||||||
if (handlers) {
|
if (handlers) {
|
||||||
|
|
Loading…
Reference in a new issue