discord_rpc.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #pragma once
  2. #include <stdint.h>
  3. // clang-format off
  4. #if defined(DISCORD_DYNAMIC_LIB)
  5. # if defined(_WIN32)
  6. # if defined(DISCORD_BUILDING_SDK)
  7. # define DISCORD_EXPORT __declspec(dllexport)
  8. # else
  9. # define DISCORD_EXPORT __declspec(dllimport)
  10. # endif
  11. # else
  12. # define DISCORD_EXPORT __attribute__((visibility("default")))
  13. # endif
  14. #else
  15. # define DISCORD_EXPORT
  16. #endif
  17. // clang-format on
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. typedef struct DiscordRichPresence {
  22. const char* state; /* max 128 bytes */
  23. const char* details; /* max 128 bytes */
  24. int64_t startTimestamp;
  25. int64_t endTimestamp;
  26. const char* largeImageKey; /* max 32 bytes */
  27. const char* largeImageText; /* max 128 bytes */
  28. const char* smallImageKey; /* max 32 bytes */
  29. const char* smallImageText; /* max 128 bytes */
  30. const char* partyId; /* max 128 bytes */
  31. int partySize;
  32. int partyMax;
  33. const char* matchSecret; /* max 128 bytes */
  34. const char* joinSecret; /* max 128 bytes */
  35. const char* spectateSecret; /* max 128 bytes */
  36. int8_t instance;
  37. } DiscordRichPresence;
  38. typedef struct DiscordUser {
  39. const char* userId;
  40. const char* username;
  41. const char* discriminator;
  42. const char* avatar;
  43. } DiscordUser;
  44. typedef struct DiscordEventHandlers {
  45. void (*ready)(const DiscordUser* request);
  46. void (*disconnected)(int errorCode, const char* message);
  47. void (*errored)(int errorCode, const char* message);
  48. void (*joinGame)(const char* joinSecret);
  49. void (*spectateGame)(const char* spectateSecret);
  50. void (*joinRequest)(const DiscordUser* request);
  51. } DiscordEventHandlers;
  52. #define DISCORD_REPLY_NO 0
  53. #define DISCORD_REPLY_YES 1
  54. #define DISCORD_REPLY_IGNORE 2
  55. DISCORD_EXPORT void Discord_Initialize(const char* applicationId,
  56. DiscordEventHandlers* handlers,
  57. int autoRegister,
  58. const char* optionalSteamId);
  59. DISCORD_EXPORT void Discord_Shutdown(void);
  60. /* checks for incoming messages, dispatches callbacks */
  61. DISCORD_EXPORT void Discord_RunCallbacks(void);
  62. /* If you disable the lib starting its own io thread, you'll need to call this from your own */
  63. #ifdef DISCORD_DISABLE_IO_THREAD
  64. DISCORD_EXPORT void Discord_UpdateConnection(void);
  65. #endif
  66. DISCORD_EXPORT void Discord_UpdatePresence(const DiscordRichPresence* presence);
  67. DISCORD_EXPORT void Discord_ClearPresence(void);
  68. DISCORD_EXPORT void Discord_Respond(const char* userid, /* DISCORD_REPLY_ */ int reply);
  69. DISCORD_EXPORT void Discord_UpdateHandlers(DiscordEventHandlers* handlers);
  70. #ifdef __cplusplus
  71. } /* extern "C" */
  72. #endif