2017-06-23 23:04:36 +00:00
|
|
|
#pragma once
|
2017-06-29 16:38:07 +00:00
|
|
|
#include <stdint.h>
|
2017-06-23 23:04:36 +00:00
|
|
|
|
2017-07-31 22:58:39 +00:00
|
|
|
// clang-format off
|
|
|
|
|
|
|
|
#if defined(DISCORD_DYNAMIC_LIB)
|
|
|
|
# if defined(_WIN32)
|
|
|
|
# if defined(DISCORD_BUILDING_SDK)
|
|
|
|
# define DISCORD_EXPORT __declspec(dllexport)
|
|
|
|
# else
|
|
|
|
# define DISCORD_EXPORT __declspec(dllimport)
|
|
|
|
# endif
|
|
|
|
# else
|
|
|
|
# define DISCORD_EXPORT __attribute__((visibility("default")))
|
|
|
|
# endif
|
|
|
|
#else
|
2017-10-12 23:08:08 +00:00
|
|
|
# define DISCORD_EXPORT
|
2017-07-31 22:58:39 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// clang-format on
|
|
|
|
|
2017-07-25 16:27:48 +00:00
|
|
|
#ifdef __cplusplus
|
2017-06-30 21:31:48 +00:00
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2017-07-20 20:22:11 +00:00
|
|
|
typedef struct DiscordRichPresence {
|
2017-07-31 22:58:39 +00:00
|
|
|
const char* state; /* max 128 bytes */
|
2017-07-28 23:06:46 +00:00
|
|
|
const char* details; /* max 128 bytes */
|
2017-06-29 16:38:07 +00:00
|
|
|
int64_t startTimestamp;
|
|
|
|
int64_t endTimestamp;
|
2017-07-31 22:58:39 +00:00
|
|
|
const char* largeImageKey; /* max 32 bytes */
|
2017-07-28 23:06:46 +00:00
|
|
|
const char* largeImageText; /* max 128 bytes */
|
2017-07-31 22:58:39 +00:00
|
|
|
const char* smallImageKey; /* max 32 bytes */
|
2017-07-28 23:06:46 +00:00
|
|
|
const char* smallImageText; /* max 128 bytes */
|
2017-07-31 22:58:39 +00:00
|
|
|
const char* partyId; /* max 128 bytes */
|
2017-06-29 15:58:38 +00:00
|
|
|
int partySize;
|
|
|
|
int partyMax;
|
2017-07-31 22:58:39 +00:00
|
|
|
const char* matchSecret; /* max 128 bytes */
|
|
|
|
const char* joinSecret; /* max 128 bytes */
|
2017-07-28 23:06:46 +00:00
|
|
|
const char* spectateSecret; /* max 128 bytes */
|
2017-06-30 21:31:48 +00:00
|
|
|
int8_t instance;
|
|
|
|
} DiscordRichPresence;
|
2017-06-23 23:04:36 +00:00
|
|
|
|
2018-04-16 17:25:44 +00:00
|
|
|
typedef struct DiscordUser {
|
2017-11-02 18:59:45 +00:00
|
|
|
const char* userId;
|
|
|
|
const char* username;
|
2017-11-30 19:22:23 +00:00
|
|
|
const char* discriminator;
|
2017-11-02 18:59:45 +00:00
|
|
|
const char* avatar;
|
2018-04-16 17:25:44 +00:00
|
|
|
} DiscordUser;
|
2017-10-12 20:06:55 +00:00
|
|
|
|
2017-07-20 20:22:11 +00:00
|
|
|
typedef struct DiscordEventHandlers {
|
2018-04-16 17:25:44 +00:00
|
|
|
void (*ready)(const DiscordUser* request);
|
2017-07-11 22:59:14 +00:00
|
|
|
void (*disconnected)(int errorCode, const char* message);
|
2017-07-24 21:58:53 +00:00
|
|
|
void (*errored)(int errorCode, const char* message);
|
2017-06-23 23:04:36 +00:00
|
|
|
void (*joinGame)(const char* joinSecret);
|
|
|
|
void (*spectateGame)(const char* spectateSecret);
|
2018-04-16 17:25:44 +00:00
|
|
|
void (*joinRequest)(const DiscordUser* request);
|
2017-06-30 21:31:48 +00:00
|
|
|
} DiscordEventHandlers;
|
2017-06-23 23:04:36 +00:00
|
|
|
|
2017-10-12 20:06:55 +00:00
|
|
|
#define DISCORD_REPLY_NO 0
|
|
|
|
#define DISCORD_REPLY_YES 1
|
|
|
|
#define DISCORD_REPLY_IGNORE 2
|
|
|
|
|
2017-07-31 22:58:39 +00:00
|
|
|
DISCORD_EXPORT void Discord_Initialize(const char* applicationId,
|
|
|
|
DiscordEventHandlers* handlers,
|
2017-08-30 22:17:47 +00:00
|
|
|
int autoRegister,
|
|
|
|
const char* optionalSteamId);
|
2017-10-12 23:08:08 +00:00
|
|
|
DISCORD_EXPORT void Discord_Shutdown(void);
|
2017-06-29 15:58:38 +00:00
|
|
|
|
2017-07-07 16:41:20 +00:00
|
|
|
/* checks for incoming messages, dispatches callbacks */
|
2017-10-12 23:08:08 +00:00
|
|
|
DISCORD_EXPORT void Discord_RunCallbacks(void);
|
2017-07-18 16:47:33 +00:00
|
|
|
|
|
|
|
/* If you disable the lib starting its own io thread, you'll need to call this from your own */
|
|
|
|
#ifdef DISCORD_DISABLE_IO_THREAD
|
2017-10-12 23:08:08 +00:00
|
|
|
DISCORD_EXPORT void Discord_UpdateConnection(void);
|
2017-07-18 16:47:33 +00:00
|
|
|
#endif
|
2017-07-07 16:41:20 +00:00
|
|
|
|
2017-07-31 22:58:39 +00:00
|
|
|
DISCORD_EXPORT void Discord_UpdatePresence(const DiscordRichPresence* presence);
|
2018-01-06 00:56:08 +00:00
|
|
|
DISCORD_EXPORT void Discord_ClearPresence(void);
|
2017-07-20 22:59:15 +00:00
|
|
|
|
2017-10-12 20:06:55 +00:00
|
|
|
DISCORD_EXPORT void Discord_Respond(const char* userid, /* DISCORD_REPLY_ */ int reply);
|
|
|
|
|
2018-03-23 17:25:28 +00:00
|
|
|
DISCORD_EXPORT void Discord_UpdateHandlers(DiscordEventHandlers* handlers);
|
|
|
|
|
2017-07-25 16:27:48 +00:00
|
|
|
#ifdef __cplusplus
|
2017-06-30 21:31:48 +00:00
|
|
|
} /* extern "C" */
|
|
|
|
#endif
|