mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-04-22 04:24:44 +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/decoder.cpp
|
||||
src/common/decoder.h
|
||||
src/common/discord.h
|
||||
src/common/discord.cpp
|
||||
src/common/elf_info.h
|
||||
src/common/endian.h
|
||||
src/common/enum.h
|
||||
|
@ -838,4 +840,9 @@ if (UNIX AND NOT APPLE)
|
|||
find_package(OpenSSL REQUIRED)
|
||||
target_link_libraries(shadps4 PRIVATE ${OPENSSL_LIBRARIES})
|
||||
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",
|
||||
"buildRoot": "${projectDir}\\Build\\${name}",
|
||||
"installRoot": "${projectDir}\\Install\\${name}",
|
||||
"cmakeCommandArgs": "",
|
||||
"cmakeCommandArgs": "-DENABLE_QT_GUI=ON -DCMAKE_PREFIX_PATH=C:\\Qt\\6.7.3\\msvc2019_64",
|
||||
"buildCommandArgs": "",
|
||||
"ctestCommandArgs": "",
|
||||
"inheritEnvironments": [ "clang_cl_x64_x64" ],
|
||||
|
|
3
externals/CMakeLists.txt
vendored
3
externals/CMakeLists.txt
vendored
|
@ -182,4 +182,5 @@ add_subdirectory(tracy)
|
|||
# pugixml
|
||||
if (NOT TARGET pugixml::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 <ctime>
|
||||
#include "common/discord.h"
|
||||
|
||||
#include "logging/log.h"
|
||||
#include "common/debug.h"
|
||||
namespace Discord {
|
||||
|
||||
void RPC::init() {
|
||||
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);
|
||||
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{};
|
||||
|
||||
if (status == Discord::RPCStatus::Playing) {
|
||||
rpc.details = "Playing a game";
|
||||
rpc.state = game.c_str();
|
||||
} else {
|
||||
rpc.details = "Idle";
|
||||
}
|
||||
rpc.details = "Playing a game";
|
||||
rpc.state = game.c_str();
|
||||
std::string largeImageUrl =
|
||||
"https://store.playstation.com/store/api/chihiro/00_09_000/titlecontainer/US/en/999/" +
|
||||
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.largeImageText = "ShadPS4 is a PS4 emulator";
|
||||
rpc.startTimestamp = startTimestamp;
|
||||
rpc.details = "Idle";
|
||||
|
||||
Discord_UpdatePresence(&rpc);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,8 @@ class RPC {
|
|||
|
||||
public:
|
||||
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();
|
||||
};
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "core/memory.h"
|
||||
#include "emulator.h"
|
||||
#include "video_core/renderdoc.h"
|
||||
#include "common/discord.h"
|
||||
|
||||
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
|
||||
std::jthread mainthread =
|
||||
std::jthread([this](std::stop_token stop_token) { linker->Execute(); });
|
||||
|
|
|
@ -34,6 +34,6 @@ int main(int argc, char* argv[]) {
|
|||
|
||||
Core::Emulator emulator;
|
||||
emulator.Run(argv[1]);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "emulator.h"
|
||||
#include "game_install_dialog.h"
|
||||
#include "main_window.h"
|
||||
#include "common/discord.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
|
@ -55,6 +56,11 @@ int main(int argc, char* argv[]) {
|
|||
emulator.Run(argv[1]);
|
||||
}
|
||||
|
||||
//Initialize Discord RPC
|
||||
Discord::RPC rpc;
|
||||
rpc.init();
|
||||
rpc.updateIdle();
|
||||
|
||||
// Run the Qt application
|
||||
return a.exec();
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "input/controller.h"
|
||||
#include "sdl_window.h"
|
||||
#include "video_core/renderdoc.h"
|
||||
#include "common/discord.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <SDL3/SDL_metal.h>
|
||||
|
@ -73,7 +74,7 @@ WindowSDL::WindowSDL(s32 width_, s32 height_, Input::GameController* controller_
|
|||
}
|
||||
|
||||
WindowSDL::~WindowSDL() = default;
|
||||
|
||||
Discord::RPC rpc;
|
||||
void WindowSDL::waitEvent() {
|
||||
// Called on main thread
|
||||
SDL_Event event;
|
||||
|
@ -112,6 +113,8 @@ void WindowSDL::waitEvent() {
|
|||
onGamepadEvent(&event);
|
||||
break;
|
||||
case SDL_EVENT_QUIT:
|
||||
rpc.init();
|
||||
rpc.updateIdle();
|
||||
is_open = false;
|
||||
break;
|
||||
default:
|
||||
|
|
Loading…
Add table
Reference in a new issue