Skip to content
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 presence ioctlv to /dev/dolphin #10940

Merged
merged 1 commit into from Aug 7, 2022

Conversation

InvoxiPlayGames
Copy link
Contributor

This adds ioctlvs to /dev/dolphin that allows a game mod or homebrew running under Dolphin to set custom Discord rich presence client IDs and statuses. This can be used for mods to show more context about what's being done in-game (what stage/track/song is being played in-game, the user's current star/coin progress, etc) to the user's Discord status.

The basic flow is as follows:

  • Guest Wii software calls IOCTL_DOLPHIN_DISCORD_SET_CLIENT on /dev/dolphin with input vector 0 set to the Discord client ID.
  • The Wii software then can call IOCTL_DOLPHIN_DISCORD_SET_PRESENCE, providing each input value (aside from party ID and secrets) as 10 individual input vectors.
  • When Dolphin next loads a title or closes the game, the original Dolphin client ID is re-applied along with the original presence information.
  • The Wii software can call IOCTL_DOLPHIN_DISCORD_RESET to reset the Discord rich presence to the default.

If guest software attempts to call IOCTL_DOLPHIN_DISCORD_SET_PRESENCE without setting a client ID, it will fail with IPC_EACCES, as will all of the requests if Discord status is disabled in Dolphin's configuration.

For testing and example purposes, I've made a quick homebrew application that makes the set client + set presence requests: https://github.com/InvoxiPlayGames/dolphin-discord-test

@Pokechu22
Copy link
Contributor

This is a neat idea, and certainly seems like something that would be useful to have in /dev/dolphin.

There are some formatting issues (see the lint builder output, and also check contributing.md for notes on variable name conventions), but the actual logic looks reasonable. I don't have much experience with the discord code myself though.

There are a few link issues with the unittests project (which does not have a dependency on UICommon, where DiscordPresence.cpp resides). I'm not sure what the best approach for fixing that is.

@phire
Copy link
Member

phire commented Aug 3, 2022

We don't want to make core dependant on UICommon

Might need to introduce a Host_UpdateDiscordPresence() function, along the same lines of other host functions like Host_UpdateTitle()

@InvoxiPlayGames
Copy link
Contributor Author

There are a few link issues with the unittests project (which does not have a dependency on UICommon, where DiscordPresence.cpp resides). I'm not sure what the best approach for fixing that is.

I was going to approach this by adding USE_DISCORD_PRESENCE as a compile time flag passed to core (like it is to UICommon), which would prevent calls to DiscordPresence existing in core at compile time, but that would still mean there is a situation where core depends on UICommon to build.

@phire
Copy link
Member

phire commented Aug 3, 2022

Even if you can get it building with our current set of targets (because static libraries don't correctly block implicit dependencies), I'm going to have to insist that you don't introduce a dependency from Core to UICommon.

Host_ methods is the way dolphin has traditionally dealt with such issues, but a callback system where core has a few std:function<void()> UpdateDiscordPresence; callbacks that UI common can set on discord presence startup might be easier.

@phire
Copy link
Member

phire commented Aug 5, 2022

Could you squash these down to just one or two commits?

Other than that, this looks fine to me.

@phire phire merged commit 4c2d707 into dolphin-emu:master Aug 7, 2022
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants