commit
b7945a4c0a
|
@ -26,3 +26,6 @@
|
|||
path = third-party/winpthread
|
||||
url = https://github.com/shadps4/winpthread.git
|
||||
branch = main
|
||||
[submodule "third-party/discord-rpc"]
|
||||
path = third-party/discord-rpc
|
||||
url = https://github.com/discord/discord-rpc
|
||||
|
|
|
@ -9,6 +9,7 @@ endif()
|
|||
project(shadps4)
|
||||
|
||||
include_directories(third-party/)
|
||||
include_directories(third-party/discord-rpc/include)
|
||||
include_directories(third-party/imgui/)
|
||||
include_directories(third-party/imgui/backends)
|
||||
include_directories(third-party/sdl/)
|
||||
|
@ -43,6 +44,8 @@ add_executable(shadps4
|
|||
src/Util/string_util.cpp
|
||||
src/Core/PS4/HLE/Graphics/video_out.cpp
|
||||
src/Core/PS4/HLE/Graphics/video_out.h
|
||||
src/discord.h
|
||||
src/discord.cpp
|
||||
"src/Util/Singleton.h" "src/Util/Disassembler.cpp" "src/Util/Disassembler.h" "src/Core/PS4/Util/aerolib.h" "src/Core/PS4/Loader/SymbolsResolver.h" "src/Core/PS4/Loader/SymbolsResolver.cpp" "src/Core/PS4/HLE/Libs.cpp" "src/Core/PS4/HLE/Libs.h" "src/Core/PS4/HLE/LibC.cpp" "src/Core/PS4/HLE/LibC.h" "src/Lib/Timer.cpp" "src/Lib/Timer.h" "src/Core/PS4/HLE/LibKernel.cpp" "src/Core/PS4/HLE/LibKernel.h" "src/Core/PS4/HLE/LibSceVideoOut.cpp" "src/Core/PS4/HLE/LibSceVideoOut.h" "src/Core/PS4/HLE/LibSceGnmDriver.cpp" "src/Core/PS4/HLE/LibSceGnmDriver.h" "src/Core/PS4/HLE/Kernel/ThreadManagement.cpp" "src/Core/PS4/HLE/Kernel/ThreadManagement.h" "src/Core/PS4/HLE/ErrorCodes.h" "src/debug.h" "src/Core/PS4/HLE/Kernel/memory_management.cpp" "src/Core/PS4/HLE/Kernel/memory_management.h" "src/Core/PS4/GPU/gpu_memory.cpp" "src/Core/PS4/GPU/gpu_memory.h" "src/emulator.cpp" "src/emulator.h")
|
||||
|
||||
find_package(OpenGL REQUIRED)
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
#include "discord.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
|
||||
void Discord::RPC::init() {
|
||||
DiscordEventHandlers handlers{};
|
||||
Discord_Initialize("1138176975865909360", &handlers, 1, nullptr);
|
||||
|
||||
startTimestamp = time(nullptr);
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
void Discord::RPC::update(Discord::RPCStatus status, const std::string& game) {
|
||||
DiscordRichPresence rpc{};
|
||||
|
||||
if (status == Discord::RPCStatus::Playing) {
|
||||
rpc.details = "Playing a game";
|
||||
rpc.state = game.c_str();
|
||||
} else {
|
||||
rpc.details = "Idle";
|
||||
}
|
||||
|
||||
rpc.largeImageKey = "pand";
|
||||
rpc.largeImageText = "ShadPS4 is a PS4 emulator";
|
||||
rpc.startTimestamp = startTimestamp;
|
||||
|
||||
Discord_UpdatePresence(&rpc);
|
||||
}
|
||||
|
||||
void Discord::RPC::stop() {
|
||||
if (enabled) {
|
||||
enabled = false;
|
||||
Discord_ClearPresence();
|
||||
Discord_Shutdown();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
#pragma once
|
||||
|
||||
#include <discord_rpc.h>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
namespace Discord {
|
||||
enum class RPCStatus { Idling, Playing };
|
||||
|
||||
class RPC {
|
||||
std::uint64_t startTimestamp;
|
||||
bool enabled = false;
|
||||
|
||||
public:
|
||||
void init();
|
||||
void update(RPCStatus status, const std::string& title);
|
||||
void stop();
|
||||
};
|
||||
} // namespace Discord
|
|
@ -31,6 +31,7 @@
|
|||
#include "Core/PS4/HLE/Libs.h"
|
||||
#include "Lib/Threads.h"
|
||||
#include <emulator.h>
|
||||
#include "discord.h"
|
||||
|
||||
// Main code
|
||||
int main(int argc, char* argv[])
|
||||
|
@ -59,6 +60,10 @@ int main(int argc, char* argv[])
|
|||
Emulator::emuRun();
|
||||
mainthread.JoinThread();
|
||||
|
||||
Discord::RPC discordRPC;
|
||||
discordRPC.init();
|
||||
discordRPC.update(Discord::RPCStatus::Idling, "");
|
||||
|
||||
#if 0
|
||||
// Setup SDL
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMEPAD) != 0)
|
||||
|
@ -240,5 +245,6 @@ int main(int argc, char* argv[])
|
|||
SDL_Quit();
|
||||
#endif
|
||||
|
||||
discordRPC.stop();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,8 @@ add_subdirectory(${zydis_DIR})
|
|||
|
||||
#========== winpthreads ======================
|
||||
add_subdirectory(winpthread)
|
||||
#=================== discord-rpc ===================
|
||||
add_subdirectory(discord-rpc)
|
||||
#=================== IMGUI ===================
|
||||
|
||||
set(IMGUI_DIR ${CMAKE_CURRENT_SOURCE_DIR}/imgui)
|
||||
|
@ -58,6 +60,6 @@ find_package(OpenGL REQUIRED)
|
|||
target_link_libraries(IMGUI PUBLIC ${OPENGL_LIBRARIES})
|
||||
|
||||
|
||||
target_link_libraries(IMGUI PUBLIC SDL3-shared ${CMAKE_DL_LIBS} Zydis winpthread)
|
||||
target_link_libraries(IMGUI PUBLIC SDL3-shared ${CMAKE_DL_LIBS} Zydis winpthread discord-rpc)
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 963aa9f3e5ce81a4682c6ca3d136cddda614db33
|
Loading…
Reference in New Issue