mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-02 22:28:45 +00:00
fix discord rpc
This commit is contained in:
parent
398019867b
commit
39b98fcfda
10 changed files with 54 additions and 16 deletions
|
@ -361,6 +361,8 @@ set(COMMON src/common/logging/backend.cpp
|
||||||
src/common/debug.h
|
src/common/debug.h
|
||||||
src/common/decoder.cpp
|
src/common/decoder.cpp
|
||||||
src/common/decoder.h
|
src/common/decoder.h
|
||||||
|
src/common/discord.h
|
||||||
|
src/common/discord.cpp
|
||||||
src/common/elf_info.h
|
src/common/elf_info.h
|
||||||
src/common/endian.h
|
src/common/endian.h
|
||||||
src/common/enum.h
|
src/common/enum.h
|
||||||
|
@ -838,4 +840,9 @@ if (UNIX AND NOT APPLE)
|
||||||
find_package(OpenSSL REQUIRED)
|
find_package(OpenSSL REQUIRED)
|
||||||
target_link_libraries(shadps4 PRIVATE ${OPENSSL_LIBRARIES})
|
target_link_libraries(shadps4 PRIVATE ${OPENSSL_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
#Discord Lib
|
||||||
|
add_subdirectory(externals/discord-rpc)
|
||||||
|
target_link_libraries(shadps4 PRIVATE discord-rpc)
|
||||||
|
include_directories(externals/discord-rpc/include)
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"configurationType": "Release",
|
"configurationType": "Release",
|
||||||
"buildRoot": "${projectDir}\\Build\\${name}",
|
"buildRoot": "${projectDir}\\Build\\${name}",
|
||||||
"installRoot": "${projectDir}\\Install\\${name}",
|
"installRoot": "${projectDir}\\Install\\${name}",
|
||||||
"cmakeCommandArgs": "",
|
"cmakeCommandArgs": "-DENABLE_QT_GUI=ON -DCMAKE_PREFIX_PATH=C:\\Qt\\6.7.3\\msvc2019_64",
|
||||||
"buildCommandArgs": "",
|
"buildCommandArgs": "",
|
||||||
"ctestCommandArgs": "",
|
"ctestCommandArgs": "",
|
||||||
"inheritEnvironments": [ "clang_cl_x64_x64" ],
|
"inheritEnvironments": [ "clang_cl_x64_x64" ],
|
||||||
|
|
3
externals/CMakeLists.txt
vendored
3
externals/CMakeLists.txt
vendored
|
@ -182,4 +182,5 @@ add_subdirectory(tracy)
|
||||||
# pugixml
|
# pugixml
|
||||||
if (NOT TARGET pugixml::pugixml)
|
if (NOT TARGET pugixml::pugixml)
|
||||||
add_subdirectory(pugixml)
|
add_subdirectory(pugixml)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
1
externals/discord-rpc
vendored
Submodule
1
externals/discord-rpc
vendored
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 963aa9f3e5ce81a4682c6ca3d136cddda614db33
|
|
@ -4,30 +4,43 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include "common/discord.h"
|
#include "common/discord.h"
|
||||||
|
#include "logging/log.h"
|
||||||
|
#include "common/debug.h"
|
||||||
namespace Discord {
|
namespace Discord {
|
||||||
|
|
||||||
void RPC::init() {
|
void RPC::init() {
|
||||||
DiscordEventHandlers handlers{};
|
DiscordEventHandlers handlers{};
|
||||||
Discord_Initialize("1139939140494971051", &handlers, 1, nullptr);
|
std::string discordAppId = "1290207945476280360";
|
||||||
|
Discord_Initialize(discordAppId.c_str(), &handlers, 1, nullptr);
|
||||||
|
LOG_INFO(Loader, "Discord RPC Initalized with App Id: {}", discordAppId);
|
||||||
startTimestamp = time(nullptr);
|
startTimestamp = time(nullptr);
|
||||||
enabled = true;
|
enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RPC::update(Discord::RPCStatus status, const std::string& game) {
|
void RPC::updatePlaying(const std::string& game, const std::string& game_id) {
|
||||||
DiscordRichPresence rpc{};
|
DiscordRichPresence rpc{};
|
||||||
|
|
||||||
if (status == Discord::RPCStatus::Playing) {
|
rpc.details = "Playing a game";
|
||||||
rpc.details = "Playing a game";
|
rpc.state = game.c_str();
|
||||||
rpc.state = game.c_str();
|
std::string largeImageUrl =
|
||||||
} else {
|
"https://store.playstation.com/store/api/chihiro/00_09_000/titlecontainer/US/en/999/" +
|
||||||
rpc.details = "Idle";
|
game_id + "_00/image";
|
||||||
}
|
rpc.largeImageKey = largeImageUrl.c_str();
|
||||||
|
rpc.largeImageText = game.c_str();
|
||||||
|
rpc.startTimestamp = startTimestamp;
|
||||||
|
LOG_INFO(Loader, "Found game. Name: {}, Id: {}", game.c_str(), game_id.c_str());
|
||||||
|
|
||||||
|
|
||||||
|
Discord_UpdatePresence(&rpc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RPC::updateIdle() {
|
||||||
|
|
||||||
|
DiscordRichPresence rpc{};
|
||||||
rpc.largeImageKey = "shadps4";
|
rpc.largeImageKey = "shadps4";
|
||||||
rpc.largeImageText = "ShadPS4 is a PS4 emulator";
|
rpc.largeImageText = "ShadPS4 is a PS4 emulator";
|
||||||
rpc.startTimestamp = startTimestamp;
|
rpc.startTimestamp = startTimestamp;
|
||||||
|
rpc.details = "Idle";
|
||||||
|
|
||||||
Discord_UpdatePresence(&rpc);
|
Discord_UpdatePresence(&rpc);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,8 @@ class RPC {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void init();
|
void init();
|
||||||
void update(RPCStatus status, const std::string& title);
|
void updatePlaying(const std::string& title, const std::string& game_id);
|
||||||
|
void updateIdle();
|
||||||
void stop();
|
void stop();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include "core/memory.h"
|
#include "core/memory.h"
|
||||||
#include "emulator.h"
|
#include "emulator.h"
|
||||||
#include "video_core/renderdoc.h"
|
#include "video_core/renderdoc.h"
|
||||||
|
#include "common/discord.h"
|
||||||
|
|
||||||
Frontend::WindowSDL* g_window = nullptr;
|
Frontend::WindowSDL* g_window = nullptr;
|
||||||
|
|
||||||
|
@ -210,6 +211,11 @@ void Emulator::Run(const std::filesystem::path& file) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Discord RPC
|
||||||
|
Discord::RPC rpc;
|
||||||
|
/*rpc.init();*/
|
||||||
|
rpc.updatePlaying(game_info.title, id);
|
||||||
|
|
||||||
// start execution
|
// start execution
|
||||||
std::jthread mainthread =
|
std::jthread mainthread =
|
||||||
std::jthread([this](std::stop_token stop_token) { linker->Execute(); });
|
std::jthread([this](std::stop_token stop_token) { linker->Execute(); });
|
||||||
|
|
|
@ -34,6 +34,6 @@ int main(int argc, char* argv[]) {
|
||||||
|
|
||||||
Core::Emulator emulator;
|
Core::Emulator emulator;
|
||||||
emulator.Run(argv[1]);
|
emulator.Run(argv[1]);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "emulator.h"
|
#include "emulator.h"
|
||||||
#include "game_install_dialog.h"
|
#include "game_install_dialog.h"
|
||||||
#include "main_window.h"
|
#include "main_window.h"
|
||||||
|
#include "common/discord.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
@ -55,6 +56,11 @@ int main(int argc, char* argv[]) {
|
||||||
emulator.Run(argv[1]);
|
emulator.Run(argv[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Initialize Discord RPC
|
||||||
|
Discord::RPC rpc;
|
||||||
|
rpc.init();
|
||||||
|
rpc.updateIdle();
|
||||||
|
|
||||||
// Run the Qt application
|
// Run the Qt application
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "input/controller.h"
|
#include "input/controller.h"
|
||||||
#include "sdl_window.h"
|
#include "sdl_window.h"
|
||||||
#include "video_core/renderdoc.h"
|
#include "video_core/renderdoc.h"
|
||||||
|
#include "common/discord.h"
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <SDL3/SDL_metal.h>
|
#include <SDL3/SDL_metal.h>
|
||||||
|
@ -73,7 +74,7 @@ WindowSDL::WindowSDL(s32 width_, s32 height_, Input::GameController* controller_
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowSDL::~WindowSDL() = default;
|
WindowSDL::~WindowSDL() = default;
|
||||||
|
Discord::RPC rpc;
|
||||||
void WindowSDL::waitEvent() {
|
void WindowSDL::waitEvent() {
|
||||||
// Called on main thread
|
// Called on main thread
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
|
@ -112,6 +113,8 @@ void WindowSDL::waitEvent() {
|
||||||
onGamepadEvent(&event);
|
onGamepadEvent(&event);
|
||||||
break;
|
break;
|
||||||
case SDL_EVENT_QUIT:
|
case SDL_EVENT_QUIT:
|
||||||
|
rpc.init();
|
||||||
|
rpc.updateIdle();
|
||||||
is_open = false;
|
is_open = false;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue