diff --git a/.gitmodules b/.gitmodules index 2008e54a..9267baa7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,10 +1,3 @@ -# SPDX-FileCopyrightText: 2024 shadPS4 Emulator Project -# SPDX-License-Identifier: GPL-2.0-or-later - -[submodule "third-party/imgui"] - path = third-party/imgui - url = https://github.com/ocornut/imgui - shallow = true [submodule "third-party/SDL"] path = third-party/SDL url = https://github.com/libsdl-org/SDL @@ -29,9 +22,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 [submodule "third-party/toml11"] path = third-party/toml11 url = https://github.com/ToruNiina/toml11 @@ -47,3 +37,7 @@ [submodule "third-party/vulkan"] path = third-party/vulkan url = https://github.com/GPUCode/vulkan +[submodule "externals/discord-rpc"] + path = externals/discord-rpc + url = https://github.com/shadps4-emu/ext-discord-rpc.git + branch = master diff --git a/.reuse/dep5 b/.reuse/dep5 index d03c7c1f..5ead99f7 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -8,5 +8,6 @@ Files: CMakeSettings.json documents/readme.txt .github/shadps4.desktop .github/shadps4.png + .gitmodules Copyright: shadPS4 Emulator Project License: GPL-2.0-or-later diff --git a/CMakeLists.txt b/CMakeLists.txt index 074fc84b..ecb5613b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,6 +81,7 @@ if (CLANG_FORMAT) unset(CCOMMENT) endif() +add_subdirectory(externals) add_subdirectory(third-party) include_directories(src) @@ -156,8 +157,6 @@ add_executable(shadps4 src/main.cpp src/core/loader/elf.cpp src/core/loader/elf.h - src/GUI/ElfViewer.cpp - src/GUI/ElfViewer.h src/Util/config.cpp src/Util/config.h src/core/virtual_memory.cpp @@ -213,7 +212,7 @@ add_executable(shadps4 create_target_directory_groups(shadps4) target_link_libraries(shadps4 PRIVATE magic_enum::magic_enum fmt::fmt spdlog::spdlog toml11::toml11) -target_link_libraries(shadps4 PRIVATE discord-rpc imgui SDL3-shared vulkan-1 xxhash Zydis) +target_link_libraries(shadps4 PRIVATE discord-rpc SDL3-shared vulkan-1 xxhash Zydis) if (WIN32) target_link_libraries(shadps4 PRIVATE mincore winpthread clang_rt.builtins-x86_64.lib) endif() diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt new file mode 100644 index 00000000..0dcd7cb4 --- /dev/null +++ b/externals/CMakeLists.txt @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +# SPDX-License-Identifier: GPL-2.0-or-later + +if (MSVC) + # Silence "deprecation" warnings + add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS) +endif() + +# Discord-RPC +set(BUILD_EXAMPLES OFF CACHE BOOL "") +add_subdirectory(discord-rpc EXCLUDE_FROM_ALL) +target_include_directories(discord-rpc INTERFACE ./discord-rpc/include) + + diff --git a/externals/discord-rpc b/externals/discord-rpc new file mode 160000 index 00000000..a3fa5e32 --- /dev/null +++ b/externals/discord-rpc @@ -0,0 +1 @@ +Subproject commit a3fa5e32f64297247b683c35acb4ab1f207171ed diff --git a/src/GUI/ElfViewer.cpp b/src/GUI/ElfViewer.cpp deleted file mode 100644 index 344e417f..00000000 --- a/src/GUI/ElfViewer.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "GUI/ElfViewer.h" -#include "core/loader/elf.h" -#include "imgui.h" - -ElfViewer::ElfViewer(Core::Loader::Elf* elf) { - this->elf = elf; -} - -void ElfViewer::Display(bool enabled) { - int SELF_HEADER = 0; - int ELF_HEADER = 1; - int SEG_HEADER_START = 100; - int ELF_PROGRAM_HEADER_START = 200; - - static int selected = -1; - ImGui::Begin("Self/Elf Viewer", &enabled); - - ImGui::BeginChild("Left Tree pane", ImVec2(300, 0), false); // left tree - if (elf->isSelfFile()) { - if (ImGui::TreeNode("Self")) { - if (ImGui::TreeNodeEx("Self Header", - ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen, - "Self Header")) { - if (ImGui::IsItemClicked()) - selected = SELF_HEADER; - } - - if (ImGui::TreeNode("Self Segment Header")) { - const auto self = elf->GetSElfHeader(); - for (u16 i = 0; i < self.segment_count; i++) { - if (ImGui::TreeNodeEx((void*)(intptr_t)i, - ImGuiTreeNodeFlags_Leaf | - ImGuiTreeNodeFlags_NoTreePushOnOpen, - "%d", i)) { - if (ImGui::IsItemClicked()) - selected = SEG_HEADER_START + i; - } - } - ImGui::TreePop(); - } - ImGui::TreeNodeEx("Self Id Header", - ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen, - "Self Id Header"); - ImGui::TreePop(); - } - } - if (ImGui::TreeNode("Elf")) { - const auto elf_header = elf->GetElfHeader(); - if (ImGui::TreeNodeEx("Elf Header", - ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen, - "Elf Header")) { - if (ImGui::IsItemClicked()) - selected = ELF_HEADER; - } - if (ImGui::TreeNode("Elf Program Headers")) { - const auto pheader = elf->GetProgramHeader(); - for (u16 i = 0; i < elf_header.e_phnum; i++) { - std::string ProgramInfo = elf->ElfPheaderFlagsStr(pheader[i].p_flags) + " " + - elf->ElfPheaderTypeStr(pheader[i].p_type); - if (ImGui::TreeNodeEx((void*)(intptr_t)i, - ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen, - "%d - %s", i, ProgramInfo.c_str())) { - if (ImGui::IsItemClicked()) - selected = ELF_PROGRAM_HEADER_START + i; - } - } - ImGui::TreePop(); - } - if (elf_header.e_shnum != 0) { - if (ImGui::TreeNode("Elf Section Headers")) { - ImGui::TreePop(); - } - } - ImGui::TreePop(); - } - ImGui::EndChild(); // end of left tree - - ImGui::SameLine(); - - ImGui::BeginChild( - "Table View", - ImVec2(0, -ImGui::GetFrameHeightWithSpacing())); // Leave room for 1 line below us - if (selected == SELF_HEADER) { - ImGui::TextWrapped("%s", elf->SElfHeaderStr().c_str()); - } - if (selected >= 100 && selected < 200) { - ImGui::TextWrapped("%s", elf->SELFSegHeader(selected - 100).c_str()); - } - if (selected == ELF_HEADER) { - ImGui::TextWrapped("%s", elf->ElfHeaderStr().c_str()); - } - if (selected >= 200 && selected < 300) { - ImGui::TextWrapped("%s", elf->ElfPHeaderStr(selected - 200).c_str()); - } - ImGui::EndChild(); - ImGui::End(); -} diff --git a/src/GUI/ElfViewer.h b/src/GUI/ElfViewer.h deleted file mode 100644 index 6e7aa6dd..00000000 --- a/src/GUI/ElfViewer.h +++ /dev/null @@ -1,18 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -namespace Core::Loader { -class Elf; -} - -class ElfViewer { -public: - explicit ElfViewer(Core::Loader::Elf* elf); - - void Display(bool enabled); - -private: - Core::Loader::Elf* elf; -}; diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index 49359516..c640ab74 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -6,11 +6,6 @@ if (MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS) endif() -# Discord-RPC -set(BUILD_EXAMPLES OFF CACHE BOOL "") -add_subdirectory(discord-rpc EXCLUDE_FROM_ALL) -target_include_directories(discord-rpc INTERFACE ./discord-rpc/include) - # fmtlib add_subdirectory(fmt EXCLUDE_FROM_ALL) @@ -49,25 +44,5 @@ option(ZYDIS_BUILD_TOOLS "" OFF) option(ZYDIS_BUILD_EXAMPLES "" OFF) add_subdirectory(zydis EXCLUDE_FROM_ALL) -# Imgui -add_library(imgui STATIC) - -target_sources(imgui PRIVATE - imgui/imgui_demo.cpp - imgui/imgui_draw.cpp - imgui/imgui_tables.cpp - imgui/imgui_widgets.cpp - imgui/imgui.cpp - imgui/backends/imgui_impl_opengl3.cpp - imgui/backends/imgui_impl_sdl3.cpp -) - -target_include_directories(imgui PUBLIC - imgui - imgui/backends - imgui/include -) - -target_link_libraries(imgui PRIVATE SDL3-shared ${CMAKE_DL_LIBS} Zydis discord-rpc) diff --git a/third-party/discord-rpc b/third-party/discord-rpc deleted file mode 160000 index 963aa9f3..00000000 --- a/third-party/discord-rpc +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 963aa9f3e5ce81a4682c6ca3d136cddda614db33 diff --git a/third-party/imgui b/third-party/imgui deleted file mode 160000 index 52125a54..00000000 --- a/third-party/imgui +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 52125a54a57a458e89bc61502010e964add3cdd5