diff --git a/discord/CMakeLists.txt b/discord/CMakeLists.txt index 7d9f5668..0d107ee5 100644 --- a/discord/CMakeLists.txt +++ b/discord/CMakeLists.txt @@ -4,9 +4,9 @@ project(discord) if (MSVC) set(CMAKE_CXX_FLAGS "-O2 /std:c++17 /EHsc") elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") - set(CMAKE_CXX_FLAGS "-O3 -std=c++17 -Wno-unused-command-line-argument -undefined dynamic_lookup") + set(CMAKE_CXX_FLAGS "-O3 -std=c++17 -Wno-unused-command-line-argument -undefined dynamic_lookup -fPIC") else () - set(CMAKE_CXX_FLAGS "-O3 -std=c++17") + set(CMAKE_CXX_FLAGS "-O3 -std=c++17 -fPIC") endif () file(GLOB SRC "src/*.cpp") @@ -16,7 +16,7 @@ include_directories("src/" "discord-rpc/include") add_subdirectory("discord-rpc") add_library(discord SHARED ${SRC}) -target_link_libraries(discord PRIVATE sdrpp_core) +target_link_libraries(discord PUBLIC sdrpp_core discord-rpc) set_target_properties(discord PROPERTIES PREFIX "") # Install directives diff --git a/discord/src/main.cpp b/discord/src/main.cpp index 681a7e67..1066bdc3 100644 --- a/discord/src/main.cpp +++ b/discord/src/main.cpp @@ -15,11 +15,28 @@ SDRPP_MOD_INFO { /* Max instances */ -1 }; +static DiscordRichPresence presence; + class PresenceModule : public ModuleManager::Instance { public: PresenceModule(std::string name) { this->name = name; gui::menu.registerEntry(name, menuHandler, this, this); + + // Discord initialization + DiscordEventHandlers handlers; + memset(&handlers, 0, sizeof(handlers)); + memset(&presence, 0, sizeof(presence)); + Discord_Initialize("833485588954742864", &handlers, 1, ""); + + // Set the first presence + presence.state = "Loading..."; + presence.details = "Initializing rich presence..."; + presence.partySize = 1; + presence.partyMax = 1; + presence.startTimestamp = time(0); + presence.largeImageKey = "image_large"; + Discord_UpdatePresence(&presence); } ~PresenceModule() {