Skip to content
This repository has been archived by the owner on Jul 10, 2023. It is now read-only.

Discord Rich Presence #1883

Open
wants to merge 11 commits into
base: alpha
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "libswirl/deps/discord_game_sdk"]
path = libswirl/deps/discord_game_sdk
url = https://github.com/Kamaropoulos/discord_game_sdk.git
28 changes: 28 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ file(GLOB lelf_SRCS ${d_deps}/libelf/el*.cpp)
file(GLOB crypt_SRCS ${d_deps}/crypto/*.cpp)
file(GLOB imgui_SRCS ${d_deps}/imgui/*.cpp)
file(GLOB lua_SRCS ${d_deps}/lua/*.c)
file(GLOB discord_SRCS ${d_deps}/discord_game_sdk/cpp/*.cpp)

file(GLOB picoModS ${gpl_deps}/picotcp/modules/*.c)
file(GLOB picoStkS ${gpl_deps}/picotcp/stack/*.c)
Expand All @@ -177,6 +178,7 @@ set(deps_SRCS
${crypt_SRCS}
${imgui_SRCS}
${lua_SRCS}
${discord_SRCS}
${gpl_deps}/xbrz/xbrz.cpp
${d_deps}/xxhash/xxhash.c
${d_deps}/cdipsr/cdipsr.cpp
Expand Down Expand Up @@ -262,6 +264,32 @@ set(reicast_SRCS ${core_SRCS} ${deps_SRCS} ${osd_SRCS})

add_executable(${TNAME}${binSuffix} ${reicast_SRCS} ${deps_SRCS})

# Discord
set(has_discord_sdk (${HOST_CPU} EQUAL ${CPU_X64} OR ${HOST_CPU} EQUAL ${CPU_X86}) AND NOT ${HOST_OS} EQUAL ${OS_ANDROID})
if(has_discord_sdk)
# SDK
set(d_discord_sdk "${d_core}/deps/discord_game_sdk")
if(${HOST_CPU} EQUAL ${CPU_X64})
find_library(discord_LIB NAMES discord_game_sdk${CMAKE_SHARED_LIBRARY_SUFFIX} HINTS "${d_discord_sdk}/lib/x86_64")
if(${HOST_OS} EQUAL ${OS_WINDOWS})
configure_file("${d_discord_sdk}/lib/x86_64/discord_game_sdk.dll" discord_game_sdk.dll COPYONLY)
else()
configure_file(${discord_LIB} discord_game_sdk${CMAKE_SHARED_LIBRARY_SUFFIX} COPYONLY)
endif()
elseif(${HOST_CPU} EQUAL ${CPU_X86})
find_library(discord_LIB NAMES discord_game_sdk${CMAKE_SHARED_LIBRARY_SUFFIX} HINTS "${d_discord_sdk}/lib/x86")
if(${HOST_OS} EQUAL ${OS_WINDOWS})
configure_file("${d_discord_sdk}/lib/x86/discord_game_sdk.dll" discord_game_sdk.dll COPYONLY)
endif()
endif()
target_include_directories(${TNAME}${binSuffix} PRIVATE "${d_discord_sdk}/cpp")
target_include_directories(${TNAME}${binSuffix} PRIVATE "${d_discord_rp}")
target_link_libraries(${TNAME}${binSuffix} ${discord_LIB})
# Rich Presence Utility
set(d_discord_rp "${d_core}/utils/discord")

endif()

target_compile_features(${TNAME}${binSuffix} PRIVATE cxx_std_14)

if(${HOST_OS} EQUAL ${OS_LINUX})
Expand Down
13 changes: 13 additions & 0 deletions libswirl/deps/discord_game_sdk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## Discord Game SDK

> The SDK is currently under extensive development and is subject to change. Suggestions
> about the current API are welcome.

### Setup

- Create an application on the Discord [developer site](https://discordapp.com/developers/applications/me).
- Set a redirect URL. If you don't have one right now, just use <http://127.0.0.1>.
- Enable Rich Presence for the application. This enables whitelist access for the SDK.
- When you are ready to test with more people, add them to the whitelist.
- Copy the **Client ID**.
- Use this `CLIENT_ID` when initializing the SDK.
Loading