discord_rpc.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. int partyPrivacy;
  34. const char* matchSecret; /* max 128 bytes */
  35. const char* joinSecret; /* max 128 bytes */
  36. const char* spectateSecret; /* max 128 bytes */
  37. int8_t instance;
  38. } DiscordRichPresence;
  39. typedef struct DiscordUser {
  40. const char* userId;
  41. const char* username;
  42. const char* discriminator;
  43. const char* avatar;
  44. } DiscordUser;
  45. typedef struct DiscordEventHandlers {
  46. void (*ready)(const DiscordUser* request);
  47. void (*disconnected)(int errorCode, const char* message);
  48. void (*errored)(int errorCode, const char* message);
  49. void (*joinGame)(const char* joinSecret);
  50. void (*spectateGame)(const char* spectateSecret);
  51. void (*joinRequest)(const DiscordUser* request);
  52. } DiscordEventHandlers;
  53. #define DISCORD_REPLY_NO 0
  54. #define DISCORD_REPLY_YES 1
  55. #define DISCORD_REPLY_IGNORE 2
  56. #define DISCORD_PARTY_PRIVATE 0
  57. #define DISCORD_PARTY_PUBLIC 1
  58. DISCORD_EXPORT void Discord_Initialize(const char* applicationId,
  59. DiscordEventHandlers* handlers,
  60. int autoRegister,
  61. const char* optionalSteamId);
  62. DISCORD_EXPORT void Discord_Shutdown(void);
  63. /* checks for incoming messages, dispatches callbacks */
  64. DISCORD_EXPORT void Discord_RunCallbacks(void);
  65. /* If you disable the lib starting its own io thread, you'll need to call this from your own */
  66. #ifdef DISCORD_DISABLE_IO_THREAD
  67. DISCORD_EXPORT void Discord_UpdateConnection(void);
  68. #endif
  69. DISCORD_EXPORT void Discord_UpdatePresence(const DiscordRichPresence* presence);
  70. DISCORD_EXPORT void Discord_ClearPresence(void);
  71. DISCORD_EXPORT void Discord_Respond(const char* userid, /* DISCORD_REPLY_ */ int reply);
  72. DISCORD_EXPORT void Discord_UpdateHandlers(DiscordEventHandlers* handlers);
  73. #ifdef __cplusplus
  74. } /* extern "C" */
  75. #endif