Qt: Add time elapsed to Discord Rich Presence (closes #2225)

This commit is contained in:
Vicki Pfau 2021-06-28 15:41:58 -07:00
parent d9627e3623
commit e3ad33366b
2 changed files with 8 additions and 0 deletions

View File

@ -7,6 +7,7 @@ Features:
- Cheat code support in homebrew ports - Cheat code support in homebrew ports
- Support for combo "Super Game Boy Color" SGB + GBC ROM hacks - Support for combo "Super Game Boy Color" SGB + GBC ROM hacks
- Support for 64 kiB SRAM saves used in some bootlegs - Support for 64 kiB SRAM saves used in some bootlegs
- Discord Rich Presence now supports time elapsed
- Additional scaling shaders - Additional scaling shaders
Emulation fixes: Emulation fixes:
- GB Memory: Add cursory cartridge open bus emulation (fixes mgba.io/i/2032) - GB Memory: Add cursory cartridge open bus emulation (fixes mgba.io/i/2032)

View File

@ -5,6 +5,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "DiscordCoordinator.h" #include "DiscordCoordinator.h"
#include <QDateTime>
#include "CoreController.h" #include "CoreController.h"
#include "GBAApp.h" #include "GBAApp.h"
@ -31,6 +33,11 @@ static void updatePresence() {
discordPresence.details = s_title.toUtf8().constData(); discordPresence.details = s_title.toUtf8().constData();
discordPresence.instance = 1; discordPresence.instance = 1;
discordPresence.largeImageKey = "mgba"; discordPresence.largeImageKey = "mgba";
#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
discordPresence.startTimestamp = QDateTime::currentSecsSinceEpoch();
#else
discordPresence.startTimestamp = QDateTime::currentMSecsSinceEpoch() / 1000;
#endif
Discord_UpdatePresence(&discordPresence); Discord_UpdatePresence(&discordPresence);
} else { } else {
Discord_ClearPresence(); Discord_ClearPresence();