From e34378a1c15e2530c91a849cd0e2d04e7221bb61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 18 Aug 2018 10:11:15 +0200 Subject: [PATCH 1/2] Enable Discord integration for Mac and Linux. --- CMakeLists.txt | 3 +++ GPU/Common/ShaderTranslation.cpp | 4 ++-- UI/DiscordIntegration.cpp | 5 +++-- ext/CMakeLists.txt | 1 + ext/discord-rpc-build/CMakeLists.txt | 30 ++++++++++++++++++++++++++++ 5 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 ext/discord-rpc-build/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 010b77f441c1..459ad3ee3821 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1757,6 +1757,9 @@ if(FFmpeg_FOUND) ) endif() +# Discord integration +target_link_libraries(${CoreLibName} discord-rpc) + setup_target_project(${CoreLibName} Core) # Generate git-version.cpp at build time. diff --git a/GPU/Common/ShaderTranslation.cpp b/GPU/Common/ShaderTranslation.cpp index b253a96f6b34..862ba286c64b 100644 --- a/GPU/Common/ShaderTranslation.cpp +++ b/GPU/Common/ShaderTranslation.cpp @@ -310,7 +310,7 @@ bool TranslateShader(std::string *dest, ShaderLanguage destLang, TranslatedShade spirv_cross::CompilerGLSL::Options options; options.version = 140; options.es = true; - glsl.set_options(options); + glsl.set_common_options(options); // Compile to GLSL, ready to give to GL driver. *dest = glsl.compile(); @@ -324,7 +324,7 @@ bool TranslateShader(std::string *dest, ShaderLanguage destLang, TranslatedShade // Set some options. spirv_cross::CompilerGLSL::Options options; options.version = gl_extensions.GLSLVersion(); - glsl.set_options(options); + glsl.set_common_options(options); // Compile to GLSL, ready to give to GL driver. *dest = glsl.compile(); return true; diff --git a/UI/DiscordIntegration.cpp b/UI/DiscordIntegration.cpp index cc5b21b0cb78..54ee337e3fd5 100644 --- a/UI/DiscordIntegration.cpp +++ b/UI/DiscordIntegration.cpp @@ -7,7 +7,7 @@ #include "DiscordIntegration.h" #include "i18n/i18n.h" -#ifdef _WIN32 +#if (PPSSPP_PLATFORM(WINDOWS) || PPSSPP_PLATFORM(MAC) || PPSSPP_PLATFORM(LINUX)) && !PPSSPP_PLATFORM(ANDROID) #define ENABLE_DISCORD @@ -29,7 +29,7 @@ static const char *ppsspp_app_id = "423397985041383434"; // No context argument? What? static void handleDiscordError(int errCode, const char *message) { - ERROR_LOG(SYSTEM, "Discord error code %d: '%s'", message); + ERROR_LOG(SYSTEM, "Discord error code %d: '%s'", errCode, message); } Discord::~Discord() { @@ -48,6 +48,7 @@ void Discord::Init() { DiscordEventHandlers eventHandlers{}; eventHandlers.errored = &handleDiscordError; Discord_Initialize(ppsspp_app_id, &eventHandlers, 0, nullptr); + INFO_LOG(SYSTEM, "Discord connection initialized"); #endif initialized_ = true; diff --git a/ext/CMakeLists.txt b/ext/CMakeLists.txt index f506eb6787b4..4a6b8e45a3ce 100644 --- a/ext/CMakeLists.txt +++ b/ext/CMakeLists.txt @@ -12,3 +12,4 @@ add_subdirectory(glslang) add_subdirectory(snappy) add_subdirectory(udis86) add_subdirectory(SPIRV-Cross-build) +add_subdirectory(discord-rpc-build) diff --git a/ext/discord-rpc-build/CMakeLists.txt b/ext/discord-rpc-build/CMakeLists.txt new file mode 100644 index 000000000000..4417fd728221 --- /dev/null +++ b/ext/discord-rpc-build/CMakeLists.txt @@ -0,0 +1,30 @@ +cmake_minimum_required (VERSION 3.2.0) +project (DiscordRPC) + +set(SRC_DIR ../discord-rpc/src) + + +# format +set(ALL_SOURCE_FILES + ${SRC_DIR}/backoff.h + ${SRC_DIR}/connection.h + ${SRC_DIR}/msg_queue.h + ${SRC_DIR}/rpc_connection.h + ${SRC_DIR}/serialization.h + ${SRC_DIR}/discord_rpc.cpp + ${SRC_DIR}/rpc_connection.cpp + ${SRC_DIR}/serialization.cpp + ${SRC_DIR}/discord_register_osx.m + ) + +if(WIN32) + set(ALL_SOURCE_FILES ${ALL_SOURCE_FILES} ${SRC_DIR}/connection_win.cpp) + set(ALL_SOURCE_FILES ${ALL_SOURCE_FILES} ${SRC_DIR}/discord_register_win.cpp) +else() + set(ALL_SOURCE_FILES ${ALL_SOURCE_FILES} ${SRC_DIR}/connection_unix.cpp) + set(ALL_SOURCE_FILES ${ALL_SOURCE_FILES} ${SRC_DIR}/discord_register_linux.cpp) +endif() + +add_library(discord-rpc STATIC ${ALL_SOURCE_FILES}) + +target_include_directories(discord-rpc PUBLIC ../discord-rpc/src ../discord-rpc/include ../rapidjson/include) From 529b8c602594dbdbe5539441f1f415ff3866872b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 26 Aug 2018 23:10:37 +0200 Subject: [PATCH 2/2] Untested attempt to fix ios/mac discord (no machines around right now) --- CMakeLists.txt | 2 ++ ext/CMakeLists.txt | 2 ++ ext/discord-rpc-build/CMakeLists.txt | 7 ++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 459ad3ee3821..f7727f88d0a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1758,7 +1758,9 @@ if(FFmpeg_FOUND) endif() # Discord integration +if(NOT IOS) target_link_libraries(${CoreLibName} discord-rpc) +endif() setup_target_project(${CoreLibName} Core) diff --git a/ext/CMakeLists.txt b/ext/CMakeLists.txt index 4a6b8e45a3ce..ade6594e8f97 100644 --- a/ext/CMakeLists.txt +++ b/ext/CMakeLists.txt @@ -12,4 +12,6 @@ add_subdirectory(glslang) add_subdirectory(snappy) add_subdirectory(udis86) add_subdirectory(SPIRV-Cross-build) +if(NOT IOS) add_subdirectory(discord-rpc-build) +endif() diff --git a/ext/discord-rpc-build/CMakeLists.txt b/ext/discord-rpc-build/CMakeLists.txt index 4417fd728221..a63ec8eecf5c 100644 --- a/ext/discord-rpc-build/CMakeLists.txt +++ b/ext/discord-rpc-build/CMakeLists.txt @@ -14,9 +14,14 @@ set(ALL_SOURCE_FILES ${SRC_DIR}/discord_rpc.cpp ${SRC_DIR}/rpc_connection.cpp ${SRC_DIR}/serialization.cpp - ${SRC_DIR}/discord_register_osx.m ) +if(APPLE) + set(ALL_SOURCE_FILES ${ALL_SOURCE_FILES} + ${SRC_DIR}/discord_register_osx.m + ) +endif() + if(WIN32) set(ALL_SOURCE_FILES ${ALL_SOURCE_FILES} ${SRC_DIR}/connection_win.cpp) set(ALL_SOURCE_FILES ${ALL_SOURCE_FILES} ${SRC_DIR}/discord_register_win.cpp)