A tool for deriving PKG packet encryption keys for ps4 written in c++
| 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | |
| 4 | #include <cstring> |
| 5 | #include <ctime> |
| 6 | #include "discord_rpc_handler.h" |
| 7 | |
| 8 | namespace DiscordRPCHandler { |
| 9 | |
| 10 | void RPC::init() { |
| 11 | DiscordEventHandlers handlers{}; |
| 12 | |
| 13 | Discord_Initialize("1139939140494971051", &handlers, 1, nullptr); |
| 14 | startTimestamp = time(nullptr); |
| 15 | rpcEnabled = true; |
| 16 | } |
| 17 | |
| 18 | void RPC::setStatusIdling() { |
| 19 | DiscordRichPresence rpc{}; |
| 20 | rpc.largeImageKey = "https://cdn.jsdelivr.net/gh/shadps4-emu/shadPS4@main/.github/shadps4.png"; |
| 21 | rpc.largeImageText = "shadPS4 is a PS4 emulator"; |
| 22 | rpc.startTimestamp = startTimestamp; |
| 23 | rpc.details = "Idle"; |
| 24 | |
| 25 | status = RPCStatus::Idling; |
| 26 | Discord_UpdatePresence(&rpc); |
| 27 | } |
| 28 | |
| 29 | void RPC::setStatusPlaying(const std::string& game_name, const std::string& game_id) { |
| 30 | DiscordRichPresence rpc{}; |
| 31 | |
| 32 | rpc.details = "Playing"; |
| 33 | rpc.state = game_name.c_str(); |
| 34 | std::string largeImageUrl = |
| 35 | "https://store.playstation.com/store/api/chihiro/00_09_000/titlecontainer/US/en/999/" + |
| 36 | game_id + "_00/image"; |
| 37 | rpc.largeImageKey = largeImageUrl.c_str(); |
| 38 | rpc.largeImageText = game_name.c_str(); |
| 39 | rpc.startTimestamp = startTimestamp; |
| 40 | |
| 41 | status = RPCStatus::Playing; |
| 42 | Discord_UpdatePresence(&rpc); |
| 43 | } |
| 44 | |
| 45 | void RPC::shutdown() { |
| 46 | if (rpcEnabled) { |
| 47 | rpcEnabled = false; |
| 48 | Discord_ClearPresence(); |
| 49 | Discord_Shutdown(); |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | bool RPC::getRPCEnabled() { |
| 54 | return rpcEnabled; |
| 55 | } |
| 56 | |
| 57 | } // namespace DiscordRPCHandler |
| 58 |