-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Discord Rich Presence support #6983
Add Discord Rich Presence support #6983
Conversation
@dolphin-emu-bot rebuild |
Sorry but as this is, I can't agree with merging this feature to the codebase. This doesn't belong in the core library of Dolphin. This should be entirely driven by the frontends or put in UICommon. I also do not think this is really worth adding yet-another-dependency or yet-another-external to Dolphin for (IMO). |
I can understand that. I'll figure how to move it over to UICommon or you can close it and I'll not argue with you about it. |
I'm sure other devs will have opinions on it, so UICommon would likely be better for now |
Posting this for @delroth, another maintainer, who currently can't access GitHub, but does have access to IRC:
and the join party thing was something I actually didn't think about, which does sound nice to have, so I've changed my opinion on the matter. |
Source/Core/Core/DiscordPresence.cpp
Outdated
void Init() | ||
{ | ||
DiscordEventHandlers handlers = {0}; | ||
Discord_Initialize("450033159212630028", &handlers, 1, NULL); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did a basic review on minor things that can be changed
Source/Core/Core/DiscordPresence.cpp
Outdated
{ | ||
void Init() | ||
{ | ||
DiscordEventHandlers handlers = {0}; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Source/Core/Core/DiscordPresence.cpp
Outdated
discord_presence.largeImageKey = "dolphin_logo"; | ||
discord_presence.largeImageText = "Dolphin is an emulator for the GameCube and the Wii."; | ||
discord_presence.details = details.empty() ? "Not in-game" : details.c_str(); | ||
discord_presence.startTimestamp = time(0); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Source/Core/Core/DiscordPresence.cpp
Outdated
void UpdateDiscordPresence(const std::string& details) | ||
{ | ||
// update Discord RPC | ||
DiscordRichPresence discord_presence = {0}; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Source/Core/Core/DiscordPresence.h
Outdated
// Licensed under GPLv2+ | ||
// Refer to the license.txt file included. | ||
|
||
// Discord Presence |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Source/Core/Core/DiscordPresence.h
Outdated
@@ -0,0 +1,17 @@ | |||
// Copyright 2008 Dolphin Emulator Project |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Source/Core/Core/DiscordPresence.cpp
Outdated
@@ -0,0 +1,33 @@ | |||
// Copyright 2008 Dolphin Emulator Project |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Source/Core/Core/DiscordPresence.h
Outdated
// Adds support for Discord Rich Presence in to Dolphin | ||
|
||
#pragma once | ||
#include <string> |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Source/Core/Core/DiscordPresence.cpp
Outdated
Discord_Shutdown(); | ||
} | ||
|
||
} |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Source/Core/Core/DiscordPresence.h
Outdated
void Init(); | ||
void UpdateDiscordPresence(const std::string& details); | ||
void Shutdown(); | ||
} |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Source/Core/Core/DiscordPresence.cpp
Outdated
// Licensed under GPLv2+ | ||
// Refer to the license.txt file included. | ||
|
||
#include "DiscordPresence.h" |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Hey, thanks for tagging me in here, I can reply by email now! :)
From my side:
* +1 to the feature.
* I'll provide the client id we'll use in the final version to make sure the
project keeps proper ownership. For testing just continue using yours for
now.
* Definitely should be out of Core into either Common or UICommon, probably
the latter.
* We should put the source code in Externals, not binaries.
* On Linux / MacOS there should be a compile time flag to not include this
integration. Can probably be enabled by default though.
* Not sure if there should be an option in Dolphin to disable this. There
is an option in discord to disable "now playing", and I can't think of why
someone would want to show dolphin but not the game they're playing. Maybe
JMC47 wants to hide his Sexy Poker addiction...
Haven't looked at the implementation yet, so high level comments only.
Thanks for the contribution!
|
I would never hide my sexy poker addiction. |
Source/Core/Core/ConfigManager.cpp
Outdated
@@ -728,12 +729,14 @@ void SConfig::SetRunningGameMetadata(const std::string& game_id, u64 title_id, u | |||
if (game_id == "00000000") | |||
{ | |||
m_title_description.clear(); | |||
Discord::UpdateDiscordPresence(m_title_description); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
// Licensed under GPLv2+ | ||
// Refer to the license.txt file included. | ||
|
||
#include "UICommon/DiscordPresence.h" |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
{ | ||
DiscordEventHandlers handlers = {}; | ||
// The number is the client ID for Dolphin, it's used for images and the appication name | ||
Discord_Initialize("450033159212630028", &handlers, 1, NULL); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
// Licensed under GPLv2+ | ||
// Refer to the license.txt file included. | ||
|
||
// Adds support for Discord Rich Presence in to Dolphin |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
||
#pragma once | ||
|
||
#include <string> |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
discord_presence.largeImageKey = "dolphin_logo"; | ||
discord_presence.largeImageText = "Dolphin is an emulator for the GameCube and the Wii."; | ||
discord_presence.details = title.empty() ? "Not in-game" : title.c_str(); | ||
discord_presence.startTimestamp = time(nullptr); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we provide a CMake option for enabling / disabling this?
Source/Core/UICommon/UICommon.cpp
Outdated
@@ -91,6 +93,7 @@ void Shutdown() | |||
VideoBackendBase::ClearList(); | |||
LogManager::Shutdown(); | |||
SConfig::Shutdown(); | |||
Discord::Shutdown(); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@@ -35,6 +35,16 @@ | |||
<Import Project="..\..\VSProps\PCHUse.props" /> | |||
</ImportGroup> | |||
<PropertyGroup Label="UserMacros" /> | |||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Generally, putting binaries into git / linking against precompiled libs sucks. |
why is this being done with a precompiled binary, corrent me if i am wrong but the source code for this is here: https://github.com/discordapp/discord-rpc |
Yeah, I mentioned it in my previous comment (which somehow I can't figure out how to make readable... Markdown not working for some reason). It's very much a prerequisite for us merging this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is certainly missing all CMake integration as well to build on other platforms.
Source/Core/UICommon/CMakeLists.txt
Outdated
@@ -2,6 +2,7 @@ add_library(uicommon | |||
AutoUpdate.cpp | |||
CommandLineParse.cpp | |||
Disassembler.cpp | |||
DiscordPresence.cpp |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
💭 Maybe use a submodule for this? Unless we prefer the code copied over. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The option to enable / disable discord integration needs to be available for CMake as well.
I don't think we should have a submodule for this. We already have the source code for many libraries in Externals, and this one isn't an especially large one. |
Was just a random thought. I see pros and cons to both approaches; but it probably doesn't matter much for the...16 files (+/- some CMake) to be included right away. |
Also, another random thought from IRC: |
@yourWaifu Done. Also in the future I wonder if we should find some nice pictures for the top 20-50 games :) |
@delroth It still doesn't look right. This is what it looks like Also here's the logo I used. if you have a higher quality one, please use that one for people with higher scaling settings. |
eb6d580
to
cd2d5c4
Compare
@delroth It works now |
790ca07
to
29039ab
Compare
I just tested it working on Linux and Windows (All screenshots above were done in Windows) @connorshea I think the PR is almost ready, I think that I just need to figure out how to successfully pass all the checks without breaking anything. I don't have access to a computer running macOS so I would totally like you to test it. Open Dolphin while the Discord client is open, and it should show up on your profile. Also test to make sure that settings for this works and can be saved after closing. |
@yourWaifu took a bit to get things set up and compiled, but it works on macOS! :D Here's what it looks like when I'm actually in a game: |
Also just tested toggling the setting off and it persists when rebooting the emulator. 👍 |
@delroth Would there be any way of utilizing games' save icons or images of their discs (from gametdb.com) for Discord game icons? They would be low-resolution but for the many less popular games it would be better than nothing. |
@8times9 Discord placed a limit of 150 for the number of assets that you can upload to Discord. Plus they want you to do via their developer dashboard instead of an API as they don't document any other way to do so. Maybe in the future, they'll add it and then we may add icons for less popular games. I like the idea though. |
I'm not sure if you guys are ok with this so I'm asking about it here. I ran into the linker issue
that for some reason only happens on Linux and not Windows. I've done some testing a found that moving MAIN_USE_DISCORD_PRESENCE from UICommon and into Core fixes this issue. I did come up with a different soluation, ditching IsSettingSaveable since it's a temp solution and instead use a vector or list of savable settings, but I felt that would be outside the scope of this pull request. |
|
||
#include "Core/ConfigManager.h" | ||
|
||
const Config::ConfigInfo<bool> MAIN_USE_DISCORD_PRESENCE{ |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
void SetDiscordPresenceEnabled(bool enabled); | ||
} // namespace Discord | ||
|
||
extern const Config::ConfigInfo<bool> MAIN_USE_DISCORD_PRESENCE; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
#ifdef USE_DISCORD_PRESENCE | ||
// Main.General | ||
|
||
// for some reason clang-format didn't like the ifdef below the comment |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Source/Core/DolphinQt2/Settings.cpp
Outdated
@@ -19,6 +19,10 @@ | |||
#include "DolphinQt2/Settings.h" | |||
#include "InputCommon/InputConfig.h" | |||
|
|||
#ifdef USE_DISCORD_PRESENCE |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@@ -9,6 +9,9 @@ | |||
|
|||
#include "Common/Config/Config.h" | |||
#include "Core/Config/GraphicsSettings.h" | |||
#ifdef USE_DISCORD_PRESENCE | |||
#include "UICommon/DiscordPresence.h" |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
29039ab
to
0ba9f5b
Compare
I have no idea if this works or not. Hopefully the build bot will tell me.
0ba9f5b
to
63f0345
Compare
OK, I think this PR is ready to be merged. I think the WIP tag can be removed now. Unless there's something else that I need to do that I'm not aware of. |
There are a few things I'm not completely happy with (the commits ordering, the fact that we don't build from Externals on Windows and instead rely on prebuilts, etc.) but overall LGTM. This PR is getting too long to nitpick, so I'll merge it as is and hopefully people can just send followup fixes if they have objections. |
Now, |
@sboukortt Yes it was unintended and to be honest, I forgot about |
@yourWaifu It's easy to fix, change |
I thought Discord's Rich Presence would be a nice feature to add to Dolphin.
A few things though.
#ifdef
s around the code because of this, but I didn't want to in the case that they did work on macOS.