From 6ef0abe9a93ef3974558aac52e2c5b3cf2807e43 Mon Sep 17 00:00:00 2001 From: Nicolas Jallamion Date: Sun, 10 Nov 2019 21:09:32 +0100 Subject: [PATCH] module/SceCommonDialog: stub sceSaveDataDialogGetStatus. (#611) format: run clang format. small refactor firmware install dialog small refactor for game install dialog. button on setting dialog for download last firmware if it is missing. fix popup failed installation with correct typo stub savedatadialogstatus --- .gitmodules | 12 ++++---- vita3k/gui/CMakeLists.txt | 2 +- vita3k/gui/include/gui/state.h | 2 +- ...dialog.cpp => firmware_install_dialog.cpp} | 22 +++++++------- vita3k/gui/src/game_install_dialog.cpp | 16 +++++----- vita3k/gui/src/gui.cpp | 4 +-- vita3k/gui/src/main_menubar.cpp | 2 +- vita3k/gui/src/private.h | 2 +- vita3k/gui/src/settings_dialog.cpp | 19 ++++++++++-- vita3k/kernel/src/relocation.cpp | 30 +++++++++---------- vita3k/modules/SceAudioIn/SceAudioIn.cpp | 3 +- .../SceCommonDialog/SceCommonDialog.cpp | 3 +- 12 files changed, 67 insertions(+), 50 deletions(-) rename vita3k/gui/src/{install_firmware_dialog.cpp => firmware_install_dialog.cpp} (76%) diff --git a/.gitmodules b/.gitmodules index 24d9d6b2d..1af56f375 100644 --- a/.gitmodules +++ b/.gitmodules @@ -35,6 +35,9 @@ [submodule "external/imgui_club"] path = external/imgui_club url = https://github.com/ocornut/imgui_club +[submodule "external/libfat16"] + path = external/libfat16 + url = https://github.com/Vita3K/libfat16 [submodule "external/microprofile"] path = external/microprofile url = https://github.com/jonasmr/microprofile @@ -47,6 +50,9 @@ [submodule "external/pugixml"] path = external/pugixml url = https://github.com/zeux/pugixml +[submodule "external/sdl"] + path = external/sdl + url = https://github.com/Vita3K/sdl [submodule "external/sdl2-cmake-scripts"] path = external/sdl2-cmake-scripts url = https://github.com/tcbrindle/sdl2-cmake-scripts @@ -78,9 +84,3 @@ [submodule "external/VulkanMemoryAllocator"] path = external/VulkanMemoryAllocator url = https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git -[submodule "external/sdl"] - path = external/sdl - url = https://github.com/Vita3K/sdl -[submodule "external/libfat16"] - path = external/libfat16 - url = https://github.com/Vita3K/libfat16 diff --git a/vita3k/gui/CMakeLists.txt b/vita3k/gui/CMakeLists.txt index 09407c39f..a9215175d 100644 --- a/vita3k/gui/CMakeLists.txt +++ b/vita3k/gui/CMakeLists.txt @@ -19,6 +19,7 @@ add_library( src/common_dialog.cpp src/condvars_dialog.cpp src/eventflags_dialog.cpp + src/firmware_install_dialog.cpp src/game_context_menu.cpp src/game_install_dialog.cpp src/game_selector.cpp @@ -26,7 +27,6 @@ add_library( src/imgui_impl_sdl_gl3.cpp ${IMGUI_IMPL_VULKAN_SOURCES} src/imgui_impl_sdl.cpp - src/install_firmware_dialog.cpp src/main_menubar.cpp src/mutexes_dialog.cpp src/perf_overlay.cpp diff --git a/vita3k/gui/include/gui/state.h b/vita3k/gui/include/gui/state.h index 2f526e3fe..898f540cb 100644 --- a/vita3k/gui/include/gui/state.h +++ b/vita3k/gui/include/gui/state.h @@ -60,8 +60,8 @@ struct GamesSelector { }; struct FileMenuState { + bool firmware_install_dialog = false; bool game_install_dialog = false; - bool install_firmware_dialog = false; }; struct DebugMenuState { diff --git a/vita3k/gui/src/install_firmware_dialog.cpp b/vita3k/gui/src/firmware_install_dialog.cpp similarity index 76% rename from vita3k/gui/src/install_firmware_dialog.cpp rename to vita3k/gui/src/firmware_install_dialog.cpp index b72ed54b2..86855f1db 100644 --- a/vita3k/gui/src/install_firmware_dialog.cpp +++ b/vita3k/gui/src/firmware_install_dialog.cpp @@ -28,37 +28,37 @@ namespace gui { -static bool draw_file_dialog = true; - -void draw_install_firmware_dialog(GuiState &gui, HostState &host) { - nfdchar_t *outpath = nullptr; +void draw_firmware_install_dialog(GuiState &gui, HostState &host) { + nfdchar_t *fw_path = nullptr; nfdresult_t result = NFD_CANCEL; - const auto BUTTON_SIZE = ImVec2(60.f, 0.f); + static bool draw_file_dialog = true; if (draw_file_dialog) { - result = NFD_OpenDialog("PUP", nullptr, &outpath); + result = NFD_OpenDialog("PUP", nullptr, &fw_path); draw_file_dialog = false; if (result == NFD_OKAY) { - install_pup(outpath, host.pref_path); + install_pup(fw_path, host.pref_path); } else if (result == NFD_CANCEL) { - gui.file_menu.install_firmware_dialog = false; + gui.file_menu.firmware_install_dialog = false; draw_file_dialog = true; } else { LOG_ERROR("Error initializing file dialog: {}", NFD_GetError()); - gui.file_menu.install_firmware_dialog = false; + gui.file_menu.firmware_install_dialog = false; draw_file_dialog = true; } } + static const auto BUTTON_SIZE = ImVec2(60.f, 0.f); + ImGui::OpenPopup("Firmware Installation"); if (ImGui::BeginPopupModal("Firmware Installation", nullptr, ImGuiWindowFlags_NoResize)) { ImGui::TextColored(GUI_COLOR_TEXT, "Successfully Installed Firmware"); - ImGui::SetCursorPosX(ImGui::GetWindowWidth() - BUTTON_SIZE.x - 10); + ImGui::SetCursorPosX(ImGui::GetWindowWidth() / 2 - 30); if (ImGui::Button("OK", BUTTON_SIZE)) { get_modules_list(gui, host); - gui.file_menu.install_firmware_dialog = false; + gui.file_menu.firmware_install_dialog = false; draw_file_dialog = true; } } diff --git a/vita3k/gui/src/game_install_dialog.cpp b/vita3k/gui/src/game_install_dialog.cpp index d9ccd150a..41e023a4b 100644 --- a/vita3k/gui/src/game_install_dialog.cpp +++ b/vita3k/gui/src/game_install_dialog.cpp @@ -33,13 +33,13 @@ namespace gui { -nfdchar_t *game_path = nullptr; -static bool draw_file_dialog = true; -static bool game_install_confirm = false; - void draw_game_install_dialog(GuiState &gui, HostState &host) { + static nfdchar_t *game_path = nullptr; nfdresult_t result = NFD_CANCEL; + static bool draw_file_dialog = true; + static bool game_install_confirm = false; + if (draw_file_dialog) { result = NFD_OpenDialog("vpk,zip", nullptr, &game_path); draw_file_dialog = false; @@ -70,14 +70,14 @@ void draw_game_install_dialog(GuiState &gui, HostState &host) { ImGui::Separator(); ImGui::Spacing(); ImGui::SetCursorPosX(ImGui::GetWindowWidth() / 2 - 65); - if (ImGui::Button("Yes", BUTTON_SIZE)) { + if (ImGui::Button("Yes", BUTTON_SIZE)) if (install_vpk(host, gui, static_cast(game_path))) { gui.game_reinstall_confirm = false; game_install_confirm = true; } - } ImGui::SameLine(); if (ImGui::Button("No", BUTTON_SIZE)) { + game_path = nullptr; gui.game_reinstall_confirm = false; gui.file_menu.game_install_dialog = false; draw_file_dialog = true; @@ -98,6 +98,7 @@ void draw_game_install_dialog(GuiState &gui, HostState &host) { if (ImGui::Button("Ok", BUTTON_SIZE)) { game_install_confirm = false; draw_file_dialog = true; + game_path = nullptr; refresh_game_list(gui, host); gui.file_menu.game_install_dialog = false; } @@ -106,7 +107,7 @@ void draw_game_install_dialog(GuiState &gui, HostState &host) { ImGui::PopStyleColor(); ImGui::PushStyleColor(ImGuiCol_Text, GUI_COLOR_TEXT_MENUBAR_OPTIONS); - if (ImGui::BeginPopupModal("Game Installation Failed", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) { + if (ImGui::BeginPopupModal("Game installation failed", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) { ImGui::PopStyleColor(); ImGui::TextColored(GUI_COLOR_TEXT, "Installation failed, please check the log for more information."); ImGui::Separator(); @@ -114,6 +115,7 @@ void draw_game_install_dialog(GuiState &gui, HostState &host) { ImGui::SetCursorPosX(ImGui::GetWindowWidth() / 2 - 30); if (ImGui::Button("Ok", BUTTON_SIZE)) { draw_file_dialog = true; + game_path = nullptr; gui.file_menu.game_install_dialog = false; } ImGui::EndPopup(); diff --git a/vita3k/gui/src/gui.cpp b/vita3k/gui/src/gui.cpp index d2562b716..3b2f4ecec 100644 --- a/vita3k/gui/src/gui.cpp +++ b/vita3k/gui/src/gui.cpp @@ -296,8 +296,8 @@ void draw_ui(GuiState &gui, HostState &host) { if (gui.file_menu.game_install_dialog) draw_game_install_dialog(gui, host); - if (gui.file_menu.install_firmware_dialog) - draw_install_firmware_dialog(gui, host); + if (gui.file_menu.firmware_install_dialog) + draw_firmware_install_dialog(gui, host); if (gui.debug_menu.threads_dialog) draw_threads_dialog(gui, host); if (gui.debug_menu.thread_details_dialog) diff --git a/vita3k/gui/src/main_menubar.cpp b/vita3k/gui/src/main_menubar.cpp index f11498392..2af4f0644 100644 --- a/vita3k/gui/src/main_menubar.cpp +++ b/vita3k/gui/src/main_menubar.cpp @@ -23,8 +23,8 @@ namespace gui { static void draw_file_menu(FileMenuState &state) { if (ImGui::BeginMenu("File")) { + ImGui::MenuItem("Install Firmware", nullptr, &state.firmware_install_dialog); ImGui::MenuItem("Install Game", nullptr, &state.game_install_dialog); - ImGui::MenuItem("Install Firmware", nullptr, &state.install_firmware_dialog); ImGui::EndMenu(); } } diff --git a/vita3k/gui/src/private.h b/vita3k/gui/src/private.h index 3ad0affff..e7d397766 100644 --- a/vita3k/gui/src/private.h +++ b/vita3k/gui/src/private.h @@ -38,8 +38,8 @@ const ImVec4 GUI_SMOOTH_GRAY = ImVec4(0.76f, 0.75f, 0.76f, 1.0f); #undef RGBA_TO_FLOAT void draw_main_menu_bar(GuiState &gui); +void draw_firmware_install_dialog(GuiState &gui, HostState &host); void draw_game_install_dialog(GuiState &gui, HostState &host); -void draw_install_firmware_dialog(GuiState &gui, HostState &host); void draw_threads_dialog(GuiState &gui, HostState &host); void draw_thread_details_dialog(GuiState &gui, HostState &host); void draw_semaphores_dialog(GuiState &gui, HostState &host); diff --git a/vita3k/gui/src/settings_dialog.cpp b/vita3k/gui/src/settings_dialog.cpp index 0a344758a..1a39f06ca 100644 --- a/vita3k/gui/src/settings_dialog.cpp +++ b/vita3k/gui/src/settings_dialog.cpp @@ -32,9 +32,18 @@ #include #include +#include namespace gui { +#ifdef _WIN32 +static const char OS_PREFIX[] = "start "; +#elif __APPLE__ +static const char OS_PREFIX[] = "open "; +#else +static const char OS_PREFIX[] = "xdg-open "; +#endif + static const char *LIST_SYS_LANG[] = { "Japanese", "American English", "French", "Spanish", "German", "Italian", "Dutch", "Portugal Portuguese", "Russian", "Korean", "Traditional Chinese", "Simplified Chinese", "Finnish", "Swedish", @@ -170,9 +179,13 @@ void draw_settings_dialog(GuiState &gui, HostState &host) { } ImGui::SameLine(); } else { - ImGui::TextColored(GUI_COLOR_TEXT, "No modules present.\nPlease install the firmware"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Put decrypted modules inside 'vs0/sys/external/'."); + ImGui::TextColored(GUI_COLOR_TEXT, "No modules present.\nPlease download and install the last firmware."); + std::ostringstream link; + if (ImGui::Button("Download Firmware")) { + std::string firmware_url = "https://www.playstation.com/en-us/support/system-updates/ps-vita/"; + link << OS_PREFIX << firmware_url; + system(link.str().c_str()); + } } if (ImGui::Button("Refresh list")) get_modules_list(gui, host); diff --git a/vita3k/kernel/src/relocation.cpp b/vita3k/kernel/src/relocation.cpp index e496b46e8..dadd7c8c2 100644 --- a/vita3k/kernel/src/relocation.cpp +++ b/vita3k/kernel/src/relocation.cpp @@ -491,41 +491,41 @@ bool relocate(const void *entries, uint32_t size, const SegmentInfosForReloc &se const EntryFormat5 *const format5_entry = static_cast(entry); g_offset += format5_entry->dist1; - + const auto s = g_saddr; const auto a = g_addend; const auto p = g_addr + g_offset; - + if (!relocate_entry(Ptr(p).get(mem), static_cast(g_type), s, a, p)) { return false; } - + if (!relocate_entry(Ptr(p + format5_entry->dist2).get(mem), static_cast(g_type2), s, a, p + format5_entry->dist2)) { return false; } - + g_offset += format5_entry->dist3; const auto p2 = g_addr + g_offset; - + if (!relocate_entry(Ptr(p2).get(mem), static_cast(g_type), s, a, p2)) { return false; } - + if (!relocate_entry(Ptr(p2 + format5_entry->dist4).get(mem), static_cast(g_type2), s, a, p2 + format5_entry->dist4)) { return false; } - + break; } case 6: { const EntryFormat6 *const format6_entry = static_cast(entry); g_offset += format6_entry->offset; - + const auto patch_seg_start = segments.find(g_patchseg)->second.addr; - + const uint32_t orgval = *Ptr(patch_seg_start + g_offset).get(mem); - + uint32_t segbase = 0; for (const auto seg_ : segments) { const auto seg = seg_.second; @@ -534,21 +534,21 @@ bool relocate(const void *entries, uint32_t size, const SegmentInfosForReloc &se g_saddr = seg.addr; } } - + assert((uint32_t)orgval >= (uint32_t)segbase); const auto addend = orgval - segbase; - + g_type2 = 0; g_type = Abs32; - + const auto s = g_saddr; const auto a = addend; const auto p = g_addr + g_offset; - + if (!relocate_entry(Ptr(p).get(mem), static_cast(g_type), s, a, p)) { return false; } - + break; } case 7: diff --git a/vita3k/modules/SceAudioIn/SceAudioIn.cpp b/vita3k/modules/SceAudioIn/SceAudioIn.cpp index 0b144c781..88fe4294f 100644 --- a/vita3k/modules/SceAudioIn/SceAudioIn.cpp +++ b/vita3k/modules/SceAudioIn/SceAudioIn.cpp @@ -53,7 +53,8 @@ EXPORT(int, sceAudioInInput, int port, void *destPtr) { return RET_ERROR(SCE_AUDIO_IN_ERROR_INVALID_PORT_PARAM); } - while (SDL_DequeueAudio(host.audio.shared.in_port.id, destPtr, host.audio.shared.in_port.len_bytes) > 0){} + while (SDL_DequeueAudio(host.audio.shared.in_port.id, destPtr, host.audio.shared.in_port.len_bytes) > 0) { + } return 0; } diff --git a/vita3k/modules/SceCommonDialog/SceCommonDialog.cpp b/vita3k/modules/SceCommonDialog/SceCommonDialog.cpp index c1a2dfd5d..2a4be5c5c 100644 --- a/vita3k/modules/SceCommonDialog/SceCommonDialog.cpp +++ b/vita3k/modules/SceCommonDialog/SceCommonDialog.cpp @@ -589,7 +589,8 @@ EXPORT(int, sceSaveDataDialogGetResult) { } EXPORT(int, sceSaveDataDialogGetStatus) { - return UNIMPLEMENTED(); + STUBBED("SCE_COMMON_DIALOG_STATUS_FINISHED"); + return SCE_COMMON_DIALOG_STATUS_FINISHED; } EXPORT(int, sceSaveDataDialogGetSubStatus) {