From c8568725c260e70a21175c361e22e1e0754836e4 Mon Sep 17 00:00:00 2001 From: lizzie Date: Wed, 4 Mar 2026 20:31:09 +0000 Subject: [PATCH 01/25] [audio_core, hle/services, video_core/compute] Inline std::unique_ptr<> allocs into std::optional<> Signed-off-by: lizzie --- src/audio_core/audio_core.cpp | 5 +- src/audio_core/audio_core.h | 20 ++---- src/audio_core/audio_in_manager.cpp | 3 +- src/audio_core/audio_out_manager.cpp | 3 +- src/core/core.cpp | 2 +- src/core/hle/service/am/applet_manager.cpp | 2 +- src/core/hle/service/am/process_creation.cpp | 52 ++++++---------- src/core/hle/service/am/process_creation.h | 9 +-- .../am/service/application_creator.cpp | 24 +++---- .../am/service/library_applet_creator.cpp | 35 +++++------ .../hle/service/audio/audio_out_manager.cpp | 4 +- .../hle/service/audio/audio_out_manager.h | 2 +- .../service/audio/audio_renderer_manager.cpp | 4 +- .../service/audio/audio_renderer_manager.h | 2 +- src/core/hle/service/os/process.cpp | 8 --- src/core/hle/service/os/process.h | 6 +- .../renderer_vulkan/vk_query_cache.cpp | 62 ++++++------------- .../renderer_vulkan/vk_update_descriptor.h | 15 ++--- 18 files changed, 92 insertions(+), 166 deletions(-) diff --git a/src/audio_core/audio_core.cpp b/src/audio_core/audio_core.cpp index fcaab2b320..28d38c8881 100644 --- a/src/audio_core/audio_core.cpp +++ b/src/audio_core/audio_core.cpp @@ -8,10 +8,11 @@ namespace AudioCore { -AudioCore::AudioCore(Core::System& system) : audio_manager{std::make_unique()} { +AudioCore::AudioCore(Core::System& system) { + audio_manager.emplace(); CreateSinks(); // Must be created after the sinks - adsp = std::make_unique(system, *output_sink); + adsp.emplace(system, *output_sink); } AudioCore ::~AudioCore() { diff --git a/src/audio_core/audio_core.h b/src/audio_core/audio_core.h index e4e27fc661..e4771d7656 100644 --- a/src/audio_core/audio_core.h +++ b/src/audio_core/audio_core.h @@ -15,10 +15,7 @@ class System; namespace AudioCore { -class AudioManager; -/** - * Main audio class, stored inside the core, and holding the audio manager, all sinks, and the ADSP. - */ +/// @brief Main audio class, stored inside the core, and holding the audio manager, all sinks, and the ADSP. class AudioCore { public: explicit AudioCore(Core::System& system); @@ -50,27 +47,22 @@ public: */ Sink::Sink& GetInputSink(); - /** - * Get the ADSP. - * - * @return Ref to the ADSP. - */ + /// @brief Get the ADSP. + /// @return Ref to the ADSP. ADSP::ADSP& ADSP(); private: - /** - * Create the sinks on startup. - */ + /// @brief Create the sinks on startup. void CreateSinks(); /// Main audio manager for audio in/out - std::unique_ptr audio_manager; + std::optional audio_manager; /// Sink used for audio renderer and audio out std::unique_ptr output_sink; /// Sink used for audio input std::unique_ptr input_sink; /// The ADSP in the sysmodule - std::unique_ptr adsp; + std::optional adsp; }; } // namespace AudioCore diff --git a/src/audio_core/audio_in_manager.cpp b/src/audio_core/audio_in_manager.cpp index 63b064922a..c11e88b317 100644 --- a/src/audio_core/audio_in_manager.cpp +++ b/src/audio_core/audio_in_manager.cpp @@ -41,8 +41,7 @@ void Manager::ReleaseSessionId(const size_t session_id) { Result Manager::LinkToManager() { std::scoped_lock l{mutex}; if (!linked_to_manager) { - AudioManager& manager{system.AudioCore().GetAudioManager()}; - manager.SetInManager(std::bind(&Manager::BufferReleaseAndRegister, this)); + system.AudioCore().GetAudioManager().SetInManager(std::bind(&Manager::BufferReleaseAndRegister, this)); linked_to_manager = true; } diff --git a/src/audio_core/audio_out_manager.cpp b/src/audio_core/audio_out_manager.cpp index 316ea7c817..dee3d493e5 100644 --- a/src/audio_core/audio_out_manager.cpp +++ b/src/audio_core/audio_out_manager.cpp @@ -40,8 +40,7 @@ void Manager::ReleaseSessionId(const size_t session_id) { Result Manager::LinkToManager() { std::scoped_lock l{mutex}; if (!linked_to_manager) { - AudioManager& manager{system.AudioCore().GetAudioManager()}; - manager.SetOutManager(std::bind(&Manager::BufferReleaseAndRegister, this)); + system.AudioCore().GetAudioManager().SetOutManager(std::bind(&Manager::BufferReleaseAndRegister, this)); linked_to_manager = true; } diff --git a/src/core/core.cpp b/src/core/core.cpp index 9db4589ceb..6ec656cf8c 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -347,7 +347,7 @@ struct System::Impl { // Register with applet manager // All threads are started, begin main process execution, now that we're in the clear - applet_manager.CreateAndInsertByFrontendAppletParameters(std::move(process), params); + applet_manager.CreateAndInsertByFrontendAppletParameters(std::make_unique(*std::move(process)), params); if (Settings::values.gamecard_inserted) { if (Settings::values.gamecard_current_game) { diff --git a/src/core/hle/service/am/applet_manager.cpp b/src/core/hle/service/am/applet_manager.cpp index c2920f91ae..2bedce03cb 100644 --- a/src/core/hle/service/am/applet_manager.cpp +++ b/src/core/hle/service/am/applet_manager.cpp @@ -268,7 +268,7 @@ void AppletManager::SetWindowSystem(WindowSystem* window_system) { if (Settings::values.enable_overlay && m_window_system->GetOverlayDisplayApplet() == nullptr) { if (auto overlay_process = CreateProcess(m_system, static_cast(AppletProgramId::OverlayDisplay), 0, 0)) { - auto overlay_applet = std::make_shared(m_system, std::move(overlay_process), false); + auto overlay_applet = std::make_shared(m_system, std::make_unique(*std::move(overlay_process)), false); overlay_applet->program_id = static_cast(AppletProgramId::OverlayDisplay); overlay_applet->applet_id = AppletId::OverlayDisplay; overlay_applet->type = AppletType::OverlayApplet; diff --git a/src/core/hle/service/am/process_creation.cpp b/src/core/hle/service/am/process_creation.cpp index b5e31353a2..cd537062d7 100644 --- a/src/core/hle/service/am/process_creation.cpp +++ b/src/core/hle/service/am/process_creation.cpp @@ -1,6 +1,7 @@ // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include #include "core/core.h" #include "core/file_sys/content_archive.h" #include "core/file_sys/nca_metadata.h" @@ -36,31 +37,23 @@ FileSys::StorageId GetStorageIdForFrontendSlot( } } -std::unique_ptr CreateProcessImpl(std::unique_ptr& out_loader, - Loader::ResultStatus& out_load_result, - Core::System& system, FileSys::VirtualFile file, - u64 program_id, u64 program_index) { +std::optional CreateProcessImpl(std::unique_ptr& out_loader, Loader::ResultStatus& out_load_result, Core::System& system, FileSys::VirtualFile file, u64 program_id, u64 program_index) { // Get the appropriate loader to parse this NCA. out_loader = Loader::GetLoader(system, file, program_id, program_index); - // Ensure we have a loader which can parse the NCA. - if (!out_loader) { - return nullptr; + if (out_loader) { + // Try to load the process. + auto process = std::optional(system); + if (process->Initialize(*out_loader, out_load_result)) { + return process; + } } - - // Try to load the process. - auto process = std::make_unique(system); - if (process->Initialize(*out_loader, out_load_result)) { - return process; - } - - return nullptr; + return std::nullopt; } } // Anonymous namespace -std::unique_ptr CreateProcess(Core::System& system, u64 program_id, - u8 minimum_key_generation, u8 maximum_key_generation) { +std::optional CreateProcess(Core::System& system, u64 program_id, u8 minimum_key_generation, u8 maximum_key_generation) { // Attempt to load program NCA. FileSys::VirtualFile nca_raw{}; @@ -70,7 +63,7 @@ std::unique_ptr CreateProcess(Core::System& system, u64 program_id, // Ensure we retrieved a program NCA. if (!nca_raw) { - return nullptr; + return std::nullopt; } // Ensure we have a suitable version. @@ -79,9 +72,8 @@ std::unique_ptr CreateProcess(Core::System& system, u64 program_id, if (nca.GetStatus() == Loader::ResultStatus::Success && (nca.GetKeyGeneration() < minimum_key_generation || nca.GetKeyGeneration() > maximum_key_generation)) { - LOG_WARNING(Service_LDR, "Skipping program {:016X} with generation {}", program_id, - nca.GetKeyGeneration()); - return nullptr; + LOG_WARNING(Service_LDR, "Skipping program {:016X} with generation {}", program_id, nca.GetKeyGeneration()); + return std::nullopt; } } @@ -90,15 +82,10 @@ std::unique_ptr CreateProcess(Core::System& system, u64 program_id, return CreateProcessImpl(loader, status, system, nca_raw, program_id, 0); } -std::unique_ptr CreateApplicationProcess(std::vector& out_control, - std::unique_ptr& out_loader, - Loader::ResultStatus& out_load_result, - Core::System& system, FileSys::VirtualFile file, - u64 program_id, u64 program_index) { - auto process = - CreateProcessImpl(out_loader, out_load_result, system, file, program_id, program_index); +std::optional CreateApplicationProcess(std::vector& out_control, std::unique_ptr& out_loader, Loader::ResultStatus& out_load_result, Core::System& system, FileSys::VirtualFile file, u64 program_id, u64 program_index) { + auto process = CreateProcessImpl(out_loader, out_load_result, system, file, program_id, program_index); if (!process) { - return nullptr; + return std::nullopt; } FileSys::NACP nacp; @@ -118,13 +105,10 @@ std::unique_ptr CreateApplicationProcess(std::vector& out_control, // TODO(DarkLordZach): When FSController/Game Card Support is added, if // current_process_game_card use correct StorageId - launch.base_game_storage_id = GetStorageIdForFrontendSlot( - storage.GetSlotForEntry(launch.title_id, FileSys::ContentRecordType::Program)); - launch.update_storage_id = GetStorageIdForFrontendSlot(storage.GetSlotForEntry( - FileSys::GetUpdateTitleID(launch.title_id), FileSys::ContentRecordType::Program)); + launch.base_game_storage_id = GetStorageIdForFrontendSlot(storage.GetSlotForEntry(launch.title_id, FileSys::ContentRecordType::Program)); + launch.update_storage_id = GetStorageIdForFrontendSlot(storage.GetSlotForEntry(FileSys::GetUpdateTitleID(launch.title_id), FileSys::ContentRecordType::Program)); system.GetARPManager().Register(launch.title_id, launch, out_control); - return process; } diff --git a/src/core/hle/service/am/process_creation.h b/src/core/hle/service/am/process_creation.h index 8cfb9e0c9e..40c3d36aff 100644 --- a/src/core/hle/service/am/process_creation.h +++ b/src/core/hle/service/am/process_creation.h @@ -24,12 +24,7 @@ class Process; namespace Service::AM { -std::unique_ptr CreateProcess(Core::System& system, u64 program_id, - u8 minimum_key_generation, u8 maximum_key_generation); -std::unique_ptr CreateApplicationProcess(std::vector& out_control, - std::unique_ptr& out_loader, - Loader::ResultStatus& out_load_result, - Core::System& system, FileSys::VirtualFile file, - u64 program_id, u64 program_index); +std::optional CreateProcess(Core::System& system, u64 program_id, u8 minimum_key_generation, u8 maximum_key_generation); +std::optional CreateApplicationProcess(std::vector& out_control, std::unique_ptr& out_loader, Loader::ResultStatus& out_load_result, Core::System& system, FileSys::VirtualFile file, u64 program_id, u64 program_index); } // namespace Service::AM diff --git a/src/core/hle/service/am/service/application_creator.cpp b/src/core/hle/service/am/service/application_creator.cpp index d16fd7dd84..4fece53119 100644 --- a/src/core/hle/service/am/service/application_creator.cpp +++ b/src/core/hle/service/am/service/application_creator.cpp @@ -21,8 +21,7 @@ namespace Service::AM { namespace { -Result CreateGuestApplication(SharedPointer* out_application_accessor, - Core::System& system, WindowSystem& window_system, u64 program_id) { +Result CreateGuestApplication(SharedPointer* out_application_accessor, Core::System& system, WindowSystem& window_system, u64 program_id) { FileSys::VirtualFile nca_raw{}; // Get the program NCA from storage. @@ -35,11 +34,10 @@ Result CreateGuestApplication(SharedPointer* out_applicati std::vector control; std::unique_ptr loader; Loader::ResultStatus result; - auto process = - CreateApplicationProcess(control, loader, result, system, nca_raw, program_id, 0); - R_UNLESS(process != nullptr, ResultUnknown); + auto process = CreateApplicationProcess(control, loader, result, system, nca_raw, program_id, 0); + R_UNLESS(process != std::nullopt, ResultUnknown); - const auto applet = std::make_shared(system, std::move(process), true); + const auto applet = std::make_shared(system, std::make_unique(*std::move(process)), true); applet->program_id = program_id; applet->applet_id = AppletId::Application; applet->type = AppletType::Application; @@ -47,8 +45,7 @@ Result CreateGuestApplication(SharedPointer* out_applicati window_system.TrackApplet(applet, true); - *out_application_accessor = - std::make_shared(system, applet, window_system); + *out_application_accessor = std::make_shared(system, applet, window_system); R_SUCCEED(); } @@ -90,12 +87,10 @@ Result IApplicationCreator::CreateSystemApplication( std::vector control; std::unique_ptr loader; + auto process = CreateProcess(system, application_id, 1, 21); + R_UNLESS(process != std::nullopt, ResultUnknown); - auto process = - CreateProcess(system, application_id, 1, 21); - R_UNLESS(process != nullptr, ResultUnknown); - - const auto applet = std::make_shared(system, std::move(process), true); + const auto applet = std::make_shared(system, std::make_unique(*std::move(process)), true); applet->program_id = application_id; applet->applet_id = AppletId::Starter; applet->type = AppletType::LibraryApplet; @@ -103,8 +98,7 @@ Result IApplicationCreator::CreateSystemApplication( m_window_system.TrackApplet(applet, true); - *out_application_accessor = - std::make_shared(system, applet, m_window_system); + *out_application_accessor = std::make_shared(system, applet, m_window_system); Core::LaunchTimestampCache::SaveLaunchTimestamp(application_id); R_SUCCEED(); } diff --git a/src/core/hle/service/am/service/library_applet_creator.cpp b/src/core/hle/service/am/service/library_applet_creator.cpp index e38729e70a..17db4b35d3 100644 --- a/src/core/hle/service/am/service/library_applet_creator.cpp +++ b/src/core/hle/service/am/service/library_applet_creator.cpp @@ -121,26 +121,23 @@ std::shared_ptr CreateGuestApplet(Core::System& system, }; auto process = CreateProcess(system, program_id, Firmware1400, Firmware2100); - if (!process) { - // Couldn't initialize the guest process - return {}; + if (process) { + const auto applet = std::make_shared(system, std::make_unique(*std::move(process)), false); + applet->program_id = program_id; + applet->applet_id = applet_id; + applet->type = AppletType::LibraryApplet; + applet->library_applet_mode = mode; + applet->window_visible = mode != LibraryAppletMode::AllForegroundInitiallyHidden; + + auto broker = std::make_shared(system); + applet->caller_applet = caller_applet; + applet->caller_applet_broker = broker; + caller_applet->child_applets.push_back(applet); + window_system.TrackApplet(applet, false); + return std::make_shared(system, broker, applet); } - - const auto applet = std::make_shared(system, std::move(process), false); - applet->program_id = program_id; - applet->applet_id = applet_id; - applet->type = AppletType::LibraryApplet; - applet->library_applet_mode = mode; - applet->window_visible = mode != LibraryAppletMode::AllForegroundInitiallyHidden; - - auto broker = std::make_shared(system); - applet->caller_applet = caller_applet; - applet->caller_applet_broker = broker; - caller_applet->child_applets.push_back(applet); - - window_system.TrackApplet(applet, false); - - return std::make_shared(system, broker, applet); + // Couldn't initialize the guest process + return {}; } std::shared_ptr CreateFrontendApplet(Core::System& system, diff --git a/src/core/hle/service/audio/audio_out_manager.cpp b/src/core/hle/service/audio/audio_out_manager.cpp index 0a8e1ec256..a5a05a1b76 100644 --- a/src/core/hle/service/audio/audio_out_manager.cpp +++ b/src/core/hle/service/audio/audio_out_manager.cpp @@ -14,7 +14,9 @@ namespace Service::Audio { using namespace AudioCore::AudioOut; IAudioOutManager::IAudioOutManager(Core::System& system_) - : ServiceFramework{system_, "audout:u"}, impl{std::make_unique(system_)} { + : ServiceFramework{system_, "audout:u"} + , impl(system_) +{ // clang-format off static const FunctionInfo functions[] = { {0, D<&IAudioOutManager::ListAudioOuts>, "ListAudioOuts"}, diff --git a/src/core/hle/service/audio/audio_out_manager.h b/src/core/hle/service/audio/audio_out_manager.h index 791274d5e9..57d1eb1e58 100644 --- a/src/core/hle/service/audio/audio_out_manager.h +++ b/src/core/hle/service/audio/audio_out_manager.h @@ -43,7 +43,7 @@ private: AudioCore::AudioOut::AudioOutParameter parameter, InCopyHandle process_handle, ClientAppletResourceUserId aruid); - std::unique_ptr impl; + std::optional impl; }; } // namespace Service::Audio diff --git a/src/core/hle/service/audio/audio_renderer_manager.cpp b/src/core/hle/service/audio/audio_renderer_manager.cpp index 6a1345c074..4f0bf0f3b9 100644 --- a/src/core/hle/service/audio/audio_renderer_manager.cpp +++ b/src/core/hle/service/audio/audio_renderer_manager.cpp @@ -15,7 +15,9 @@ namespace Service::Audio { using namespace AudioCore::Renderer; IAudioRendererManager::IAudioRendererManager(Core::System& system_) - : ServiceFramework{system_, "audren:u"}, impl{std::make_unique(system_)} { + : ServiceFramework{system_, "audren:u"} + , impl(system_) +{ // clang-format off static const FunctionInfo functions[] = { {0, D<&IAudioRendererManager::OpenAudioRenderer>, "OpenAudioRenderer"}, diff --git a/src/core/hle/service/audio/audio_renderer_manager.h b/src/core/hle/service/audio/audio_renderer_manager.h index 69eee664c3..3f25ad6df1 100644 --- a/src/core/hle/service/audio/audio_renderer_manager.h +++ b/src/core/hle/service/audio/audio_renderer_manager.h @@ -30,7 +30,7 @@ private: Result GetAudioDeviceServiceWithRevisionInfo(Out> out_audio_device, u32 revision, ClientAppletResourceUserId aruid); - std::unique_ptr impl; + std::optional impl; u32 num_audio_devices{0}; }; diff --git a/src/core/hle/service/os/process.cpp b/src/core/hle/service/os/process.cpp index 0dbadc315e..ec00af1433 100644 --- a/src/core/hle/service/os/process.cpp +++ b/src/core/hle/service/os/process.cpp @@ -10,14 +10,6 @@ namespace Service { -Process::Process(Core::System& system) - : m_system(system), m_process(), m_main_thread_priority(), m_main_thread_stack_size(), - m_process_started() {} - -Process::~Process() { - this->Finalize(); -} - bool Process::Initialize(Loader::AppLoader& loader, Loader::ResultStatus& out_load_result) { // First, ensure we are not holding another process. this->Finalize(); diff --git a/src/core/hle/service/os/process.h b/src/core/hle/service/os/process.h index 9109b7d0a5..cec61c76c7 100644 --- a/src/core/hle/service/os/process.h +++ b/src/core/hle/service/os/process.h @@ -22,8 +22,8 @@ namespace Service { class Process { public: - explicit Process(Core::System& system); - ~Process(); + inline explicit Process(Core::System& system) noexcept : m_system(system) {} + inline ~Process() { this->Finalize(); } bool Initialize(Loader::AppLoader& loader, Loader::ResultStatus& out_load_result); void Finalize(); @@ -50,8 +50,8 @@ public: private: Core::System& m_system; Kernel::KProcess* m_process{}; - s32 m_main_thread_priority{}; u64 m_main_thread_stack_size{}; + s32 m_main_thread_priority{}; bool m_process_started{}; }; diff --git a/src/video_core/renderer_vulkan/vk_query_cache.cpp b/src/video_core/renderer_vulkan/vk_query_cache.cpp index 7cdb3acadd..7bb632cedc 100644 --- a/src/video_core/renderer_vulkan/vk_query_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_query_cache.cpp @@ -126,16 +126,14 @@ public: current_query = nullptr; amend_value = 0; accumulation_value = 0; - queries_prefix_scan_pass = std::make_unique( - device, scheduler, descriptor_pool, compute_pass_descriptor_queue); + queries_prefix_scan_pass.emplace(device, scheduler, descriptor_pool, compute_pass_descriptor_queue); const VkBufferCreateInfo buffer_ci = { .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, .pNext = nullptr, .flags = 0, .size = 8, - .usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_TRANSFER_SRC_BIT | - VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, + .usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, .sharingMode = VK_SHARING_MODE_EXCLUSIVE, .queueFamilyIndexCount = 0, .pQueueFamilyIndices = nullptr, @@ -592,8 +590,7 @@ private: VideoCommon::HostQueryBase* current_query; bool has_started{}; std::mutex flush_guard; - - std::unique_ptr queries_prefix_scan_pass; + std::optional queries_prefix_scan_pass; }; // Transform feedback queries @@ -1176,35 +1173,21 @@ private: } // namespace struct QueryCacheRuntimeImpl { - QueryCacheRuntimeImpl(QueryCacheRuntime& runtime, VideoCore::RasterizerInterface* rasterizer_, - Tegra::MaxwellDeviceMemoryManager& device_memory_, - Vulkan::BufferCache& buffer_cache_, const Device& device_, - const MemoryAllocator& memory_allocator_, Scheduler& scheduler_, - StagingBufferPool& staging_pool_, - ComputePassDescriptorQueue& compute_pass_descriptor_queue, - DescriptorPool& descriptor_pool, TextureCache& texture_cache_) - : rasterizer{rasterizer_}, device_memory{device_memory_}, buffer_cache{buffer_cache_}, - device{device_}, memory_allocator{memory_allocator_}, scheduler{scheduler_}, - staging_pool{staging_pool_}, guest_streamer(0, runtime), - sample_streamer(static_cast(QueryType::ZPassPixelCount64), runtime, rasterizer, - texture_cache_, device, scheduler, memory_allocator, - compute_pass_descriptor_queue, descriptor_pool), - tfb_streamer(static_cast(QueryType::StreamingByteCount), runtime, device, - scheduler, memory_allocator, staging_pool), - primitives_succeeded_streamer( - static_cast(QueryType::StreamingPrimitivesSucceeded), runtime, tfb_streamer, - device_memory_), - primitives_needed_minus_succeeded_streamer( - static_cast(QueryType::StreamingPrimitivesNeededMinusSucceeded), runtime, 0u), - hcr_setup{}, hcr_is_set{}, is_hcr_running{}, maxwell3d{} { + QueryCacheRuntimeImpl(QueryCacheRuntime& runtime, VideoCore::RasterizerInterface* rasterizer_, Tegra::MaxwellDeviceMemoryManager& device_memory_, Vulkan::BufferCache& buffer_cache_, const Device& device_, const MemoryAllocator& memory_allocator_, Scheduler& scheduler_, StagingBufferPool& staging_pool_, ComputePassDescriptorQueue& compute_pass_descriptor_queue, DescriptorPool& descriptor_pool, TextureCache& texture_cache_) + : rasterizer{rasterizer_}, device_memory{device_memory_}, buffer_cache{buffer_cache_} + , device{device_}, memory_allocator{memory_allocator_}, scheduler{scheduler_} + , staging_pool{staging_pool_}, guest_streamer(0, runtime) + , sample_streamer(size_t(QueryType::ZPassPixelCount64), runtime, rasterizer, texture_cache_, device, scheduler, memory_allocator, compute_pass_descriptor_queue, descriptor_pool) + , tfb_streamer(size_t(QueryType::StreamingByteCount), runtime, device, scheduler, memory_allocator, staging_pool) + , primitives_succeeded_streamer(size_t(QueryType::StreamingPrimitivesSucceeded), runtime, tfb_streamer, device_memory_) + , primitives_needed_minus_succeeded_streamer(size_t(QueryType::StreamingPrimitivesNeededMinusSucceeded), runtime, 0u) + , hcr_setup{}, hcr_is_set{}, is_hcr_running{}, maxwell3d{} { hcr_setup.sType = VK_STRUCTURE_TYPE_CONDITIONAL_RENDERING_BEGIN_INFO_EXT; hcr_setup.pNext = nullptr; hcr_setup.flags = 0; - conditional_resolve_pass = std::make_unique( - device, scheduler, descriptor_pool, compute_pass_descriptor_queue); - + conditional_resolve_pass.emplace(device, scheduler, descriptor_pool, compute_pass_descriptor_queue); const VkBufferCreateInfo buffer_ci = { .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, .pNext = nullptr, @@ -1241,7 +1224,7 @@ struct QueryCacheRuntimeImpl { std::vector> copies_setup; // Host conditional rendering data - std::unique_ptr conditional_resolve_pass; + std::optional conditional_resolve_pass; vk::Buffer hcr_resolve_buffer; VkConditionalRenderingBeginInfoEXT hcr_setup; VkBuffer hcr_buffer; @@ -1253,13 +1236,7 @@ struct QueryCacheRuntimeImpl { Maxwell3D* maxwell3d; }; -QueryCacheRuntime::QueryCacheRuntime(VideoCore::RasterizerInterface* rasterizer, - Tegra::MaxwellDeviceMemoryManager& device_memory_, - Vulkan::BufferCache& buffer_cache_, const Device& device_, - const MemoryAllocator& memory_allocator_, - Scheduler& scheduler_, StagingBufferPool& staging_pool_, - ComputePassDescriptorQueue& compute_pass_descriptor_queue, - DescriptorPool& descriptor_pool, TextureCache& texture_cache_) { +QueryCacheRuntime::QueryCacheRuntime(VideoCore::RasterizerInterface* rasterizer, Tegra::MaxwellDeviceMemoryManager& device_memory_, Vulkan::BufferCache& buffer_cache_, const Device& device_, const MemoryAllocator& memory_allocator_, Scheduler& scheduler_, StagingBufferPool& staging_pool_, ComputePassDescriptorQueue& compute_pass_descriptor_queue, DescriptorPool& descriptor_pool, TextureCache& texture_cache_) { impl = std::make_unique( *this, rasterizer, device_memory_, buffer_cache_, device_, memory_allocator_, scheduler_, staging_pool_, compute_pass_descriptor_queue, descriptor_pool, texture_cache_); @@ -1484,13 +1461,11 @@ void QueryCacheRuntime::Barriers(bool is_prebarrier) { impl->scheduler.RequestOutsideRenderPassOperationContext(); if (is_prebarrier) { impl->scheduler.Record([](vk::CommandBuffer cmdbuf) { - cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, - VK_PIPELINE_STAGE_TRANSFER_BIT, 0, READ_BARRIER); + cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, READ_BARRIER); }); } else { impl->scheduler.Record([](vk::CommandBuffer cmdbuf) { - cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, - VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, WRITE_BARRIER); + cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, WRITE_BARRIER); }); } } @@ -1583,8 +1558,7 @@ void QueryCacheRuntime::SyncValues(std::span values, VkBuffer ba } impl->scheduler.RequestOutsideRenderPassOperationContext(); - impl->scheduler.Record([src_buffer, dst_buffers = std::move(impl->buffers_to_upload_to), - vk_copies = std::move(impl->copies_setup)](vk::CommandBuffer cmdbuf) { + impl->scheduler.Record([src_buffer, dst_buffers = std::move(impl->buffers_to_upload_to), vk_copies = std::move(impl->copies_setup)](vk::CommandBuffer cmdbuf) { size_t size = dst_buffers.size(); for (size_t i = 0; i < size; i++) { cmdbuf.CopyBuffer(src_buffer, dst_buffers[i].first, vk_copies[i]); diff --git a/src/video_core/renderer_vulkan/vk_update_descriptor.h b/src/video_core/renderer_vulkan/vk_update_descriptor.h index 82fce298da..3a1343e02e 100644 --- a/src/video_core/renderer_vulkan/vk_update_descriptor.h +++ b/src/video_core/renderer_vulkan/vk_update_descriptor.h @@ -12,20 +12,15 @@ namespace Vulkan { class Device; class Scheduler; -struct DescriptorUpdateEntry { - struct Empty {}; - +union DescriptorUpdateEntry { DescriptorUpdateEntry() = default; DescriptorUpdateEntry(VkDescriptorImageInfo image_) : image{image_} {} DescriptorUpdateEntry(VkDescriptorBufferInfo buffer_) : buffer{buffer_} {} DescriptorUpdateEntry(VkBufferView texel_buffer_) : texel_buffer{texel_buffer_} {} - - union { - Empty empty{}; - VkDescriptorImageInfo image; - VkDescriptorBufferInfo buffer; - VkBufferView texel_buffer; - }; + std::monostate empty{}; + VkDescriptorImageInfo image; + VkDescriptorBufferInfo buffer; + VkBufferView texel_buffer; }; class UpdateDescriptorQueue final { From 05b8a85aabe01a25ba2bad2f41c4d874bf8166f1 Mon Sep 17 00:00:00 2001 From: lizzie Date: Sat, 7 Mar 2026 04:18:30 +0000 Subject: [PATCH 02/25] fx --- src/audio_core/audio_core.cpp | 3 +++ src/audio_core/audio_core.h | 3 +++ src/audio_core/audio_in_manager.cpp | 3 +++ src/audio_core/audio_out_manager.cpp | 3 +++ src/core/hle/service/am/process_creation.cpp | 3 +++ src/core/hle/service/am/process_creation.h | 3 +++ src/core/hle/service/am/service/application_creator.cpp | 2 +- src/core/hle/service/am/service/library_applet_creator.cpp | 2 +- src/core/hle/service/audio/audio_out_manager.cpp | 2 +- src/core/hle/service/audio/audio_out_manager.h | 2 +- src/core/hle/service/audio/audio_renderer_manager.cpp | 3 +++ src/core/hle/service/audio/audio_renderer_manager.h | 3 +++ src/core/hle/service/os/process.cpp | 3 +++ src/core/hle/service/os/process.h | 3 +++ src/video_core/renderer_vulkan/vk_update_descriptor.h | 5 ++++- 15 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/audio_core/audio_core.cpp b/src/audio_core/audio_core.cpp index 28d38c8881..234c831ac0 100644 --- a/src/audio_core/audio_core.cpp +++ b/src/audio_core/audio_core.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/audio_core/audio_core.h b/src/audio_core/audio_core.h index e4771d7656..ababd780b1 100644 --- a/src/audio_core/audio_core.h +++ b/src/audio_core/audio_core.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/audio_core/audio_in_manager.cpp b/src/audio_core/audio_in_manager.cpp index c11e88b317..6b528e9db0 100644 --- a/src/audio_core/audio_in_manager.cpp +++ b/src/audio_core/audio_in_manager.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/audio_core/audio_out_manager.cpp b/src/audio_core/audio_out_manager.cpp index dee3d493e5..569df8d1e0 100644 --- a/src/audio_core/audio_out_manager.cpp +++ b/src/audio_core/audio_out_manager.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/core/hle/service/am/process_creation.cpp b/src/core/hle/service/am/process_creation.cpp index cd537062d7..a20ac7de83 100644 --- a/src/core/hle/service/am/process_creation.cpp +++ b/src/core/hle/service/am/process_creation.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/core/hle/service/am/process_creation.h b/src/core/hle/service/am/process_creation.h index 40c3d36aff..57d8b8f815 100644 --- a/src/core/hle/service/am/process_creation.h +++ b/src/core/hle/service/am/process_creation.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/core/hle/service/am/service/application_creator.cpp b/src/core/hle/service/am/service/application_creator.cpp index 4fece53119..e8e4a103c2 100644 --- a/src/core/hle/service/am/service/application_creator.cpp +++ b/src/core/hle/service/am/service/application_creator.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project diff --git a/src/core/hle/service/am/service/library_applet_creator.cpp b/src/core/hle/service/am/service/library_applet_creator.cpp index 17db4b35d3..9f0359ed2b 100644 --- a/src/core/hle/service/am/service/library_applet_creator.cpp +++ b/src/core/hle/service/am/service/library_applet_creator.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project diff --git a/src/core/hle/service/audio/audio_out_manager.cpp b/src/core/hle/service/audio/audio_out_manager.cpp index a5a05a1b76..3b2087932c 100644 --- a/src/core/hle/service/audio/audio_out_manager.cpp +++ b/src/core/hle/service/audio/audio_out_manager.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project diff --git a/src/core/hle/service/audio/audio_out_manager.h b/src/core/hle/service/audio/audio_out_manager.h index 57d1eb1e58..ec974aaba4 100644 --- a/src/core/hle/service/audio/audio_out_manager.h +++ b/src/core/hle/service/audio/audio_out_manager.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project diff --git a/src/core/hle/service/audio/audio_renderer_manager.cpp b/src/core/hle/service/audio/audio_renderer_manager.cpp index 4f0bf0f3b9..972e930a89 100644 --- a/src/core/hle/service/audio/audio_renderer_manager.cpp +++ b/src/core/hle/service/audio/audio_renderer_manager.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/core/hle/service/audio/audio_renderer_manager.h b/src/core/hle/service/audio/audio_renderer_manager.h index 3f25ad6df1..fdce8b6ffa 100644 --- a/src/core/hle/service/audio/audio_renderer_manager.h +++ b/src/core/hle/service/audio/audio_renderer_manager.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/core/hle/service/os/process.cpp b/src/core/hle/service/os/process.cpp index ec00af1433..2d5d7def64 100644 --- a/src/core/hle/service/os/process.cpp +++ b/src/core/hle/service/os/process.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/core/hle/service/os/process.h b/src/core/hle/service/os/process.h index cec61c76c7..ca10945f84 100644 --- a/src/core/hle/service/os/process.h +++ b/src/core/hle/service/os/process.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/video_core/renderer_vulkan/vk_update_descriptor.h b/src/video_core/renderer_vulkan/vk_update_descriptor.h index 3a1343e02e..1497108b16 100644 --- a/src/video_core/renderer_vulkan/vk_update_descriptor.h +++ b/src/video_core/renderer_vulkan/vk_update_descriptor.h @@ -1,10 +1,13 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #pragma once #include - +#include #include "video_core/vulkan_common/vulkan_wrapper.h" namespace Vulkan { From f2c46eadc15e5ae52f91532758191d3baba1d7b0 Mon Sep 17 00:00:00 2001 From: lizzie Date: Sun, 8 Mar 2026 19:32:24 +0100 Subject: [PATCH 03/25] [ports] build fixes for *BSD make (#3496) Signed-off-by: lizzie Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3496 Reviewed-by: DraVee Reviewed-by: crueter Co-authored-by: lizzie Co-committed-by: lizzie --- docs/Caveats.md | 10 ++++++++-- src/common/thread.cpp | 4 +++- src/video_core/host_shaders/CMakeLists.txt | 6 ++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/docs/Caveats.md b/docs/Caveats.md index 39b5ab15e6..d554f3ff77 100644 --- a/docs/Caveats.md +++ b/docs/Caveats.md @@ -91,7 +91,7 @@ After configuration, you may need to modify `externals/ffmpeg/CMakeFiles/ffmpeg- `-lc++-experimental` doesn't exist in OpenBSD but the LLVM driver still tries to link against it, to solve just symlink `ln -s /usr/lib/libc++.a /usr/lib/libc++experimental.a`. Builds are currently not working due to lack of `std::jthread` and such, either compile libc++ manually or wait for ports to catch up. -If clang has errors, try using `g++-11`. +If clang has errors, try using `g++11`. ## FreeBSD @@ -107,6 +107,8 @@ hw.usb.usbhid.enable="0" ## NetBSD +2026-02-07: `vulkan-headers` must not be installed, since the version found in `pkgsrc` is older than required. Either wait for binary packages to update or build newer versions from source. + Install `pkgin` if not already `pkg_add pkgin`, see also the general [pkgsrc guide](https://www.netbsd.org/docs/pkgsrc/using.html). For NetBSD 10.1 provide `echo 'PKG_PATH="https://cdn.netbsd.org/pub/pkgsrc/packages/NetBSD/amd64/10.1/All/"' >/etc/pkg_install.conf`. If `pkgin` is taking too much time consider adding the following to `/etc/rc.conf`: ```sh @@ -116,7 +118,7 @@ ip6addrctl_policy=ipv4_prefer System provides a default `g++-10` which doesn't support the current C++ codebase; install `clang-19` with `pkgin install clang-19`. Or install `gcc14` (or `gcc15` with current pkgsrc). Provided that, the following CMake commands may work: -- `cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -Bbuild` +- `cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -Bbuild` (Recommended) - `cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/pkg/gcc14/bin/gcc -DCMAKE_CXX_COMPILER=/usr/pkg/gcc14/bin/g++ -Bbuild` - `cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/pkg/gcc15/bin/gcc -DCMAKE_CXX_COMPILER=/usr/pkg/gcc15/bin/g++ -Bbuild` @@ -138,8 +140,12 @@ cmake --install build However, pkgsrc is highly recommended, see [getting pkgsrc](https://iso.us.netbsd.org/pub/pkgsrc/current/pkgsrc/doc/pkgsrc.html#getting). You must get `current` not the `2025Q2` version. +`QtCore` on NetBSD is included, but due to misconfigurations(!) we MUST include one of the standard headers that include `bits/c++config.h`, since source_location (required by `QtCore`) isn't properly configured to intake `bits/c++config.h` (none of the experimental library is). This is a bug with NetBSD packaging and not our fault, but alas. + ## DragonFlyBSD +2026-02-07: `vulkan-headers` and `vulkan-utility-libraries` must NOT be uninstalled, since they're too old: `1.3.289`. Either wait for binary packages to update or build newer versions from source. + If `libstdc++.so.6` is not found (`GLIBCXX_3.4.30`) then attempt: ```sh diff --git a/src/common/thread.cpp b/src/common/thread.cpp index eac0f60131..b0b63ae35c 100644 --- a/src/common/thread.cpp +++ b/src/common/thread.cpp @@ -19,10 +19,12 @@ #include #include "common/string_util.h" #else -#if defined(__Bitrig__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__) +#if defined(__FreeBSD__) #include #include #include +#elif defined(__DragonFly__) || defined(__OpenBSD__) || defined(__Bitrig__) +#include #endif #include #include diff --git a/src/video_core/host_shaders/CMakeLists.txt b/src/video_core/host_shaders/CMakeLists.txt index 60b399ccba..668f939546 100644 --- a/src/video_core/host_shaders/CMakeLists.txt +++ b/src/video_core/host_shaders/CMakeLists.txt @@ -118,6 +118,8 @@ if (NOT GLSLANG_ERROR STREQUAL "") set(QUIET_FLAG "") endif() +# Shader files must depend on their directory otherwise *BSD make will spontaneously combust +file(MAKE_DIRECTORY "${SHADER_DIR}") foreach(SOURCE_FILE IN ITEMS ${SHADER_FILES}) get_filename_component(FILENAME ${SOURCE_FILE} NAME) string(REPLACE "." "_" SHADER_NAME ${FILENAME}) @@ -133,6 +135,7 @@ foreach(SOURCE_FILE IN ITEMS ${SHADER_FILES}) ${SOURCE_FILE} DEPENDS ${INPUT_FILE} + ${SHADER_DIR} # HEADER_GENERATOR should be included here but msbuild seems to assume it's always modified ) set(SHADER_HEADERS ${SHADER_HEADERS} ${SOURCE_HEADER_FILE}) @@ -148,6 +151,8 @@ foreach(SOURCE_FILE IN ITEMS ${SHADER_FILES}) ${GLSLANGVALIDATOR} -V ${QUIET_FLAG} -I"${FIDELITYFX_INCLUDE_DIR}" ${GLSL_FLAGS} --variable-name ${SPIRV_VARIABLE_NAME} -o ${SPIRV_HEADER_FILE} ${SOURCE_FILE} --target-env ${SPIR_V_VERSION} MAIN_DEPENDENCY ${SOURCE_FILE} + DEPENDS + ${SHADER_DIR} ) set(SHADER_HEADERS ${SHADER_HEADERS} ${SPIRV_HEADER_FILE}) endif() @@ -167,6 +172,7 @@ foreach(FILEPATH IN ITEMS ${FIDELITYFX_FILES}) ${SOURCE_FILE} DEPENDS ${INPUT_FILE} + ${SHADER_DIR} # HEADER_GENERATOR should be included here but msbuild seems to assume it's always modified ) set(SHADER_HEADERS ${SHADER_HEADERS} ${SOURCE_HEADER_FILE}) From 80bafc8fe876371c90d64fb9b7288e03d2ba8da8 Mon Sep 17 00:00:00 2001 From: wildcard Date: Sun, 8 Mar 2026 20:48:19 +0100 Subject: [PATCH 04/25] [vulkan] Fix incorrect offset application for Array2D textures (#3696) Earlier we were taking the coords and adding them to coords instead of actually taking offsets and adding it to coord Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3696 Reviewed-by: MaranBr Reviewed-by: crueter Co-authored-by: wildcard Co-committed-by: wildcard --- src/shader_recompiler/backend/spirv/emit_spirv_image.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp index 4bff810547..c4c898bec9 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp @@ -343,8 +343,8 @@ void AddOffsetToCoordinates(EmitContext& ctx, const IR::TextureInstInfo& info, I break; } case TextureType::ColorArray2D: - offset = ctx.OpCompositeConstruct(ctx.U32[3], ctx.OpCompositeExtract(ctx.U32[1], coords, 0), - ctx.OpCompositeExtract(ctx.U32[1], coords, 1), + offset = ctx.OpCompositeConstruct(ctx.U32[3], ctx.OpCompositeExtract(ctx.U32[1], offset, 0), + ctx.OpCompositeExtract(ctx.U32[1], offset, 1), ctx.u32_zero_value); [[fallthrough]]; case TextureType::Color3D: { From 0a169dec4dc8438aac40206bfa62cf151d34afd5 Mon Sep 17 00:00:00 2001 From: lizzie Date: Sun, 8 Mar 2026 20:48:47 +0100 Subject: [PATCH 05/25] [qt] fix crash when having an invalid graphics backend (#3693) closely related to #3692, however the crash may also occur when sharing configs between macOS and a system that had OpenGL Signed-off-by: lizzie Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3693 Reviewed-by: DraVee Reviewed-by: crueter Co-authored-by: lizzie Co-committed-by: lizzie --- src/yuzu/configuration/configure_graphics.cpp | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp index 8663594678..b0c63aff4f 100644 --- a/src/yuzu/configuration/configure_graphics.cpp +++ b/src/yuzu/configuration/configure_graphics.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: 2016 Citra Emulator Project @@ -416,11 +416,9 @@ const QString ConfigureGraphics::TranslateVSyncMode(VkPresentModeKHR mode, } int ConfigureGraphics::FindIndex(u32 enumeration, int value) const { - for (u32 i = 0; i < combobox_translations.at(enumeration).size(); i++) { - if (combobox_translations.at(enumeration)[i].first == static_cast(value)) { + for (u32 i = 0; enumeration < combobox_translations.size() && i < combobox_translations.at(enumeration).size(); i++) + if (combobox_translations.at(enumeration)[i].first == u32(value)) return i; - } - } return -1; } @@ -433,13 +431,11 @@ void ConfigureGraphics::ApplyConfiguration() { UpdateVsyncSetting(); Settings::values.vulkan_device.SetGlobal(true); - if (Settings::IsConfiguringGlobal() || - (!Settings::IsConfiguringGlobal() && api_restore_global_button->isEnabled())) { - auto backend = static_cast( - combobox_translations - .at(Settings::EnumMetadata< - Settings::RendererBackend>::Index())[api_combobox->currentIndex()] - .first); + auto const index = Settings::EnumMetadata::Index(); + if (Settings::IsConfiguringGlobal() || (!Settings::IsConfiguringGlobal() && api_restore_global_button->isEnabled())) { + auto backend = index >= combobox_translations.size() || size_t(api_combobox->currentIndex()) >= combobox_translations.at(index).size() + ? Settings::values.renderer_backend.GetValue() + : Settings::RendererBackend(combobox_translations.at(index)[api_combobox->currentIndex()].first); switch (backend) { case Settings::RendererBackend::Vulkan: Settings::values.vulkan_device.SetGlobal(Settings::IsConfiguringGlobal()); @@ -507,13 +503,12 @@ void ConfigureGraphics::RetrieveVulkanDevices() { Settings::RendererBackend ConfigureGraphics::GetCurrentGraphicsBackend() const { const auto selected_backend = [&]() { - if (!Settings::IsConfiguringGlobal() && !api_restore_global_button->isEnabled()) { + auto const index = Settings::EnumMetadata::Index(); + if (!Settings::IsConfiguringGlobal() && !api_restore_global_button->isEnabled()) return Settings::values.renderer_backend.GetValue(true); - } - return Settings::RendererBackend( - combobox_translations.at(Settings::EnumMetadata::Index()) - .at(api_combobox->currentIndex()) - .first); + return index >= combobox_translations.size() || size_t(api_combobox->currentIndex()) >= combobox_translations.at(index).size() + ? Settings::values.renderer_backend.GetValue() + : Settings::RendererBackend(combobox_translations.at(index).at(api_combobox->currentIndex()).first); }(); if (selected_backend == Settings::RendererBackend::Vulkan && UISettings::values.has_broken_vulkan) From 1864160326c4d1f7484c41aa824e33ac7e28e1c1 Mon Sep 17 00:00:00 2001 From: lizzie Date: Sun, 8 Mar 2026 20:49:17 +0100 Subject: [PATCH 06/25] [qt] remove 'None' interface since net code already uses first avail interface anyways, disable changing ifaces at runtime (#3683) Signed-off-by: lizzie Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3683 Reviewed-by: DraVee Reviewed-by: crueter Co-authored-by: lizzie Co-committed-by: lizzie --- src/yuzu/configuration/configure_network.cpp | 21 ++++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/yuzu/configuration/configure_network.cpp b/src/yuzu/configuration/configure_network.cpp index 7df5e51a7f..62a097117e 100644 --- a/src/yuzu/configuration/configure_network.cpp +++ b/src/yuzu/configuration/configure_network.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project @@ -12,14 +12,13 @@ #include "yuzu/configuration/configure_network.h" ConfigureNetwork::ConfigureNetwork(const Core::System& system_, QWidget* parent) - : QWidget(parent), ui(std::make_unique()), system{system_} { + : QWidget(parent) + , ui(std::make_unique()) + , system{system_} +{ ui->setupUi(this); - - ui->network_interface->addItem(tr("None")); - for (const auto& iface : Network::GetAvailableNetworkInterfaces()) { + for (const auto& iface : Network::GetAvailableNetworkInterfaces()) ui->network_interface->addItem(QString::fromStdString(iface.name)); - } - this->SetConfiguration(); } @@ -44,13 +43,9 @@ void ConfigureNetwork::RetranslateUI() { void ConfigureNetwork::SetConfiguration() { const bool runtime_lock = !system.IsPoweredOn(); - - const std::string& network_interface = Settings::values.network_interface.GetValue(); - const bool& airplane_mode = Settings::values.airplane_mode.GetValue(); - + auto const network_interface = Settings::values.network_interface.GetValue(); + auto const airplane_mode = Settings::values.airplane_mode.GetValue(); ui->network_interface->setCurrentText(QString::fromStdString(network_interface)); ui->network_interface->setEnabled(runtime_lock); - ui->airplane_mode->setChecked(airplane_mode); - ui->network_interface->setEnabled(true); } From 38aa2bc5e1620539d4804528a37f72dc30376ead Mon Sep 17 00:00:00 2001 From: lizzie Date: Sun, 8 Mar 2026 20:50:29 +0100 Subject: [PATCH 07/25] [hle/services] use ankerl:: for Service's function handlers map, use const char* instead of std::string{} (#3671) Signed-off-by: lizzie Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3671 Reviewed-by: DraVee Reviewed-by: crueter Co-authored-by: lizzie Co-committed-by: lizzie --- src/core/hle/service/service.cpp | 16 +++++++++------- src/core/hle/service/service.h | 28 +++++++++++----------------- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index b972b83e1a..8b71a97320 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project @@ -29,10 +29,13 @@ namespace Service { return function_string; } -ServiceFrameworkBase::ServiceFrameworkBase(Core::System& system_, const char* service_name_, - u32 max_sessions_, InvokerFn* handler_invoker_) - : SessionRequestHandler(system_.Kernel(), service_name_), system{system_}, - service_name{service_name_}, handler_invoker{handler_invoker_}, max_sessions{max_sessions_} {} +ServiceFrameworkBase::ServiceFrameworkBase(Core::System& system_, const char* service_name_, u32 max_sessions_, InvokerFn* handler_invoker_) + : SessionRequestHandler(system_.Kernel(), service_name_) + , system{system_} + , service_name{service_name_} + , handler_invoker{handler_invoker_} + , max_sessions{max_sessions_} +{} ServiceFrameworkBase::~ServiceFrameworkBase() { // Wait for other threads to release access before destroying @@ -50,8 +53,7 @@ void ServiceFrameworkBase::RegisterHandlersBaseTipc(const FunctionInfoBase* func // Usually this array is sorted by id already, so hint to insert at the end handlers_tipc.reserve(handlers_tipc.size() + n); for (std::size_t i = 0; i < n; ++i) - handlers_tipc.emplace_hint(handlers_tipc.cend(), functions[i].expected_header, - functions[i]); + handlers_tipc.emplace_hint(handlers_tipc.cend(), functions[i].expected_header, functions[i]); } void ServiceFrameworkBase::ReportUnimplementedFunction(HLERequestContext& ctx, diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index dbc870a662..41429958ad 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project @@ -8,8 +8,7 @@ #include #include -#include -#include +#include #include "common/common_types.h" #include "core/hle/service/hle_ipc.h" @@ -78,13 +77,6 @@ protected: [[nodiscard]] virtual std::unique_lock LockService() noexcept { return std::unique_lock{lock_service}; } - - /// System context that the service operates under. - Core::System& system; - - /// Identifier string used to connect to the service. - std::string service_name; - private: template friend class ServiceFramework; @@ -106,16 +98,19 @@ private: void RegisterHandlersBaseTipc(const FunctionInfoBase* functions, std::size_t n); void ReportUnimplementedFunction(HLERequestContext& ctx, const FunctionInfoBase* info); - boost::container::flat_map handlers; - boost::container::flat_map handlers_tipc; +protected: + ankerl::unordered_dense::map handlers; + ankerl::unordered_dense::map handlers_tipc; /// Used to gain exclusive access to the service members, e.g. from CoreTiming thread. std::mutex lock_service; + /// System context that the service operates under. + Core::System& system; + /// Identifier string used to connect to the service. + const char* service_name; /// Function used to safely up-cast pointers to the derived class before invoking a handler. InvokerFn* handler_invoker; - /// Maximum number of concurrent sessions that this service can handle. u32 max_sessions; - /// Flag to store if a port was already create/installed to detect multiple install attempts, /// which is not supported. bool service_registered = false; @@ -159,8 +154,7 @@ protected: * @param max_sessions_ Maximum number of sessions that can be connected to this service at the * same time. */ - explicit ServiceFramework(Core::System& system_, const char* service_name_, - u32 max_sessions_ = ServerSessionCountMax) + explicit ServiceFramework(Core::System& system_, const char* service_name_, u32 max_sessions_ = ServerSessionCountMax) : ServiceFrameworkBase(system_, service_name_, max_sessions_, Invoker) {} /// Registers handlers in the service. @@ -219,7 +213,7 @@ private: static void Invoker(ServiceFrameworkBase* object, HandlerFnP member, HLERequestContext& ctx) { // Cast back up to our original types and call the member function - (static_cast(object)->*static_cast>(member))(ctx); + (static_cast(object)->*HandlerFnP(member))(ctx); } }; From c7b23f4a1aec49b445bf88196d7206c93b1a8759 Mon Sep 17 00:00:00 2001 From: crueter Date: Sun, 8 Mar 2026 20:53:37 +0100 Subject: [PATCH 08/25] [time] fix: guard timezone out buffer logging (#3668) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Original text, per the emailed patch: --------------- Hello, I am submitting a small fix to prevent an unintended abort when _GLIBCXX_ASSERTIONS is enabled, caused by out-of-bounds access in debug logging. Background / Issue In the server-side implementations of ITimeZoneService::ToPosixTime and ToPosixTimeWithMyRule, the SCOPE_EXIT debug logging previously accessed out_times[0] and out_times[1] unconditionally. However, out_times is an IPC-provided output buffer (OutArray, which inherits from std::span). Its length depends on the caller-provided buffer capacity. During debugging, I encountered a case where out_times.size() == 1. Under _GLIBCXX_ASSERTIONS, accessing out_times[1] triggers a std::span::operator[] assertion failure (std::__glibcxx_assert_fail) and aborts the process, causing the service thread to crash. This results in an unintended crash caused solely by debug logging. Change Description In the SCOPE_EXIT logging blocks of both ToPosixTime and ToPosixTimeWithMyRule, I added bounds checks before accessing out_times[0] and out_times[1]: Access out_times[0] only if out_times.size() > 0 Access out_times[1] only if out_times.size() > 1 Print 0 when the corresponding element is unavailable This change only affects debug log output. It does not modify IPC semantics or the time conversion logic itself. Reproduction Context (for reference) I encountered this issue while running 13 Sentinels: Aegis Rim (title ID: 01008D7016438000). During the “Load Game” flow, ToPosixTimeWithMyRule is invoked with an out_times buffer of length 1, which previously led to the out-of-bounds access in the logging code. Thank you for your time and review. Best regards, darkpaper Environment: Arch Linux / KDE / X11 This email and the accompanying patch were prepared with assistance from an LLM. Authored-by: darkpaper Signed-off-by: crueter Co-authored-by: darkpaper Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3668 --- src/core/hle/service/glue/time/time_zone.cpp | 12 +++++++++--- src/core/hle/service/psc/time/time_zone_service.cpp | 9 +++++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/core/hle/service/glue/time/time_zone.cpp b/src/core/hle/service/glue/time/time_zone.cpp index b2e8159653..c358cfbf28 100644 --- a/src/core/hle/service/glue/time/time_zone.cpp +++ b/src/core/hle/service/glue/time/time_zone.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -104,7 +107,8 @@ Result TimeZoneService::LoadLocationNameList( OutArray out_names, u32 index) { SCOPE_EXIT { LOG_DEBUG(Service_Time, "called. index={} out_count={} out_names[0]={} out_names[1]={}", - index, *out_count, out_names[0], out_names[1]); + index, *out_count, out_names.size() > 0 ? out_names[0] : Service::PSC::Time::LocationName{}, + out_names.size() > 1 ? out_names[1] : Service::PSC::Time::LocationName{}); }; std::scoped_lock l{m_mutex}; @@ -208,7 +212,8 @@ Result TimeZoneService::ToPosixTime(Out out_count, SCOPE_EXIT { LOG_DEBUG(Service_Time, "called. calendar_time={} out_count={} out_times[0]={} out_times[1]={}", - calendar_time, *out_count, out_times[0], out_times[1]); + calendar_time, *out_count, out_times.size() > 0 ? out_times[0] : s64{0}, + out_times.size() > 1 ? out_times[1] : s64{0}); }; R_RETURN(m_wrapped_service->ToPosixTime(out_count, out_times, calendar_time, rule)); @@ -220,7 +225,8 @@ Result TimeZoneService::ToPosixTimeWithMyRule( SCOPE_EXIT { LOG_DEBUG(Service_Time, "called. calendar_time={} out_count={} out_times[0]={} out_times[1]={}", - calendar_time, *out_count, out_times[0], out_times[1]); + calendar_time, *out_count, out_times.size() > 0 ? out_times[0] : s64{0}, + out_times.size() > 1 ? out_times[1] : s64{0}); }; R_RETURN(m_wrapped_service->ToPosixTimeWithMyRule(out_count, out_times, calendar_time)); diff --git a/src/core/hle/service/psc/time/time_zone_service.cpp b/src/core/hle/service/psc/time/time_zone_service.cpp index 9e0674f275..d49c0056ec 100644 --- a/src/core/hle/service/psc/time/time_zone_service.cpp +++ b/src/core/hle/service/psc/time/time_zone_service.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -148,7 +151,8 @@ Result TimeZoneService::ToPosixTime(Out out_count, SCOPE_EXIT { LOG_DEBUG(Service_Time, "called. calendar_time={} out_count={} out_times[0]={} out_times[1]={} ", - calendar_time, *out_count, out_times[0], out_times[1]); + calendar_time, *out_count, out_times.size() > 0 ? out_times[0] : s64{0}, + out_times.size() > 1 ? out_times[1] : s64{0}); }; R_RETURN( @@ -161,7 +165,8 @@ Result TimeZoneService::ToPosixTimeWithMyRule(Out out_count, SCOPE_EXIT { LOG_DEBUG(Service_Time, "called. calendar_time={} out_count={} out_times[0]={} out_times[1]={} ", - calendar_time, *out_count, out_times[0], out_times[1]); + calendar_time, *out_count, out_times.size() > 0 ? out_times[0] : s64{0}, + out_times.size() > 1 ? out_times[1] : s64{0}); }; R_RETURN( From 3d1a67af18128831539c24f804b112f75b0194fd Mon Sep 17 00:00:00 2001 From: crueter Date: Sun, 8 Mar 2026 22:33:51 +0100 Subject: [PATCH 09/25] [externals] Update dependencies (#3664) * zlib: 1.3.1.2 -> 1.3.2 * vulkan-validation-layers: 1.4.335.0 -> 1.4.341.0 * sirit: 1.0.3 -> 1.0.4 * httplib: 0.35.0 -> 0.37.0 * xbyak: 7.33.3 -> 7.35.2 * catch2: 3.12.0 -> 3.13.0 * vulkan-headers: 1.4.342 -> 1.4.345 * vulkan-utility-libraries: 1.4.342 -> 1.4.345 Also fixed a build error with newer xbyak. Signed-off-by: crueter Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3664 --- .patch/httplib/0002-fix-zstd.patch | 89 +++++++++++++++++++ cpmfile.json | 8 +- externals/cpmfile.json | 25 +++--- src/CMakeLists.txt | 1 + src/core/CMakeLists.txt | 2 +- .../src/dynarmic/backend/x64/a32_emit_x64.cpp | 2 +- .../backend/x64/emit_x64_data_processing.cpp | 2 +- .../backend/x64/emit_x64_saturation.cpp | 4 +- tools/cpm/package/update.sh | 29 +++++- tools/cpm/package/util/fix-hash.sh | 8 +- 10 files changed, 145 insertions(+), 25 deletions(-) create mode 100644 .patch/httplib/0002-fix-zstd.patch diff --git a/.patch/httplib/0002-fix-zstd.patch b/.patch/httplib/0002-fix-zstd.patch new file mode 100644 index 0000000000..f54485ea53 --- /dev/null +++ b/.patch/httplib/0002-fix-zstd.patch @@ -0,0 +1,89 @@ +From 509be32bbfa6eb95014860f7c9ea6d45c8ddaa56 Mon Sep 17 00:00:00 2001 +From: crueter +Date: Sun, 8 Mar 2026 15:11:12 -0400 +Subject: [PATCH] [cmake] Simplify zstd find logic, and support pre-existing + zstd target + +Some deduplication work on the zstd required/if-available logic. Also +adds support for pre-existing `zstd::libzstd` which is useful for +projects that bundle their own zstd in a way that doesn't get caught by +`CONFIG` + +Signed-off-by: crueter +--- + CMakeLists.txt | 46 ++++++++++++++++++++++++++-------------------- + 1 file changed, 26 insertions(+), 20 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 1874e36be0..8d31198006 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -241,28 +241,34 @@ endif() + # NOTE: + # zstd < 1.5.6 does not provide the CMake imported target `zstd::libzstd`. + # Older versions must be consumed via their pkg-config file. +-if(HTTPLIB_REQUIRE_ZSTD) +- find_package(zstd 1.5.6 CONFIG) +- if(NOT zstd_FOUND) +- find_package(PkgConfig REQUIRED) +- pkg_check_modules(zstd REQUIRED IMPORTED_TARGET libzstd) +- add_library(zstd::libzstd ALIAS PkgConfig::zstd) +- endif() +- set(HTTPLIB_IS_USING_ZSTD TRUE) +-elseif(HTTPLIB_USE_ZSTD_IF_AVAILABLE) +- find_package(zstd 1.5.6 CONFIG QUIET) +- if(NOT zstd_FOUND) +- find_package(PkgConfig QUIET) +- if(PKG_CONFIG_FOUND) +- pkg_check_modules(zstd QUIET IMPORTED_TARGET libzstd) +- +- if(TARGET PkgConfig::zstd) ++if (HTTPLIB_REQUIRE_ZSTD) ++ set(HTTPLIB_ZSTD_REQUESTED ON) ++ set(HTTPLIB_ZSTD_REQUIRED REQUIRED) ++elseif (HTTPLIB_USE_ZSTD_IF_AVAILABLE) ++ set(HTTPLIB_ZSTD_REQUESTED ON) ++ set(HTTPLIB_ZSTD_REQUIRED QUIET) ++endif() ++ ++if (HTTPLIB_ZSTD_REQUESTED) ++ if (TARGET zstd::libzstd) ++ set(HTTPLIB_IS_USING_ZSTD TRUE) ++ else() ++ find_package(zstd 1.5.6 CONFIG QUIET) ++ ++ if (NOT zstd_FOUND) ++ find_package(PkgConfig ${HTTPLIB_ZSTD_REQUIRED}) ++ pkg_check_modules(zstd ${HTTPLIB_ZSTD_REQUIRED} IMPORTED_TARGET libzstd) ++ ++ if (TARGET PkgConfig::zstd) + add_library(zstd::libzstd ALIAS PkgConfig::zstd) + endif() + endif() ++ ++ # This will always be true if zstd is required. ++ # If zstd *isn't* found when zstd is set to required, ++ # CMake will error out earlier in this block. ++ set(HTTPLIB_IS_USING_ZSTD ${zstd_FOUND}) + endif() +- # Both find_package and PkgConf set a XXX_FOUND var +- set(HTTPLIB_IS_USING_ZSTD ${zstd_FOUND}) + endif() + + # Used for default, common dirs that the end-user can change (if needed) +@@ -317,13 +323,13 @@ if(HTTPLIB_COMPILE) + $ + $ + ) +- ++ + # Add C++20 module support if requested + # Include from separate file to prevent parse errors on older CMake versions + if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.28") + include(cmake/modules.cmake) + endif() +- ++ + set_target_properties(${PROJECT_NAME} + PROPERTIES + VERSION ${${PROJECT_NAME}_VERSION} diff --git a/cpmfile.json b/cpmfile.json index 774f160360..c938e67e88 100644 --- a/cpmfile.json +++ b/cpmfile.json @@ -46,9 +46,9 @@ "package": "ZLIB", "repo": "madler/zlib", "tag": "v%VERSION%", - "hash": "06eaa3a1eaaeb31f461a2283b03a91ed8eb2406e62cd97ea1c69836324909edeecd93edd03ff0bf593d9dde223e3376149134c5b1fe2e8688c258cadf8cd60ff", + "hash": "16fea4df307a68cf0035858abe2fd550250618a97590e202037acd18a666f57afc10f8836cbbd472d54a0e76539d0e558cb26f059d53de52ff90634bbf4f47d4", "version": "1.2", - "git_version": "1.3.1.2", + "git_version": "1.3.2", "options": [ "ZLIB_BUILD_SHARED OFF", "ZLIB_INSTALL OFF" @@ -98,9 +98,9 @@ "package": "VVL", "repo": "KhronosGroup/Vulkan-ValidationLayers", "tag": "vulkan-sdk-%VERSION%", - "git_version": "1.4.335.0", + "git_version": "1.4.341.0", "artifact": "android-binaries-%VERSION%.zip", - "hash": "48167c4a17736301bd08f9290f41830443e1f18cce8ad867fc6f289b49e18b40e93c9850b377951af82f51b5b6d7313aa6a884fc5df79f5ce3df82696c1c1244" + "hash": "8812ae84cbe49e6a3418ade9c458d3be6d74a3dffd319d4502007b564d580998056e8190414368ec11b27bc83993c7a0dad713c31bcc3d9553b51243efee3753" }, "quazip": { "package": "QuaZip-Qt6", diff --git a/externals/cpmfile.json b/externals/cpmfile.json index 9644647638..de024fd40e 100644 --- a/externals/cpmfile.json +++ b/externals/cpmfile.json @@ -9,7 +9,7 @@ }, "sirit": { "repo": "eden-emulator/sirit", - "git_version": "1.0.3", + "git_version": "1.0.4", "tag": "v%VERSION%", "artifact": "sirit-source-%VERSION%.tar.zst", "hash_suffix": "sha512sum", @@ -28,11 +28,12 @@ "httplib": { "repo": "yhirose/cpp-httplib", "tag": "v%VERSION%", - "hash": "a229e24cca4afe78e5c0aa2e482f15108ac34101fd8dbd927365f15e8c37dec4de38c5277d635017d692a5b320e1b929f8bfcc076f52b8e4dcdab8fe53bfdf2e", - "git_version": "0.30.1", + "hash": "5efa8140aadffe105dcf39935b732476e95755f6c7473ada3d0b64df2bc02c557633ae3948a25b45e1cf67e89a3ff6329fb30362e4ac033b9a1d1e453aa2eded", + "git_version": "0.37.0", "find_args": "MODULE GLOBAL", "patches": [ - "0001-mingw.patch" + "0001-mingw.patch", + "0002-fix-zstd.patch" ], "options": [ "HTTPLIB_REQUIRE_OPENSSL ON" @@ -55,8 +56,8 @@ "package": "xbyak", "repo": "herumi/xbyak", "tag": "v%VERSION%", - "hash": "ac333d7bea1d61865bebebb116201a58db431946aa2f11aa042ef5795c390ff30af4d6c90ed3b3d24443a1d430703b08f14fc13b2fa405c155a241456ed78a47", - "git_version": "7.33.2" + "hash": "b6475276b2faaeb315734ea8f4f8bd87ededcee768961b39679bee547e7f3e98884d8b7851e176d861dab30a80a76e6ea302f8c111483607dde969b4797ea95a", + "git_version": "7.35.2" }, "oaknut": { "repo": "eden-emulator/oaknut", @@ -146,9 +147,9 @@ "package": "Catch2", "repo": "catchorg/Catch2", "tag": "v%VERSION%", - "hash": "acb3f463a7404d6a3bce52e474075cdadf9bb241d93feaf147c182d756e5a2f8bd412f4658ca186d15ab8fed36fc587d79ec311f55642d8e4ded16df9e213656", + "hash": "7eea385d79d88a5690cde131fe7ccda97d5c54ea09d6f515000d7bf07c828809d61c1ac99912c1ee507cf933f61c1c47ecdcc45df7850ffa82714034b0fccf35", "version": "3.0.1", - "git_version": "3.12.0", + "git_version": "3.13.0", "patches": [ "0001-solaris-isnan-fix.patch" ] @@ -256,15 +257,15 @@ "repo": "KhronosGroup/Vulkan-Headers", "package": "VulkanHeaders", "version": "1.4.317", - "hash": "26e0ad8fa34ab65a91ca62ddc54cc4410d209a94f64f2817dcdb8061dc621539a4262eab6387e9b9aa421db3dbf2cf8e2a4b041b696d0d03746bae1f25191272", - "git_version": "1.4.342", + "hash": "d2846ea228415772645eea4b52a9efd33e6a563043dd3de059e798be6391a8f0ca089f455ae420ff22574939ed0f48ed7c6ff3d5a9987d5231dbf3b3f89b484b", + "git_version": "1.4.345", "tag": "v%VERSION%" }, "vulkan-utility-libraries": { "repo": "KhronosGroup/Vulkan-Utility-Libraries", "package": "VulkanUtilityLibraries", - "hash": "8147370f964fd82c315d6bb89adeda30186098427bf3efaa641d36282d42a263f31e96e4586bfd7ae0410ff015379c19aa4512ba160630444d3d8553afd1ec14", - "git_version": "1.4.342", + "hash": "114f6b237a6dcba923ccc576befb5dea3f1c9b3a30de7dc741f234a831d1c2d52d8a224afb37dd57dffca67ac0df461eaaab6a5ab5e503b393f91c166680c3e1", + "git_version": "1.4.345", "tag": "v%VERSION%" }, "frozen": { diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 21affffb6b..dfb311b327 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,6 @@ # SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project # SPDX-License-Identifier: GPL-3.0-or-later + # SPDX-FileCopyrightText: 2018 yuzu Emulator Project # SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 08d6e73688..7566372b51 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -1220,7 +1220,7 @@ target_link_libraries(core PRIVATE RenderDoc::API ZLIB::ZLIB) -target_link_libraries(core PRIVATE httplib::httplib) +target_link_libraries(core PUBLIC httplib::httplib zstd::zstd) if (ENABLE_WEB_SERVICE) target_compile_definitions(core PUBLIC ENABLE_WEB_SERVICE) diff --git a/src/dynarmic/src/dynarmic/backend/x64/a32_emit_x64.cpp b/src/dynarmic/src/dynarmic/backend/x64/a32_emit_x64.cpp index 38cec7c750..f037919eb0 100644 --- a/src/dynarmic/src/dynarmic/backend/x64/a32_emit_x64.cpp +++ b/src/dynarmic/src/dynarmic/backend/x64/a32_emit_x64.cpp @@ -687,7 +687,7 @@ void A32EmitX64::EmitA32BXWritePC(A32EmitContext& ctx, IR::Inst* inst) { auto args = ctx.reg_alloc.GetArgumentInfo(inst); auto& arg = args[0]; - const u32 upper_without_t = (ctx.EndLocation().SetSingleStepping(false).UniqueHash() >> 32) & 0xFFFFFFFE; + const u64 upper_without_t = (ctx.EndLocation().SetSingleStepping(false).UniqueHash() >> 32) & 0xFFFFFFFE; // Pseudocode: // if (new_pc & 1) { diff --git a/src/dynarmic/src/dynarmic/backend/x64/emit_x64_data_processing.cpp b/src/dynarmic/src/dynarmic/backend/x64/emit_x64_data_processing.cpp index 108a341a71..f2af4e5b80 100644 --- a/src/dynarmic/src/dynarmic/backend/x64/emit_x64_data_processing.cpp +++ b/src/dynarmic/src/dynarmic/backend/x64/emit_x64_data_processing.cpp @@ -947,7 +947,7 @@ static void EmitAdd(BlockOfCode& code, EmitContext& ctx, IR::Inst* inst, size_t const Xbyak::Reg8 overflow = overflow_inst ? ctx.reg_alloc.ScratchGpr(code).cvt8() : Xbyak::Reg8{-1}; if (args[1].IsImmediate() && args[1].GetType() == IR::Type::U32) { - const u32 op_arg = args[1].GetImmediateU32(); + const u64 op_arg = args[1].GetImmediateU64(); if (carry_in.IsImmediate()) { if (carry_in.GetImmediateU1()) { // In range for a valid LEA materialisation diff --git a/src/dynarmic/src/dynarmic/backend/x64/emit_x64_saturation.cpp b/src/dynarmic/src/dynarmic/backend/x64/emit_x64_saturation.cpp index 2ba67f5a13..85ee3584eb 100644 --- a/src/dynarmic/src/dynarmic/backend/x64/emit_x64_saturation.cpp +++ b/src/dynarmic/src/dynarmic/backend/x64/emit_x64_saturation.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later /* This file is part of the dynarmic project. @@ -135,7 +135,7 @@ void EmitX64::EmitSignedSaturation(EmitContext& ctx, IR::Inst* inst) { const u32 mask = (1u << N) - 1; const u32 positive_saturated_value = (1u << (N - 1)) - 1; - const u32 negative_saturated_value = 1u << (N - 1); + const u64 negative_saturated_value = 1u << (N - 1); const Xbyak::Reg32 result = ctx.reg_alloc.ScratchGpr(code).cvt32(); const Xbyak::Reg32 reg_a = ctx.reg_alloc.UseGpr(code, args[0]).cvt32(); diff --git a/tools/cpm/package/update.sh b/tools/cpm/package/update.sh index be6a0fbbef..92f4f423a9 100755 --- a/tools/cpm/package/update.sh +++ b/tools/cpm/package/update.sh @@ -19,7 +19,8 @@ Check a specific package or packages for updates. Options: -n, --dry-run Do not update the package if it has an update available - -a, --all Operate on all packages in this project. + -a, --all Operate on all packages in this project. + -c, --commit Automatically generate a commit message EOF @@ -38,6 +39,7 @@ while :; do case "$char" in a) ALL=1 ;; n) UPDATE=false ;; + c) COMMIT=true ;; h) usage ;; *) die "Invalid option -$char" ;; esac @@ -46,6 +48,7 @@ while :; do --dry-run) UPDATE=false ;; --all) ALL=1 ;; --help) usage ;; + --commit) COMMIT=true ;; "$0") break ;; "") break ;; *) packages="$packages $1" ;; @@ -56,6 +59,7 @@ done [ "$ALL" != 1 ] || packages="${LIBS:-$packages}" : "${UPDATE:=true}" +: "${COMMIT:=false}" [ -n "$packages" ] || usage for pkg in $packages; do @@ -93,6 +97,9 @@ for pkg in $packages; do filter_out yotta # mbedtls + # ???????????????????????????????? + filter_out vksc + # ignore betas/alphas (remove if needed) filter_out alpha filter_out beta @@ -119,19 +126,35 @@ for pkg in $packages; do else NEW_GIT_VERSION=$(echo "$LATEST" | sed "s/$VERSION_PREFIX//g") fi + else + NEW_GIT_VERSION="$LATEST" fi + _commit="$_commit +* $PACKAGE: $GIT_VERSION -> $NEW_GIT_VERSION" + echo "-- * Version $LATEST available, current is $TAG" if [ "$UPDATE" = "true" ]; then if [ "$HAS_REPLACE" = "true" ]; then NEW_JSON=$(echo "$JSON" | jq ".git_version = \"$NEW_GIT_VERSION\"") else - NEW_JSON=$(echo "$JSON" | jq ".tag = \"$LATEST\"") + NEW_JSON=$(echo "$JSON" | jq ".tag = \"$NEW_GIT_VERSION\"") fi "$SCRIPTS"/util/replace.sh "$PACKAGE" "$NEW_JSON" - QUIET=true "$SCRIPTS"/util/fix-hash.sh + echo "-- * -- Updating hash" + + export UPDATE + QUIET=true "$SCRIPTS"/util/fix-hash.sh "$PACKAGE" fi done + +if [ "$UPDATE" = "true" ] && [ "$COMMIT" = "true" ] && [ -n "$_commit" ]; then + for file in $CPMFILES; do + git add "$file" + done + git commit -m "Update dependencies +$_commit" +fi diff --git a/tools/cpm/package/util/fix-hash.sh b/tools/cpm/package/util/fix-hash.sh index 07b9d266dd..3a69f0aaa7 100755 --- a/tools/cpm/package/util/fix-hash.sh +++ b/tools/cpm/package/util/fix-hash.sh @@ -3,9 +3,15 @@ # SPDX-FileCopyrightText: Copyright 2026 crueter # SPDX-License-Identifier: LGPL-3.0-or-later +# shellcheck disable=SC1091 + : "${PACKAGE:=$1}" -# shellcheck disable=SC1091 +# re-read json files +# shellcheck disable=SC2016 +PACKAGES=$(echo "$CPMFILES" | xargs jq -s 'reduce .[] as $item ({}; . * $item)') +export PACKAGES + . "$SCRIPTS"/vars.sh [ "$CI" = null ] || exit 0 From 361e6209b2a7cbe2aec8119539f93b40f8a06213 Mon Sep 17 00:00:00 2001 From: smiRaphi Date: Sun, 8 Mar 2026 22:37:20 +0100 Subject: [PATCH 10/25] [settings] Add back & properly implement use_dev_keys (#3631) Was removed recently but also wasn't really working before, this adds it to the debug UI (under the kiosk option) and also makes it properly reload the keys on launch & setting change. Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3631 Reviewed-by: crueter Reviewed-by: CamilleLaVey Co-authored-by: smiRaphi Co-committed-by: smiRaphi --- src/common/settings.h | 1 + src/core/crypto/key_manager.cpp | 16 +++++++++++++--- src/core/crypto/key_manager.h | 3 ++- src/yuzu/configuration/configure_debug.cpp | 4 ++++ src/yuzu/configuration/configure_debug.ui | 7 +++++++ src/yuzu/main_window.cpp | 5 +++++ 6 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/common/settings.h b/src/common/settings.h index ac04d26fc5..8cd55bcdd3 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -777,6 +777,7 @@ struct Values { Setting reporting_services{ linkage, false, "reporting_services", Category::Debugging, Specialization::Default, false}; Setting quest_flag{linkage, false, "quest_flag", Category::Debugging}; + Setting use_dev_keys{linkage, false, "use_dev_keys", Category::Debugging}; Setting disable_macro_jit{linkage, false, "disable_macro_jit", Category::DebuggingGraphics}; Setting disable_macro_hle{linkage, false, "disable_macro_hle", diff --git a/src/core/crypto/key_manager.cpp b/src/core/crypto/key_manager.cpp index 9a1b9d7a50..fc0ee064cc 100644 --- a/src/core/crypto/key_manager.cpp +++ b/src/core/crypto/key_manager.cpp @@ -21,6 +21,7 @@ #include "common/fs/path_util.h" #include "common/hex_util.h" #include "common/logging/log.h" +#include "common/settings.h" #include "common/string_util.h" #include "core/crypto/aes_util.h" #include "core/crypto/key_manager.h" @@ -642,8 +643,15 @@ void KeyManager::ReloadKeys() { const auto keys_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::KeysDir); if (!Common::FS::CreateDir(keys_dir)) LOG_ERROR(Core, "Failed to create the keys directory."); - LoadFromFile(keys_dir / "prod.keys_autogenerated", false); - LoadFromFile(keys_dir / "prod.keys", false); + if (Settings::values.use_dev_keys.GetValue()) { + dev_mode = true; + LoadFromFile(keys_dir / "dev.keys_autogenerated", false); + LoadFromFile(keys_dir / "dev.keys", false); + } else { + dev_mode = false; + LoadFromFile(keys_dir / "prod.keys_autogenerated", false); + LoadFromFile(keys_dir / "prod.keys", false); + } LoadFromFile(keys_dir / "title.keys_autogenerated", true); LoadFromFile(keys_dir / "title.keys", true); LoadFromFile(keys_dir / "console.keys_autogenerated", false); @@ -838,7 +846,7 @@ void KeyManager::WriteKeyToFile(KeyCategory category, std::string_view keyname, std::string filename = "title.keys_autogenerated"; if (category == KeyCategory::Standard) { - filename = "prod.keys_autogenerated"; + filename = dev_mode ? "dev.keys_autogenerated" : "prod.keys_autogenerated"; } else if (category == KeyCategory::Console) { filename = "console.keys_autogenerated"; } @@ -936,6 +944,8 @@ bool KeyManager::KeyFileExists(bool title) { const auto keys_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::KeysDir); if (title) return Common::FS::Exists(keys_dir / "title.keys"); + if (Settings::values.use_dev_keys.GetValue()) + return Common::FS::Exists(keys_dir / "dev.keys"); return Common::FS::Exists(keys_dir / "prod.keys"); } diff --git a/src/core/crypto/key_manager.h b/src/core/crypto/key_manager.h index 4d51b42677..7ef8375690 100644 --- a/src/core/crypto/key_manager.h +++ b/src/core/crypto/key_manager.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project @@ -314,6 +314,7 @@ private: std::array eticket_extended_kek{}; RSAKeyPair<2048> eticket_rsa_keypair{}; + bool dev_mode; void LoadFromFile(const std::filesystem::path& file_path, bool is_title_keys); template diff --git a/src/yuzu/configuration/configure_debug.cpp b/src/yuzu/configuration/configure_debug.cpp index bc835d35a2..e0bdbaeaa1 100644 --- a/src/yuzu/configuration/configure_debug.cpp +++ b/src/yuzu/configuration/configure_debug.cpp @@ -12,6 +12,7 @@ #include "common/logging/filter.h" #include "common/settings.h" #include "core/core.h" +#include "core/crypto/key_manager.h" #include "ui_configure_debug.h" #include "yuzu/configuration/configure_debug.h" #include "yuzu/debugger/console.h" @@ -45,6 +46,7 @@ void ConfigureDebug::SetConfiguration() { ui->reporting_services->setChecked(Settings::values.reporting_services.GetValue()); ui->dump_audio_commands->setChecked(Settings::values.dump_audio_commands.GetValue()); ui->quest_flag->setChecked(Settings::values.quest_flag.GetValue()); + ui->use_dev_keys->setChecked(Settings::values.use_dev_keys.GetValue()); ui->use_debug_asserts->setChecked(Settings::values.use_debug_asserts.GetValue()); ui->use_auto_stub->setChecked(Settings::values.use_auto_stub.GetValue()); ui->enable_all_controllers->setChecked(Settings::values.enable_all_controllers.GetValue()); @@ -105,6 +107,7 @@ void ConfigureDebug::ApplyConfiguration() { Settings::values.reporting_services = ui->reporting_services->isChecked(); Settings::values.dump_audio_commands = ui->dump_audio_commands->isChecked(); Settings::values.quest_flag = ui->quest_flag->isChecked(); + Settings::values.use_dev_keys = ui->use_dev_keys->isChecked(); Settings::values.use_debug_asserts = ui->use_debug_asserts->isChecked(); Settings::values.use_auto_stub = ui->use_auto_stub->isChecked(); Settings::values.enable_all_controllers = ui->enable_all_controllers->isChecked(); @@ -126,6 +129,7 @@ void ConfigureDebug::ApplyConfiguration() { Common::Log::Filter filter; filter.ParseFilterString(Settings::values.log_filter.GetValue()); Common::Log::SetGlobalFilter(filter); + Core::Crypto::KeyManager::Instance().ReloadKeys(); } void ConfigureDebug::changeEvent(QEvent* event) { diff --git a/src/yuzu/configuration/configure_debug.ui b/src/yuzu/configuration/configure_debug.ui index 1b1423b62c..f76f3b012d 100644 --- a/src/yuzu/configuration/configure_debug.ui +++ b/src/yuzu/configuration/configure_debug.ui @@ -435,6 +435,13 @@ + + + + Use dev.keys + + + diff --git a/src/yuzu/main_window.cpp b/src/yuzu/main_window.cpp index 688078385a..399b3bd976 100644 --- a/src/yuzu/main_window.cpp +++ b/src/yuzu/main_window.cpp @@ -139,6 +139,8 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual #include "core/perf_stats.h" +#include "core/crypto/key_manager.h" + // Input // #include "hid_core/hid_core.h" #include "hid_core/frontend/emulated_controller.h" @@ -564,6 +566,9 @@ MainWindow::MainWindow(bool has_broken_vulkan) // Check for orphaned profiles and reset profile data if necessary QtCommon::Content::FixProfiles(); + if (Settings::values.use_dev_keys.GetValue()) { + Core::Crypto::KeyManager::Instance().ReloadKeys(); + } game_list->LoadCompatibilityList(); game_list->PopulateAsync(UISettings::values.game_dirs); From f8ea09fa0f06572b32df1ead2fb38a64098e312e Mon Sep 17 00:00:00 2001 From: MaranBr Date: Sun, 8 Mar 2026 22:45:35 +0100 Subject: [PATCH 11/25] [video_core] Simplify TextureCache GC and remove redundant code (#3652) This enhances the garbage collection in TextureCache to make it more responsive and reliable during long gameplay sessions. Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3652 Co-authored-by: MaranBr Co-committed-by: MaranBr --- src/video_core/texture_cache/texture_cache.h | 141 ++---------------- .../texture_cache/texture_cache_base.h | 1 - 2 files changed, 12 insertions(+), 130 deletions(-) diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index 71210ffe6e..e32f21d2ce 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h @@ -70,14 +70,10 @@ TextureCache

::TextureCache(Runtime& runtime_, Tegra::MaxwellDeviceMemoryManag (std::max)((std::min)(device_local_memory - min_vacancy_critical, min_spacing_critical), DEFAULT_CRITICAL_MEMORY)); minimum_memory = static_cast((device_local_memory - mem_threshold) / 2); - - lowmemorydevice = false; } else { expected_memory = DEFAULT_EXPECTED_MEMORY + 512_MiB; critical_memory = DEFAULT_CRITICAL_MEMORY + 1_GiB; minimum_memory = 0; - - lowmemorydevice = true; } const bool gpu_unswizzle_enabled = Settings::values.gpu_unswizzle_enabled.GetValue(); @@ -122,102 +118,46 @@ void TextureCache

::RunGarbageCollector() { bool aggressive_mode = false; u64 ticks_to_destroy = 0; size_t num_iterations = 0; - const auto Configure = [&](bool allow_aggressive) { high_priority_mode = total_used_memory >= expected_memory; aggressive_mode = allow_aggressive && total_used_memory >= critical_memory; ticks_to_destroy = aggressive_mode ? 10ULL : high_priority_mode ? 25ULL : 50ULL; num_iterations = aggressive_mode ? 40 : (high_priority_mode ? 20 : 10); }; - - const auto Cleanup = [this, &num_iterations, &high_priority_mode, - &aggressive_mode](ImageId image_id) { + const auto Cleanup = [this, &num_iterations, &high_priority_mode, &aggressive_mode](ImageId image_id) { if (num_iterations == 0) { return true; } --num_iterations; auto& image = slot_images[image_id]; - - // Never delete recently allocated sparse textures (within 3 frames) - const bool is_recently_allocated = image.allocation_tick >= frame_tick - 3; - if (is_recently_allocated && image.info.is_sparse) { - return false; - } - if (True(image.flags & ImageFlagBits::IsDecoding)) { - // This image is still being decoded, deleting it will invalidate the slot - // used by the async decoder thread. return false; } - - // Prioritize large sparse textures for cleanup - const bool is_large_sparse = lowmemorydevice && - image.info.is_sparse && - image.guest_size_bytes >= 256_MiB; - - if (!aggressive_mode && !is_large_sparse && - True(image.flags & ImageFlagBits::CostlyLoad)) { - return false; - } - - const bool must_download = - image.IsSafeDownload() && False(image.flags & ImageFlagBits::BadOverlap); - if (!high_priority_mode && !is_large_sparse && must_download) { - return false; - } - - if (must_download && !is_large_sparse) { + const bool must_download = image.IsSafeDownload() && False(image.flags & ImageFlagBits::BadOverlap); + if (must_download && !image.info.is_sparse) { auto map = runtime.DownloadStagingBuffer(image.unswizzled_size_bytes); const auto copies = FixSmallVectorADL(FullDownloadCopies(image.info)); image.DownloadMemory(map, copies); runtime.Finish(); - SwizzleImage(*gpu_memory, image.gpu_addr, image.info, copies, map.mapped_span, - swizzle_data_buffer); + SwizzleImage(*gpu_memory, image.gpu_addr, image.info, copies, map.mapped_span, swizzle_data_buffer); } - if (True(image.flags & ImageFlagBits::Tracked)) { UntrackImage(image, image_id); } UnregisterImage(image_id); - DeleteImage(image_id, image.scale_tick > frame_tick + 5); - - if (total_used_memory < critical_memory) { - if (aggressive_mode) { - // Sink the aggresiveness. - num_iterations >>= 2; - aggressive_mode = false; - return false; - } - if (high_priority_mode && total_used_memory < expected_memory) { - num_iterations >>= 1; - high_priority_mode = false; - } + DeleteImage(image_id, (frame_tick - image.scale_tick) > 5 || aggressive_mode); + if (aggressive_mode && total_used_memory < critical_memory) { + num_iterations >>= 2; + aggressive_mode = false; + } + if (high_priority_mode && total_used_memory < expected_memory) { + num_iterations >>= 1; + high_priority_mode = false; } return false; }; - - // Aggressively clear massive sparse textures - if (total_used_memory >= expected_memory) { - lru_cache.ForEachItemBelow(frame_tick, [&](ImageId image_id) { - auto& image = slot_images[image_id]; - // Only target sparse textures that are old enough - if (lowmemorydevice && - image.info.is_sparse && - image.guest_size_bytes >= 256_MiB && - image.allocation_tick < frame_tick - 3) { - LOG_DEBUG(HW_GPU, "GC targeting old sparse texture at 0x{:X} ({} MiB, age: {} frames)", - image.gpu_addr, image.guest_size_bytes / (1024 * 1024), - frame_tick - image.allocation_tick); - return Cleanup(image_id); - } - return false; - }); - } - Configure(false); lru_cache.ForEachItemBelow(frame_tick - ticks_to_destroy, Cleanup); - - // If pressure is still too high, prune aggressively. if (total_used_memory >= critical_memory) { Configure(true); lru_cache.ForEachItemBelow(frame_tick - ticks_to_destroy, Cleanup); @@ -1196,9 +1136,6 @@ void TextureCache

::RefreshContents(Image& image, ImageId image_id) { } image.flags &= ~ImageFlagBits::CpuModified; - if( lowmemorydevice && image.info.format == PixelFormat::BC1_RGBA_UNORM && MapSizeBytes(image) >= 256_MiB ) { - return; - } TrackImage(image, image_id); @@ -1619,39 +1556,6 @@ ImageId TextureCache

::InsertImage(const ImageInfo& info, GPUVAddr gpu_addr, } } ASSERT_MSG(cpu_addr, "Tried to insert an image to an invalid gpu_addr=0x{:x}", gpu_addr); - - // For large sparse textures, aggressively clean up old allocations at same address - if (lowmemorydevice && info.is_sparse && CalculateGuestSizeInBytes(info) >= 256_MiB) { - const auto alloc_it = image_allocs_table.find(gpu_addr); - if (alloc_it != image_allocs_table.end()) { - const ImageAllocId alloc_id = alloc_it->second; - auto& alloc_images = slot_image_allocs[alloc_id].images; - - // Collect old images at this address that were created more than 2 frames ago - boost::container::small_vector to_delete; - for (ImageId old_image_id : alloc_images) { - Image& old_image = slot_images[old_image_id]; - if (old_image.info.is_sparse && - old_image.gpu_addr == gpu_addr && - old_image.allocation_tick < frame_tick - 2) { // Try not to delete fresh textures - to_delete.push_back(old_image_id); - } - } - - // Delete old images immediately - for (ImageId old_id : to_delete) { - Image& old_image = slot_images[old_id]; - LOG_DEBUG(HW_GPU, "Immediately deleting old sparse texture at 0x{:X} ({} MiB)", - gpu_addr, old_image.guest_size_bytes / (1024 * 1024)); - if (True(old_image.flags & ImageFlagBits::Tracked)) { - UntrackImage(old_image, old_id); - } - UnregisterImage(old_id); - DeleteImage(old_id, true); - } - } - } - const ImageId image_id = JoinImages(info, gpu_addr, *cpu_addr); const Image& image = slot_images[image_id]; // Using "image.gpu_addr" instead of "gpu_addr" is important because it might be different @@ -1667,27 +1571,6 @@ template ImageId TextureCache

::JoinImages(const ImageInfo& info, GPUVAddr gpu_addr, DAddr cpu_addr) { ImageInfo new_info = info; const size_t size_bytes = CalculateGuestSizeInBytes(new_info); - - // Proactive cleanup for large sparse texture allocations - if (lowmemorydevice && new_info.is_sparse && size_bytes >= 256_MiB) { - const u64 estimated_alloc_size = size_bytes; - - if (total_used_memory + estimated_alloc_size >= critical_memory) { - LOG_DEBUG(HW_GPU, "Large sparse texture allocation ({} MiB) - running aggressive GC. " - "Current memory: {} MiB, Critical: {} MiB", - size_bytes / (1024 * 1024), - total_used_memory / (1024 * 1024), - critical_memory / (1024 * 1024)); - RunGarbageCollector(); - - // If still over threshold after GC, try one more aggressive pass - if (total_used_memory + estimated_alloc_size >= critical_memory) { - LOG_DEBUG(HW_GPU, "Still critically low on memory, running second GC pass"); - RunGarbageCollector(); - } - } - } - const bool broken_views = runtime.HasBrokenTextureViewFormats(); const bool native_bgr = runtime.HasNativeBgr(); join_overlap_ids.clear(); diff --git a/src/video_core/texture_cache/texture_cache_base.h b/src/video_core/texture_cache/texture_cache_base.h index 4b4061f21d..47f52c5c99 100644 --- a/src/video_core/texture_cache/texture_cache_base.h +++ b/src/video_core/texture_cache/texture_cache_base.h @@ -478,7 +478,6 @@ private: u64 minimum_memory; u64 expected_memory; u64 critical_memory; - bool lowmemorydevice = false; size_t gpu_unswizzle_maxsize = 0; size_t swizzle_chunk_size = 0; u32 swizzle_slices_per_batch = 0; From 6693b99ae44209b8e10ecc8b09517ceae9ab0bc0 Mon Sep 17 00:00:00 2001 From: lizzie Date: Sun, 8 Mar 2026 22:45:38 +0100 Subject: [PATCH 12/25] [core] coalesce tracking entries for GPU (#3677) I think I may have attempted this before, but I doubt it. Anyways this should reduce virtual buffers from 3 to just 1, also improved access times :) Signed-off-by: lizzie Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3677 Reviewed-by: crueter Co-authored-by: lizzie Co-committed-by: lizzie --- src/core/device_memory_manager.h | 26 +++++----- src/core/device_memory_manager.inc | 79 ++++++++++++------------------ 2 files changed, 46 insertions(+), 59 deletions(-) diff --git a/src/core/device_memory_manager.h b/src/core/device_memory_manager.h index 9d86a17d12..3d97fdcc5c 100644 --- a/src/core/device_memory_manager.h +++ b/src/core/device_memory_manager.h @@ -76,16 +76,16 @@ public: template void ApplyOpOnPAddr(PAddr address, Common::ScratchBuffer& buffer, Func&& operation) { - DAddr subbits = static_cast(address & page_mask); + DAddr subbits = DAddr(address & page_mask); const u32 base = compressed_device_addr[(address >> page_bits)]; if ((base >> MULTI_FLAG_BITS) == 0) [[likely]] { - const DAddr d_address = (static_cast(base) << page_bits) + subbits; + const DAddr d_address = (DAddr(base) << page_bits) + subbits; operation(d_address); return; } InnerGatherDeviceAddresses(buffer, address); for (u32 value : buffer) { - operation((static_cast(value) << page_bits) + subbits); + operation((DAddr(value) << page_bits) + subbits); } } @@ -96,12 +96,12 @@ public: } PAddr GetPhysicalRawAddressFromDAddr(DAddr address) const { - PAddr subbits = static_cast(address & page_mask); - auto paddr = compressed_physical_ptr[(address >> page_bits)]; + PAddr subbits = PAddr(address & page_mask); + auto paddr = tracked_entries[(address >> page_bits)].compressed_physical_ptr; if (paddr == 0) { return 0; } - return (static_cast(paddr - 1) << page_bits) + subbits; + return (PAddr(paddr - 1) << page_bits) + subbits; } template @@ -172,9 +172,14 @@ private: const uintptr_t physical_base; DeviceInterface* device_inter; - Common::VirtualBuffer compressed_physical_ptr; + + struct TrackedEntry { + VAddr cpu_backing_address; + u32 continuity_tracker; + u32 compressed_physical_ptr; + }; Common::VirtualBuffer compressed_device_addr; - Common::VirtualBuffer continuity_tracker; + Common::VirtualBuffer tracked_entries; // Process memory interfaces @@ -189,17 +194,16 @@ private: static constexpr size_t asid_start_bit = guest_max_as_bits; std::pair ExtractCPUBacking(size_t page_index) { - auto content = cpu_backing_address[page_index]; + auto content = tracked_entries[page_index].cpu_backing_address; const VAddr address = content & guest_mask; const Asid asid{static_cast(content >> asid_start_bit)}; return std::make_pair(asid, address); } void InsertCPUBacking(size_t page_index, VAddr address, Asid asid) { - cpu_backing_address[page_index] = address | (asid.id << asid_start_bit); + tracked_entries[page_index].cpu_backing_address = address | (asid.id << asid_start_bit); } - Common::VirtualBuffer cpu_backing_address; std::array t_slot{}; u32 cache_cursor = 0; using CounterType = u8; diff --git a/src/core/device_memory_manager.inc b/src/core/device_memory_manager.inc index 08fe799174..15e3a1ad52 100644 --- a/src/core/device_memory_manager.inc +++ b/src/core/device_memory_manager.inc @@ -166,29 +166,21 @@ struct DeviceMemoryManagerAllocator { template DeviceMemoryManager::DeviceMemoryManager(const DeviceMemory& device_memory_) - : physical_base{reinterpret_cast(device_memory_.buffer.BackingBasePointer())}, - device_inter{nullptr}, compressed_physical_ptr(device_as_size >> Memory::YUZU_PAGEBITS), - compressed_device_addr(1ULL << ((Settings::values.memory_layout_mode.GetValue() == - Settings::MemoryLayout::Memory_4Gb - ? physical_min_bits - : physical_max_bits) - - Memory::YUZU_PAGEBITS)), - continuity_tracker(device_as_size >> Memory::YUZU_PAGEBITS), - cpu_backing_address(device_as_size >> Memory::YUZU_PAGEBITS) { + : physical_base{uintptr_t(device_memory_.buffer.BackingBasePointer())} + , device_inter{nullptr} + , compressed_device_addr(1ULL << ((Settings::values.memory_layout_mode.GetValue() == Settings::MemoryLayout::Memory_4Gb ? physical_min_bits : physical_max_bits) - Memory::YUZU_PAGEBITS)) + , tracked_entries(device_as_size >> Memory::YUZU_PAGEBITS) +{ impl = std::make_unique>(); cached_pages = std::make_unique(); const size_t total_virtual = device_as_size >> Memory::YUZU_PAGEBITS; for (size_t i = 0; i < total_virtual; i++) { - compressed_physical_ptr[i] = 0; - continuity_tracker[i] = 1; - cpu_backing_address[i] = 0; + tracked_entries[i].compressed_physical_ptr = 0; + tracked_entries[i].continuity_tracker = 1; + tracked_entries[i].cpu_backing_address = 0; } - const size_t total_phys = 1ULL << ((Settings::values.memory_layout_mode.GetValue() == - Settings::MemoryLayout::Memory_4Gb - ? physical_min_bits - : physical_max_bits) - - Memory::YUZU_PAGEBITS); + const size_t total_phys = 1ULL << ((Settings::values.memory_layout_mode.GetValue() == Settings::MemoryLayout::Memory_4Gb ? physical_min_bits : physical_max_bits) - Memory::YUZU_PAGEBITS); for (size_t i = 0; i < total_phys; i++) { compressed_device_addr[i] = 0; } @@ -228,11 +220,11 @@ void DeviceMemoryManager::Map(DAddr address, VAddr virtual_address, size const VAddr new_vaddress = virtual_address + i * Memory::YUZU_PAGESIZE; auto* ptr = process_memory->GetPointerSilent(Common::ProcessAddress(new_vaddress)); if (ptr == nullptr) [[unlikely]] { - compressed_physical_ptr[start_page_d + i] = 0; + tracked_entries[start_page_d + i].compressed_physical_ptr = 0; continue; } auto phys_addr = static_cast(GetRawPhysicalAddr(ptr) >> Memory::YUZU_PAGEBITS) + 1U; - compressed_physical_ptr[start_page_d + i] = phys_addr; + tracked_entries[start_page_d + i].compressed_physical_ptr = phys_addr; InsertCPUBacking(start_page_d + i, new_vaddress, asid); const u32 base_dev = compressed_device_addr[phys_addr - 1U]; const u32 new_dev = static_cast(start_page_d + i); @@ -260,9 +252,9 @@ void DeviceMemoryManager::Unmap(DAddr address, size_t size) { device_inter->InvalidateRegion(address, size); std::scoped_lock lk(mapping_guard); for (size_t i = 0; i < num_pages; i++) { - auto phys_addr = compressed_physical_ptr[start_page_d + i]; - compressed_physical_ptr[start_page_d + i] = 0; - cpu_backing_address[start_page_d + i] = 0; + auto phys_addr = tracked_entries[start_page_d + i].compressed_physical_ptr; + tracked_entries[start_page_d + i].compressed_physical_ptr = 0; + tracked_entries[start_page_d + i].cpu_backing_address = 0; if (phys_addr != 0) [[likely]] { const u32 base_dev = compressed_device_addr[phys_addr - 1U]; if ((base_dev >> MULTI_FLAG_BITS) == 0) [[likely]] { @@ -300,14 +292,14 @@ void DeviceMemoryManager::TrackContinuityImpl(DAddr address, VAddr virtu page_count = 1; } last_ptr = new_ptr; - continuity_tracker[start_page_d + index] = static_cast(page_count); + tracked_entries[start_page_d + index].continuity_tracker = static_cast(page_count); } } template u8* DeviceMemoryManager::GetSpan(const DAddr src_addr, const std::size_t size) { size_t page_index = src_addr >> page_bits; size_t subbits = src_addr & page_mask; - if ((static_cast(continuity_tracker[page_index]) << page_bits) >= size + subbits) { + if ((static_cast(tracked_entries[page_index].continuity_tracker) << page_bits) >= size + subbits) { return GetPointer(src_addr); } return nullptr; @@ -317,7 +309,7 @@ template const u8* DeviceMemoryManager::GetSpan(const DAddr src_addr, const std::size_t size) const { size_t page_index = src_addr >> page_bits; size_t subbits = src_addr & page_mask; - if ((static_cast(continuity_tracker[page_index]) << page_bits) >= size + subbits) { + if ((static_cast(tracked_entries[page_index].continuity_tracker) << page_bits) >= size + subbits) { return GetPointer(src_addr); } return nullptr; @@ -342,12 +334,10 @@ template T* DeviceMemoryManager::GetPointer(DAddr address) { const size_t index = address >> Memory::YUZU_PAGEBITS; const size_t offset = address & Memory::YUZU_PAGEMASK; - auto phys_addr = compressed_physical_ptr[index]; - if (phys_addr == 0) [[unlikely]] { + auto phys_addr = tracked_entries[index].compressed_physical_ptr; + if (phys_addr == 0) [[unlikely]] return nullptr; - } - return GetPointerFromRaw((static_cast(phys_addr - 1) << Memory::YUZU_PAGEBITS) + - offset); + return GetPointerFromRaw((PAddr(phys_addr - 1) << Memory::YUZU_PAGEBITS) + offset); } template @@ -355,12 +345,10 @@ template const T* DeviceMemoryManager::GetPointer(DAddr address) const { const size_t index = address >> Memory::YUZU_PAGEBITS; const size_t offset = address & Memory::YUZU_PAGEMASK; - auto phys_addr = compressed_physical_ptr[index]; - if (phys_addr == 0) [[unlikely]] { + auto phys_addr = tracked_entries[index].compressed_physical_ptr; + if (phys_addr == 0) return nullptr; - } - return GetPointerFromRaw((static_cast(phys_addr - 1) << Memory::YUZU_PAGEBITS) + - offset); + return GetPointerFromRaw((PAddr(phys_addr - 1) << Memory::YUZU_PAGEBITS) + offset); } template @@ -386,18 +374,14 @@ T DeviceMemoryManager::Read(DAddr address) const { } template -void DeviceMemoryManager::WalkBlock(DAddr addr, std::size_t size, auto on_unmapped, - auto on_memory, auto increment) { +void DeviceMemoryManager::WalkBlock(DAddr addr, std::size_t size, auto on_unmapped, auto on_memory, auto increment) { std::size_t remaining_size = size; std::size_t page_index = addr >> Memory::YUZU_PAGEBITS; std::size_t page_offset = addr & Memory::YUZU_PAGEMASK; - while (remaining_size) { - const size_t next_pages = static_cast(continuity_tracker[page_index]); - const std::size_t copy_amount = - (std::min)((next_pages << Memory::YUZU_PAGEBITS) - page_offset, remaining_size); - const auto current_vaddr = - static_cast((page_index << Memory::YUZU_PAGEBITS) + page_offset); + const size_t next_pages = std::size_t(tracked_entries[page_index].continuity_tracker); + const std::size_t copy_amount = (std::min)((next_pages << Memory::YUZU_PAGEBITS) - page_offset, remaining_size); + const auto current_vaddr = u64((page_index << Memory::YUZU_PAGEBITS) + page_offset); SCOPE_EXIT{ page_index += next_pages; page_offset = 0; @@ -405,13 +389,12 @@ void DeviceMemoryManager::WalkBlock(DAddr addr, std::size_t size, auto o remaining_size -= copy_amount; }; - auto phys_addr = compressed_physical_ptr[page_index]; + auto phys_addr = tracked_entries[page_index].compressed_physical_ptr; if (phys_addr == 0) { on_unmapped(copy_amount, current_vaddr); continue; } - auto* mem_ptr = GetPointerFromRaw( - (static_cast(phys_addr - 1) << Memory::YUZU_PAGEBITS) + page_offset); + auto* mem_ptr = GetPointerFromRaw((PAddr(phys_addr - 1) << Memory::YUZU_PAGEBITS) + page_offset); on_memory(copy_amount, mem_ptr); } } @@ -430,7 +413,7 @@ void DeviceMemoryManager::ReadBlock(DAddr address, void* dest_pointer, s } const std::size_t page_index = address >> Memory::YUZU_PAGEBITS; - const auto phys_addr = compressed_physical_ptr[page_index]; + const auto phys_addr = tracked_entries[page_index].compressed_physical_ptr; if (phys_addr != 0) { auto* const mem_ptr = GetPointerFromRaw((PAddr(phys_addr - 1) << Memory::YUZU_PAGEBITS)); t_slot[cache_cursor % t_slot.size()] = TranslationEntry{.guest_page = guest_page, .host_ptr = mem_ptr}; @@ -488,7 +471,7 @@ void DeviceMemoryManager::ReadBlockUnsafe(DAddr address, void* dest_poin } const std::size_t page_index = address >> Memory::YUZU_PAGEBITS; - const auto phys_addr = compressed_physical_ptr[page_index]; + const auto phys_addr = tracked_entries[page_index].compressed_physical_ptr; if (phys_addr != 0) { auto* const mem_ptr = GetPointerFromRaw((PAddr(phys_addr - 1) << Memory::YUZU_PAGEBITS)); t_slot[cache_cursor % t_slot.size()] = TranslationEntry{.guest_page = guest_page, .host_ptr = mem_ptr}; From f5e2b1fb132f0a553cb37edec0ce58b4e4638878 Mon Sep 17 00:00:00 2001 From: crueter Date: Sun, 8 Mar 2026 23:22:51 +0100 Subject: [PATCH 13/25] [dynarmic] Remove incorrect LICENSE (#3698) Our dynarmic is GPLv3, not BSD. Signed-off-by: crueter Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3698 --- src/dynarmic/LICENSE.txt | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 src/dynarmic/LICENSE.txt diff --git a/src/dynarmic/LICENSE.txt b/src/dynarmic/LICENSE.txt deleted file mode 100644 index a6bc0ba042..0000000000 --- a/src/dynarmic/LICENSE.txt +++ /dev/null @@ -1,12 +0,0 @@ -Copyright (C) 2017 merryhime - -Permission to use, copy, modify, and/or distribute this software for -any purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN -AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. From a1b50e9339fc4ad003ea55de6fdaabf92a12e163 Mon Sep 17 00:00:00 2001 From: xbzk Date: Mon, 9 Mar 2026 00:30:10 +0100 Subject: [PATCH 14/25] [android] patches bin button + version bug fixes (#3691) This fixed the delete button enabled for external content (which is auto handled and the proper way to get rid of them is either by removing its folder from ext content list, or removing the file itself) by streaming patch source thru jni. Along the way stumbled upon another bug: If you have an external content update installed (say latest version for example) and you NAND install a previous update (like in silksong's hard mode update), the newest update version string would leak to the previous one. Did videos for both. Fixed both. Seems good to go. Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3691 Reviewed-by: crueter Reviewed-by: Lizzie Reviewed-by: DraVee Co-authored-by: xbzk Co-committed-by: xbzk --- .../yuzu/yuzu_emu/adapters/AddonAdapter.kt | 18 ++- .../java/org/yuzu/yuzu_emu/model/Patch.kt | 16 +- src/android/app/src/main/jni/native.cpp | 2 +- src/common/android/id_cache.cpp | 2 +- src/core/file_sys/patch_manager.cpp | 143 +++++++++++++----- src/core/file_sys/patch_manager.h | 1 + 6 files changed, 134 insertions(+), 48 deletions(-) diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/AddonAdapter.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/AddonAdapter.kt index 371fef0025..cbca66e13a 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/AddonAdapter.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/AddonAdapter.kt @@ -40,11 +40,21 @@ class AddonAdapter(val addonViewModel: AddonViewModel) : } } - val deleteAction = { - addonViewModel.setAddonToDelete(model) + val canDelete = model.isRemovable + binding.deleteCard.isEnabled = canDelete + binding.buttonDelete.isEnabled = canDelete + binding.deleteCard.alpha = if (canDelete) 1f else 0.38f + + if (canDelete) { + val deleteAction = { + addonViewModel.setAddonToDelete(model) + } + binding.deleteCard.setOnClickListener { deleteAction() } + binding.buttonDelete.setOnClickListener { deleteAction() } + } else { + binding.deleteCard.setOnClickListener(null) + binding.buttonDelete.setOnClickListener(null) } - binding.deleteCard.setOnClickListener { deleteAction() } - binding.buttonDelete.setOnClickListener { deleteAction() } } } } diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/Patch.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/Patch.kt index 8a367116c1..a3785dd3ac 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/Patch.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/Patch.kt @@ -16,5 +16,17 @@ data class Patch( val type: Int, val programId: String, val titleId: String, - val numericVersion: Long = 0 -) + val numericVersion: Long = 0, + val source: Int = 0 +) { + companion object { + const val SOURCE_UNKNOWN = 0 + const val SOURCE_NAND = 1 + const val SOURCE_SDMC = 2 + const val SOURCE_EXTERNAL = 3 + const val SOURCE_PACKED = 4 + } + + val isRemovable: Boolean + get() = source != SOURCE_EXTERNAL && source != SOURCE_PACKED +} diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp index 3f0029c78a..2108e05911 100644 --- a/src/android/app/src/main/jni/native.cpp +++ b/src/android/app/src/main/jni/native.cpp @@ -1407,7 +1407,7 @@ jobjectArray Java_org_yuzu_yuzu_1emu_NativeLibrary_getPatchesForFile(JNIEnv* env Common::Android::ToJString(env, patch.version), static_cast(patch.type), Common::Android::ToJString(env, std::to_string(patch.program_id)), Common::Android::ToJString(env, std::to_string(patch.title_id)), - static_cast(patch.numeric_version)); + static_cast(patch.numeric_version), static_cast(patch.source)); env->SetObjectArrayElement(jpatchArray, i, jpatch); ++i; } diff --git a/src/common/android/id_cache.cpp b/src/common/android/id_cache.cpp index c7f5332a68..76af1e0fb2 100644 --- a/src/common/android/id_cache.cpp +++ b/src/common/android/id_cache.cpp @@ -516,7 +516,7 @@ namespace Common::Android { s_patch_class = reinterpret_cast(env->NewGlobalRef(patch_class)); s_patch_constructor = env->GetMethodID( patch_class, "", - "(ZLjava/lang/String;Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;J)V"); + "(ZLjava/lang/String;Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;JI)V"); s_patch_enabled_field = env->GetFieldID(patch_class, "enabled", "Z"); s_patch_name_field = env->GetFieldID(patch_class, "name", "Ljava/lang/String;"); s_patch_version_field = env->GetFieldID(patch_class, "version", "Ljava/lang/String;"); diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp index e9c3bb75c2..627646ee84 100644 --- a/src/core/file_sys/patch_manager.cpp +++ b/src/core/file_sys/patch_manager.cpp @@ -123,6 +123,39 @@ bool IsVersionedExternalUpdateDisabled(const std::vector& disabled, return std::find(disabled.cbegin(), disabled.cend(), disabled_key) != disabled.cend() || std::find(disabled.cbegin(), disabled.cend(), "Update") != disabled.cend(); } + +std::string GetUpdateVersionStringFromSlot(const ContentProvider* provider, u64 update_tid) { + if (provider == nullptr) { + return {}; + } + + auto control_nca = provider->GetEntry(update_tid, ContentRecordType::Control); + if (control_nca == nullptr || + control_nca->GetStatus() != Loader::ResultStatus::Success) { + return {}; + } + + const auto romfs = control_nca->GetRomFS(); + if (romfs == nullptr) { + return {}; + } + + const auto extracted = ExtractRomFS(romfs); + if (extracted == nullptr) { + return {}; + } + + auto nacp_file = extracted->GetFile("control.nacp"); + if (nacp_file == nullptr) { + nacp_file = extracted->GetFile("Control.nacp"); + } + if (nacp_file == nullptr) { + return {}; + } + + NACP nacp{nacp_file}; + return nacp.GetVersionString(); +} } // Anonymous namespace PatchManager::PatchManager(u64 title_id_, @@ -771,6 +804,7 @@ std::vector PatchManager::GetPatches(VirtualFile update_raw) const { std::nullopt, std::nullopt, ContentRecordType::Program, update_tid); for (const auto& [slot, entry] : all_updates) { + (void)entry; if (slot == ContentProviderUnionSlot::External || slot == ContentProviderUnionSlot::FrontendManual) { continue; @@ -786,7 +820,7 @@ std::vector PatchManager::GetPatches(VirtualFile update_raw) const { source_suffix = " (NAND)"; break; case ContentProviderUnionSlot::SDMC: - source_type = PatchSource::NAND; + source_type = PatchSource::SDMC; source_suffix = " (SDMC)"; break; default: @@ -795,19 +829,16 @@ std::vector PatchManager::GetPatches(VirtualFile update_raw) const { std::string version_str; u32 numeric_ver = 0; - PatchManager update{update_tid, fs_controller, content_provider}; - const auto metadata = update.GetControlMetadata(); - const auto& nacp = metadata.first; + const auto* slot_provider = content_union->GetSlotProvider(slot); + version_str = GetUpdateVersionStringFromSlot(slot_provider, update_tid); - if (nacp != nullptr) { - version_str = nacp->GetVersionString(); - } - - const auto meta_ver = content_provider.GetEntryVersion(update_tid); - if (meta_ver.has_value()) { - numeric_ver = *meta_ver; - if (version_str.empty() && numeric_ver != 0) { - version_str = FormatTitleVersion(numeric_ver); + if (slot_provider != nullptr) { + const auto slot_ver = slot_provider->GetEntryVersion(update_tid); + if (slot_ver.has_value()) { + numeric_ver = *slot_ver; + if (version_str.empty() && numeric_ver != 0) { + version_str = FormatTitleVersion(numeric_ver); + } } } @@ -956,37 +987,60 @@ std::vector PatchManager::GetPatches(VirtualFile update_raw) const { } // DLC - const auto dlc_entries = - content_provider.ListEntriesFilter(TitleType::AOC, ContentRecordType::Data); - std::vector dlc_match; - dlc_match.reserve(dlc_entries.size()); - std::copy_if(dlc_entries.begin(), dlc_entries.end(), std::back_inserter(dlc_match), - [this](const ContentProviderEntry& entry) { - const auto base_tid = GetBaseTitleID(entry.title_id); - const bool matches_base = base_tid == title_id; + bool has_external_dlc = false; + bool has_nand_dlc = false; + bool has_sdmc_dlc = false; + bool has_other_dlc = false; + const auto dlc_entries_with_origin = + content_union->ListEntriesFilterOrigin(std::nullopt, TitleType::AOC, ContentRecordType::Data); - if (!matches_base) { - LOG_DEBUG(Loader, "DLC {:016X} base {:016X} doesn't match title {:016X}", - entry.title_id, base_tid, title_id); - return false; - } + dlc_match.reserve(dlc_entries_with_origin.size()); + for (const auto& [slot, entry] : dlc_entries_with_origin) { + const auto base_tid = GetBaseTitleID(entry.title_id); + const bool matches_base = base_tid == title_id; + if (!matches_base) { + LOG_DEBUG(Loader, "DLC {:016X} base {:016X} doesn't match title {:016X}", + entry.title_id, base_tid, title_id); + continue; + } - auto nca = content_provider.GetEntry(entry); - if (!nca) { - LOG_DEBUG(Loader, "Failed to get NCA for DLC {:016X}", entry.title_id); - return false; - } + const auto* slot_provider = content_union->GetSlotProvider(slot); + if (slot_provider == nullptr) { + continue; + } - const auto status = nca->GetStatus(); - if (status != Loader::ResultStatus::Success) { - LOG_DEBUG(Loader, "DLC {:016X} NCA has status {}", - entry.title_id, static_cast(status)); - return false; - } + auto nca = slot_provider->GetEntry(entry); + if (!nca) { + LOG_DEBUG(Loader, "Failed to get NCA for DLC {:016X}", entry.title_id); + continue; + } - return true; - }); + const auto status = nca->GetStatus(); + if (status != Loader::ResultStatus::Success) { + LOG_DEBUG(Loader, "DLC {:016X} NCA has status {}", entry.title_id, + static_cast(status)); + continue; + } + + switch (slot) { + case ContentProviderUnionSlot::External: + case ContentProviderUnionSlot::FrontendManual: + has_external_dlc = true; + break; + case ContentProviderUnionSlot::UserNAND: + case ContentProviderUnionSlot::SysNAND: + has_nand_dlc = true; + break; + case ContentProviderUnionSlot::SDMC: + has_sdmc_dlc = true; + break; + default: + has_other_dlc = true; + break; + } + dlc_match.push_back(entry); + } if (!dlc_match.empty()) { // Ensure sorted so DLC IDs show in order. @@ -1000,13 +1054,22 @@ std::vector PatchManager::GetPatches(VirtualFile update_raw) const { const auto dlc_disabled = std::find(disabled.begin(), disabled.end(), "DLC") != disabled.end(); + PatchSource dlc_source = PatchSource::Unknown; + if (has_external_dlc && !has_nand_dlc && !has_sdmc_dlc && !has_other_dlc) { + dlc_source = PatchSource::External; + } else if (has_nand_dlc && !has_external_dlc && !has_sdmc_dlc && !has_other_dlc) { + dlc_source = PatchSource::NAND; + } else if (has_sdmc_dlc && !has_external_dlc && !has_nand_dlc && !has_other_dlc) { + dlc_source = PatchSource::SDMC; + } + out.push_back({.enabled = !dlc_disabled, .name = "DLC", .version = std::move(list), .type = PatchType::DLC, .program_id = title_id, .title_id = dlc_match.back().title_id, - .source = PatchSource::Unknown}); + .source = dlc_source}); } return out; diff --git a/src/core/file_sys/patch_manager.h b/src/core/file_sys/patch_manager.h index 2be963078d..755d924fd4 100644 --- a/src/core/file_sys/patch_manager.h +++ b/src/core/file_sys/patch_manager.h @@ -34,6 +34,7 @@ enum class PatchType { Update, DLC, Mod }; enum class PatchSource { Unknown, NAND, + SDMC, External, Packed, }; From 07e3a2aa46d1b8e9e28fdc3b306d1628e5c92f3e Mon Sep 17 00:00:00 2001 From: crueter Date: Tue, 10 Mar 2026 05:36:12 +0100 Subject: [PATCH 15/25] [settings] Disable fastmem on Linux systems with non-4kb page sizes (#3669) Asahi, etc Signed-off-by: crueter Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3669 Reviewed-by: Lizzie Reviewed-by: CamilleLaVey --- src/common/settings.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/common/settings.cpp b/src/common/settings.cpp index c952567e63..4197c99663 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -27,6 +27,10 @@ #include "common/settings.h" #include "common/time_zone.h" +#if defined(__linux__ ) && defined(ARCHITECTURE_arm64) +#include +#endif + namespace Settings { // Clang 14 and earlier have errors when explicitly instantiating these classes @@ -178,7 +182,11 @@ bool IsFastmemEnabled() { return bool(values.cpuopt_fastmem); else if (values.cpu_accuracy.GetValue() == CpuAccuracy::Unsafe) return bool(values.cpuopt_unsafe_host_mmu); -#if !defined(__APPLE__) && !defined(__linux__) && !defined(__ANDROID__) && !defined(_WIN32) +#if defined(__linux__) && defined(ARCHITECTURE_arm64) + // Only 4kb systems support host MMU right now + // TODO: Support this + return getpagesize() == 4096; +#elif !defined(__APPLE__) && !defined(__ANDROID__) && !defined(_WIN32) && !defined(__linux__) return false; #else return true; From 0ff1d215c81bda45e84c45d0dddb1f7ffb81f7b1 Mon Sep 17 00:00:00 2001 From: crueter Date: Tue, 10 Mar 2026 05:37:45 +0100 Subject: [PATCH 16/25] [desktop] Port some QtCommon changes from QML branch (#3703) - Linker now resolves implementation differences - Remove unneeded ifdefs - Better abstractions overall Signed-off-by: crueter Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3703 Reviewed-by: Lizzie Reviewed-by: CamilleLaVey --- .ci/license-header.sh | 4 +- src/CMakeLists.txt | 1 - src/qt_common/CMakeLists.txt | 6 +- src/qt_common/abstract/frontend.cpp | 64 +------ src/qt_common/abstract/frontend.h | 150 ++++++---------- src/qt_common/abstract/progress.cpp | 17 ++ src/qt_common/abstract/progress.h | 45 +++++ src/qt_common/abstract/qt_progress_dialog.cpp | 4 - src/qt_common/abstract/qt_progress_dialog.h | 47 ----- src/qt_common/config/qt_config.cpp | 10 +- src/qt_common/config/shared_translation.h | 2 +- src/qt_common/discord/discord_impl.cpp | 2 +- src/qt_common/gamemode.cpp | 2 +- src/qt_common/gui_settings.cpp | 2 +- src/qt_common/qt_common.cpp | 13 -- src/qt_common/qt_common.h | 10 +- src/qt_common/util/applet.h | 2 +- src/qt_common/util/compress.cpp | 2 +- src/qt_common/util/compress.h | 2 +- src/qt_common/util/content.cpp | 162 ++++++++---------- src/qt_common/util/content.h | 4 +- src/qt_common/util/fs.cpp | 2 +- src/qt_common/util/fs.h | 2 +- src/qt_common/util/game.cpp | 24 +-- src/qt_common/util/game.h | 2 +- src/qt_common/util/meta.cpp | 2 +- src/qt_common/util/meta.h | 2 +- src/qt_common/util/path.cpp | 20 +-- src/qt_common/util/path.h | 2 +- src/qt_common/util/rom.cpp | 2 +- src/qt_common/util/rom.h | 2 +- src/yuzu/CMakeLists.txt | 1 + src/yuzu/libqt_common.cpp | 119 +++++++++++++ src/yuzu/libqt_common.h | 37 ++++ src/yuzu/main_window.cpp | 3 +- tools/clang-format.sh | 5 +- 36 files changed, 405 insertions(+), 371 deletions(-) create mode 100644 src/qt_common/abstract/progress.cpp create mode 100644 src/qt_common/abstract/progress.h delete mode 100644 src/qt_common/abstract/qt_progress_dialog.cpp delete mode 100644 src/qt_common/abstract/qt_progress_dialog.h create mode 100644 src/yuzu/libqt_common.cpp create mode 100644 src/yuzu/libqt_common.h diff --git a/.ci/license-header.sh b/.ci/license-header.sh index 70a842e01d..6b19f91185 100755 --- a/.ci/license-header.sh +++ b/.ci/license-header.sh @@ -115,7 +115,7 @@ for file in $FILES; do *.cmake|*.sh|*CMakeLists.txt) begin="#" ;; - *.kt*|*.cpp|*.h) + *.kt*|*.cpp|*.h|*.qml) begin="//" ;; *) @@ -193,7 +193,7 @@ if [ "$UPDATE" = "true" ]; then begin="#" shell=true ;; - *.kt*|*.cpp|*.h) + *) begin="//" shell="false" ;; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dfb311b327..a9fa5314b7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -242,7 +242,6 @@ if (YUZU_CMD) endif() if (ENABLE_QT) - add_definitions(-DYUZU_QT_WIDGETS) add_subdirectory(qt_common) add_subdirectory(yuzu) endif() diff --git a/src/qt_common/CMakeLists.txt b/src/qt_common/CMakeLists.txt index 65f5b1ee2b..f0522c07d2 100644 --- a/src/qt_common/CMakeLists.txt +++ b/src/qt_common/CMakeLists.txt @@ -1,6 +1,8 @@ # SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project # SPDX-License-Identifier: GPL-3.0-or-later +set(CMAKE_AUTOMOC ON) + add_library(qt_common STATIC qt_common.h qt_common.cpp @@ -26,7 +28,7 @@ add_library(qt_common STATIC util/mod.h util/mod.cpp abstract/frontend.h abstract/frontend.cpp - abstract/qt_progress_dialog.h abstract/qt_progress_dialog.cpp + abstract/progress.h abstract/progress.cpp qt_string_lookup.h qt_compat.h @@ -93,3 +95,5 @@ if (UNIX AND NOT APPLE) target_link_libraries(qt_common PRIVATE Qt6::GuiPrivate) endif() endif() + +create_target_directory_groups(qt_common) diff --git a/src/qt_common/abstract/frontend.cpp b/src/qt_common/abstract/frontend.cpp index 620256c2d8..05eb550095 100644 --- a/src/qt_common/abstract/frontend.cpp +++ b/src/qt_common/abstract/frontend.cpp @@ -1,75 +1,27 @@ // SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later -#include #include "frontend.h" -#include "qt_common/qt_common.h" - -#ifdef YUZU_QT_WIDGETS -#include -#endif - -#include -#include namespace QtCommon::Frontend { -StandardButton ShowMessage(Icon icon, const QString& title, const QString& text, - StandardButtons buttons, QObject* parent) { -#ifdef YUZU_QT_WIDGETS - QMessageBox* box = new QMessageBox(icon, title, text, buttons, (QWidget*)parent); - return static_cast(box->exec()); -#endif - // TODO(crueter): If Qt Widgets is disabled... - // need a way to reference icon/buttons too -} - const QString GetOpenFileName(const QString& title, const QString& dir, const QString& filter, - QString* selectedFilter, Options options) { -#ifdef YUZU_QT_WIDGETS - return QFileDialog::getOpenFileName(rootObject, title, dir, filter, selectedFilter, options); -#endif + QString* selectedFilter) { + return QFileDialog::getOpenFileName(rootObject, title, dir, filter, selectedFilter); } const QStringList GetOpenFileNames(const QString& title, const QString& dir, const QString& filter, - QString* selectedFilter, Options options) { -#ifdef YUZU_QT_WIDGETS - return QFileDialog::getOpenFileNames(rootObject, title, dir, filter, selectedFilter, options); -#endif + QString* selectedFilter) { + return QFileDialog::getOpenFileNames(rootObject, title, dir, filter, selectedFilter); } const QString GetSaveFileName(const QString& title, const QString& dir, const QString& filter, - QString* selectedFilter, Options options) { -#ifdef YUZU_QT_WIDGETS - return QFileDialog::getSaveFileName(rootObject, title, dir, filter, selectedFilter, options); -#endif + QString* selectedFilter) { + return QFileDialog::getSaveFileName(rootObject, title, dir, filter, selectedFilter); } -const QString GetExistingDirectory(const QString& caption, const QString& dir, Options options) { -#ifdef YUZU_QT_WIDGETS - return QFileDialog::getExistingDirectory(rootObject, caption, dir, options); -#endif -} - -int Choice(const QString& title, const QString& caption, const QStringList& options) { - QMessageBox box(rootObject); - box.setText(caption); - box.setWindowTitle(title); - - for (const QString& opt : options) { - box.addButton(opt, QMessageBox::AcceptRole); - } - - box.addButton(QMessageBox::Cancel); - - box.exec(); - auto button = box.clickedButton(); - return options.indexOf(button->text()); -} - -const QString GetTextInput(const QString& title, const QString& caption, - const QString& defaultText) { - return QInputDialog::getText(rootObject, title, caption, QLineEdit::Normal, defaultText); +const QString GetExistingDirectory(const QString& caption, const QString& dir) { + return QFileDialog::getExistingDirectory(rootObject, caption, dir); } } // namespace QtCommon::Frontend diff --git a/src/qt_common/abstract/frontend.h b/src/qt_common/abstract/frontend.h index 40ef80cbb7..9b70f6849e 100644 --- a/src/qt_common/abstract/frontend.h +++ b/src/qt_common/abstract/frontend.h @@ -7,11 +7,7 @@ #include #include "qt_common/qt_common.h" -#ifdef YUZU_QT_WIDGETS #include -#include -#include -#endif /** * manages common functionality e.g. message boxes and such for Qt/QML @@ -20,60 +16,39 @@ namespace QtCommon::Frontend { Q_NAMESPACE -#ifdef YUZU_QT_WIDGETS -using Options = QFileDialog::Options; -using Option = QFileDialog::Option; - -using StandardButton = QMessageBox::StandardButton; -using StandardButtons = QMessageBox::StandardButtons; - -using Icon = QMessageBox::Icon; -#else -enum Option { - ShowDirsOnly = 0x00000001, - DontResolveSymlinks = 0x00000002, - DontConfirmOverwrite = 0x00000004, - DontUseNativeDialog = 0x00000008, - ReadOnly = 0x00000010, - HideNameFilterDetails = 0x00000020, - DontUseCustomDirectoryIcons = 0x00000040 -}; -Q_ENUM_NS(Option) -Q_DECLARE_FLAGS(Options, Option) -Q_FLAG_NS(Options) - enum StandardButton { - // keep this in sync with QDialogButtonBox::StandardButton and QPlatformDialogHelper::StandardButton - NoButton = 0x00000000, - Ok = 0x00000400, - Save = 0x00000800, - SaveAll = 0x00001000, - Open = 0x00002000, - Yes = 0x00004000, - YesToAll = 0x00008000, - No = 0x00010000, - NoToAll = 0x00020000, - Abort = 0x00040000, - Retry = 0x00080000, - Ignore = 0x00100000, - Close = 0x00200000, - Cancel = 0x00400000, - Discard = 0x00800000, - Help = 0x01000000, - Apply = 0x02000000, - Reset = 0x04000000, - RestoreDefaults = 0x08000000, + // keep this in sync with QDialogButtonBox::StandardButton and + // QPlatformDialogHelper::StandardButton + NoButton = 0x00000000, + Ok = 0x00000400, + Save = 0x00000800, + SaveAll = 0x00001000, + Open = 0x00002000, + Yes = 0x00004000, + YesToAll = 0x00008000, + No = 0x00010000, + NoToAll = 0x00020000, + Abort = 0x00040000, + Retry = 0x00080000, + Ignore = 0x00100000, + Close = 0x00200000, + Cancel = 0x00400000, + Discard = 0x00800000, + Help = 0x01000000, + Apply = 0x02000000, + Reset = 0x04000000, + RestoreDefaults = 0x08000000, - FirstButton = Ok, // internal - LastButton = RestoreDefaults, // internal + FirstButton = Ok, // internal + LastButton = RestoreDefaults, // internal - YesAll = YesToAll, // obsolete - NoAll = NoToAll, // obsolete + YesAll = YesToAll, // obsolete + NoAll = NoToAll, // obsolete - Default = 0x00000100, // obsolete - Escape = 0x00000200, // obsolete - FlagMask = 0x00000300, // obsolete - ButtonMask = ~FlagMask // obsolete + Default = 0x00000100, // obsolete + Escape = 0x00000200, // obsolete + FlagMask = 0x00000300, // obsolete + ButtonMask = ~FlagMask // obsolete }; Q_ENUM_NS(StandardButton) @@ -83,7 +58,7 @@ typedef StandardButton Button; Q_DECLARE_FLAGS(StandardButtons, StandardButton) Q_FLAG_NS(StandardButtons) -enum Icon { +enum class Icon { // keep this in sync with QMessageDialogOptions::StandardIcon NoIcon = 0, Information = 1, @@ -93,29 +68,26 @@ enum Icon { }; Q_ENUM_NS(Icon) -#endif - -// TODO(crueter) widgets-less impl, choices et al. -StandardButton ShowMessage(Icon icon, - const QString &title, - const QString &text, +StandardButton ShowMessage(Icon icon, const QString& title, const QString& text, StandardButtons buttons = StandardButton::NoButton, - QObject *parent = nullptr); + QObject* parent = nullptr); -#define UTIL_OVERRIDES(level) \ - inline StandardButton level(QObject *parent, \ - const QString &title, \ - const QString &text, \ - StandardButtons buttons = StandardButton::Ok) \ - { \ - return ShowMessage(Icon::level, title, text, buttons, parent); \ - } \ - inline StandardButton level(const QString title, \ - const QString &text, \ - StandardButtons buttons \ - = StandardButton::Ok) \ - { \ - return ShowMessage(Icon::level, title, text, buttons, rootObject); \ +#define UTIL_OVERRIDES(level) \ + inline StandardButton level(QObject* parent, const QString& title, const QString& text, \ + StandardButtons buttons) { \ + return ShowMessage(Icon::level, title, text, buttons, parent); \ + } \ + inline StandardButton level(QObject* parent, const QString& title, const QString& text, \ + int buttons = StandardButton::Ok) { \ + return ShowMessage(Icon::level, title, text, StandardButtons(buttons), parent); \ + } \ + inline StandardButton level(const QString title, const QString& text, \ + StandardButtons buttons) { \ + return ShowMessage(Icon::level, title, text, buttons, rootObject); \ + } \ + inline StandardButton level(const QString& title, const QString& text, \ + int buttons = StandardButton::Ok) { \ + return ShowMessage(Icon::level, title, text, StandardButtons(buttons), rootObject); \ } UTIL_OVERRIDES(Information) @@ -123,27 +95,17 @@ UTIL_OVERRIDES(Warning) UTIL_OVERRIDES(Critical) UTIL_OVERRIDES(Question) -const QString GetOpenFileName(const QString &title, - const QString &dir, - const QString &filter, - QString *selectedFilter = nullptr, - Options options = Options()); +const QString GetOpenFileName(const QString& title, const QString& dir, const QString& filter, + QString* selectedFilter = nullptr); -const QStringList GetOpenFileNames(const QString &title, - const QString &dir, - const QString &filter, - QString *selectedFilter = nullptr, - Options options = Options()); +const QStringList GetOpenFileNames(const QString& title, const QString& dir, const QString& filter, + QString* selectedFilter = nullptr); -const QString GetSaveFileName(const QString &title, - const QString &dir, - const QString &filter, - QString *selectedFilter = nullptr, - Options options = Options()); +const QString GetSaveFileName(const QString& title, const QString& dir, const QString& filter, + QString* selectedFilter = nullptr); -const QString GetExistingDirectory(const QString &caption = QString(), - const QString &dir = QString(), - Options options = Option::ShowDirsOnly); +const QString GetExistingDirectory(const QString& caption = QString(), + const QString& dir = QString()); int Choice(const QString& title = QString(), const QString& caption = QString(), const QStringList& options = {}); diff --git a/src/qt_common/abstract/progress.cpp b/src/qt_common/abstract/progress.cpp new file mode 100644 index 0000000000..c9185a756d --- /dev/null +++ b/src/qt_common/abstract/progress.cpp @@ -0,0 +1,17 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "progress.h" + +namespace QtCommon::Frontend { + +QtProgressDialog::QtProgressDialog(const QString&, + const QString&, + int, + int, + QObject* parent, + Qt::WindowFlags) + : QObject(parent) +{} + +} diff --git a/src/qt_common/abstract/progress.h b/src/qt_common/abstract/progress.h new file mode 100644 index 0000000000..b6f2975c1e --- /dev/null +++ b/src/qt_common/abstract/progress.h @@ -0,0 +1,45 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + +#pragma once + +#include +#include + +namespace QtCommon::Frontend { + +class QtProgressDialog : public QObject { + Q_OBJECT +public: + QtProgressDialog(const QString& labelText, const QString& cancelButtonText, int minimum, + int maximum, QObject* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); + + virtual ~QtProgressDialog() = default; + + virtual bool wasCanceled() const = 0; + virtual void setWindowModality(Qt::WindowModality modality) = 0; + virtual void setMinimumDuration(int durationMs) = 0; + virtual void setAutoClose(bool autoClose) = 0; + virtual void setAutoReset(bool autoReset) = 0; + +public slots: + virtual void setTitle(QString title) = 0; + virtual void setLabelText(QString text) = 0; + virtual void setMinimum(int min) = 0; + virtual void setMaximum(int max) = 0; + virtual void setValue(int value) = 0; + + virtual bool close() = 0; + virtual void show() = 0; +}; + +std::unique_ptr newProgressDialog(const QString& labelText, + const QString& cancelButtonText, int minimum, + int maximum, + Qt::WindowFlags f = Qt::WindowFlags()); + +QtProgressDialog* newProgressDialogPtr(const QString& labelText, const QString& cancelButtonText, + int minimum, int maximum, + Qt::WindowFlags f = Qt::WindowFlags()); + +} // namespace QtCommon::Frontend diff --git a/src/qt_common/abstract/qt_progress_dialog.cpp b/src/qt_common/abstract/qt_progress_dialog.cpp deleted file mode 100644 index b4bf74c8bd..0000000000 --- a/src/qt_common/abstract/qt_progress_dialog.cpp +++ /dev/null @@ -1,4 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - -#include "qt_progress_dialog.h" diff --git a/src/qt_common/abstract/qt_progress_dialog.h b/src/qt_common/abstract/qt_progress_dialog.h deleted file mode 100644 index 17f6817ffa..0000000000 --- a/src/qt_common/abstract/qt_progress_dialog.h +++ /dev/null @@ -1,47 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - -#ifndef QT_PROGRESS_DIALOG_H -#define QT_PROGRESS_DIALOG_H - -#include - -#ifdef YUZU_QT_WIDGETS -#include -#endif - -namespace QtCommon::Frontend { -#ifdef YUZU_QT_WIDGETS - -using QtProgressDialog = QProgressDialog; - -// TODO(crueter): QML impl -#else -class QtProgressDialog -{ -public: - QtProgressDialog(const QString &labelText, - const QString &cancelButtonText, - int minimum, - int maximum, - QObject *parent = nullptr, - Qt::WindowFlags f = Qt::WindowFlags()); - - bool wasCanceled() const; - void setWindowModality(Qt::WindowModality modality); - void setMinimumDuration(int durationMs); - void setAutoClose(bool autoClose); - void setAutoReset(bool autoReset); - -public slots: - void setLabelText(QString &text); - void setRange(int min, int max); - void setValue(int progress); - bool close(); - - void show(); -}; -#endif // YUZU_QT_WIDGETS - -} -#endif // QT_PROGRESS_DIALOG_H diff --git a/src/qt_common/config/qt_config.cpp b/src/qt_common/config/qt_config.cpp index c5a8f62745..2ae03ae3b8 100644 --- a/src/qt_common/config/qt_config.cpp +++ b/src/qt_common/config/qt_config.cpp @@ -319,7 +319,7 @@ void QtConfig::ReadUIGamelistValues() { } void QtConfig::ReadUILayoutValues() { - BeginGroup(Settings::TranslateCategory(Settings::Category::UiGameList)); + BeginGroup(Settings::TranslateCategory(Settings::Category::UiLayout)); ReadCategory(Settings::Category::UiLayout); @@ -578,10 +578,10 @@ void QtConfig::SaveMultiplayerValues() { } std::vector& QtConfig::FindRelevantList(Settings::Category category) { - auto& map = Settings::values.linkage.by_category; - if (map.contains(category)) { - return Settings::values.linkage.by_category[category]; - } + auto& list = Settings::values.linkage.by_category[category]; + if (!list.empty()) + return list; + return UISettings::values.linkage.by_category[category]; } diff --git a/src/qt_common/config/shared_translation.h b/src/qt_common/config/shared_translation.h index afb18ec435..6fbeb1df6e 100644 --- a/src/qt_common/config/shared_translation.h +++ b/src/qt_common/config/shared_translation.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2024 Torzu Emulator Project diff --git a/src/qt_common/discord/discord_impl.cpp b/src/qt_common/discord/discord_impl.cpp index 3bf5544198..82f805b888 100644 --- a/src/qt_common/discord/discord_impl.cpp +++ b/src/qt_common/discord/discord_impl.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: 2018 Citra Emulator Project diff --git a/src/qt_common/gamemode.cpp b/src/qt_common/gamemode.cpp index 6a3d870aae..dae6676fee 100644 --- a/src/qt_common/gamemode.cpp +++ b/src/qt_common/gamemode.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project diff --git a/src/qt_common/gui_settings.cpp b/src/qt_common/gui_settings.cpp index 982d28bbcb..4a1506261a 100644 --- a/src/qt_common/gui_settings.cpp +++ b/src/qt_common/gui_settings.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later #include "gui_settings.h" diff --git a/src/qt_common/qt_common.cpp b/src/qt_common/qt_common.cpp index af4e4ffa61..8954bf09f2 100644 --- a/src/qt_common/qt_common.cpp +++ b/src/qt_common/qt_common.cpp @@ -3,19 +3,14 @@ #include "qt_common.h" #include "common/fs/fs.h" -#include "common/fs/ryujinx_compat.h" #include #include #include "common/logging/log.h" #include "core/frontend/emu_window.h" -#include "qt_common/abstract/frontend.h" -#include "qt_common/qt_string_lookup.h" #include -#include - #include #if !defined(WIN32) && !defined(__APPLE__) @@ -27,11 +22,7 @@ namespace QtCommon { -#ifdef YUZU_QT_WIDGETS QWidget* rootObject = nullptr; -#else -QObject* rootObject = nullptr; -#endif std::unique_ptr system = nullptr; std::shared_ptr vfs = nullptr; @@ -118,11 +109,7 @@ const QString tr(const std::string& str) return QGuiApplication::tr(str.c_str()); } -#ifdef YUZU_QT_WIDGETS void Init(QWidget* root) -#else -void Init(QObject* root) -#endif { system = std::make_unique(); rootObject = root; diff --git a/src/qt_common/qt_common.h b/src/qt_common/qt_common.h index a2700427ab..9c7816a2ed 100644 --- a/src/qt_common/qt_common.h +++ b/src/qt_common/qt_common.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later #ifndef QT_COMMON_H @@ -14,11 +14,7 @@ namespace QtCommon { -#ifdef YUZU_QT_WIDGETS extern QWidget *rootObject; -#else -extern QObject *rootObject; -#endif extern std::unique_ptr system; extern std::shared_ptr vfs; @@ -30,11 +26,7 @@ Core::Frontend::WindowSystemType GetWindowSystemType(); Core::Frontend::EmuWindow::WindowSystemInfo GetWindowSystemInfo(QWindow *window); -#ifdef YUZU_QT_WIDGETS void Init(QWidget *root); -#else -void Init(QObject *root); -#endif const QString tr(const char *str); const QString tr(const std::string &str); diff --git a/src/qt_common/util/applet.h b/src/qt_common/util/applet.h index 2b48d16698..34183274ff 100644 --- a/src/qt_common/util/applet.h +++ b/src/qt_common/util/applet.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later #ifndef QT_APPLET_UTIL_H diff --git a/src/qt_common/util/compress.cpp b/src/qt_common/util/compress.cpp index 94dca41151..527640cb98 100644 --- a/src/qt_common/util/compress.cpp +++ b/src/qt_common/util/compress.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later #include "compress.h" diff --git a/src/qt_common/util/compress.h b/src/qt_common/util/compress.h index 2b3ffd1cbd..a16c6bff1a 100644 --- a/src/qt_common/util/compress.h +++ b/src/qt_common/util/compress.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later #pragma once diff --git a/src/qt_common/util/content.cpp b/src/qt_common/util/content.cpp index 9ba5ab264c..dd095a40a4 100644 --- a/src/qt_common/util/content.cpp +++ b/src/qt_common/util/content.cpp @@ -12,7 +12,7 @@ #include "compress.h" #include "qt_common/abstract/frontend.h" -#include "qt_common/abstract/qt_progress_dialog.h" +#include "qt_common/abstract/progress.h" #include "qt_common/qt_common.h" #include @@ -22,20 +22,18 @@ namespace QtCommon::Content { -bool CheckGameFirmware(u64 program_id, QObject* parent) +bool CheckGameFirmware(u64 program_id) { if (FirmwareManager::GameRequiresFirmware(program_id) && !FirmwareManager::CheckFirmwarePresence(*system)) { - auto result = QtCommon::Frontend::ShowMessage( - QMessageBox::Warning, + auto result = QtCommon::Frontend::Warning( tr("Game Requires Firmware"), tr("The game you are trying to launch requires firmware to boot or to get past the " "opening menu. Please " "dump and install firmware, or press \"OK\" to launch anyways."), - QMessageBox::Ok | QMessageBox::Cancel, - parent); + QtCommon::Frontend::Ok | QtCommon::Frontend::Cancel); - return result == QMessageBox::Ok; + return result == QtCommon::Frontend::Ok; } return true; @@ -43,26 +41,23 @@ bool CheckGameFirmware(u64 program_id, QObject* parent) void InstallFirmware(const QString& location, bool recursive) { - QtCommon::Frontend::QtProgressDialog progress(tr("Installing Firmware..."), - tr("Cancel"), - 0, - 100, - rootObject); - progress.setWindowModality(Qt::WindowModal); - progress.setMinimumDuration(100); - progress.setAutoClose(false); - progress.setAutoReset(false); - progress.show(); + // Initialize a progress dialog. + auto progress = QtCommon::Frontend::newProgressDialog(tr("Installing Firmware..."), + tr("Cancel"), 0, 100); + progress->show(); + + QGuiApplication::processEvents(); // Declare progress callback. auto callback = [&](size_t total_size, size_t processed_size) { - progress.setValue(static_cast((processed_size * 100) / total_size)); - return progress.wasCanceled(); + QGuiApplication::processEvents(); + progress->setValue(static_cast((processed_size * 100) / total_size)); + return progress->wasCanceled(); }; QString failedTitle = tr("Firmware Install Failed"); QString successTitle = tr("Firmware Install Succeeded"); - QMessageBox::Icon icon; + QtCommon::Frontend::Icon icon; FirmwareInstallResult result; const auto ShowMessage = [&]() { @@ -104,7 +99,7 @@ void InstallFirmware(const QString& location, bool recursive) if (out.size() <= 0) { result = FirmwareInstallResult::NoNCAs; - icon = QMessageBox::Warning; + icon = QtCommon::Frontend::Icon::Warning; ShowMessage(); return; } @@ -114,7 +109,7 @@ void InstallFirmware(const QString& location, bool recursive) if (sysnand_content_vdir->IsWritable() && !sysnand_content_vdir->CleanSubdirectoryRecursive("registered")) { result = FirmwareInstallResult::FailedDelete; - icon = QMessageBox::Critical; + icon = QtCommon::Frontend::Icon::Critical; ShowMessage(); return; } @@ -145,7 +140,7 @@ void InstallFirmware(const QString& location, bool recursive) if (callback(100, 20 + static_cast(((i) / static_cast(out.size())) * 70.0))) { result = FirmwareInstallResult::FailedCorrupted; - icon = QMessageBox::Warning; + icon = QtCommon::Frontend::Icon::Warning; ShowMessage(); return; } @@ -153,7 +148,7 @@ void InstallFirmware(const QString& location, bool recursive) if (!success) { result = FirmwareInstallResult::FailedCopy; - icon = QMessageBox::Critical; + icon = QtCommon::Frontend::Icon::Critical; ShowMessage(); return; } @@ -162,8 +157,9 @@ void InstallFirmware(const QString& location, bool recursive) system->GetFileSystemController().CreateFactories(*vfs); auto VerifyFirmwareCallback = [&](size_t total_size, size_t processed_size) { - progress.setValue(90 + static_cast((processed_size * 10) / total_size)); - return progress.wasCanceled(); + QGuiApplication::processEvents(); + progress->setValue(90 + static_cast((processed_size * 10) / total_size)); + return progress->wasCanceled(); }; auto results = ContentManager::VerifyInstalledContents(*QtCommon::system, @@ -174,14 +170,15 @@ void InstallFirmware(const QString& location, bool recursive) if (results.size() > 0) { const auto failed_names = QString::fromStdString( fmt::format("{}", fmt::join(results, "\n"))); - progress.close(); + progress->close(); QtCommon::Frontend::Critical( tr("Firmware integrity verification failed!"), tr("Verification failed for the following files:\n\n%1").arg(failed_names)); return; } - progress.close(); + progress->close(); + QGuiApplication::processEvents(); const auto pair = FirmwareManager::GetFirmwareVersion(*system); const auto firmware_data = pair.first; @@ -221,19 +218,16 @@ QString UnzipFirmwareToTmp(const QString& location) // Content // void VerifyGameContents(const std::string& game_path) { - QtCommon::Frontend::QtProgressDialog progress(tr("Verifying integrity..."), - tr("Cancel"), - 0, - 100, - rootObject); - progress.setWindowModality(Qt::WindowModal); - progress.setMinimumDuration(100); - progress.setAutoClose(false); - progress.setAutoReset(false); + auto progress = + QtCommon::Frontend::newProgressDialog(tr("Verifying integrity..."), tr("Cancel"), 0, 100); + progress->show(); + + QGuiApplication::processEvents(); const auto callback = [&](size_t total_size, size_t processed_size) { - progress.setValue(static_cast((processed_size * 100) / total_size)); - return progress.wasCanceled(); + QGuiApplication::processEvents(); + progress->setValue(static_cast((processed_size * 100) / total_size)); + return progress->wasCanceled(); }; const auto result = ContentManager::VerifyGameContents(*system, game_path, callback); @@ -260,12 +254,8 @@ void VerifyGameContents(const std::string& game_path) void InstallKeys() { - const QString key_source_location - = QtCommon::Frontend::GetOpenFileName(tr("Select Dumped Keys Location"), - {}, - QStringLiteral("Decryption Keys (*.keys)"), - {}, - QtCommon::Frontend::Option::ReadOnly); + const QString key_source_location = QtCommon::Frontend::GetOpenFileName( + tr("Select Dumped Keys Location"), {}, QStringLiteral("Decryption Keys (*.keys)"), {}); if (key_source_location.isEmpty()) return; @@ -289,27 +279,22 @@ void InstallKeys() void VerifyInstalledContents() { // Initialize a progress dialog. - QtCommon::Frontend::QtProgressDialog progress(tr("Verifying integrity..."), - tr("Cancel"), - 0, - 100, - rootObject); - progress.setWindowModality(Qt::WindowModal); - progress.setMinimumDuration(100); - progress.setAutoClose(false); - progress.setAutoReset(false); + auto progress = QtCommon::Frontend::newProgressDialog(tr("Verifying integrity..."), + tr("Cancel"), 0, 100); + progress->show(); + + QGuiApplication::processEvents(); // Declare progress callback. auto QtProgressCallback = [&](size_t total_size, size_t processed_size) { - progress.setValue(static_cast((processed_size * 100) / total_size)); - return progress.wasCanceled(); - }; + QGuiApplication::processEvents(); + progress->setValue(static_cast((processed_size * 100) / total_size)); + return progress->wasCanceled(); }; - const std::vector result - = ContentManager::VerifyInstalledContents(*QtCommon::system, - *QtCommon::provider, - QtProgressCallback); - progress.close(); + const std::vector result = ContentManager::VerifyInstalledContents( + *QtCommon::system, *QtCommon::provider, QtProgressCallback); + + progress->close(); if (result.empty()) { QtCommon::Frontend::Information(tr("Integrity verification succeeded!"), @@ -374,28 +359,29 @@ void FixProfiles() void ClearDataDir(FrontendCommon::DataManager::DataDir dir, const std::string& user_id) { - auto result = QtCommon::Frontend::Warning(tr("Really clear data?"), - tr("Important data may be lost!"), - QMessageBox::Yes | QMessageBox::No); + using namespace QtCommon::Frontend; + auto result = Warning(tr("Really clear data?"), + tr("Important data may be lost!"), + Yes | No); - if (result != QMessageBox::Yes) + if (result != Yes) return; - result = QtCommon::Frontend::Warning( + result = Warning( tr("Are you REALLY sure?"), tr("Once deleted, your data will NOT come back!\n" "Only do this if you're 100% sure you want to delete this data."), - QMessageBox::Yes | QMessageBox::No); + Yes | No); - if (result != QMessageBox::Yes) + if (result != Yes) return; - QtCommon::Frontend::QtProgressDialog dialog(tr("Clearing..."), QString(), 0, 0); - dialog.show(); + auto dialog = newProgressDialog(tr("Clearing..."), QString(), 0, 0); + dialog->show(); FrontendCommon::DataManager::ClearDir(dir, user_id); - dialog.close(); + dialog->close(); } void ExportDataDir(FrontendCommon::DataManager::DataDir data_dir, @@ -413,18 +399,12 @@ void ExportDataDir(FrontendCommon::DataManager::DataDir data_dir, if (zip_dump_location.isEmpty()) return; - QtProgressDialog* progress = new QtProgressDialog( - tr("Exporting data. This may take a while..."), tr("Cancel"), 0, 100, rootObject); + auto progress = QtCommon::Frontend::newProgressDialogPtr( + tr("Exporting data. This may take a while..."), tr("Cancel"), 0, 100); - progress->setWindowTitle(tr("Exporting")); - progress->setWindowModality(Qt::WindowModal); - progress->setMinimumDuration(100); - progress->setAutoClose(false); - progress->setAutoReset(false); + progress->setTitle(tr("Exporting")); progress->show(); - QGuiApplication::processEvents(); - auto progress_callback = [=](size_t total_size, size_t processed_size) { QMetaObject::invokeMethod(progress, "setValue", @@ -485,23 +465,16 @@ void ImportDataDir(FrontendCommon::DataManager::DataDir data_dir, "proceed?"), StandardButton::Yes | StandardButton::No); - if (button != QMessageBox::Yes) + if (button != QtCommon::Frontend::Yes) return; - QtProgressDialog* progress = new QtProgressDialog( - tr("Importing data. This may take a while..."), tr("Cancel"), 0, 100, rootObject); + QtProgressDialog* progress = newProgressDialogPtr( + tr("Importing data. This may take a while..."), tr("Cancel"), 0, 100); - progress->setWindowTitle(tr("Importing")); - progress->setWindowModality(Qt::WindowModal); - progress->setMinimumDuration(100); - progress->setAutoClose(false); - progress->setAutoReset(false); + progress->setTitle(tr("Importing")); progress->show(); - progress->setValue(0); - QGuiApplication::processEvents(); - - // to prevent GUI mangling we have to run this in a thread as well + // to prevent GUI mangling we have to run this in a thread as well QFuture delete_future = QtConcurrent::run([=]() { FrontendCommon::DataManager::ClearDir(data_dir, user_id); return !progress->wasCanceled(); @@ -532,7 +505,7 @@ void ImportDataDir(FrontendCommon::DataManager::DataDir data_dir, QObject::connect(watcher, &QFutureWatcher::finished, rootObject, [=]() { progress->close(); - // this sucks + // this sucks if (watcher->result()) { Information(tr("Imported Successfully"), tr("Data was imported successfully.")); } else if (progress->wasCanceled()) { @@ -553,4 +526,5 @@ void ImportDataDir(FrontendCommon::DataManager::DataDir data_dir, }); } +// TODO(crueter): Port InstallFirmware et al. from QML Branch } // namespace QtCommon::Content diff --git a/src/qt_common/util/content.h b/src/qt_common/util/content.h index 6e8642083f..c1e2e7791d 100644 --- a/src/qt_common/util/content.h +++ b/src/qt_common/util/content.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later #ifndef QT_CONTENT_UTIL_H @@ -13,7 +13,7 @@ namespace QtCommon::Content { // -bool CheckGameFirmware(u64 program_id, QObject *parent); +bool CheckGameFirmware(u64 program_id); enum class FirmwareInstallResult { Success, diff --git a/src/qt_common/util/fs.cpp b/src/qt_common/util/fs.cpp index dd105849aa..e171b8eaf5 100644 --- a/src/qt_common/util/fs.cpp +++ b/src/qt_common/util/fs.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later #include diff --git a/src/qt_common/util/fs.h b/src/qt_common/util/fs.h index 41669e8019..ef56a361dd 100644 --- a/src/qt_common/util/fs.h +++ b/src/qt_common/util/fs.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later #include "common/common_types.h" diff --git a/src/qt_common/util/game.cpp b/src/qt_common/util/game.cpp index 34fbd04ff9..3e07b9d6b5 100644 --- a/src/qt_common/util/game.cpp +++ b/src/qt_common/util/game.cpp @@ -403,29 +403,29 @@ void ResetMetadata(bool show_message) { inline constexpr bool CreateShortcutMessagesGUI(ShortcutMessages imsg, const QString& game_title) { int result = 0; - QMessageBox::StandardButtons buttons; + using namespace QtCommon::Frontend; + int buttons; + switch (imsg) { case ShortcutMessages::Fullscreen: - buttons = QMessageBox::Yes | QMessageBox::No; - result - = QtCommon::Frontend::Information(tr("Create Shortcut"), - tr("Do you want to launch the game in fullscreen?"), - buttons); - return result == QMessageBox::Yes; + buttons = Yes | No; + result = QtCommon::Frontend::Information( + tr("Create Shortcut"), tr("Do you want to launch the game in fullscreen?"), buttons); + return result == Yes; case ShortcutMessages::Success: - QtCommon::Frontend::Information(tr("Shortcut Created"), - tr("Successfully created a shortcut to %1").arg(game_title)); + QtCommon::Frontend::Information( + tr("Shortcut Created"), tr("Successfully created a shortcut to %1").arg(game_title)); return false; case ShortcutMessages::Volatile: - buttons = QMessageBox::StandardButton::Ok | QMessageBox::StandardButton::Cancel; + buttons = Ok | Cancel; result = QtCommon::Frontend::Warning( tr("Shortcut may be Volatile!"), tr("This will create a shortcut to the current AppImage. This may " "not work well if you update. Continue?"), buttons); - return result == QMessageBox::Ok; + return result == Ok; default: - buttons = QMessageBox::Ok; + buttons = Ok; QtCommon::Frontend::Critical(tr("Failed to Create Shortcut"), tr("Failed to create a shortcut to %1").arg(game_title), buttons); diff --git a/src/qt_common/util/game.h b/src/qt_common/util/game.h index 2a7c77ef2d..16a1b7340a 100644 --- a/src/qt_common/util/game.h +++ b/src/qt_common/util/game.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later #ifndef QT_GAME_UTIL_H diff --git a/src/qt_common/util/meta.cpp b/src/qt_common/util/meta.cpp index 4c7f1409e3..ead090b7a4 100644 --- a/src/qt_common/util/meta.cpp +++ b/src/qt_common/util/meta.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later #include "qt_common/util/meta.h" diff --git a/src/qt_common/util/meta.h b/src/qt_common/util/meta.h index c0a37db983..53501591e0 100644 --- a/src/qt_common/util/meta.h +++ b/src/qt_common/util/meta.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later #ifndef QT_META_H diff --git a/src/qt_common/util/path.cpp b/src/qt_common/util/path.cpp index 73689058c6..a99d3b03ea 100644 --- a/src/qt_common/util/path.cpp +++ b/src/qt_common/util/path.cpp @@ -1,28 +1,24 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later -#include "qt_common/util/path.h" #include #include #include +#include #include "common/fs/fs.h" #include "common/fs/path_util.h" #include "qt_common/abstract/frontend.h" -#include +#include "qt_common/util/path.h" namespace QtCommon::Path { -bool OpenShaderCache(u64 program_id, QObject *parent) -{ +bool OpenShaderCache(u64 program_id, QObject* parent) { const auto shader_cache_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::ShaderDir); const auto shader_cache_folder_path{shader_cache_dir / fmt::format("{:016x}", program_id)}; if (!Common::FS::CreateDirs(shader_cache_folder_path)) { - QtCommon::Frontend::ShowMessage(QMessageBox::Warning, - tr("Error Opening Shader Cache"), - tr("Failed to create or open shader cache for this title, " - "ensure your app data directory has write permissions."), - QMessageBox::Ok, - parent); + QtCommon::Frontend::Warning(tr("Error Opening Shader Cache"), + tr("Failed to create or open shader cache for this title, " + "ensure your app data directory has write permissions.")); } const auto shader_path_string{Common::FS::PathToUTF8String(shader_cache_folder_path)}; @@ -30,4 +26,4 @@ bool OpenShaderCache(u64 program_id, QObject *parent) return QDesktopServices::openUrl(QUrl::fromLocalFile(qt_shader_cache_path)); } -} +} // namespace QtCommon::Path diff --git a/src/qt_common/util/path.h b/src/qt_common/util/path.h index 855b06caa9..7a1d74b354 100644 --- a/src/qt_common/util/path.h +++ b/src/qt_common/util/path.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later #ifndef QT_PATH_UTIL_H diff --git a/src/qt_common/util/rom.cpp b/src/qt_common/util/rom.cpp index 1617548db3..ef4d4e1ae4 100644 --- a/src/qt_common/util/rom.cpp +++ b/src/qt_common/util/rom.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later #include "qt_common/util/rom.h" diff --git a/src/qt_common/util/rom.h b/src/qt_common/util/rom.h index f76b09753d..5dd372e450 100644 --- a/src/qt_common/util/rom.h +++ b/src/qt_common/util/rom.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later #ifndef QT_ROM_UTIL_H diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt index 99fb2fec15..982c0eb196 100644 --- a/src/yuzu/CMakeLists.txt +++ b/src/yuzu/CMakeLists.txt @@ -244,6 +244,7 @@ add_executable(yuzu configuration/addon/mod_select_dialog.h configuration/addon/mod_select_dialog.cpp configuration/addon/mod_select_dialog.ui render/performance_overlay.h render/performance_overlay.cpp render/performance_overlay.ui + libqt_common.h libqt_common.cpp ) set_target_properties(yuzu PROPERTIES OUTPUT_NAME "eden") diff --git a/src/yuzu/libqt_common.cpp b/src/yuzu/libqt_common.cpp new file mode 100644 index 0000000000..6da75033af --- /dev/null +++ b/src/yuzu/libqt_common.cpp @@ -0,0 +1,119 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + +#include +#include +#include +#include +#include + +#include "libqt_common.h" +#include "qt_common/abstract/frontend.h" +#include "qt_common/abstract/progress.h" +#include "qt_common/qt_common.h" + +namespace QtCommon::Frontend { + +StandardButton ShowMessage( + Icon icon, const QString &title, const QString &text, StandardButtons buttons, QObject *parent) +{ + QMessageBox *box = new QMessageBox(QMessageBox::Icon(int(icon)), title, text, QMessageBox::StandardButtons(int(buttons)), (QWidget *) parent); + return StandardButton(box->exec()); +} + +WidgetsProgressDialog::WidgetsProgressDialog(const QString& labelText, + const QString& cancelButtonText, int minimum, + int maximum, QWidget* parent, Qt::WindowFlags f) + : QtProgressDialog(labelText, cancelButtonText, minimum, maximum, parent, f), + m_dialog(new QProgressDialog(labelText, cancelButtonText, minimum, maximum, parent, f)) { + m_dialog->setAutoClose(false); + m_dialog->setAutoReset(false); + m_dialog->setMinimumDuration(100); + m_dialog->setWindowModality(Qt::WindowModal); +} + +bool WidgetsProgressDialog::wasCanceled() const { + return m_dialog->wasCanceled(); +} + +void WidgetsProgressDialog::setWindowModality(Qt::WindowModality modality) { + m_dialog->setWindowModality(modality); +} + +void WidgetsProgressDialog::setMinimumDuration(int durationMs) { + m_dialog->setMinimumDuration(durationMs); +} + +void WidgetsProgressDialog::setAutoClose(bool autoClose) { + m_dialog->setAutoClose(autoClose); +} + +void WidgetsProgressDialog::setAutoReset(bool autoReset) { + m_dialog->setAutoReset(autoReset); +} + +void WidgetsProgressDialog::setTitle(QString title) { + m_dialog->setWindowTitle(title); +} + +void WidgetsProgressDialog::setLabelText(QString text) { + m_dialog->setLabelText(text); +} + +void WidgetsProgressDialog::setMinimum(int min) { + m_dialog->setMinimum(min); +} + +void WidgetsProgressDialog::setMaximum(int max) { + m_dialog->setMaximum(max); +} + +void WidgetsProgressDialog::setValue(int value) { + m_dialog->setValue(value); +} + +bool WidgetsProgressDialog::close() { + m_dialog->close(); + return true; +} + +void WidgetsProgressDialog::show() { + m_dialog->show(); +} + +std::unique_ptr newProgressDialog(const QString& labelText, const QString& cancelButtonText, + int minimum, int maximum, Qt::WindowFlags f) { + return std::make_unique(labelText, cancelButtonText, minimum, maximum, + (QWidget*)rootObject, f); +} + +QtProgressDialog* newProgressDialogPtr(const QString& labelText, const QString& cancelButtonText, + int minimum, int maximum, + Qt::WindowFlags f) { + return new WidgetsProgressDialog(labelText, cancelButtonText, minimum, maximum, + (QWidget*)rootObject, f); +} + +int Choice(const QString& title, const QString& caption, const QStringList& options) { + QMessageBox box(rootObject); + box.setText(caption); + box.setWindowTitle(title); + + for (const QString& opt : options) { + box.addButton(opt, QMessageBox::AcceptRole); + } + + box.addButton(QMessageBox::Cancel); + + box.exec(); + auto button = box.clickedButton(); + return options.indexOf(button->text()); +} + +const QString GetTextInput(const QString& title, const QString& caption, + const QString& defaultText) { + return QInputDialog::getText(rootObject, title, caption, QLineEdit::Normal, defaultText); +} + + +} // namespace QtCommon::Frontend diff --git a/src/yuzu/libqt_common.h b/src/yuzu/libqt_common.h new file mode 100644 index 0000000000..9fb0add154 --- /dev/null +++ b/src/yuzu/libqt_common.h @@ -0,0 +1,37 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + +#pragma once + +#include "qt_common/abstract/progress.h" + +#include + +namespace QtCommon::Frontend { + +class WidgetsProgressDialog : public QtProgressDialog { + Q_OBJECT +public: + WidgetsProgressDialog(const QString& labelText, const QString& cancelButtonText, int minimum, + int maximum, QWidget* parent = nullptr, Qt::WindowFlags f = {}); + + bool wasCanceled() const override; + void setWindowModality(Qt::WindowModality modality) override; + void setMinimumDuration(int durationMs) override; + void setAutoClose(bool autoClose) override; + void setAutoReset(bool autoReset) override; + +public slots: + void setTitle(QString title) override; + void setLabelText(QString text) override; + void setMinimum(int min) override; + void setMaximum(int max) override; + void setValue(int value) override; + bool close() override; + void show() override; + +private: + QProgressDialog* m_dialog; +}; + +} diff --git a/src/yuzu/main_window.cpp b/src/yuzu/main_window.cpp index 399b3bd976..aaac46bffb 100644 --- a/src/yuzu/main_window.cpp +++ b/src/yuzu/main_window.cpp @@ -1929,9 +1929,8 @@ bool MainWindow::LoadROM(const QString& filename, Service::AM::FrontendAppletPar /** firmware check */ - if (!QtCommon::Content::CheckGameFirmware(params.program_id, this)) { + if (!QtCommon::Content::CheckGameFirmware(params.program_id)) return false; - } /** Exec */ const Core::SystemResultStatus result{ diff --git a/tools/clang-format.sh b/tools/clang-format.sh index 2deb0a3ade..e2857d9723 100755 --- a/tools/clang-format.sh +++ b/tools/clang-format.sh @@ -1,6 +1,7 @@ #! /bin/sh -# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project # SPDX-License-Identifier: GPL-3.0-or-later -exec find src -iname "*.h" -o -iname "*.cpp" | xargs clang-format -i -style=file:src/.clang-format +# Only clang-formats Qt stuff. :) +find src/qt_common src/yuzu -iname "*.h" -o -iname "*.cpp" | xargs clang-format -i -style=file:src/.clang-format From 769edbfea31e0300137bb1214dd2822fceaa09ab Mon Sep 17 00:00:00 2001 From: crueter Date: Tue, 10 Mar 2026 05:44:51 +0100 Subject: [PATCH 17/25] [video_core] Revert "Simplify TextureCache GC and remove redundant code" (#3652) (#3704) regr. Steam Deck Please, for the love of God, stop saying "YOLO good to merge" after testers report performance regressions (and promptly get brushed to the side). Seriously, what the hell? This reverts commit f8ea09fa0f06572b32df1ead2fb38a64098e312e. Signed-off-by: crueter Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3704 Reviewed-by: Lizzie Reviewed-by: DraVee --- src/video_core/texture_cache/texture_cache.h | 143 ++++++++++++++++-- .../texture_cache/texture_cache_base.h | 1 + 2 files changed, 131 insertions(+), 13 deletions(-) diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index e32f21d2ce..71210ffe6e 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h @@ -70,10 +70,14 @@ TextureCache

::TextureCache(Runtime& runtime_, Tegra::MaxwellDeviceMemoryManag (std::max)((std::min)(device_local_memory - min_vacancy_critical, min_spacing_critical), DEFAULT_CRITICAL_MEMORY)); minimum_memory = static_cast((device_local_memory - mem_threshold) / 2); + + lowmemorydevice = false; } else { expected_memory = DEFAULT_EXPECTED_MEMORY + 512_MiB; critical_memory = DEFAULT_CRITICAL_MEMORY + 1_GiB; minimum_memory = 0; + + lowmemorydevice = true; } const bool gpu_unswizzle_enabled = Settings::values.gpu_unswizzle_enabled.GetValue(); @@ -118,46 +122,102 @@ void TextureCache

::RunGarbageCollector() { bool aggressive_mode = false; u64 ticks_to_destroy = 0; size_t num_iterations = 0; + const auto Configure = [&](bool allow_aggressive) { high_priority_mode = total_used_memory >= expected_memory; aggressive_mode = allow_aggressive && total_used_memory >= critical_memory; ticks_to_destroy = aggressive_mode ? 10ULL : high_priority_mode ? 25ULL : 50ULL; num_iterations = aggressive_mode ? 40 : (high_priority_mode ? 20 : 10); }; - const auto Cleanup = [this, &num_iterations, &high_priority_mode, &aggressive_mode](ImageId image_id) { + + const auto Cleanup = [this, &num_iterations, &high_priority_mode, + &aggressive_mode](ImageId image_id) { if (num_iterations == 0) { return true; } --num_iterations; auto& image = slot_images[image_id]; - if (True(image.flags & ImageFlagBits::IsDecoding)) { + + // Never delete recently allocated sparse textures (within 3 frames) + const bool is_recently_allocated = image.allocation_tick >= frame_tick - 3; + if (is_recently_allocated && image.info.is_sparse) { return false; } - const bool must_download = image.IsSafeDownload() && False(image.flags & ImageFlagBits::BadOverlap); - if (must_download && !image.info.is_sparse) { + + if (True(image.flags & ImageFlagBits::IsDecoding)) { + // This image is still being decoded, deleting it will invalidate the slot + // used by the async decoder thread. + return false; + } + + // Prioritize large sparse textures for cleanup + const bool is_large_sparse = lowmemorydevice && + image.info.is_sparse && + image.guest_size_bytes >= 256_MiB; + + if (!aggressive_mode && !is_large_sparse && + True(image.flags & ImageFlagBits::CostlyLoad)) { + return false; + } + + const bool must_download = + image.IsSafeDownload() && False(image.flags & ImageFlagBits::BadOverlap); + if (!high_priority_mode && !is_large_sparse && must_download) { + return false; + } + + if (must_download && !is_large_sparse) { auto map = runtime.DownloadStagingBuffer(image.unswizzled_size_bytes); const auto copies = FixSmallVectorADL(FullDownloadCopies(image.info)); image.DownloadMemory(map, copies); runtime.Finish(); - SwizzleImage(*gpu_memory, image.gpu_addr, image.info, copies, map.mapped_span, swizzle_data_buffer); + SwizzleImage(*gpu_memory, image.gpu_addr, image.info, copies, map.mapped_span, + swizzle_data_buffer); } + if (True(image.flags & ImageFlagBits::Tracked)) { UntrackImage(image, image_id); } UnregisterImage(image_id); - DeleteImage(image_id, (frame_tick - image.scale_tick) > 5 || aggressive_mode); - if (aggressive_mode && total_used_memory < critical_memory) { - num_iterations >>= 2; - aggressive_mode = false; - } - if (high_priority_mode && total_used_memory < expected_memory) { - num_iterations >>= 1; - high_priority_mode = false; + DeleteImage(image_id, image.scale_tick > frame_tick + 5); + + if (total_used_memory < critical_memory) { + if (aggressive_mode) { + // Sink the aggresiveness. + num_iterations >>= 2; + aggressive_mode = false; + return false; + } + if (high_priority_mode && total_used_memory < expected_memory) { + num_iterations >>= 1; + high_priority_mode = false; + } } return false; }; + + // Aggressively clear massive sparse textures + if (total_used_memory >= expected_memory) { + lru_cache.ForEachItemBelow(frame_tick, [&](ImageId image_id) { + auto& image = slot_images[image_id]; + // Only target sparse textures that are old enough + if (lowmemorydevice && + image.info.is_sparse && + image.guest_size_bytes >= 256_MiB && + image.allocation_tick < frame_tick - 3) { + LOG_DEBUG(HW_GPU, "GC targeting old sparse texture at 0x{:X} ({} MiB, age: {} frames)", + image.gpu_addr, image.guest_size_bytes / (1024 * 1024), + frame_tick - image.allocation_tick); + return Cleanup(image_id); + } + return false; + }); + } + Configure(false); lru_cache.ForEachItemBelow(frame_tick - ticks_to_destroy, Cleanup); + + // If pressure is still too high, prune aggressively. if (total_used_memory >= critical_memory) { Configure(true); lru_cache.ForEachItemBelow(frame_tick - ticks_to_destroy, Cleanup); @@ -1136,6 +1196,9 @@ void TextureCache

::RefreshContents(Image& image, ImageId image_id) { } image.flags &= ~ImageFlagBits::CpuModified; + if( lowmemorydevice && image.info.format == PixelFormat::BC1_RGBA_UNORM && MapSizeBytes(image) >= 256_MiB ) { + return; + } TrackImage(image, image_id); @@ -1556,6 +1619,39 @@ ImageId TextureCache

::InsertImage(const ImageInfo& info, GPUVAddr gpu_addr, } } ASSERT_MSG(cpu_addr, "Tried to insert an image to an invalid gpu_addr=0x{:x}", gpu_addr); + + // For large sparse textures, aggressively clean up old allocations at same address + if (lowmemorydevice && info.is_sparse && CalculateGuestSizeInBytes(info) >= 256_MiB) { + const auto alloc_it = image_allocs_table.find(gpu_addr); + if (alloc_it != image_allocs_table.end()) { + const ImageAllocId alloc_id = alloc_it->second; + auto& alloc_images = slot_image_allocs[alloc_id].images; + + // Collect old images at this address that were created more than 2 frames ago + boost::container::small_vector to_delete; + for (ImageId old_image_id : alloc_images) { + Image& old_image = slot_images[old_image_id]; + if (old_image.info.is_sparse && + old_image.gpu_addr == gpu_addr && + old_image.allocation_tick < frame_tick - 2) { // Try not to delete fresh textures + to_delete.push_back(old_image_id); + } + } + + // Delete old images immediately + for (ImageId old_id : to_delete) { + Image& old_image = slot_images[old_id]; + LOG_DEBUG(HW_GPU, "Immediately deleting old sparse texture at 0x{:X} ({} MiB)", + gpu_addr, old_image.guest_size_bytes / (1024 * 1024)); + if (True(old_image.flags & ImageFlagBits::Tracked)) { + UntrackImage(old_image, old_id); + } + UnregisterImage(old_id); + DeleteImage(old_id, true); + } + } + } + const ImageId image_id = JoinImages(info, gpu_addr, *cpu_addr); const Image& image = slot_images[image_id]; // Using "image.gpu_addr" instead of "gpu_addr" is important because it might be different @@ -1571,6 +1667,27 @@ template ImageId TextureCache

::JoinImages(const ImageInfo& info, GPUVAddr gpu_addr, DAddr cpu_addr) { ImageInfo new_info = info; const size_t size_bytes = CalculateGuestSizeInBytes(new_info); + + // Proactive cleanup for large sparse texture allocations + if (lowmemorydevice && new_info.is_sparse && size_bytes >= 256_MiB) { + const u64 estimated_alloc_size = size_bytes; + + if (total_used_memory + estimated_alloc_size >= critical_memory) { + LOG_DEBUG(HW_GPU, "Large sparse texture allocation ({} MiB) - running aggressive GC. " + "Current memory: {} MiB, Critical: {} MiB", + size_bytes / (1024 * 1024), + total_used_memory / (1024 * 1024), + critical_memory / (1024 * 1024)); + RunGarbageCollector(); + + // If still over threshold after GC, try one more aggressive pass + if (total_used_memory + estimated_alloc_size >= critical_memory) { + LOG_DEBUG(HW_GPU, "Still critically low on memory, running second GC pass"); + RunGarbageCollector(); + } + } + } + const bool broken_views = runtime.HasBrokenTextureViewFormats(); const bool native_bgr = runtime.HasNativeBgr(); join_overlap_ids.clear(); diff --git a/src/video_core/texture_cache/texture_cache_base.h b/src/video_core/texture_cache/texture_cache_base.h index 47f52c5c99..4b4061f21d 100644 --- a/src/video_core/texture_cache/texture_cache_base.h +++ b/src/video_core/texture_cache/texture_cache_base.h @@ -478,6 +478,7 @@ private: u64 minimum_memory; u64 expected_memory; u64 critical_memory; + bool lowmemorydevice = false; size_t gpu_unswizzle_maxsize = 0; size_t swizzle_chunk_size = 0; u32 swizzle_slices_per_batch = 0; From 8678cb06eb28a6416a4c6911458fc04113ad8ed4 Mon Sep 17 00:00:00 2001 From: crueter Date: Tue, 10 Mar 2026 06:51:08 +0100 Subject: [PATCH 18/25] [meta] clang-format literally all of the Qt code (#3706) I'm tired of dealing with this tbh Signed-off-by: crueter Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3706 Reviewed-by: Lizzie --- src/qt_common/abstract/frontend.cpp | 6 +- src/qt_common/abstract/progress.cpp | 11 +- src/qt_common/config/shared_translation.cpp | 502 +++++++----------- src/qt_common/config/shared_translation.h | 25 +- src/qt_common/config/uisettings.h | 12 +- src/qt_common/discord/discord_impl.cpp | 8 +- src/qt_common/gamemode.cpp | 4 +- src/qt_common/gui_settings.cpp | 5 +- src/qt_common/qt_common.cpp | 39 +- src/qt_common/qt_common.h | 14 +- src/qt_common/qt_string_lookup.h | 20 +- src/qt_common/util/applet.h | 4 +- src/qt_common/util/compress.cpp | 106 ++-- src/qt_common/util/compress.h | 110 ++-- src/qt_common/util/content.cpp | 188 +++---- src/qt_common/util/content.h | 24 +- src/qt_common/util/fs.cpp | 25 +- src/qt_common/util/fs.h | 10 +- src/qt_common/util/game.cpp | 168 +++--- src/qt_common/util/game.h | 32 +- src/qt_common/util/meta.cpp | 7 +- src/qt_common/util/meta.h | 2 +- src/qt_common/util/mod.cpp | 3 +- src/qt_common/util/mod.h | 6 +- src/qt_common/util/path.h | 6 +- src/qt_common/util/rom.cpp | 11 +- src/qt_common/util/rom.h | 10 +- src/yuzu/about_dialog.cpp | 23 +- src/yuzu/applets/qt_controller.cpp | 21 +- src/yuzu/applets/qt_software_keyboard.cpp | 30 +- src/yuzu/applets/qt_web_browser.cpp | 26 +- src/yuzu/applets/qt_web_browser.h | 3 +- src/yuzu/bootmanager.cpp | 37 +- .../configuration/addon/mod_select_dialog.cpp | 3 +- .../configuration/addon/mod_select_dialog.h | 5 +- src/yuzu/configuration/configure_audio.cpp | 17 +- src/yuzu/configuration/configure_cpu.cpp | 14 +- src/yuzu/configuration/configure_cpu.h | 4 +- src/yuzu/configuration/configure_debug.cpp | 11 +- src/yuzu/configuration/configure_dialog.cpp | 35 +- src/yuzu/configuration/configure_dialog.h | 2 +- .../configuration/configure_filesystem.cpp | 30 +- src/yuzu/configuration/configure_general.cpp | 2 +- src/yuzu/configuration/configure_graphics.cpp | 93 ++-- .../configure_graphics_advanced.cpp | 4 +- .../configure_graphics_extensions.cpp | 18 +- src/yuzu/configuration/configure_hotkeys.cpp | 4 +- src/yuzu/configuration/configure_input.cpp | 15 +- .../configure_input_advanced.cpp | 2 +- .../configuration/configure_input_per_game.h | 4 +- .../configuration/configure_input_player.cpp | 20 +- .../configure_input_player_widget.cpp | 5 +- src/yuzu/configuration/configure_network.cpp | 5 +- src/yuzu/configuration/configure_per_game.cpp | 10 +- src/yuzu/configuration/configure_per_game.h | 4 +- .../configure_per_game_addons.cpp | 44 +- .../configuration/configure_per_game_addons.h | 7 +- .../configure_profile_manager.cpp | 52 +- .../configuration/configure_profile_manager.h | 5 +- src/yuzu/configuration/configure_ringcon.cpp | 4 +- src/yuzu/configuration/configure_system.cpp | 7 +- src/yuzu/configuration/configure_tas.cpp | 5 +- .../configure_touch_from_button.cpp | 7 +- src/yuzu/configuration/configure_ui.cpp | 2 +- src/yuzu/configuration/configure_web.cpp | 22 +- src/yuzu/configuration/configure_web.h | 6 +- src/yuzu/configuration/shared_widget.cpp | 51 +- src/yuzu/configuration/shared_widget.h | 4 +- .../configuration/system/new_user_dialog.h | 16 +- src/yuzu/data_dialog.cpp | 47 +- src/yuzu/data_dialog.h | 15 +- src/yuzu/debugger/console.cpp | 4 +- src/yuzu/deps_dialog.cpp | 42 +- src/yuzu/deps_dialog.h | 31 +- src/yuzu/game/game_card.cpp | 4 +- src/yuzu/game/game_card.h | 8 +- src/yuzu/game/game_list.cpp | 25 +- src/yuzu/game/game_list.h | 10 +- src/yuzu/game/game_list_p.h | 20 +- src/yuzu/game/game_list_worker.cpp | 69 +-- src/yuzu/game/game_list_worker.h | 2 +- src/yuzu/hotkeys.cpp | 4 +- src/yuzu/install_dialog.cpp | 4 +- src/yuzu/libqt_common.cpp | 20 +- src/yuzu/libqt_common.h | 2 +- src/yuzu/loading_screen.cpp | 2 +- src/yuzu/main.cpp | 9 +- src/yuzu/main_window.cpp | 490 +++++++++-------- src/yuzu/main_window.h | 33 +- src/yuzu/migration_dialog.cpp | 28 +- src/yuzu/migration_dialog.h | 25 +- src/yuzu/migration_worker.cpp | 26 +- src/yuzu/migration_worker.h | 26 +- src/yuzu/multiplayer/chat_room.h | 2 +- src/yuzu/multiplayer/direct_connect.cpp | 4 +- src/yuzu/multiplayer/host_room.cpp | 5 +- src/yuzu/multiplayer/lobby.cpp | 5 +- src/yuzu/multiplayer/state.cpp | 2 +- src/yuzu/render/performance_overlay.h | 16 +- src/yuzu/ryujinx_dialog.cpp | 38 +- src/yuzu/ryujinx_dialog.h | 12 +- src/yuzu/set_play_time_dialog.cpp | 13 +- src/yuzu/set_play_time_dialog.h | 4 +- src/yuzu/user_data_migration.cpp | 86 ++- src/yuzu/user_data_migration.h | 5 +- src/yuzu/util/util.cpp | 12 +- src/yuzu/vk_device_info.cpp | 7 +- 107 files changed, 1457 insertions(+), 1737 deletions(-) diff --git a/src/qt_common/abstract/frontend.cpp b/src/qt_common/abstract/frontend.cpp index 05eb550095..de362b253f 100644 --- a/src/qt_common/abstract/frontend.cpp +++ b/src/qt_common/abstract/frontend.cpp @@ -6,17 +6,17 @@ namespace QtCommon::Frontend { const QString GetOpenFileName(const QString& title, const QString& dir, const QString& filter, - QString* selectedFilter) { + QString* selectedFilter) { return QFileDialog::getOpenFileName(rootObject, title, dir, filter, selectedFilter); } const QStringList GetOpenFileNames(const QString& title, const QString& dir, const QString& filter, - QString* selectedFilter) { + QString* selectedFilter) { return QFileDialog::getOpenFileNames(rootObject, title, dir, filter, selectedFilter); } const QString GetSaveFileName(const QString& title, const QString& dir, const QString& filter, - QString* selectedFilter) { + QString* selectedFilter) { return QFileDialog::getSaveFileName(rootObject, title, dir, filter, selectedFilter); } diff --git a/src/qt_common/abstract/progress.cpp b/src/qt_common/abstract/progress.cpp index c9185a756d..2141e41d44 100644 --- a/src/qt_common/abstract/progress.cpp +++ b/src/qt_common/abstract/progress.cpp @@ -5,13 +5,8 @@ namespace QtCommon::Frontend { -QtProgressDialog::QtProgressDialog(const QString&, - const QString&, - int, - int, - QObject* parent, +QtProgressDialog::QtProgressDialog(const QString&, const QString&, int, int, QObject* parent, Qt::WindowFlags) - : QObject(parent) -{} + : QObject(parent) {} -} +} // namespace QtCommon::Frontend diff --git a/src/qt_common/config/shared_translation.cpp b/src/qt_common/config/shared_translation.cpp index d1ed32134c..a0c4779b73 100644 --- a/src/qt_common/config/shared_translation.cpp +++ b/src/qt_common/config/shared_translation.cpp @@ -9,24 +9,23 @@ #include "shared_translation.h" +#include +#include +#include #include #include "common/settings.h" #include "common/settings_enums.h" #include "common/settings_setting.h" #include "common/time_zone.h" #include "qt_common/config/uisettings.h" -#include -#include -#include namespace ConfigurationShared { -std::unique_ptr InitializeTranslations(QObject* parent) -{ +std::unique_ptr InitializeTranslations(QObject* parent) { std::unique_ptr translations = std::make_unique(); const auto& tr = [parent](const char* text) -> QString { return parent->tr(text); }; -#define INSERT(SETTINGS, ID, NAME, TOOLTIP) \ +#define INSERT(SETTINGS, ID, NAME, TOOLTIP) \ translations->insert(std::pair{SETTINGS::values.ID.Id(), std::pair{(NAME), (TOOLTIP)}}) // A setting can be ignored by giving it a blank name @@ -47,10 +46,9 @@ std::unique_ptr InitializeTranslations(QObject* parent) INSERT(Settings, login_share_applet_mode, tr("Login share"), QString()); INSERT(Settings, wifi_web_auth_applet_mode, tr("Wifi web auth"), QString()); INSERT(Settings, my_page_applet_mode, tr("My page"), QString()); - INSERT(Settings, - enable_overlay, - tr("Enable Overlay Applet"), - tr("Enables Horizon\'s built-in overlay applet. Press and hold the home button for 1 second to show it.")); + INSERT(Settings, enable_overlay, tr("Enable Overlay Applet"), + tr("Enables Horizon\'s built-in overlay applet. Press and hold the home button for 1 " + "second to show it.")); // Audio INSERT(Settings, sink_id, tr("Output Engine:"), QString()); @@ -62,23 +60,16 @@ std::unique_ptr InitializeTranslations(QObject* parent) INSERT(UISettings, mute_when_in_background, tr("Mute audio when in background"), QString()); // Core - INSERT( - Settings, - use_multi_core, - tr("Multicore CPU Emulation"), - tr("This option increases CPU emulation thread use from 1 to the maximum of 4.\n" - "This is mainly a debug option and shouldn't be disabled.")); - INSERT( - Settings, - memory_layout_mode, - tr("Memory Layout"), - tr("Increases the amount of emulated RAM.\nDoesn't affect performance/stability but may allow HD texture " - "mods to load.")); + INSERT(Settings, use_multi_core, tr("Multicore CPU Emulation"), + tr("This option increases CPU emulation thread use from 1 to the maximum of 4.\n" + "This is mainly a debug option and shouldn't be disabled.")); + INSERT(Settings, memory_layout_mode, tr("Memory Layout"), + tr("Increases the amount of emulated RAM.\nDoesn't affect performance/stability but may " + "allow HD texture " + "mods to load.")); INSERT(Settings, use_speed_limit, QString(), QString()); INSERT(Settings, current_speed_mode, QString(), QString()); - INSERT(Settings, - speed_limit, - tr("Limit Speed Percent"), + INSERT(Settings, speed_limit, tr("Limit Speed Percent"), tr("Controls the game's maximum rendering speed, but it's up to each game if it runs " "faster or not.\n200% for a 30 FPS game is 60 FPS, and for a " "60 FPS game it will be 120 FPS.\nDisabling it means unlocking the framerate to the " @@ -91,171 +82,128 @@ std::unique_ptr InitializeTranslations(QObject* parent) tr("When the Slow Speed hotkey is pressed, the speed will be limited to this " "percentage.")); - INSERT(Settings, - sync_core_speed, - tr("Synchronize Core Speed"), + INSERT(Settings, sync_core_speed, tr("Synchronize Core Speed"), tr("Synchronizes CPU core speed with the game's maximum rendering speed to boost FPS " "without affecting game speed (animations, physics, etc.).\n" "Can help reduce stuttering at lower framerates.")); // Cpu - INSERT(Settings, - cpu_accuracy, - tr("Accuracy:"), + INSERT(Settings, cpu_accuracy, tr("Accuracy:"), tr("Change the accuracy of the emulated CPU (for debugging only).")); INSERT(Settings, cpu_backend, tr("Backend:"), QString()); - INSERT(Settings, - fast_cpu_time, - tr("CPU Overclock"), - tr("Overclocks the emulated CPU to remove some FPS limiters. Weaker CPUs may see reduced performance, " - "and certain games may behave improperly.\nUse Boost (1700MHz) to run at the Switch's highest native " + INSERT(Settings, fast_cpu_time, tr("CPU Overclock"), + tr("Overclocks the emulated CPU to remove some FPS limiters. Weaker CPUs may see " + "reduced performance, " + "and certain games may behave improperly.\nUse Boost (1700MHz) to run at the " + "Switch's highest native " "clock, or Fast (2000MHz) to run at 2x clock.")); INSERT(Settings, use_custom_cpu_ticks, QString(), QString()); - INSERT(Settings, - cpu_ticks, - tr("Custom CPU Ticks"), + INSERT(Settings, cpu_ticks, tr("Custom CPU Ticks"), tr("Set a custom value of CPU ticks. Higher values can increase performance, but may " "cause deadlocks. A range of 77-21000 is recommended.")); INSERT(Settings, cpu_backend, tr("Backend:"), QString()); - INSERT(Settings, vtable_bouncing, - tr("Virtual Table Bouncing"), - tr("Bounces (by emulating a 0-valued return) any functions that triggers a prefetch abort")); + INSERT(Settings, vtable_bouncing, tr("Virtual Table Bouncing"), + tr("Bounces (by emulating a 0-valued return) any functions that triggers a prefetch " + "abort")); // Cpu Debug // Cpu Unsafe - INSERT(Settings, cpuopt_unsafe_host_mmu, tr("Enable Host MMU Emulation (fastmem)"), - tr("This optimization speeds up memory accesses by the guest program.\nEnabling it causes guest memory reads/writes to be done directly into memory and make use of Host's MMU.\nDisabling this forces all memory accesses to use Software MMU Emulation.")); INSERT( - Settings, - cpuopt_unsafe_unfuse_fma, + Settings, cpuopt_unsafe_host_mmu, tr("Enable Host MMU Emulation (fastmem)"), + tr("This optimization speeds up memory accesses by the guest program.\nEnabling it causes " + "guest memory reads/writes to be done directly into memory and make use of Host's " + "MMU.\nDisabling this forces all memory accesses to use Software MMU Emulation.")); + INSERT( + Settings, cpuopt_unsafe_unfuse_fma, tr("Unfuse FMA (improve performance on CPUs without FMA)"), tr("This option improves speed by reducing accuracy of fused-multiply-add instructions on " "CPUs without native FMA support.")); INSERT( - Settings, - cpuopt_unsafe_reduce_fp_error, - tr("Faster FRSQRTE and FRECPE"), + Settings, cpuopt_unsafe_reduce_fp_error, tr("Faster FRSQRTE and FRECPE"), tr("This option improves the speed of some approximate floating-point functions by using " "less accurate native approximations.")); - INSERT(Settings, - cpuopt_unsafe_ignore_standard_fpcr, + INSERT(Settings, cpuopt_unsafe_ignore_standard_fpcr, tr("Faster ASIMD instructions (32 bits only)"), tr("This option improves the speed of 32 bits ASIMD floating-point functions by running " "with incorrect rounding modes.")); - INSERT(Settings, - cpuopt_unsafe_inaccurate_nan, - tr("Inaccurate NaN handling"), + INSERT(Settings, cpuopt_unsafe_inaccurate_nan, tr("Inaccurate NaN handling"), tr("This option improves speed by removing NaN checking.\nPlease note this also reduces " "accuracy of certain floating-point instructions.")); - INSERT(Settings, - cpuopt_unsafe_fastmem_check, - tr("Disable address space checks"), + INSERT(Settings, cpuopt_unsafe_fastmem_check, tr("Disable address space checks"), tr("This option improves speed by eliminating a safety check before every memory " "operation.\nDisabling it may allow arbitrary code execution.")); INSERT( - Settings, - cpuopt_unsafe_ignore_global_monitor, - tr("Ignore global monitor"), + Settings, cpuopt_unsafe_ignore_global_monitor, tr("Ignore global monitor"), tr("This option improves speed by relying only on the semantics of cmpxchg to ensure " "safety of exclusive access instructions.\nPlease note this may result in deadlocks and " "other race conditions.")); // Renderer - INSERT( - Settings, - renderer_backend, - tr("API:"), - tr("Changes the output graphics API.\nVulkan is recommended.")); - INSERT(Settings, - vulkan_device, - tr("Device:"), + INSERT(Settings, renderer_backend, tr("API:"), + tr("Changes the output graphics API.\nVulkan is recommended.")); + INSERT(Settings, vulkan_device, tr("Device:"), tr("This setting selects the GPU to use (Vulkan only).")); - INSERT(Settings, - resolution_setup, - tr("Resolution:"), + INSERT(Settings, resolution_setup, tr("Resolution:"), tr("Forces to render at a different resolution.\n" "Higher resolutions require more VRAM and bandwidth.\n" "Options lower than 1X can cause artifacts.")); INSERT(Settings, scaling_filter, tr("Window Adapting Filter:"), QString()); - INSERT(Settings, - fsr_sharpening_slider, - tr("FSR Sharpness:"), + INSERT(Settings, fsr_sharpening_slider, tr("FSR Sharpness:"), tr("Determines how sharpened the image will look using FSR's dynamic contrast.")); - INSERT(Settings, - anti_aliasing, - tr("Anti-Aliasing Method:"), + INSERT(Settings, anti_aliasing, tr("Anti-Aliasing Method:"), tr("The anti-aliasing method to use.\nSMAA offers the best quality.\nFXAA " "can produce a more stable picture in lower resolutions.")); - INSERT(Settings, - fullscreen_mode, - tr("Fullscreen Mode:"), + INSERT(Settings, fullscreen_mode, tr("Fullscreen Mode:"), tr("The method used to render the window in fullscreen.\nBorderless offers the best " "compatibility with the on-screen keyboard that some games request for " "input.\nExclusive " "fullscreen may offer better performance and better Freesync/Gsync support.")); - INSERT(Settings, - aspect_ratio, - tr("Aspect Ratio:"), + INSERT(Settings, aspect_ratio, tr("Aspect Ratio:"), tr("Stretches the renderer to fit the specified aspect ratio.\nMost games only support " "16:9, so modifications are required to get other ratios.\nAlso controls the " "aspect ratio of captured screenshots.")); - INSERT(Settings, - use_disk_shader_cache, - tr("Use persistent pipeline cache"), + INSERT(Settings, use_disk_shader_cache, tr("Use persistent pipeline cache"), tr("Allows saving shaders to storage for faster loading on following game " "boots.\nDisabling it is only intended for debugging.")); - INSERT(Settings, - optimize_spirv_output, - tr("Optimize SPIRV output"), + INSERT(Settings, optimize_spirv_output, tr("Optimize SPIRV output"), tr("Runs an additional optimization pass over generated SPIRV shaders.\n" "Will increase time required for shader compilation.\nMay slightly improve " "performance.\nThis feature is experimental.")); - INSERT(Settings, - nvdec_emulation, - tr("NVDEC emulation:"), + INSERT(Settings, nvdec_emulation, tr("NVDEC emulation:"), tr("Specifies how videos should be decoded.\nIt can either use the CPU or the GPU for " "decoding, or perform no decoding at all (black screen on videos).\n" "In most cases, GPU decoding provides the best performance.")); - INSERT(Settings, - accelerate_astc, - tr("ASTC Decoding Method:"), + INSERT(Settings, accelerate_astc, tr("ASTC Decoding Method:"), tr("This option controls how ASTC textures should be decoded.\n" "CPU: Use the CPU for decoding.\n" "GPU: Use the GPU's compute shaders to decode ASTC textures (recommended).\n" "CPU Asynchronously: Use the CPU to decode ASTC textures on demand. Eliminates" "ASTC decoding\nstuttering but may present artifacts.")); - INSERT( - Settings, - astc_recompression, - tr("ASTC Recompression Method:"), - tr("Most GPUs lack support for ASTC textures and must decompress to an" - "intermediate format: RGBA8.\n" - "BC1/BC3: The intermediate format will be recompressed to BC1 or BC3 format,\n" - " saving VRAM but degrading image quality.")); + INSERT(Settings, astc_recompression, tr("ASTC Recompression Method:"), + tr("Most GPUs lack support for ASTC textures and must decompress to an" + "intermediate format: RGBA8.\n" + "BC1/BC3: The intermediate format will be recompressed to BC1 or BC3 format,\n" + " saving VRAM but degrading image quality.")); INSERT(Settings, frame_pacing_mode, tr("Frame Pacing Mode (Vulkan only)"), - tr("Controls how the emulator manages frame pacing to reduce stuttering and make the frame rate smoother and more consistent.")); - INSERT(Settings, - vram_usage_mode, - tr("VRAM Usage Mode:"), - tr("Selects whether the emulator should prefer to conserve memory or make maximum usage of available video memory for performance.\nAggressive mode may impact performance of other applications such as recording software.")); - INSERT(Settings, - skip_cpu_inner_invalidation, - tr("Skip CPU Inner Invalidation"), + tr("Controls how the emulator manages frame pacing to reduce stuttering and make the " + "frame rate smoother and more consistent.")); + INSERT(Settings, vram_usage_mode, tr("VRAM Usage Mode:"), + tr("Selects whether the emulator should prefer to conserve memory or make maximum usage " + "of available video memory for performance.\nAggressive mode may impact performance " + "of other applications such as recording software.")); + INSERT(Settings, skip_cpu_inner_invalidation, tr("Skip CPU Inner Invalidation"), tr("Skips certain cache invalidations during memory updates, reducing CPU usage and " "improving latency. This may cause soft-crashes.")); - INSERT( - Settings, - vsync_mode, - tr("VSync Mode:"), - tr("FIFO (VSync) does not drop frames or exhibit tearing but is limited by the screen " - "refresh rate.\nFIFO Relaxed allows tearing as it recovers from a slow down.\n" - "Mailbox can have lower latency than FIFO and does not tear but may drop " - "frames.\nImmediate (no synchronization) presents whatever is available and can " - "exhibit tearing.")); + INSERT(Settings, vsync_mode, tr("VSync Mode:"), + tr("FIFO (VSync) does not drop frames or exhibit tearing but is limited by the screen " + "refresh rate.\nFIFO Relaxed allows tearing as it recovers from a slow down.\n" + "Mailbox can have lower latency than FIFO and does not tear but may drop " + "frames.\nImmediate (no synchronization) presents whatever is available and can " + "exhibit tearing.")); INSERT(Settings, bg_red, QString(), QString()); INSERT(Settings, bg_green, QString(), QString()); INSERT(Settings, bg_blue, QString(), QString()); @@ -264,103 +212,74 @@ std::unique_ptr InitializeTranslations(QObject* parent) INSERT(Settings, use_asynchronous_gpu_emulation, QString(), QString()); INSERT(Settings, sync_memory_operations, tr("Sync Memory Operations"), - tr("Ensures data consistency between compute and memory operations.\nThis option fixes issues in games, but may degrade performance.\nUnreal Engine 4 games often see the most significant changes thereof.")); - INSERT(Settings, - async_presentation, - tr("Enable asynchronous presentation (Vulkan only)"), + tr("Ensures data consistency between compute and memory operations.\nThis option fixes " + "issues in games, but may degrade performance.\nUnreal Engine 4 games often see the " + "most significant changes thereof.")); + INSERT(Settings, async_presentation, tr("Enable asynchronous presentation (Vulkan only)"), tr("Slightly improves performance by moving presentation to a separate CPU thread.")); INSERT( - Settings, - renderer_force_max_clock, - tr("Force maximum clocks (Vulkan only)"), + Settings, renderer_force_max_clock, tr("Force maximum clocks (Vulkan only)"), tr("Runs work in the background while waiting for graphics commands to keep the GPU from " "lowering its clock speed.")); - INSERT(Settings, - max_anisotropy, - tr("Anisotropic Filtering:"), - tr("Controls the quality of texture rendering at oblique angles.\nSafe to set at 16x on most GPUs.")); - INSERT(Settings, - gpu_accuracy, - tr("GPU Mode:"), - tr("Controls the GPU emulation mode.\nMost games render fine with Fast or Balanced modes, but Accurate is still " + INSERT(Settings, max_anisotropy, tr("Anisotropic Filtering:"), + tr("Controls the quality of texture rendering at oblique angles.\nSafe to set at 16x on " + "most GPUs.")); + INSERT(Settings, gpu_accuracy, tr("GPU Mode:"), + tr("Controls the GPU emulation mode.\nMost games render fine with Fast or Balanced " + "modes, but Accurate is still " "required for some.\nParticles tend to only render correctly with Accurate mode.")); - INSERT(Settings, - dma_accuracy, - tr("DMA Accuracy:"), - tr("Controls the DMA precision accuracy. Safe precision fixes issues in some games but may degrade performance.")); - INSERT(Settings, - use_asynchronous_shaders, - tr("Enable asynchronous shader compilation"), + INSERT(Settings, dma_accuracy, tr("DMA Accuracy:"), + tr("Controls the DMA precision accuracy. Safe precision fixes issues in some games but " + "may degrade performance.")); + INSERT(Settings, use_asynchronous_shaders, tr("Enable asynchronous shader compilation"), tr("May reduce shader stutter.")); - INSERT(Settings, - fast_gpu_time, - tr("Fast GPU Time"), + INSERT(Settings, fast_gpu_time, tr("Fast GPU Time"), tr("Overclocks the emulated GPU to increase dynamic resolution and render " "distance.\nUse 256 for maximal performance and 512 for maximal graphics fidelity.")); - INSERT(Settings, - gpu_unswizzle_enabled, - tr("GPU Unswizzle"), + INSERT(Settings, gpu_unswizzle_enabled, tr("GPU Unswizzle"), tr("Accelerates BCn 3D texture decoding using GPU compute.\n" "Disable if experiencing crashes or graphical glitches.")); - INSERT(Settings, - gpu_unswizzle_texture_size, - tr("GPU Unswizzle Max Texture Size"), + INSERT(Settings, gpu_unswizzle_texture_size, tr("GPU Unswizzle Max Texture Size"), tr("Sets the maximum size (MiB) for GPU-based texture unswizzling.\n" - "While the GPU is faster for medium and large textures, the CPU may be more efficient for very small ones.\n" + "While the GPU is faster for medium and large textures, the CPU may be more " + "efficient for very small ones.\n" "Adjust this to find the balance between GPU acceleration and CPU overhead.")); - INSERT(Settings, - gpu_unswizzle_stream_size, - tr("GPU Unswizzle Stream Size"), + INSERT(Settings, gpu_unswizzle_stream_size, tr("GPU Unswizzle Stream Size"), tr("Sets the maximum amount of texture data (in MiB) processed per frame.\n" - "Higher values can reduce stutter during texture loading but may impact frame consistency.")); - INSERT(Settings, - gpu_unswizzle_chunk_size, - tr("GPU Unswizzle Chunk Size"), + "Higher values can reduce stutter during texture loading but may impact frame " + "consistency.")); + INSERT(Settings, gpu_unswizzle_chunk_size, tr("GPU Unswizzle Chunk Size"), tr("Determines the number of depth slices processed in a single dispatch.\n" - "Increasing this can improve throughput on high-end GPUs but may cause TDR or driver timeouts on weaker hardware.")); + "Increasing this can improve throughput on high-end GPUs but may cause TDR or driver " + "timeouts on weaker hardware.")); - INSERT(Settings, - use_vulkan_driver_pipeline_cache, - tr("Use Vulkan pipeline cache"), + INSERT(Settings, use_vulkan_driver_pipeline_cache, tr("Use Vulkan pipeline cache"), tr("Enables GPU vendor-specific pipeline cache.\nThis option can improve shader loading " "time significantly in cases where the Vulkan driver does not store pipeline cache " "files internally.")); + INSERT(Settings, enable_compute_pipelines, tr("Enable Compute Pipelines (Intel Vulkan Only)"), + tr("Required by some games.\nThis setting only exists for Intel " + "proprietary drivers and may crash if enabled.\nCompute pipelines are always enabled " + "on all other drivers.")); INSERT( - Settings, - enable_compute_pipelines, - tr("Enable Compute Pipelines (Intel Vulkan Only)"), - tr("Required by some games.\nThis setting only exists for Intel " - "proprietary drivers and may crash if enabled.\nCompute pipelines are always enabled " - "on all other drivers.")); - INSERT( - Settings, - use_reactive_flushing, - tr("Enable Reactive Flushing"), + Settings, use_reactive_flushing, tr("Enable Reactive Flushing"), tr("Uses reactive flushing instead of predictive flushing, allowing more accurate memory " "syncing.")); - INSERT(Settings, - use_video_framerate, - tr("Sync to framerate of video playback"), + INSERT(Settings, use_video_framerate, tr("Sync to framerate of video playback"), tr("Run the game at normal speed during video playback, even when the framerate is " "unlocked.")); - INSERT(Settings, - barrier_feedback_loops, - tr("Barrier feedback loops"), + INSERT(Settings, barrier_feedback_loops, tr("Barrier feedback loops"), tr("Improves rendering of transparency effects in specific games.")); - INSERT(Settings, - enable_buffer_history, - tr("Enable buffer history"), - tr("Enables access to previous buffer states.\nThis option may improve rendering quality and performance consistency in some games.")); - INSERT(Settings, - fix_bloom_effects, - tr("Fix bloom effects"), - tr("Removes bloom in Burnout.")); + INSERT(Settings, enable_buffer_history, tr("Enable buffer history"), + tr("Enables access to previous buffer states.\nThis option may improve rendering " + "quality and performance consistency in some games.")); + INSERT(Settings, fix_bloom_effects, tr("Fix bloom effects"), tr("Removes bloom in Burnout.")); - INSERT(Settings, - rescale_hack, - tr("Enable Legacy Rescale Pass"), - tr("May fix rescale issues in some games by relying on behavior from the previous implementation.\n" - "Legacy behavior workaround that fixes line artifacts on AMD and Intel GPUs, and grey texture flicker on Nvidia GPUs in Luigis Mansion 3.")); + INSERT(Settings, rescale_hack, tr("Enable Legacy Rescale Pass"), + tr("May fix rescale issues in some games by relying on behavior from the previous " + "implementation.\n" + "Legacy behavior workaround that fixes line artifacts on AMD and Intel GPUs, and " + "grey texture flicker on Nvidia GPUs in Luigis Mansion 3.")); // Renderer (Extensions) INSERT(Settings, dyna_state, tr("Extended Dynamic State"), @@ -368,59 +287,42 @@ std::unique_ptr InitializeTranslations(QObject* parent) "Higher states allow for more features and can increase performance, but may cause " "additional graphical issues.")); - INSERT(Settings, - vertex_input_dynamic_state, - tr("Vertex Input Dynamic State"), + INSERT(Settings, vertex_input_dynamic_state, tr("Vertex Input Dynamic State"), tr("Enables vertex input dynamic state feature for better quality and performance.")); - INSERT(Settings, - provoking_vertex, - tr("Provoking Vertex"), + INSERT(Settings, provoking_vertex, tr("Provoking Vertex"), tr("Improves lighting and vertex handling in some games.\n" "Only Vulkan 1.0+ devices support this extension.")); - INSERT(Settings, - descriptor_indexing, - tr("Descriptor Indexing"), + INSERT(Settings, descriptor_indexing, tr("Descriptor Indexing"), tr("Improves texture & buffer handling and the Maxwell translation layer.\n" "Some Vulkan 1.1+ and all 1.2+ devices support this extension.")); - INSERT(Settings, - sample_shading, - tr("Sample Shading"), - tr("Allows the fragment shader to execute per sample in a multi-sampled fragment " - "instead of once per fragment. Improves graphics quality at the cost of performance.\n" - "Higher values improve quality but degrade performance.")); + INSERT( + Settings, sample_shading, tr("Sample Shading"), + tr("Allows the fragment shader to execute per sample in a multi-sampled fragment " + "instead of once per fragment. Improves graphics quality at the cost of performance.\n" + "Higher values improve quality but degrade performance.")); // Renderer (Debug) // System - INSERT(Settings, - rng_seed, - tr("RNG Seed"), + INSERT(Settings, rng_seed, tr("RNG Seed"), tr("Controls the seed of the random number generator.\nMainly used for speedrunning.")); INSERT(Settings, rng_seed_enabled, QString(), QString()); INSERT(Settings, device_name, tr("Device Name"), tr("The name of the console.")); - INSERT(Settings, - custom_rtc, - tr("Custom RTC Date:"), + INSERT(Settings, custom_rtc, tr("Custom RTC Date:"), tr("This option allows to change the clock of the console.\n" "Can be used to manipulate time in games.")); INSERT(Settings, custom_rtc_enabled, QString(), QString()); - INSERT(Settings, - custom_rtc_offset, - QStringLiteral(" "), + INSERT(Settings, custom_rtc_offset, QStringLiteral(" "), tr("The number of seconds from the current unix time")); - INSERT(Settings, - language_index, - tr("Language:"), + INSERT(Settings, language_index, tr("Language:"), tr("This option can be overridden when region setting is auto-select")); INSERT(Settings, region_index, tr("Region:"), tr("The region of the console.")); INSERT(Settings, time_zone_index, tr("Time Zone:"), tr("The time zone of the console.")); INSERT(Settings, sound_index, tr("Sound Output Mode:"), QString()); - INSERT(Settings, - use_docked_mode, - tr("Console Mode:"), + INSERT(Settings, use_docked_mode, tr("Console Mode:"), tr("Selects if the console is in Docked or Handheld mode.\nGames will change " "their resolution, details and supported controllers and depending on this setting.\n" "Setting to Handheld can help improve performance for low end systems.")); @@ -444,31 +346,19 @@ std::unique_ptr InitializeTranslations(QObject* parent) // Ui // Ui General - INSERT(UISettings, - select_user_on_boot, - tr("Prompt for user profile on boot"), + INSERT(UISettings, select_user_on_boot, tr("Prompt for user profile on boot"), tr("Useful if multiple people use the same PC.")); - INSERT(UISettings, - pause_when_in_background, - tr("Pause when not in focus"), + INSERT(UISettings, pause_when_in_background, tr("Pause when not in focus"), tr("Pauses emulation when focusing on other windows.")); - INSERT(UISettings, - confirm_before_stopping, - tr("Confirm before stopping emulation"), + INSERT(UISettings, confirm_before_stopping, tr("Confirm before stopping emulation"), tr("Overrides prompts asking to confirm stopping the emulation.\nEnabling " "it bypasses such prompts and directly exits the emulation.")); - INSERT(UISettings, - hide_mouse, - tr("Hide mouse on inactivity"), + INSERT(UISettings, hide_mouse, tr("Hide mouse on inactivity"), tr("Hides the mouse after 2.5s of inactivity.")); - INSERT(UISettings, - controller_applet_disabled, - tr("Disable controller applet"), + INSERT(UISettings, controller_applet_disabled, tr("Disable controller applet"), tr("Forcibly disables the use of the controller applet in emulated programs.\n" - "When a program attempts to open the controller applet, it is immediately closed.")); - INSERT(UISettings, - check_for_updates, - tr("Check for updates"), + "When a program attempts to open the controller applet, it is immediately closed.")); + INSERT(UISettings, check_for_updates, tr("Check for updates"), tr("Whether or not to check for updates upon startup.")); // Linux @@ -489,9 +379,9 @@ std::unique_ptr InitializeTranslations(QObject* parent) return translations; } -std::unique_ptr ComboboxEnumeration(QObject* parent) -{ - std::unique_ptr translations = std::make_unique(); +std::unique_ptr ComboboxEnumeration(QObject* parent) { + std::unique_ptr translations = + std::make_unique(); const auto& tr = [&](const char* text, const char* context = "") { return parent->tr(text, context); }; @@ -537,15 +427,15 @@ std::unique_ptr ComboboxEnumeration(QObject* parent) PAIR(VramUsageMode, Conservative, tr("Conservative")), PAIR(VramUsageMode, Aggressive, tr("Aggressive")), }}); - translations->insert({Settings::EnumMetadata::Index(), { - PAIR(RendererBackend, Vulkan, tr("Vulkan")), + translations->insert( + {Settings::EnumMetadata::Index(), + {PAIR(RendererBackend, Vulkan, tr("Vulkan")), #ifdef HAS_OPENGL - PAIR(RendererBackend, OpenGL_GLSL, tr("OpenGL GLSL")), - PAIR(RendererBackend, OpenGL_GLASM, tr("OpenGL GLASM (Assembly Shaders, NVIDIA Only)")), - PAIR(RendererBackend, OpenGL_SPIRV, tr("OpenGL SPIR-V (Experimental, AMD/Mesa Only)")), + PAIR(RendererBackend, OpenGL_GLSL, tr("OpenGL GLSL")), + PAIR(RendererBackend, OpenGL_GLASM, tr("OpenGL GLASM (Assembly Shaders, NVIDIA Only)")), + PAIR(RendererBackend, OpenGL_SPIRV, tr("OpenGL SPIR-V (Experimental, AMD/Mesa Only)")), #endif - PAIR(RendererBackend, Null, tr("Null")) - }}); + PAIR(RendererBackend, Null, tr("Null"))}}); translations->insert({Settings::EnumMetadata::Index(), { PAIR(GpuAccuracy, Low, tr("Fast")), @@ -679,58 +569,58 @@ std::unique_ptr ComboboxEnumeration(QObject* parent) translations->insert( {Settings::EnumMetadata::Index(), { - {static_cast(Settings::TimeZone::Auto), - tr("Auto (%1)", "Auto select time zone") - .arg(QString::fromStdString( - Settings::GetTimeZoneString(Settings::TimeZone::Auto)))}, - {static_cast(Settings::TimeZone::Default), - tr("Default (%1)", "Default time zone") - .arg(QString::fromStdString(Common::TimeZone::GetDefaultTimeZone()))}, - PAIR(TimeZone, Cet, tr("CET")), - PAIR(TimeZone, Cst6Cdt, tr("CST6CDT")), - PAIR(TimeZone, Cuba, tr("Cuba")), - PAIR(TimeZone, Eet, tr("EET")), - PAIR(TimeZone, Egypt, tr("Egypt")), - PAIR(TimeZone, Eire, tr("Eire")), - PAIR(TimeZone, Est, tr("EST")), - PAIR(TimeZone, Est5Edt, tr("EST5EDT")), - PAIR(TimeZone, Gb, tr("GB")), - PAIR(TimeZone, GbEire, tr("GB-Eire")), - PAIR(TimeZone, Gmt, tr("GMT")), - PAIR(TimeZone, GmtPlusZero, tr("GMT+0")), - PAIR(TimeZone, GmtMinusZero, tr("GMT-0")), - PAIR(TimeZone, GmtZero, tr("GMT0")), - PAIR(TimeZone, Greenwich, tr("Greenwich")), - PAIR(TimeZone, Hongkong, tr("Hongkong")), - PAIR(TimeZone, Hst, tr("HST")), - PAIR(TimeZone, Iceland, tr("Iceland")), - PAIR(TimeZone, Iran, tr("Iran")), - PAIR(TimeZone, Israel, tr("Israel")), - PAIR(TimeZone, Jamaica, tr("Jamaica")), - PAIR(TimeZone, Japan, tr("Japan")), - PAIR(TimeZone, Kwajalein, tr("Kwajalein")), - PAIR(TimeZone, Libya, tr("Libya")), - PAIR(TimeZone, Met, tr("MET")), - PAIR(TimeZone, Mst, tr("MST")), - PAIR(TimeZone, Mst7Mdt, tr("MST7MDT")), - PAIR(TimeZone, Navajo, tr("Navajo")), - PAIR(TimeZone, Nz, tr("NZ")), - PAIR(TimeZone, NzChat, tr("NZ-CHAT")), - PAIR(TimeZone, Poland, tr("Poland")), - PAIR(TimeZone, Portugal, tr("Portugal")), - PAIR(TimeZone, Prc, tr("PRC")), - PAIR(TimeZone, Pst8Pdt, tr("PST8PDT")), - PAIR(TimeZone, Roc, tr("ROC")), - PAIR(TimeZone, Rok, tr("ROK")), - PAIR(TimeZone, Singapore, tr("Singapore")), - PAIR(TimeZone, Turkey, tr("Turkey")), - PAIR(TimeZone, Uct, tr("UCT")), - PAIR(TimeZone, Universal, tr("Universal")), - PAIR(TimeZone, Utc, tr("UTC")), - PAIR(TimeZone, WSu, tr("W-SU")), - PAIR(TimeZone, Wet, tr("WET")), - PAIR(TimeZone, Zulu, tr("Zulu")), - }}); + {static_cast(Settings::TimeZone::Auto), + tr("Auto (%1)", "Auto select time zone") + .arg(QString::fromStdString( + Settings::GetTimeZoneString(Settings::TimeZone::Auto)))}, + {static_cast(Settings::TimeZone::Default), + tr("Default (%1)", "Default time zone") + .arg(QString::fromStdString(Common::TimeZone::GetDefaultTimeZone()))}, + PAIR(TimeZone, Cet, tr("CET")), + PAIR(TimeZone, Cst6Cdt, tr("CST6CDT")), + PAIR(TimeZone, Cuba, tr("Cuba")), + PAIR(TimeZone, Eet, tr("EET")), + PAIR(TimeZone, Egypt, tr("Egypt")), + PAIR(TimeZone, Eire, tr("Eire")), + PAIR(TimeZone, Est, tr("EST")), + PAIR(TimeZone, Est5Edt, tr("EST5EDT")), + PAIR(TimeZone, Gb, tr("GB")), + PAIR(TimeZone, GbEire, tr("GB-Eire")), + PAIR(TimeZone, Gmt, tr("GMT")), + PAIR(TimeZone, GmtPlusZero, tr("GMT+0")), + PAIR(TimeZone, GmtMinusZero, tr("GMT-0")), + PAIR(TimeZone, GmtZero, tr("GMT0")), + PAIR(TimeZone, Greenwich, tr("Greenwich")), + PAIR(TimeZone, Hongkong, tr("Hongkong")), + PAIR(TimeZone, Hst, tr("HST")), + PAIR(TimeZone, Iceland, tr("Iceland")), + PAIR(TimeZone, Iran, tr("Iran")), + PAIR(TimeZone, Israel, tr("Israel")), + PAIR(TimeZone, Jamaica, tr("Jamaica")), + PAIR(TimeZone, Japan, tr("Japan")), + PAIR(TimeZone, Kwajalein, tr("Kwajalein")), + PAIR(TimeZone, Libya, tr("Libya")), + PAIR(TimeZone, Met, tr("MET")), + PAIR(TimeZone, Mst, tr("MST")), + PAIR(TimeZone, Mst7Mdt, tr("MST7MDT")), + PAIR(TimeZone, Navajo, tr("Navajo")), + PAIR(TimeZone, Nz, tr("NZ")), + PAIR(TimeZone, NzChat, tr("NZ-CHAT")), + PAIR(TimeZone, Poland, tr("Poland")), + PAIR(TimeZone, Portugal, tr("Portugal")), + PAIR(TimeZone, Prc, tr("PRC")), + PAIR(TimeZone, Pst8Pdt, tr("PST8PDT")), + PAIR(TimeZone, Roc, tr("ROC")), + PAIR(TimeZone, Rok, tr("ROK")), + PAIR(TimeZone, Singapore, tr("Singapore")), + PAIR(TimeZone, Turkey, tr("Turkey")), + PAIR(TimeZone, Uct, tr("UCT")), + PAIR(TimeZone, Universal, tr("Universal")), + PAIR(TimeZone, Utc, tr("UTC")), + PAIR(TimeZone, WSu, tr("W-SU")), + PAIR(TimeZone, Wet, tr("WET")), + PAIR(TimeZone, Zulu, tr("Zulu")), + }}); translations->insert({Settings::EnumMetadata::Index(), { PAIR(AudioMode, Mono, tr("Mono")), @@ -803,9 +693,9 @@ std::unique_ptr ComboboxEnumeration(QObject* parent) }}); translations->insert({Settings::EnumMetadata::Index(), - { - PAIR(GameListMode, TreeView, tr("Tree View")), - PAIR(GameListMode, GridView, tr("Grid View")), + { + PAIR(GameListMode, TreeView, tr("Tree View")), + PAIR(GameListMode, GridView, tr("Grid View")), }}); #undef PAIR diff --git a/src/qt_common/config/shared_translation.h b/src/qt_common/config/shared_translation.h index 6fbeb1df6e..6529c7bf40 100644 --- a/src/qt_common/config/shared_translation.h +++ b/src/qt_common/config/shared_translation.h @@ -13,8 +13,8 @@ #include #include #include -#include #include +#include #include "common/common_types.h" #include "common/settings_enums.h" @@ -23,7 +23,7 @@ using TranslationMap = std::map>; using ComboboxTranslations = std::vector>; using ComboboxTranslationMap = std::map; -std::unique_ptr InitializeTranslations(QObject *parent); +std::unique_ptr InitializeTranslations(QObject* parent); std::unique_ptr ComboboxEnumeration(QObject* parent); @@ -39,15 +39,15 @@ static const std::map scaling_filter_texts_map {Settings::ScalingFilter::Bilinear, QStringLiteral(QT_TRANSLATE_NOOP("MainWindow", "Bilinear"))}, {Settings::ScalingFilter::Bicubic, QStringLiteral(QT_TRANSLATE_NOOP("MainWindow", "Bicubic"))}, - {Settings::ScalingFilter::ZeroTangent, QStringLiteral(QT_TRANSLATE_NOOP("MainWindow", "Zero-Tangent"))}, + {Settings::ScalingFilter::ZeroTangent, + QStringLiteral(QT_TRANSLATE_NOOP("MainWindow", "Zero-Tangent"))}, {Settings::ScalingFilter::BSpline, QStringLiteral(QT_TRANSLATE_NOOP("MainWindow", "B-Spline"))}, - {Settings::ScalingFilter::Mitchell, QStringLiteral(QT_TRANSLATE_NOOP("MainWindow", "Mitchell"))}, - {Settings::ScalingFilter::Spline1, - QStringLiteral(QT_TRANSLATE_NOOP("MainWindow", "Spline-1"))}, + {Settings::ScalingFilter::Mitchell, + QStringLiteral(QT_TRANSLATE_NOOP("MainWindow", "Mitchell"))}, + {Settings::ScalingFilter::Spline1, QStringLiteral(QT_TRANSLATE_NOOP("MainWindow", "Spline-1"))}, {Settings::ScalingFilter::Gaussian, QStringLiteral(QT_TRANSLATE_NOOP("MainWindow", "Gaussian"))}, - {Settings::ScalingFilter::Lanczos, - QStringLiteral(QT_TRANSLATE_NOOP("MainWindow", "Lanczos"))}, + {Settings::ScalingFilter::Lanczos, QStringLiteral(QT_TRANSLATE_NOOP("MainWindow", "Lanczos"))}, {Settings::ScalingFilter::ScaleForce, QStringLiteral(QT_TRANSLATE_NOOP("MainWindow", "ScaleForce"))}, {Settings::ScalingFilter::Fsr, QStringLiteral(QT_TRANSLATE_NOOP("MainWindow", "FSR"))}, @@ -68,9 +68,12 @@ static const std::map gpu_accuracy_texts_map = { static const std::map renderer_backend_texts_map = { {Settings::RendererBackend::Vulkan, QStringLiteral(QT_TRANSLATE_NOOP("MainWindow", "Vulkan"))}, - {Settings::RendererBackend::OpenGL_GLSL, QStringLiteral(QT_TRANSLATE_NOOP("MainWindow", "OpenGL GLSL"))}, - {Settings::RendererBackend::OpenGL_SPIRV, QStringLiteral(QT_TRANSLATE_NOOP("MainWindow", "OpenGL SPIRV"))}, - {Settings::RendererBackend::OpenGL_GLASM, QStringLiteral(QT_TRANSLATE_NOOP("MainWindow", "OpenGL GLASM"))}, + {Settings::RendererBackend::OpenGL_GLSL, + QStringLiteral(QT_TRANSLATE_NOOP("MainWindow", "OpenGL GLSL"))}, + {Settings::RendererBackend::OpenGL_SPIRV, + QStringLiteral(QT_TRANSLATE_NOOP("MainWindow", "OpenGL SPIRV"))}, + {Settings::RendererBackend::OpenGL_GLASM, + QStringLiteral(QT_TRANSLATE_NOOP("MainWindow", "OpenGL GLASM"))}, {Settings::RendererBackend::Null, QStringLiteral(QT_TRANSLATE_NOOP("MainWindow", "Null"))}, }; diff --git a/src/qt_common/config/uisettings.h b/src/qt_common/config/uisettings.h index 49205c5b84..c2a14858dd 100644 --- a/src/qt_common/config/uisettings.h +++ b/src/qt_common/config/uisettings.h @@ -145,14 +145,15 @@ struct Values { // Linux/MinGW may support (requires libdl support) SwitchableSetting enable_gamemode{linkage, #ifndef _MSC_VER - true, + true, #else - false, + false, #endif - "enable_gamemode", Category::UiGeneral}; + "enable_gamemode", Category::UiGeneral}; #ifdef __unix__ SwitchableSetting gui_force_x11{linkage, false, "gui_force_x11", Category::UiGeneral}; - Setting gui_hide_backend_warning{linkage, false, "gui_hide_backend_warning", Category::UiGeneral}; + Setting gui_hide_backend_warning{linkage, false, "gui_hide_backend_warning", + Category::UiGeneral}; #endif // Discord RPC @@ -210,7 +211,8 @@ struct Values { Setting folder_icon_size{linkage, 48, "folder_icon_size", Category::UiGameList}; Setting row_1_text_id{linkage, 3, "row_1_text_id", Category::UiGameList}; Setting row_2_text_id{linkage, 2, "row_2_text_id", Category::UiGameList}; - Setting game_list_mode{linkage, Settings::GameListMode::TreeView, "game_list_mode", Category::UiGameList}; + Setting game_list_mode{linkage, Settings::GameListMode::TreeView, + "game_list_mode", Category::UiGameList}; Setting show_game_name{linkage, true, "show_game_name", Category::UiGameList}; std::atomic_bool is_game_list_reload_pending{false}; diff --git a/src/qt_common/discord/discord_impl.cpp b/src/qt_common/discord/discord_impl.cpp index 82f805b888..37b24cdd57 100644 --- a/src/qt_common/discord/discord_impl.cpp +++ b/src/qt_common/discord/discord_impl.cpp @@ -70,7 +70,9 @@ std::string DiscordImpl::GetGameString(const std::string& title) { } static constexpr char DEFAULT_DISCORD_TEXT[] = "Eden is an emulator for the Nintendo Switch"; -static constexpr char DEFAULT_DISCORD_IMAGE[] = "https://git.eden-emu.dev/eden-emu/eden/raw/branch/master/dist/qt_themes/default/icons/256x256/eden.png"; +static constexpr char DEFAULT_DISCORD_IMAGE[] = + "https://git.eden-emu.dev/eden-emu/eden/raw/branch/master/dist/qt_themes/default/icons/256x256/" + "eden.png"; void DiscordImpl::UpdateGameStatus(bool use_default) { const std::string url = use_default ? std::string{DEFAULT_DISCORD_IMAGE} : game_url; @@ -120,7 +122,9 @@ void DiscordImpl::Update() { return; } - s64 start_time = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); + s64 start_time = std::chrono::duration_cast( + std::chrono::system_clock::now().time_since_epoch()) + .count(); DiscordRichPresence presence{}; presence.largeImageKey = DEFAULT_DISCORD_IMAGE; presence.largeImageText = DEFAULT_DISCORD_TEXT; diff --git a/src/qt_common/gamemode.cpp b/src/qt_common/gamemode.cpp index dae6676fee..b6ce5c2ca8 100644 --- a/src/qt_common/gamemode.cpp +++ b/src/qt_common/gamemode.cpp @@ -9,9 +9,9 @@ #ifdef __unix__ #include #endif -#include "qt_common/gamemode.h" #include "common/logging/log.h" #include "qt_common/config/uisettings.h" +#include "qt_common/gamemode.h" namespace Common::FeralGamemode { @@ -49,4 +49,4 @@ void Stop() noexcept { } } -} // namespace Common::Linux +} // namespace Common::FeralGamemode diff --git a/src/qt_common/gui_settings.cpp b/src/qt_common/gui_settings.cpp index 4a1506261a..8b85fe43d6 100644 --- a/src/qt_common/gui_settings.cpp +++ b/src/qt_common/gui_settings.cpp @@ -1,16 +1,17 @@ // SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later -#include "gui_settings.h" #include "common/fs/fs.h" #include "common/fs/path_util.h" +#include "gui_settings.h" namespace FS = Common::FS; namespace GraphicsBackend { QString GuiConfigPath() { - return QString::fromStdString(FS::PathToUTF8String(FS::GetEdenPath(FS::EdenPath::ConfigDir) / "gui_config.ini")); + return QString::fromStdString( + FS::PathToUTF8String(FS::GetEdenPath(FS::EdenPath::ConfigDir) / "gui_config.ini")); } void SetForceX11(bool state) { diff --git a/src/qt_common/qt_common.cpp b/src/qt_common/qt_common.cpp index 8954bf09f2..e886593780 100644 --- a/src/qt_common/qt_common.cpp +++ b/src/qt_common/qt_common.cpp @@ -1,8 +1,8 @@ // SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later -#include "qt_common.h" #include "common/fs/fs.h" +#include "qt_common.h" #include #include @@ -28,8 +28,7 @@ std::unique_ptr system = nullptr; std::shared_ptr vfs = nullptr; std::unique_ptr provider = nullptr; -Core::Frontend::WindowSystemType GetWindowSystemType() -{ +Core::Frontend::WindowSystemType GetWindowSystemType() { // Determine WSI type based on Qt platform. QString platform_name = QGuiApplication::platformName(); if (platform_name == QStringLiteral("windows")) @@ -51,8 +50,7 @@ Core::Frontend::WindowSystemType GetWindowSystemType() return Core::Frontend::WindowSystemType::Windows; } // namespace Core::Frontend::WindowSystemType -Core::Frontend::EmuWindow::WindowSystemInfo GetWindowSystemInfo(QWindow* window) -{ +Core::Frontend::EmuWindow::WindowSystemInfo GetWindowSystemInfo(QWindow* window) { Core::Frontend::EmuWindow::WindowSystemInfo wsi; wsi.type = GetWindowSystemType(); @@ -60,8 +58,8 @@ Core::Frontend::EmuWindow::WindowSystemInfo GetWindowSystemInfo(QWindow* window) // Our Win32 Qt external doesn't have the private API. wsi.render_surface = reinterpret_cast(window->winId()); #elif defined(__APPLE__) - id layer = reinterpret_cast( - objc_msgSend)(reinterpret_cast(window->winId()), sel_registerName("layer")); + id layer = reinterpret_cast(objc_msgSend)( + reinterpret_cast(window->winId()), sel_registerName("layer")); // In Qt 6, the layer of the NSView might be a QContainerLayer. // MoltenVK needs a CAMetalLayer. We search for it in sublayers. @@ -69,15 +67,20 @@ Core::Frontend::EmuWindow::WindowSystemInfo GetWindowSystemInfo(QWindow* window) id metal_layer = nullptr; if (layer) { - if (reinterpret_cast(objc_msgSend)(layer, sel_registerName("isKindOfClass:"), metal_layer_class)) { + if (reinterpret_cast(objc_msgSend)( + layer, sel_registerName("isKindOfClass:"), metal_layer_class)) { metal_layer = layer; } else { - id sublayers = reinterpret_cast(objc_msgSend)(layer, sel_registerName("sublayers")); + id sublayers = reinterpret_cast(objc_msgSend)( + layer, sel_registerName("sublayers")); if (sublayers) { - unsigned long count = reinterpret_cast(objc_msgSend)(sublayers, sel_registerName("count")); + unsigned long count = reinterpret_cast(objc_msgSend)( + sublayers, sel_registerName("count")); for (unsigned long i = 0; i < count; ++i) { - id sublayer = reinterpret_cast(objc_msgSend)(sublayers, sel_registerName("objectAtIndex:"), i); - if (reinterpret_cast(objc_msgSend)(sublayer, sel_registerName("isKindOfClass:"), metal_layer_class)) { + id sublayer = reinterpret_cast(objc_msgSend)( + sublayers, sel_registerName("objectAtIndex:"), i); + if (reinterpret_cast(objc_msgSend)( + sublayer, sel_registerName("isKindOfClass:"), metal_layer_class)) { metal_layer = sublayer; break; } @@ -99,26 +102,22 @@ Core::Frontend::EmuWindow::WindowSystemInfo GetWindowSystemInfo(QWindow* window) return wsi; } -const QString tr(const char* str) -{ +const QString tr(const char* str) { return QGuiApplication::tr(str); } -const QString tr(const std::string& str) -{ +const QString tr(const std::string& str) { return QGuiApplication::tr(str.c_str()); } -void Init(QWidget* root) -{ +void Init(QWidget* root) { system = std::make_unique(); rootObject = root; vfs = std::make_unique(); provider = std::make_unique(); } -std::filesystem::path GetEdenCommand() -{ +std::filesystem::path GetEdenCommand() { std::filesystem::path command; // TODO: flatpak? diff --git a/src/qt_common/qt_common.h b/src/qt_common/qt_common.h index 9c7816a2ed..19c09ef5d0 100644 --- a/src/qt_common/qt_common.h +++ b/src/qt_common/qt_common.h @@ -4,17 +4,17 @@ #ifndef QT_COMMON_H #define QT_COMMON_H +#include #include +#include #include "core/core.h" #include "core/file_sys/registered_cache.h" -#include -#include #include namespace QtCommon { -extern QWidget *rootObject; +extern QWidget* rootObject; extern std::unique_ptr system; extern std::shared_ptr vfs; @@ -24,12 +24,12 @@ typedef std::function QtProgressCallback; Core::Frontend::WindowSystemType GetWindowSystemType(); -Core::Frontend::EmuWindow::WindowSystemInfo GetWindowSystemInfo(QWindow *window); +Core::Frontend::EmuWindow::WindowSystemInfo GetWindowSystemInfo(QWindow* window); -void Init(QWidget *root); +void Init(QWidget* root); -const QString tr(const char *str); -const QString tr(const std::string &str); +const QString tr(const char* str); +const QString tr(const std::string& str); std::filesystem::path GetEdenCommand(); } // namespace QtCommon diff --git a/src/qt_common/qt_string_lookup.h b/src/qt_common/qt_string_lookup.h index 5b7dbd5f0c..daefe20a1a 100644 --- a/src/qt_common/qt_string_lookup.h +++ b/src/qt_common/qt_string_lookup.h @@ -11,8 +11,9 @@ /// Small helper to look up enums. /// res = the result code /// base = the base matching value in the StringKey table -#define LOOKUP_ENUM(res, base) QtCommon::StringLookup::Lookup( \ - QtCommon::StringLookup::StringKey((int) res + (int) QtCommon::StringLookup::base)) +#define LOOKUP_ENUM(res, base) \ + QtCommon::StringLookup::Lookup( \ + QtCommon::StringLookup::StringKey((int)res + (int)QtCommon::StringLookup::base)) namespace QtCommon::StringLookup { @@ -111,16 +112,14 @@ static const constexpr frozen::map strings = { QT_TR_NOOP("Would you like to migrate your data for use in Eden?\n" "Select the corresponding button to migrate data from that emulator.\n" "This may take a while.")}, - {MigrationTooltipClearShader, - QT_TR_NOOP("Clearing shader cache is recommended for all " - "users.\nDo not uncheck unless you know what " - "you're doing.")}, + {MigrationTooltipClearShader, QT_TR_NOOP("Clearing shader cache is recommended for all " + "users.\nDo not uncheck unless you know what " + "you're doing.")}, {MigrationTooltipKeepOld, QT_TR_NOOP("Keeps the old data directory. This is recommended if you aren't\n" "space-constrained and want to keep separate data for the old emulator.")}, - {MigrationTooltipClearOld, - QT_TR_NOOP("Deletes the old data directory.\nThis is recommended on " - "devices with space constraints.")}, + {MigrationTooltipClearOld, QT_TR_NOOP("Deletes the old data directory.\nThis is recommended on " + "devices with space constraints.")}, {MigrationTooltipLinkOld, QT_TR_NOOP("Creates a filesystem link between the old directory and Eden directory.\n" "This is recommended if you want to share data between emulators.")}, @@ -135,8 +134,7 @@ static const constexpr frozen::map strings = { {RyujinxNoSaveId, QT_TR_NOOP("Title %1 not found in Ryujinx title database.")}, }; -static inline const QString Lookup(StringKey key) -{ +static inline const QString Lookup(StringKey key) { return QObject::tr(strings.at(key).data()); } diff --git a/src/qt_common/util/applet.h b/src/qt_common/util/applet.h index 34183274ff..f88aa066b2 100644 --- a/src/qt_common/util/applet.h +++ b/src/qt_common/util/applet.h @@ -5,7 +5,5 @@ #define QT_APPLET_UTIL_H // TODO -namespace QtCommon::Applets { - -} +namespace QtCommon::Applets {} #endif // QT_APPLET_UTIL_H diff --git a/src/qt_common/util/compress.cpp b/src/qt_common/util/compress.cpp index 527640cb98..c86e190bee 100644 --- a/src/qt_common/util/compress.cpp +++ b/src/qt_common/util/compress.cpp @@ -10,11 +10,8 @@ /** This is a modified version of JlCompress **/ namespace QtCommon::Compress { -bool compressDir(QString fileCompressed, - QString dir, - const Options &options, - QtCommon::QtProgressCallback callback) -{ +bool compressDir(QString fileCompressed, QString dir, const Options& options, + QtCommon::QtProgressCallback callback) { // Create zip QuaZip zip(fileCompressed); QDir().mkpath(QFileInfo(fileCompressed).absolutePath()); @@ -26,8 +23,7 @@ bool compressDir(QString fileCompressed, // See how big the overall fs structure is // good approx. of total progress // TODO(crueter): QDirListing impl... or fs::recursive_dir_iterator - QDirIterator iter(dir, - QDir::NoDotAndDotDot | QDir::Hidden | QDir::Files, + QDirIterator iter(dir, QDir::NoDotAndDotDot | QDir::Hidden | QDir::Files, QDirIterator::Subdirectories); std::size_t total = 0; @@ -54,14 +50,8 @@ bool compressDir(QString fileCompressed, return true; } -bool compressSubDir(QuaZip *zip, - QString dir, - QString origDir, - const Options &options, - std::size_t total, - std::size_t &progress, - QtProgressCallback callback) -{ +bool compressSubDir(QuaZip* zip, QString dir, QString origDir, const Options& options, + std::size_t total, std::size_t& progress, QtProgressCallback callback) { // zip: object where to add the file // dir: current real directory // origDir: original real directory @@ -69,22 +59,20 @@ bool compressSubDir(QuaZip *zip, if (!zip) return false; - if (zip->getMode() != QuaZip::mdCreate && zip->getMode() != QuaZip::mdAppend - && zip->getMode() != QuaZip::mdAdd) + if (zip->getMode() != QuaZip::mdCreate && zip->getMode() != QuaZip::mdAppend && + zip->getMode() != QuaZip::mdAdd) return false; QDir directory(dir); if (!directory.exists()) return false; - QDir origDirectory(origDir); if (dir != origDir) { QuaZipFile dirZipFile(zip); std::unique_ptr qzni; - qzni = std::make_unique(origDirectory.relativeFilePath(dir) - + QLatin1String("/"), - dir); + qzni = std::make_unique( + origDirectory.relativeFilePath(dir) + QLatin1String("/"), dir); if (!dirZipFile.open(QIODevice::WriteOnly, *qzni, nullptr, 0, 0)) { return false; } @@ -92,18 +80,18 @@ bool compressSubDir(QuaZip *zip, } // For each subfolder - QFileInfoList subfiles = directory.entryInfoList(QDir::AllDirs | QDir::NoDotAndDotDot - | QDir::Hidden | QDir::Dirs); - for (const auto &file : std::as_const(subfiles)) { - if (!compressSubDir( - zip, file.absoluteFilePath(), origDir, options, total, progress, callback)) { + QFileInfoList subfiles = + directory.entryInfoList(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::Hidden | QDir::Dirs); + for (const auto& file : std::as_const(subfiles)) { + if (!compressSubDir(zip, file.absoluteFilePath(), origDir, options, total, progress, + callback)) { return false; } } // For each file in directory QFileInfoList files = directory.entryInfoList(QDir::Hidden | QDir::Files); - for (const auto &file : std::as_const(files)) { + for (const auto& file : std::as_const(files)) { // If it's not a file or it's the compressed file being created if (!file.isFile() || file.absoluteFilePath() == zip->getZipName()) continue; @@ -112,7 +100,8 @@ bool compressSubDir(QuaZip *zip, QString filename = origDirectory.relativeFilePath(file.absoluteFilePath()); // Compress the file - if (!compressFile(zip, file.absoluteFilePath(), filename, options, total, progress, callback)) { + if (!compressFile(zip, file.absoluteFilePath(), filename, options, total, progress, + callback)) { return false; } } @@ -120,40 +109,26 @@ bool compressSubDir(QuaZip *zip, return true; } -bool compressFile(QuaZip *zip, - QString fileName, - QString fileDest, - const Options &options, - std::size_t total, - std::size_t &progress, - QtCommon::QtProgressCallback callback) -{ +bool compressFile(QuaZip* zip, QString fileName, QString fileDest, const Options& options, + std::size_t total, std::size_t& progress, QtCommon::QtProgressCallback callback) { // zip: object where to add the file // fileName: real file name // fileDest: file name inside the zip object if (!zip) return false; - if (zip->getMode() != QuaZip::mdCreate && zip->getMode() != QuaZip::mdAppend - && zip->getMode() != QuaZip::mdAdd) + if (zip->getMode() != QuaZip::mdCreate && zip->getMode() != QuaZip::mdAppend && + zip->getMode() != QuaZip::mdAdd) return false; QuaZipFile outFile(zip); if (options.getDateTime().isNull()) { - if (!outFile.open(QIODevice::WriteOnly, - QuaZipNewInfo(fileDest, fileName), - nullptr, - 0, - options.getCompressionMethod(), - options.getCompressionLevel())) + if (!outFile.open(QIODevice::WriteOnly, QuaZipNewInfo(fileDest, fileName), nullptr, 0, + options.getCompressionMethod(), options.getCompressionLevel())) return false; } else { - if (!outFile.open(QIODevice::WriteOnly, - QuaZipNewInfo(fileDest, fileName), - nullptr, - 0, - options.getCompressionMethod(), - options.getCompressionLevel())) + if (!outFile.open(QIODevice::WriteOnly, QuaZipNewInfo(fileDest, fileName), nullptr, 0, + options.getCompressionMethod(), options.getCompressionLevel())) return false; } @@ -171,7 +146,8 @@ bool compressFile(QuaZip *zip, if (!inFile.open(QIODevice::ReadOnly)) { return false; } - if (!copyData(inFile, outFile, total, progress, callback) || outFile.getZipError() != UNZ_OK) { + if (!copyData(inFile, outFile, total, progress, callback) || + outFile.getZipError() != UNZ_OK) { return false; } inFile.close(); @@ -181,12 +157,8 @@ bool compressFile(QuaZip *zip, return outFile.getZipError() == UNZ_OK; } -bool copyData(QIODevice &inFile, - QIODevice &outFile, - std::size_t total, - std::size_t &progress, - QtProgressCallback callback) -{ +bool copyData(QIODevice& inFile, QIODevice& outFile, std::size_t total, std::size_t& progress, + QtProgressCallback callback) { while (!inFile.atEnd()) { char buf[4096]; qint64 readLen = inFile.read(buf, 4096); @@ -203,15 +175,13 @@ bool copyData(QIODevice &inFile, return true; } -QStringList extractDir(QString fileCompressed, QString dir, QtCommon::QtProgressCallback callback) -{ +QStringList extractDir(QString fileCompressed, QString dir, QtCommon::QtProgressCallback callback) { // Open zip QuaZip zip(fileCompressed); return extractDir(zip, dir, callback); } -QStringList extractDir(QuaZip &zip, const QString &dir, QtCommon::QtProgressCallback callback) -{ +QStringList extractDir(QuaZip& zip, const QString& dir, QtCommon::QtProgressCallback callback) { if (!zip.open(QuaZip::mdUnzip)) { return QStringList(); } @@ -226,7 +196,7 @@ QStringList extractDir(QuaZip &zip, const QString &dir, QtCommon::QtProgressCall } std::size_t total = 0; - for (const QuaZipFileInfo64 &info : zip.getFileInfoList64()) { + for (const QuaZipFileInfo64& info : zip.getFileInfoList64()) { total += info.uncompressedSize; } @@ -256,13 +226,8 @@ QStringList extractDir(QuaZip &zip, const QString &dir, QtCommon::QtProgressCall return extracted; } -bool extractFile(QuaZip *zip, - QString fileName, - QString fileDest, - std::size_t total, - std::size_t &progress, - QtCommon::QtProgressCallback callback) -{ +bool extractFile(QuaZip* zip, QString fileName, QString fileDest, std::size_t total, + std::size_t& progress, QtCommon::QtProgressCallback callback) { // zip: object where to add the file // filename: real file name // fileincompress: file name of the compressed file @@ -334,8 +299,7 @@ bool extractFile(QuaZip *zip, return true; } -bool removeFile(QStringList listFile) -{ +bool removeFile(QStringList listFile) { bool ret = true; // For each file for (int i = 0; i < listFile.count(); i++) { diff --git a/src/qt_common/util/compress.h b/src/qt_common/util/compress.h index a16c6bff1a..640dcad420 100644 --- a/src/qt_common/util/compress.h +++ b/src/qt_common/util/compress.h @@ -5,9 +5,9 @@ #include #include -#include "qt_common/qt_common.h" #include #include +#include "qt_common/qt_common.h" /** This is a modified version of JlCompress **/ namespace QtCommon::Compress { @@ -15,49 +15,49 @@ namespace QtCommon::Compress { class Options { public: /** - * The enum values refer to the comments in the open function of the quazipfile.h file. - * - * The value is represented by two hexadecimal characters, - * the left character indicating the compression method, - * and the right character indicating the compression level. - * - * method == 0 indicates that the file is not compressed but rather stored as is. - * method == 8(Z_DEFLATED) indicates that zlib compression is used. - * - * A higher value of level indicates a smaller size of the compressed file, - * although it also implies more time consumed during the compression process. - */ - enum CompressionStrategy - { + * The enum values refer to the comments in the open function of the quazipfile.h file. + * + * The value is represented by two hexadecimal characters, + * the left character indicating the compression method, + * and the right character indicating the compression level. + * + * method == 0 indicates that the file is not compressed but rather stored as is. + * method == 8(Z_DEFLATED) indicates that zlib compression is used. + * + * A higher value of level indicates a smaller size of the compressed file, + * although it also implies more time consumed during the compression process. + */ + enum CompressionStrategy { /// Storage without compression - Storage = 0x00, // Z_NO_COMPRESSION 0 - /// The fastest compression speed - Fastest = 0x81, // Z_BEST_SPEED 1 - /// Relatively fast compression speed - Faster = 0x83, + Storage = 0x00, // Z_NO_COMPRESSION 0 + /// The fastest compression speed + Fastest = 0x81, // Z_BEST_SPEED 1 + /// Relatively fast compression speed + Faster = 0x83, /// Standard compression speed and ratio Standard = 0x86, /// Better compression ratio - Better = 0x87, + Better = 0x87, /// The best compression ratio - Best = 0x89, // Z_BEST_COMPRESSION 9 - /// The default compression strategy, according to the open function of quazipfile.h, - /// the value of method is Z_DEFLATED, and the value of level is Z_DEFAULT_COMPRESSION -1 (equals lvl 6) - Default = 0xff + Best = 0x89, // Z_BEST_COMPRESSION 9 + /// The default compression strategy, according to the open function of + /// quazipfile.h, the value of method is Z_DEFLATED, and the value of level is + /// Z_DEFAULT_COMPRESSION -1 (equals lvl 6) + Default = 0xff }; public: - explicit Options(const CompressionStrategy& strategy) - : m_compressionStrategy(strategy) {} + explicit Options(const CompressionStrategy& strategy) : m_compressionStrategy(strategy) {} - explicit Options(const QDateTime& dateTime = QDateTime(), const CompressionStrategy& strategy = Default) + explicit Options(const QDateTime& dateTime = QDateTime(), + const CompressionStrategy& strategy = Default) : m_dateTime(dateTime), m_compressionStrategy(strategy) {} QDateTime getDateTime() const { return m_dateTime; } - void setDateTime(const QDateTime &dateTime) { + void setDateTime(const QDateTime& dateTime) { m_dateTime = dateTime; } @@ -70,10 +70,11 @@ public: } int getCompressionLevel() const { - return m_compressionStrategy != Default ? m_compressionStrategy & 0x0f : Z_DEFAULT_COMPRESSION; + return m_compressionStrategy != Default ? m_compressionStrategy & 0x0f + : Z_DEFAULT_COMPRESSION; } - void setCompressionStrategy(const CompressionStrategy &strategy) { + void setCompressionStrategy(const CompressionStrategy& strategy) { m_compressionStrategy = strategy; } @@ -89,34 +90,21 @@ private: * @param fileCompressed Destination file * @param dir The directory to compress * @param options Compression level, etc - * @param callback Callback that takes in two std::size_t (total, progress) and returns false if the current operation should be cancelled. + * @param callback Callback that takes in two std::size_t (total, progress) and returns false + * if the current operation should be cancelled. */ -bool compressDir(QString fileCompressed, - QString dir, - const Options& options = Options(), +bool compressDir(QString fileCompressed, QString dir, const Options& options = Options(), QtCommon::QtProgressCallback callback = {}); // Internal // -bool compressSubDir(QuaZip *zip, - QString dir, - QString origDir, - const Options &options, - std::size_t total, - std::size_t &progress, +bool compressSubDir(QuaZip* zip, QString dir, QString origDir, const Options& options, + std::size_t total, std::size_t& progress, QtCommon::QtProgressCallback callback); -bool compressFile(QuaZip *zip, - QString fileName, - QString fileDest, - const Options &options, - std::size_t total, - std::size_t &progress, - QtCommon::QtProgressCallback callback); +bool compressFile(QuaZip* zip, QString fileName, QString fileDest, const Options& options, + std::size_t total, std::size_t& progress, QtCommon::QtProgressCallback callback); -bool copyData(QIODevice &inFile, - QIODevice &outFile, - std::size_t total, - std::size_t &progress, +bool copyData(QIODevice& inFile, QIODevice& outFile, std::size_t total, std::size_t& progress, QtCommon::QtProgressCallback callback); // Extract // @@ -125,20 +113,18 @@ bool copyData(QIODevice &inFile, * @brief Extract a zip file and report its progress. * @param fileCompressed Compressed file * @param dir The directory to push the results to - * @param callback Callback that takes in two std::size_t (total, progress) and returns false if the current operation should be cancelled. + * @param callback Callback that takes in two std::size_t (total, progress) and returns false + * if the current operation should be cancelled. */ -QStringList extractDir(QString fileCompressed, QString dir, QtCommon::QtProgressCallback callback = {}); +QStringList extractDir(QString fileCompressed, QString dir, + QtCommon::QtProgressCallback callback = {}); // Internal // -QStringList extractDir(QuaZip &zip, const QString &dir, QtCommon::QtProgressCallback callback); +QStringList extractDir(QuaZip& zip, const QString& dir, QtCommon::QtProgressCallback callback); -bool extractFile(QuaZip *zip, - QString fileName, - QString fileDest, - std::size_t total, - std::size_t &progress, - QtCommon::QtProgressCallback callback); +bool extractFile(QuaZip* zip, QString fileName, QString fileDest, std::size_t total, + std::size_t& progress, QtCommon::QtProgressCallback callback); bool removeFile(QStringList listFile); -} +} // namespace QtCommon::Compress diff --git a/src/qt_common/util/content.cpp b/src/qt_common/util/content.cpp index dd095a40a4..4d9b324608 100644 --- a/src/qt_common/util/content.cpp +++ b/src/qt_common/util/content.cpp @@ -15,17 +15,16 @@ #include "qt_common/abstract/progress.h" #include "qt_common/qt_common.h" +#include #include #include #include -#include namespace QtCommon::Content { -bool CheckGameFirmware(u64 program_id) -{ - if (FirmwareManager::GameRequiresFirmware(program_id) - && !FirmwareManager::CheckFirmwarePresence(*system)) { +bool CheckGameFirmware(u64 program_id) { + if (FirmwareManager::GameRequiresFirmware(program_id) && + !FirmwareManager::CheckFirmwarePresence(*system)) { auto result = QtCommon::Frontend::Warning( tr("Game Requires Firmware"), tr("The game you are trying to launch requires firmware to boot or to get past the " @@ -39,11 +38,10 @@ bool CheckGameFirmware(u64 program_id) return true; } -void InstallFirmware(const QString& location, bool recursive) -{ +void InstallFirmware(const QString& location, bool recursive) { // Initialize a progress dialog. - auto progress = QtCommon::Frontend::newProgressDialog(tr("Installing Firmware..."), - tr("Cancel"), 0, 100); + auto progress = + QtCommon::Frontend::newProgressDialog(tr("Installing Firmware..."), tr("Cancel"), 0, 100); progress->show(); QGuiApplication::processEvents(); @@ -61,9 +59,7 @@ void InstallFirmware(const QString& location, bool recursive) FirmwareInstallResult result; const auto ShowMessage = [&]() { - QtCommon::Frontend::ShowMessage(icon, - failedTitle, - GetFirmwareInstallResultString(result)); + QtCommon::Frontend::ShowMessage(icon, failedTitle, GetFirmwareInstallResultString(result)); }; LOG_INFO(Frontend, "Installing firmware from {}", location.toStdString()); @@ -88,12 +84,10 @@ void InstallFirmware(const QString& location, bool recursive) callback(100, 10); if (recursive) { - Common::FS::IterateDirEntriesRecursively(firmware_source_path, - dir_callback, + Common::FS::IterateDirEntriesRecursively(firmware_source_path, dir_callback, Common::FS::DirEntryFilter::File); } else { - Common::FS::IterateDirEntries(firmware_source_path, - dir_callback, + Common::FS::IterateDirEntries(firmware_source_path, dir_callback, Common::FS::DirEntryFilter::File); } @@ -106,8 +100,8 @@ void InstallFirmware(const QString& location, bool recursive) // Locate and erase the content of nand/system/Content/registered/*.nca, if any. auto sysnand_content_vdir = system->GetFileSystemController().GetSystemNANDContentDirectory(); - if (sysnand_content_vdir->IsWritable() - && !sysnand_content_vdir->CleanSubdirectoryRecursive("registered")) { + if (sysnand_content_vdir->IsWritable() && + !sysnand_content_vdir->CleanSubdirectoryRecursive("registered")) { result = FirmwareInstallResult::FailedDelete; icon = QtCommon::Frontend::Icon::Critical; ShowMessage(); @@ -125,16 +119,14 @@ void InstallFirmware(const QString& location, bool recursive) int i = 0; for (const auto& firmware_src_path : out) { i++; - auto firmware_src_vfile = vfs->OpenFile(firmware_src_path.generic_string(), - FileSys::OpenMode::Read); - auto firmware_dst_vfile = firmware_vdir->CreateFileRelative( - firmware_src_path.filename().string()); + auto firmware_src_vfile = + vfs->OpenFile(firmware_src_path.generic_string(), FileSys::OpenMode::Read); + auto firmware_dst_vfile = + firmware_vdir->CreateFileRelative(firmware_src_path.filename().string()); if (!VfsRawCopy(firmware_src_vfile, firmware_dst_vfile)) { - LOG_ERROR(Frontend, - "Failed to copy firmware file {} to {} in registered folder!", - firmware_src_path.generic_string(), - firmware_src_path.filename().string()); + LOG_ERROR(Frontend, "Failed to copy firmware file {} to {} in registered folder!", + firmware_src_path.generic_string(), firmware_src_path.filename().string()); success = false; } @@ -162,14 +154,12 @@ void InstallFirmware(const QString& location, bool recursive) return progress->wasCanceled(); }; - auto results = ContentManager::VerifyInstalledContents(*QtCommon::system, - *QtCommon::provider, - VerifyFirmwareCallback, - true); + auto results = ContentManager::VerifyInstalledContents(*QtCommon::system, *QtCommon::provider, + VerifyFirmwareCallback, true); if (results.size() > 0) { - const auto failed_names = QString::fromStdString( - fmt::format("{}", fmt::join(results, "\n"))); + const auto failed_names = + QString::fromStdString(fmt::format("{}", fmt::join(results, "\n"))); progress->close(); QtCommon::Frontend::Critical( tr("Firmware integrity verification failed!"), @@ -185,13 +175,11 @@ void InstallFirmware(const QString& location, bool recursive) const std::string display_version(firmware_data.display_version.data()); result = FirmwareInstallResult::Success; - QtCommon::Frontend::Information(successTitle, - GetFirmwareInstallResultString(result).arg( - QString::fromStdString(display_version))); + QtCommon::Frontend::Information(successTitle, GetFirmwareInstallResultString(result).arg( + QString::fromStdString(display_version))); } -QString UnzipFirmwareToTmp(const QString& location) -{ +QString UnzipFirmwareToTmp(const QString& location) { namespace fs = std::filesystem; fs::path tmp{fs::temp_directory_path()}; @@ -216,8 +204,7 @@ QString UnzipFirmwareToTmp(const QString& location) } // Content // -void VerifyGameContents(const std::string& game_path) -{ +void VerifyGameContents(const std::string& game_path) { auto progress = QtCommon::Frontend::newProgressDialog(tr("Verifying integrity..."), tr("Cancel"), 0, 100); progress->show(); @@ -234,34 +221,30 @@ void VerifyGameContents(const std::string& game_path) switch (result) { case ContentManager::GameVerificationResult::Success: - QtCommon::Frontend::Information(rootObject, - tr("Integrity verification succeeded!"), + QtCommon::Frontend::Information(rootObject, tr("Integrity verification succeeded!"), tr("The operation completed successfully.")); break; case ContentManager::GameVerificationResult::Failed: - QtCommon::Frontend::Critical(rootObject, - tr("Integrity verification failed!"), + QtCommon::Frontend::Critical(rootObject, tr("Integrity verification failed!"), tr("File contents may be corrupt or missing.")); break; case ContentManager::GameVerificationResult::NotImplemented: QtCommon::Frontend::Warning( - rootObject, - tr("Integrity verification couldn't be performed"), + rootObject, tr("Integrity verification couldn't be performed"), tr("Firmware installation cancelled, firmware may be in a bad state or corrupted. " "File contents could not be checked for validity.")); } } -void InstallKeys() -{ +void InstallKeys() { const QString key_source_location = QtCommon::Frontend::GetOpenFileName( tr("Select Dumped Keys Location"), {}, QStringLiteral("Decryption Keys (*.keys)"), {}); if (key_source_location.isEmpty()) return; - FirmwareManager::KeyInstallResult result - = FirmwareManager::InstallKeys(key_source_location.toStdString(), "keys"); + FirmwareManager::KeyInstallResult result = + FirmwareManager::InstallKeys(key_source_location.toStdString(), "keys"); system->GetFileSystemController().CreateFactories(*QtCommon::vfs); @@ -276,11 +259,10 @@ void InstallKeys() } } -void VerifyInstalledContents() -{ +void VerifyInstalledContents() { // Initialize a progress dialog. - auto progress = QtCommon::Frontend::newProgressDialog(tr("Verifying integrity..."), - tr("Cancel"), 0, 100); + auto progress = + QtCommon::Frontend::newProgressDialog(tr("Verifying integrity..."), tr("Cancel"), 0, 100); progress->show(); QGuiApplication::processEvents(); @@ -289,7 +271,8 @@ void VerifyInstalledContents() auto QtProgressCallback = [&](size_t total_size, size_t processed_size) { QGuiApplication::processEvents(); progress->setValue(static_cast((processed_size * 100) / total_size)); - return progress->wasCanceled(); }; + return progress->wasCanceled(); + }; const std::vector result = ContentManager::VerifyInstalledContents( *QtCommon::system, *QtCommon::provider, QtProgressCallback); @@ -300,17 +283,18 @@ void VerifyInstalledContents() QtCommon::Frontend::Information(tr("Integrity verification succeeded!"), tr("The operation completed successfully.")); } else { - const auto failed_names = QString::fromStdString(fmt::format("{}", fmt::join(result, "\n"))); + const auto failed_names = + QString::fromStdString(fmt::format("{}", fmt::join(result, "\n"))); QtCommon::Frontend::Critical( tr("Integrity verification failed!"), tr("Verification failed for the following files:\n\n%1").arg(failed_names)); } } -void FixProfiles() -{ +void FixProfiles() { // Reset user save files after config is initialized and migration is done. - // Doing it at init time causes profiles to read from the wrong place entirely if NAND dir is not default + // Doing it at init time causes profiles to read from the wrong place entirely if NAND dir is + // not default // TODO: better solution system->GetProfileManager().ResetUserSaveFile(); std::vector orphaned = system->GetProfileManager().FindOrphanedProfiles(); @@ -350,28 +334,27 @@ void FixProfiles() "%2

" "Click \"OK\" to open your save folder and fix up your profiles.
" "Hint: copy the contents of the largest or last-modified folder elsewhere, " - "delete all orphaned profiles, and move your copied contents to the good profile.

" - "Still confused? See the help page.
") + "delete all orphaned profiles, and move your copied contents to the good " + "profile.

" + "Still confused? See the help page.
") .arg(qorphaned, qgood)); QtCommon::Game::OpenSaveFolder(); } -void ClearDataDir(FrontendCommon::DataManager::DataDir dir, const std::string& user_id) -{ +void ClearDataDir(FrontendCommon::DataManager::DataDir dir, const std::string& user_id) { using namespace QtCommon::Frontend; - auto result = Warning(tr("Really clear data?"), - tr("Important data may be lost!"), - Yes | No); + auto result = Warning(tr("Really clear data?"), tr("Important data may be lost!"), Yes | No); if (result != Yes) return; - result = Warning( - tr("Are you REALLY sure?"), - tr("Once deleted, your data will NOT come back!\n" - "Only do this if you're 100% sure you want to delete this data."), - Yes | No); + result = Warning(tr("Are you REALLY sure?"), + tr("Once deleted, your data will NOT come back!\n" + "Only do this if you're 100% sure you want to delete this data."), + Yes | No); if (result != Yes) return; @@ -384,17 +367,13 @@ void ClearDataDir(FrontendCommon::DataManager::DataDir dir, const std::string& u dialog->close(); } -void ExportDataDir(FrontendCommon::DataManager::DataDir data_dir, - const std::string& user_id, - const QString& name, - std::function callback) -{ +void ExportDataDir(FrontendCommon::DataManager::DataDir data_dir, const std::string& user_id, + const QString& name, std::function callback) { using namespace QtCommon::Frontend; const std::string dir = FrontendCommon::DataManager::GetDataDirString(data_dir, user_id); - const QString zip_dump_location = GetSaveFileName(tr("Select Export Location"), - tr("%1.zip").arg(name), - tr("Zipped Archives (*.zip)")); + const QString zip_dump_location = GetSaveFileName( + tr("Select Export Location"), tr("%1.zip").arg(name), tr("Zipped Archives (*.zip)")); if (zip_dump_location.isEmpty()) return; @@ -406,18 +385,15 @@ void ExportDataDir(FrontendCommon::DataManager::DataDir data_dir, progress->show(); auto progress_callback = [=](size_t total_size, size_t processed_size) { - QMetaObject::invokeMethod(progress, - "setValue", - Qt::DirectConnection, - Q_ARG(int, static_cast((processed_size * 100) / total_size))); + QMetaObject::invokeMethod( + progress, "setValue", Qt::DirectConnection, + Q_ARG(int, static_cast((processed_size * 100) / total_size))); return !progress->wasCanceled(); }; QFuture future = QtConcurrent::run([=]() { - return QtCommon::Compress::compressDir(zip_dump_location, - QString::fromStdString(dir), - QtCommon::Compress::Options(), - progress_callback); + return QtCommon::Compress::compressDir(zip_dump_location, QString::fromStdString(dir), + QtCommon::Compress::Options(), progress_callback); }); QFutureWatcher* watcher = new QFutureWatcher(rootObject); @@ -444,37 +420,34 @@ void ExportDataDir(FrontendCommon::DataManager::DataDir data_dir, watcher->setFuture(future); } -void ImportDataDir(FrontendCommon::DataManager::DataDir data_dir, - const std::string& user_id, - std::function callback) -{ +void ImportDataDir(FrontendCommon::DataManager::DataDir data_dir, const std::string& user_id, + std::function callback) { const std::string dir = FrontendCommon::DataManager::GetDataDirString(data_dir, user_id); using namespace QtCommon::Frontend; - const QString zip_dump_location = GetOpenFileName(tr("Select Import Location"), - {}, - tr("Zipped Archives (*.zip)")); + const QString zip_dump_location = + GetOpenFileName(tr("Select Import Location"), {}, tr("Zipped Archives (*.zip)")); if (zip_dump_location.isEmpty()) return; - StandardButton button = Warning( - tr("Import Warning"), - tr("All previous data in this directory will be deleted. Are you sure you wish to " - "proceed?"), - StandardButton::Yes | StandardButton::No); + StandardButton button = + Warning(tr("Import Warning"), + tr("All previous data in this directory will be deleted. Are you sure you wish to " + "proceed?"), + StandardButton::Yes | StandardButton::No); if (button != QtCommon::Frontend::Yes) return; - QtProgressDialog* progress = newProgressDialogPtr( - tr("Importing data. This may take a while..."), tr("Cancel"), 0, 100); + QtProgressDialog* progress = + newProgressDialogPtr(tr("Importing data. This may take a while..."), tr("Cancel"), 0, 100); progress->setTitle(tr("Importing")); progress->show(); - // to prevent GUI mangling we have to run this in a thread as well + // to prevent GUI mangling we have to run this in a thread as well QFuture delete_future = QtConcurrent::run([=]() { FrontendCommon::DataManager::ClearDir(data_dir, user_id); return !progress->wasCanceled(); @@ -485,17 +458,14 @@ void ImportDataDir(FrontendCommon::DataManager::DataDir data_dir, QObject::connect(delete_watcher, &QFutureWatcher::finished, rootObject, [=]() { auto progress_callback = [=](size_t total_size, size_t processed_size) { - QMetaObject::invokeMethod(progress, - "setValue", - Qt::DirectConnection, - Q_ARG(int, - static_cast((processed_size * 100) / total_size))); + QMetaObject::invokeMethod( + progress, "setValue", Qt::DirectConnection, + Q_ARG(int, static_cast((processed_size * 100) / total_size))); return !progress->wasCanceled(); }; QFuture future = QtConcurrent::run([=]() { - return !QtCommon::Compress::extractDir(zip_dump_location, - QString::fromStdString(dir), + return !QtCommon::Compress::extractDir(zip_dump_location, QString::fromStdString(dir), progress_callback) .empty(); }); @@ -505,7 +475,7 @@ void ImportDataDir(FrontendCommon::DataManager::DataDir data_dir, QObject::connect(watcher, &QFutureWatcher::finished, rootObject, [=]() { progress->close(); - // this sucks + // this sucks if (watcher->result()) { Information(tr("Imported Successfully"), tr("Data was imported successfully.")); } else if (progress->wasCanceled()) { diff --git a/src/qt_common/util/content.h b/src/qt_common/util/content.h index c1e2e7791d..20dacf540a 100644 --- a/src/qt_common/util/content.h +++ b/src/qt_common/util/content.h @@ -23,8 +23,7 @@ enum class FirmwareInstallResult { FailedCorrupted, }; -inline const QString GetFirmwareInstallResultString(FirmwareInstallResult result) -{ +inline const QString GetFirmwareInstallResultString(FirmwareInstallResult result) { return LOOKUP_ENUM(result, FwInstallSuccess); } @@ -33,30 +32,29 @@ inline const QString GetFirmwareInstallResultString(FirmwareInstallResult result * \param result The result code. * \return A string representation of the passed result code. */ -inline const QString GetKeyInstallResultString(FirmwareManager::KeyInstallResult result) -{ +inline const QString GetKeyInstallResultString(FirmwareManager::KeyInstallResult result) { return LOOKUP_ENUM(result, KeyInstallSuccess); } -void InstallFirmware(const QString &location, bool recursive); +void InstallFirmware(const QString& location, bool recursive); -QString UnzipFirmwareToTmp(const QString &location); +QString UnzipFirmwareToTmp(const QString& location); // Keys // void InstallKeys(); // Content // -void VerifyGameContents(const std::string &game_path); +void VerifyGameContents(const std::string& game_path); void VerifyInstalledContents(); -void ClearDataDir(FrontendCommon::DataManager::DataDir dir, const std::string &user_id = ""); -void ExportDataDir(FrontendCommon::DataManager::DataDir dir, - const std::string &user_id = "", - const QString &name = QStringLiteral("export"), +void ClearDataDir(FrontendCommon::DataManager::DataDir dir, const std::string& user_id = ""); +void ExportDataDir(FrontendCommon::DataManager::DataDir dir, const std::string& user_id = "", + const QString& name = QStringLiteral("export"), + std::function callback = {}); +void ImportDataDir(FrontendCommon::DataManager::DataDir dir, const std::string& user_id = "", std::function callback = {}); -void ImportDataDir(FrontendCommon::DataManager::DataDir dir, const std::string &user_id = "", std::function callback = {}); // Profiles // void FixProfiles(); -} +} // namespace QtCommon::Content #endif // QT_CONTENT_UTIL_H diff --git a/src/qt_common/util/fs.cpp b/src/qt_common/util/fs.cpp index e171b8eaf5..b5f2844bbf 100644 --- a/src/qt_common/util/fs.cpp +++ b/src/qt_common/util/fs.cpp @@ -13,8 +13,7 @@ namespace fs = std::filesystem; namespace QtCommon::FS { -void LinkRyujinx(std::filesystem::path &from, std::filesystem::path &to) -{ +void LinkRyujinx(std::filesystem::path& from, std::filesystem::path& to) { std::error_code ec; // "ignore" errors--if the dir fails to be deleted, error handling later will handle it @@ -25,12 +24,12 @@ void LinkRyujinx(std::filesystem::path &from, std::filesystem::path &to) } else { QtCommon::Frontend::Critical( tr("Failed to link save data"), - tr("Could not link directory:\n\t%1\nTo:\n\t%2").arg(QString::fromStdString(from.string()), QString::fromStdString(to.string()))); + tr("Could not link directory:\n\t%1\nTo:\n\t%2") + .arg(QString::fromStdString(from.string()), QString::fromStdString(to.string()))); } } -bool CheckUnlink(const fs::path &eden_dir, const fs::path &ryu_dir) -{ +bool CheckUnlink(const fs::path& eden_dir, const fs::path& ryu_dir) { bool eden_link = Common::FS::IsSymlink(eden_dir); bool ryu_link = Common::FS::IsSymlink(ryu_dir); @@ -64,7 +63,7 @@ bool CheckUnlink(const fs::path &eden_dir, const fs::path &ryu_dir) // NB: do NOT use remove_all, as Windows treats this as a remove_all to the target, // NOT the junction fs::remove(linked); - } catch (std::exception &e) { + } catch (std::exception& e) { QtCommon::Frontend::Critical( tr("Failed to unlink old directory"), tr("OS returned error: %1").arg(QString::fromStdString(e.what()))); @@ -74,7 +73,7 @@ bool CheckUnlink(const fs::path &eden_dir, const fs::path &ryu_dir) // then COPY the other dir try { fs::copy(orig, linked, fs::copy_options::recursive); - } catch (std::exception &e) { + } catch (std::exception& e) { QtCommon::Frontend::Critical( tr("Failed to copy save data"), tr("OS returned error: %1").arg(QString::fromStdString(e.what()))); @@ -87,8 +86,7 @@ bool CheckUnlink(const fs::path &eden_dir, const fs::path &ryu_dir) return true; } -const fs::path GetRyujinxSavePath(const fs::path &path_hint, const u64 &program_id) -{ +const fs::path GetRyujinxSavePath(const fs::path& path_hint, const u64& program_id) { auto ryu_path = path_hint; auto kvdb_path = Common::FS::GetKvdbPath(ryu_path); @@ -99,10 +97,13 @@ const fs::path GetRyujinxSavePath(const fs::path &path_hint, const u64 &program_ tr("Could not find Ryujinx installation"), tr("Could not find a valid Ryujinx installation. This may typically occur if you are " "using Ryujinx in portable mode.\n\nWould you like to manually select a portable " - "folder to use?"), StandardButton::Yes | StandardButton::No); + "folder to use?"), + StandardButton::Yes | StandardButton::No); if (res == StandardButton::Yes) { - auto selected_path = GetExistingDirectory(tr("Ryujinx Portable Location"), QDir::homePath()).toStdString(); + auto selected_path = + GetExistingDirectory(tr("Ryujinx Portable Location"), QDir::homePath()) + .toStdString(); if (selected_path.empty()) return fs::path{}; @@ -131,7 +132,7 @@ const fs::path GetRyujinxSavePath(const fs::path &path_hint, const u64 &program_ Common::FS::IMENReadResult res = Common::FS::ReadKvdb(kvdb_path, imens); if (res == Common::FS::IMENReadResult::Success) { - for (const Common::FS::IMEN &imen : imens) { + for (const Common::FS::IMEN& imen : imens) { if (imen.title_id == program_id) return Common::FS::GetRyuSavePath(ryu_path, imen.save_id); } diff --git a/src/qt_common/util/fs.h b/src/qt_common/util/fs.h index ef56a361dd..5ab59e2a45 100644 --- a/src/qt_common/util/fs.h +++ b/src/qt_common/util/fs.h @@ -1,19 +1,19 @@ // SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later -#include "common/common_types.h" #include #include +#include "common/common_types.h" #pragma once namespace QtCommon::FS { -void LinkRyujinx(std::filesystem::path &from, std::filesystem::path &to); -const std::filesystem::path GetRyujinxSavePath(const std::filesystem::path &path_hint, const u64 &program_id); +void LinkRyujinx(std::filesystem::path& from, std::filesystem::path& to); +const std::filesystem::path GetRyujinxSavePath(const std::filesystem::path& path_hint, + const u64& program_id); /// returns FALSE if the dirs are NOT linked -bool CheckUnlink(const std::filesystem::path& eden_dir, - const std::filesystem::path& ryu_dir); +bool CheckUnlink(const std::filesystem::path& eden_dir, const std::filesystem::path& ryu_dir); } // namespace QtCommon::FS diff --git a/src/qt_common/util/game.cpp b/src/qt_common/util/game.cpp index 3e07b9d6b5..e037fdae6c 100644 --- a/src/qt_common/util/game.cpp +++ b/src/qt_common/util/game.cpp @@ -18,40 +18,34 @@ #include #ifdef _WIN32 -#include "common/scope_exit.h" -#include "common/string_util.h" #include #include +#include "common/scope_exit.h" +#include "common/string_util.h" #else -#include "fmt/ostream.h" #include +#include "fmt/ostream.h" #endif namespace QtCommon::Game { -bool CreateShortcutLink(const std::filesystem::path& shortcut_path, - const std::string& comment, +bool CreateShortcutLink(const std::filesystem::path& shortcut_path, const std::string& comment, const std::filesystem::path& icon_path, - const std::filesystem::path& command, - const std::string& arguments, - const std::string& categories, - const std::string& keywords, - const std::string& name) -try { + const std::filesystem::path& command, const std::string& arguments, + const std::string& categories, const std::string& keywords, + const std::string& name) try { #ifdef _WIN32 // Windows HRESULT hr = CoInitialize(nullptr); if (FAILED(hr)) { LOG_ERROR(Frontend, "CoInitialize failed"); return false; } - SCOPE_EXIT - { + SCOPE_EXIT { CoUninitialize(); }; IShellLinkW* ps1 = nullptr; IPersistFile* persist_file = nullptr; - SCOPE_EXIT - { + SCOPE_EXIT { if (persist_file != nullptr) { persist_file->Release(); } @@ -59,10 +53,7 @@ try { ps1->Release(); } }; - HRESULT hres = CoCreateInstance(CLSID_ShellLink, - nullptr, - CLSCTX_INPROC_SERVER, - IID_IShellLinkW, + HRESULT hres = CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, IID_IShellLinkW, reinterpret_cast(&ps1)); if (FAILED(hres)) { LOG_ERROR(Frontend, "Failed to create IShellLinkW instance"); @@ -142,10 +133,8 @@ try { return false; } -bool MakeShortcutIcoPath(const u64 program_id, - const std::string_view game_file_name, - std::filesystem::path& out_icon_path) -{ +bool MakeShortcutIcoPath(const u64 program_id, const std::string_view game_file_name, + std::filesystem::path& out_icon_path) { // Get path to Yuzu icons directory & icon extension std::string ico_extension = "png"; #if defined(_WIN32) @@ -166,46 +155,38 @@ bool MakeShortcutIcoPath(const u64 program_id, return true; } -void OpenEdenFolder(const Common::FS::EdenPath& path) -{ +void OpenEdenFolder(const Common::FS::EdenPath& path) { QDesktopServices::openUrl( QUrl::fromLocalFile(QString::fromStdString(Common::FS::GetEdenPathString(path)))); } -void OpenRootDataFolder() -{ +void OpenRootDataFolder() { OpenEdenFolder(Common::FS::EdenPath::EdenDir); } -void OpenNANDFolder() -{ +void OpenNANDFolder() { OpenEdenFolder(Common::FS::EdenPath::NANDDir); } -void OpenSaveFolder() -{ - const auto path = Common::FS::GetEdenPath(Common::FS::EdenPath::NANDDir) - / "user/save/0000000000000000"; +void OpenSaveFolder() { + const auto path = + Common::FS::GetEdenPath(Common::FS::EdenPath::NANDDir) / "user/save/0000000000000000"; QDesktopServices::openUrl(QUrl::fromLocalFile(QString::fromStdString(path.string()))); } -void OpenSDMCFolder() -{ +void OpenSDMCFolder() { OpenEdenFolder(Common::FS::EdenPath::SDMCDir); } -void OpenModFolder() -{ +void OpenModFolder() { OpenEdenFolder(Common::FS::EdenPath::LoadDir); } -void OpenLogFolder() -{ +void OpenLogFolder() { OpenEdenFolder(Common::FS::EdenPath::LogDir); } -static QString GetGameListErrorRemoving(QtCommon::Game::InstalledEntryType type) -{ +static QString GetGameListErrorRemoving(QtCommon::Game::InstalledEntryType type) { switch (type) { case QtCommon::Game::InstalledEntryType::Game: return tr("Error Removing Contents"); @@ -219,10 +200,9 @@ static QString GetGameListErrorRemoving(QtCommon::Game::InstalledEntryType type) } // Game Content // -void RemoveBaseContent(u64 program_id, InstalledEntryType type) -{ - const auto res = ContentManager::RemoveBaseContent(system->GetFileSystemController(), - program_id); +void RemoveBaseContent(u64 program_id, InstalledEntryType type) { + const auto res = + ContentManager::RemoveBaseContent(system->GetFileSystemController(), program_id); if (res) { QtCommon::Frontend::Information(tr("Successfully Removed"), tr("Successfully removed the installed base game.")); @@ -234,8 +214,7 @@ void RemoveBaseContent(u64 program_id, InstalledEntryType type) } } -void RemoveUpdateContent(u64 program_id, InstalledEntryType type) -{ +void RemoveUpdateContent(u64 program_id, InstalledEntryType type) { const auto res = ContentManager::RemoveUpdate(system->GetFileSystemController(), program_id); if (res) { QtCommon::Frontend::Information(tr("Successfully Removed"), @@ -246,8 +225,7 @@ void RemoveUpdateContent(u64 program_id, InstalledEntryType type) } } -void RemoveAddOnContent(u64 program_id, InstalledEntryType type) -{ +void RemoveAddOnContent(u64 program_id, InstalledEntryType type) { const size_t count = ContentManager::RemoveAllDLC(*system, program_id); if (count == 0) { QtCommon::Frontend::Warning(GetGameListErrorRemoving(type), @@ -261,8 +239,7 @@ void RemoveAddOnContent(u64 program_id, InstalledEntryType type) // Global Content // -void RemoveTransferableShaderCache(u64 program_id, GameListRemoveTarget target) -{ +void RemoveTransferableShaderCache(u64 program_id, GameListRemoveTarget target) { const auto target_file_name = [target] { switch (target) { case GameListRemoveTarget::GlShaderCache: @@ -291,8 +268,7 @@ void RemoveTransferableShaderCache(u64 program_id, GameListRemoveTarget target) } } -void RemoveVulkanDriverPipelineCache(u64 program_id) -{ +void RemoveVulkanDriverPipelineCache(u64 program_id) { static constexpr std::string_view target_file_name = "vulkan_pipelines.bin"; const auto shader_cache_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::ShaderDir); @@ -308,8 +284,7 @@ void RemoveVulkanDriverPipelineCache(u64 program_id) } } -void RemoveAllTransferableShaderCaches(u64 program_id) -{ +void RemoveAllTransferableShaderCaches(u64 program_id) { const auto shader_cache_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::ShaderDir); const auto program_shader_cache_dir = shader_cache_dir / fmt::format("{:016x}", program_id); @@ -329,14 +304,13 @@ void RemoveAllTransferableShaderCaches(u64 program_id) } } -void RemoveCustomConfiguration(u64 program_id, const std::string& game_path) -{ +void RemoveCustomConfiguration(u64 program_id, const std::string& game_path) { const auto file_path = std::filesystem::path(Common::FS::ToU8String(game_path)); - const auto config_file_name - = program_id == 0 ? Common::FS::PathToUTF8String(file_path.filename()).append(".ini") - : fmt::format("{:016X}.ini", program_id); - const auto custom_config_file_path = Common::FS::GetEdenPath(Common::FS::EdenPath::ConfigDir) - / "custom" / config_file_name; + const auto config_file_name = + program_id == 0 ? Common::FS::PathToUTF8String(file_path.filename()).append(".ini") + : fmt::format("{:016X}.ini", program_id); + const auto custom_config_file_path = + Common::FS::GetEdenPath(Common::FS::EdenPath::ConfigDir) / "custom" / config_file_name; if (!Common::FS::Exists(custom_config_file_path)) { QtCommon::Frontend::Warning(tr("Error Removing Custom Configuration"), @@ -353,20 +327,14 @@ void RemoveCustomConfiguration(u64 program_id, const std::string& game_path) } } -void RemoveCacheStorage(u64 program_id) -{ +void RemoveCacheStorage(u64 program_id) { const auto nand_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::NANDDir); - auto vfs_nand_dir = vfs->OpenDirectory(Common::FS::PathToUTF8String(nand_dir), - FileSys::OpenMode::Read); + auto vfs_nand_dir = + vfs->OpenDirectory(Common::FS::PathToUTF8String(nand_dir), FileSys::OpenMode::Read); - const auto cache_storage_path - = FileSys::SaveDataFactory::GetFullPath({}, - vfs_nand_dir, - FileSys::SaveDataSpaceId::User, - FileSys::SaveDataType::Cache, - 0 /* program_id */, - {}, - 0); + const auto cache_storage_path = FileSys::SaveDataFactory::GetFullPath( + {}, vfs_nand_dir, FileSys::SaveDataSpaceId::User, FileSys::SaveDataType::Cache, + 0 /* program_id */, {}, 0); const auto path = Common::FS::ConcatPathSafe(nand_dir, cache_storage_path); @@ -400,8 +368,7 @@ void ResetMetadata(bool show_message) { // Uhhh // // Messages in pre-defined message boxes for less code spaghetti -inline constexpr bool CreateShortcutMessagesGUI(ShortcutMessages imsg, const QString& game_title) -{ +inline constexpr bool CreateShortcutMessagesGUI(ShortcutMessages imsg, const QString& game_title) { int result = 0; using namespace QtCommon::Frontend; int buttons; @@ -433,13 +400,9 @@ inline constexpr bool CreateShortcutMessagesGUI(ShortcutMessages imsg, const QSt } } -void CreateShortcut(const std::string& game_path, - const u64 program_id, - const std::string& game_title_, - const ShortcutTarget& target, - std::string arguments_, - const bool needs_title) -{ +void CreateShortcut(const std::string& game_path, const u64 program_id, + const std::string& game_title_, const ShortcutTarget& target, + std::string arguments_, const bool needs_title) { // Get path to Eden executable std::filesystem::path command = GetEdenCommand(); @@ -453,13 +416,11 @@ void CreateShortcut(const std::string& game_path, return; } - const FileSys::PatchManager pm{program_id, - QtCommon::system->GetFileSystemController(), + const FileSys::PatchManager pm{program_id, QtCommon::system->GetFileSystemController(), QtCommon::system->GetContentProvider()}; const auto control = pm.GetControlMetadata(); - const auto loader = Loader::GetLoader(*QtCommon::system, - QtCommon::vfs->OpenFile(game_path, - FileSys::OpenMode::Read)); + const auto loader = Loader::GetLoader( + *QtCommon::system, QtCommon::vfs->OpenFile(game_path, FileSys::OpenMode::Read)); std::string game_title{game_title_}; @@ -490,8 +451,8 @@ void CreateShortcut(const std::string& game_path, LOG_WARNING(Frontend, "Could not read icon from {:s}", game_path); } - QImage icon_data = QImage::fromData(icon_image_file.data(), - static_cast(icon_image_file.size())); + QImage icon_data = + QImage::fromData(icon_image_file.data(), static_cast(icon_image_file.size())); std::filesystem::path out_icon_path; if (QtCommon::Game::MakeShortcutIcoPath(program_id, game_title, out_icon_path)) { if (!SaveIconToFile(out_icon_path, icon_data)) { @@ -524,39 +485,32 @@ void CreateShortcut(const std::string& game_path, const std::string categories = "Game;Emulator;Qt;"; const std::string keywords = "Switch;Nintendo;"; - if (QtCommon::Game::CreateShortcutLink(shortcut_path, - comment, - out_icon_path, - command, - arguments, - categories, - keywords, - game_title)) { + if (QtCommon::Game::CreateShortcutLink(shortcut_path, comment, out_icon_path, command, + arguments, categories, keywords, game_title)) { CreateShortcutMessagesGUI(ShortcutMessages::Success, qgame_title); return; } CreateShortcutMessagesGUI(ShortcutMessages::Failed, qgame_title); } -// TODO: You want this to be constexpr? Well too bad, clang19 doesn't believe this is a string literal -std::string GetShortcutPath(ShortcutTarget target) -{ +// TODO: You want this to be constexpr? Well too bad, clang19 doesn't believe this is a string +// literal +std::string GetShortcutPath(ShortcutTarget target) { { std::string shortcut_path{}; if (target == ShortcutTarget::Desktop) { - shortcut_path - = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation).toStdString(); + shortcut_path = + QStandardPaths::writableLocation(QStandardPaths::DesktopLocation).toStdString(); } else if (target == ShortcutTarget::Applications) { - shortcut_path - = QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation).toStdString(); + shortcut_path = QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation) + .toStdString(); } return shortcut_path; } } -void CreateHomeMenuShortcut(ShortcutTarget target) -{ +void CreateHomeMenuShortcut(ShortcutTarget target) { constexpr u64 QLaunchId = static_cast(Service::AM::AppletProgramId::QLaunch); auto bis_system = QtCommon::system->GetFileSystemController().GetSystemNANDContents(); if (!bis_system) { diff --git a/src/qt_common/util/game.h b/src/qt_common/util/game.h index 16a1b7340a..0d7f03fa86 100644 --- a/src/qt_common/util/game.h +++ b/src/qt_common/util/game.h @@ -29,27 +29,18 @@ enum class ShortcutTarget { Applications, }; -enum class ShortcutMessages{ - Fullscreen = 0, - Success = 1, - Volatile = 2, - Failed = 3 -}; +enum class ShortcutMessages { Fullscreen = 0, Success = 1, Volatile = 2, Failed = 3 }; -bool CreateShortcutLink(const std::filesystem::path& shortcut_path, - const std::string& comment, +bool CreateShortcutLink(const std::filesystem::path& shortcut_path, const std::string& comment, const std::filesystem::path& icon_path, - const std::filesystem::path& command, - const std::string& arguments, - const std::string& categories, - const std::string& keywords, + const std::filesystem::path& command, const std::string& arguments, + const std::string& categories, const std::string& keywords, const std::string& name); -bool MakeShortcutIcoPath(const u64 program_id, - const std::string_view game_file_name, +bool MakeShortcutIcoPath(const u64 program_id, const std::string_view game_file_name, std::filesystem::path& out_icon_path); -void OpenEdenFolder(const Common::FS::EdenPath &path); +void OpenEdenFolder(const Common::FS::EdenPath& path); void OpenRootDataFolder(); void OpenNANDFolder(); void OpenSaveFolder(); @@ -71,16 +62,13 @@ void RemoveCacheStorage(u64 program_id); void ResetMetadata(bool show_message = true); // Shortcuts // -void CreateShortcut(const std::string& game_path, - const u64 program_id, - const std::string& game_title_, - const ShortcutTarget& target, - std::string arguments_, - const bool needs_title); +void CreateShortcut(const std::string& game_path, const u64 program_id, + const std::string& game_title_, const ShortcutTarget& target, + std::string arguments_, const bool needs_title); std::string GetShortcutPath(ShortcutTarget target); void CreateHomeMenuShortcut(ShortcutTarget target); -} +} // namespace QtCommon::Game #endif // QT_GAME_UTIL_H diff --git a/src/qt_common/util/meta.cpp b/src/qt_common/util/meta.cpp index ead090b7a4..4607321285 100644 --- a/src/qt_common/util/meta.cpp +++ b/src/qt_common/util/meta.cpp @@ -1,7 +1,6 @@ // SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later -#include "qt_common/util/meta.h" #include "common/common_types.h" #include "core/core.h" #include "core/frontend/applets/cabinet.h" @@ -9,11 +8,11 @@ #include "core/frontend/applets/profile_select.h" #include "core/frontend/applets/software_keyboard.h" #include "core/hle/service/am/frontend/applet_web_browser_types.h" +#include "qt_common/util/meta.h" namespace QtCommon::Meta { -void RegisterMetaTypes() -{ +void RegisterMetaTypes() { // Register integral and floating point types qRegisterMetaType("u8"); qRegisterMetaType("u16"); @@ -72,4 +71,4 @@ void RegisterMetaTypes() qRegisterMetaType("Core::SystemResultStatus"); } -} +} // namespace QtCommon::Meta diff --git a/src/qt_common/util/meta.h b/src/qt_common/util/meta.h index 53501591e0..ae6dbc49d8 100644 --- a/src/qt_common/util/meta.h +++ b/src/qt_common/util/meta.h @@ -11,5 +11,5 @@ namespace QtCommon::Meta { // void RegisterMetaTypes(); -} +} // namespace QtCommon::Meta #endif // QT_META_H diff --git a/src/qt_common/util/mod.cpp b/src/qt_common/util/mod.cpp index 1ab05af9b6..38bc8f5be0 100644 --- a/src/qt_common/util/mod.cpp +++ b/src/qt_common/util/mod.cpp @@ -43,7 +43,8 @@ QStringList GetModFolders(const QString& root, const QString& fallbackName) { QString name = QtCommon::Frontend::GetTextInput( tr("Mod Name"), tr("What should this mod be called?"), default_name); - if (name.isEmpty()) return {}; + if (name.isEmpty()) + return {}; // if std_path is empty, frontend_common could not determine mod type and/or name. // so we have to prompt the user and set up the structure ourselves diff --git a/src/qt_common/util/mod.h b/src/qt_common/util/mod.h index 8bdb4bc9dd..2148bed65c 100644 --- a/src/qt_common/util/mod.h +++ b/src/qt_common/util/mod.h @@ -7,8 +7,8 @@ namespace QtCommon::Mod { -QStringList GetModFolders(const QString &root, const QString &fallbackName); +QStringList GetModFolders(const QString& root, const QString& fallbackName); -const QString ExtractMod(const QString &path); +const QString ExtractMod(const QString& path); -} +} // namespace QtCommon::Mod diff --git a/src/qt_common/util/path.h b/src/qt_common/util/path.h index 7a1d74b354..aff0009f34 100644 --- a/src/qt_common/util/path.h +++ b/src/qt_common/util/path.h @@ -4,9 +4,11 @@ #ifndef QT_PATH_UTIL_H #define QT_PATH_UTIL_H -#include "common/common_types.h" #include +#include "common/common_types.h" -namespace QtCommon::Path { bool OpenShaderCache(u64 program_id, QObject *parent); } +namespace QtCommon::Path { +bool OpenShaderCache(u64 program_id, QObject* parent); +} #endif // QT_PATH_UTIL_H diff --git a/src/qt_common/util/rom.cpp b/src/qt_common/util/rom.cpp index ef4d4e1ae4..c77fa9530d 100644 --- a/src/qt_common/util/rom.cpp +++ b/src/qt_common/util/rom.cpp @@ -7,13 +7,8 @@ namespace QtCommon::ROM { -bool RomFSRawCopy(size_t total_size, - size_t& read_size, - QtProgressCallback callback, - const FileSys::VirtualDir& src, - const FileSys::VirtualDir& dest, - bool full) -{ +bool RomFSRawCopy(size_t total_size, size_t& read_size, QtProgressCallback callback, + const FileSys::VirtualDir& src, const FileSys::VirtualDir& dest, bool full) { // TODO(crueter) // if (src == nullptr || dest == nullptr || !src->IsReadable() || !dest->IsWritable()) // return false; @@ -75,4 +70,4 @@ bool RomFSRawCopy(size_t total_size, return true; } -} +} // namespace QtCommon::ROM diff --git a/src/qt_common/util/rom.h b/src/qt_common/util/rom.h index 5dd372e450..5ceadaf46b 100644 --- a/src/qt_common/util/rom.h +++ b/src/qt_common/util/rom.h @@ -4,17 +4,13 @@ #ifndef QT_ROM_UTIL_H #define QT_ROM_UTIL_H -#include "qt_common/qt_common.h" #include +#include "qt_common/qt_common.h" namespace QtCommon::ROM { -bool RomFSRawCopy(size_t total_size, - size_t& read_size, - QtProgressCallback callback, - const FileSys::VirtualDir& src, - const FileSys::VirtualDir& dest, - bool full); +bool RomFSRawCopy(size_t total_size, size_t& read_size, QtProgressCallback callback, + const FileSys::VirtualDir& src, const FileSys::VirtualDir& dest, bool full); } #endif // QT_ROM_UTIL_H diff --git a/src/yuzu/about_dialog.cpp b/src/yuzu/about_dialog.cpp index 9f7597f471..2694f421cb 100644 --- a/src/yuzu/about_dialog.cpp +++ b/src/yuzu/about_dialog.cpp @@ -1,29 +1,24 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include "yuzu/about_dialog.h" #include +#include #include "common/scm_rev.h" #include "ui_aboutdialog.h" -#include +#include "yuzu/about_dialog.h" AboutDialog::AboutDialog(QWidget* parent) - : QDialog(parent) - , ui{std::make_unique()} -{ + : QDialog(parent), ui{std::make_unique()} { static const std::string build_id = std::string{Common::g_build_id}; - static const std::string yuzu_build = fmt::format("{} | {} | {}", - std::string{Common::g_build_name}, - std::string{Common::g_build_version}, - std::string{Common::g_compiler_id} - ); + static const std::string yuzu_build = + fmt::format("{} | {} | {}", std::string{Common::g_build_name}, + std::string{Common::g_build_version}, std::string{Common::g_compiler_id}); - const auto override_build = fmt::format(fmt::runtime( - std::string(Common::g_title_bar_format_idle)), - build_id); + const auto override_build = + fmt::format(fmt::runtime(std::string(Common::g_title_bar_format_idle)), build_id); const auto yuzu_build_version = override_build.empty() ? yuzu_build : override_build; ui->setupUi(this); diff --git a/src/yuzu/applets/qt_controller.cpp b/src/yuzu/applets/qt_controller.cpp index aa210caf77..e7fa93a793 100644 --- a/src/yuzu/applets/qt_controller.cpp +++ b/src/yuzu/applets/qt_controller.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project @@ -17,8 +17,8 @@ #include "hid_core/hid_core.h" #include "hid_core/hid_types.h" #include "hid_core/resources/npad/npad.h" -#include "ui_qt_controller.h" #include "qt_common/qt_compat.h" +#include "ui_qt_controller.h" #include "yuzu/applets/qt_controller.h" #include "yuzu/configuration/configure_input.h" #include "yuzu/configuration/configure_input_profile_dialog.h" @@ -188,14 +188,15 @@ QtControllerSelectorDialog::QtControllerSelectorDialog( CheckIfParametersMet(); }); - connect(connected_controller_checkboxes[i], &QCheckBox::STATE_CHANGED, [this, i](int state) { - player_groupboxes[i]->setChecked(state == Qt::Checked); - UpdateControllerIcon(i); - UpdateControllerState(i); - UpdateLEDPattern(i); - UpdateBorderColor(i); - CheckIfParametersMet(); - }); + connect(connected_controller_checkboxes[i], &QCheckBox::STATE_CHANGED, + [this, i](int state) { + player_groupboxes[i]->setChecked(state == Qt::Checked); + UpdateControllerIcon(i); + UpdateControllerState(i); + UpdateLEDPattern(i); + UpdateBorderColor(i); + CheckIfParametersMet(); + }); if (i == 0) { connect(emulated_controllers[i], qOverload(&QComboBox::currentIndexChanged), diff --git a/src/yuzu/applets/qt_software_keyboard.cpp b/src/yuzu/applets/qt_software_keyboard.cpp index 0b894bf51a..41f0b85e96 100644 --- a/src/yuzu/applets/qt_software_keyboard.cpp +++ b/src/yuzu/applets/qt_software_keyboard.cpp @@ -1499,22 +1499,22 @@ void QtSoftwareKeyboardDialog::StartInputThread() { input_interpreter->PollInput(); HandleButtonPressedOnce< Core::HID::NpadButton::A, Core::HID::NpadButton::B, Core::HID::NpadButton::X, - Core::HID::NpadButton::Y, Core::HID::NpadButton::StickL, Core::HID::NpadButton::StickR, - Core::HID::NpadButton::L, Core::HID::NpadButton::R, Core::HID::NpadButton::Plus, - Core::HID::NpadButton::Left, Core::HID::NpadButton::Up, Core::HID::NpadButton::Right, - Core::HID::NpadButton::Down, Core::HID::NpadButton::StickLLeft, - Core::HID::NpadButton::StickLUp, Core::HID::NpadButton::StickLRight, - Core::HID::NpadButton::StickLDown, Core::HID::NpadButton::StickRLeft, - Core::HID::NpadButton::StickRUp, Core::HID::NpadButton::StickRRight, - Core::HID::NpadButton::StickRDown>(); + Core::HID::NpadButton::Y, Core::HID::NpadButton::StickL, + Core::HID::NpadButton::StickR, Core::HID::NpadButton::L, Core::HID::NpadButton::R, + Core::HID::NpadButton::Plus, Core::HID::NpadButton::Left, Core::HID::NpadButton::Up, + Core::HID::NpadButton::Right, Core::HID::NpadButton::Down, + Core::HID::NpadButton::StickLLeft, Core::HID::NpadButton::StickLUp, + Core::HID::NpadButton::StickLRight, Core::HID::NpadButton::StickLDown, + Core::HID::NpadButton::StickRLeft, Core::HID::NpadButton::StickRUp, + Core::HID::NpadButton::StickRRight, Core::HID::NpadButton::StickRDown>(); HandleButtonHold(); + Core::HID::NpadButton::R, Core::HID::NpadButton::Left, + Core::HID::NpadButton::Up, Core::HID::NpadButton::Right, + Core::HID::NpadButton::Down, Core::HID::NpadButton::StickLLeft, + Core::HID::NpadButton::StickLUp, Core::HID::NpadButton::StickLRight, + Core::HID::NpadButton::StickLDown, Core::HID::NpadButton::StickRLeft, + Core::HID::NpadButton::StickRUp, Core::HID::NpadButton::StickRRight, + Core::HID::NpadButton::StickRDown>(); std::this_thread::sleep_for(std::chrono::milliseconds(50)); } }); diff --git a/src/yuzu/applets/qt_web_browser.cpp b/src/yuzu/applets/qt_web_browser.cpp index 2141b9d0e7..e7c50aa3fb 100644 --- a/src/yuzu/applets/qt_web_browser.cpp +++ b/src/yuzu/applets/qt_web_browser.cpp @@ -63,8 +63,8 @@ QtNXWebEngineView::QtNXWebEngineView(QWidget* parent, Core::System& system, : QWebEngineView(parent), input_subsystem{input_subsystem_}, url_interceptor(std::make_unique()), input_interpreter(std::make_unique(system)), - default_profile{QWebEngineProfile::defaultProfile()}, global_settings{ - default_profile->settings()} { + default_profile{QWebEngineProfile::defaultProfile()}, + global_settings{default_profile->settings()} { default_profile->setPersistentStoragePath(QString::fromStdString(Common::FS::PathToUTF8String( Common::FS::GetEdenPath(Common::FS::EdenPath::EdenDir) / "qtwebengine"))); @@ -299,21 +299,21 @@ void QtNXWebEngineView::StartInputThread() { while (!stoken.stop_requested()) { input_interpreter->PollInput(); - HandleWindowFooterButtonPressedOnce(); + HandleWindowFooterButtonPressedOnce< + Core::HID::NpadButton::A, Core::HID::NpadButton::B, Core::HID::NpadButton::X, + Core::HID::NpadButton::Y, Core::HID::NpadButton::L, Core::HID::NpadButton::R>(); HandleWindowKeyButtonPressedOnce< - Core::HID::NpadButton::Left, Core::HID::NpadButton::Up, Core::HID::NpadButton::Right, - Core::HID::NpadButton::Down, Core::HID::NpadButton::StickLLeft, - Core::HID::NpadButton::StickLUp, Core::HID::NpadButton::StickLRight, - Core::HID::NpadButton::StickLDown>(); + Core::HID::NpadButton::Left, Core::HID::NpadButton::Up, + Core::HID::NpadButton::Right, Core::HID::NpadButton::Down, + Core::HID::NpadButton::StickLLeft, Core::HID::NpadButton::StickLUp, + Core::HID::NpadButton::StickLRight, Core::HID::NpadButton::StickLDown>(); HandleWindowKeyButtonHold< - Core::HID::NpadButton::Left, Core::HID::NpadButton::Up, Core::HID::NpadButton::Right, - Core::HID::NpadButton::Down, Core::HID::NpadButton::StickLLeft, - Core::HID::NpadButton::StickLUp, Core::HID::NpadButton::StickLRight, - Core::HID::NpadButton::StickLDown>(); + Core::HID::NpadButton::Left, Core::HID::NpadButton::Up, + Core::HID::NpadButton::Right, Core::HID::NpadButton::Down, + Core::HID::NpadButton::StickLLeft, Core::HID::NpadButton::StickLUp, + Core::HID::NpadButton::StickLRight, Core::HID::NpadButton::StickLDown>(); std::this_thread::sleep_for(std::chrono::milliseconds(50)); } diff --git a/src/yuzu/applets/qt_web_browser.h b/src/yuzu/applets/qt_web_browser.h index 6a2dd0c8ba..f6869bbb35 100644 --- a/src/yuzu/applets/qt_web_browser.h +++ b/src/yuzu/applets/qt_web_browser.h @@ -169,7 +169,8 @@ private: std::unique_ptr input_interpreter; std::jthread input_thread; std::atomic finished{}; - Service::AM::Frontend::WebExitReason exit_reason{Service::AM::Frontend::WebExitReason::EndButtonPressed}; + Service::AM::Frontend::WebExitReason exit_reason{ + Service::AM::Frontend::WebExitReason::EndButtonPressed}; std::string last_url{"http://localhost/"}; bool is_local{}; QWebEngineProfile* default_profile; diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index 72a5157fc4..69b3681d0a 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp @@ -54,12 +54,12 @@ #include "input_common/drivers/tas_input.h" #include "input_common/drivers/touch_screen.h" #include "input_common/main.h" +#include "qt_common/qt_common.h" #include "video_core/gpu.h" #include "video_core/rasterizer_interface.h" #include "video_core/renderer_base.h" #include "yuzu/bootmanager.h" #include "yuzu/main_window.h" -#include "qt_common/qt_common.h" class QObject; class QPaintEngine; @@ -282,8 +282,8 @@ struct NullRenderWidget : public RenderWidget { GRenderWindow::GRenderWindow(MainWindow* parent, EmuThread* emu_thread_, std::shared_ptr input_subsystem_, Core::System& system_) - : QWidget(parent), - emu_thread(emu_thread_), input_subsystem{std::move(input_subsystem_)}, system{system_} { + : QWidget(parent), emu_thread(emu_thread_), input_subsystem{std::move(input_subsystem_)}, + system{system_} { setWindowTitle(QStringLiteral("Eden %1 | %2-%3") .arg(QString::fromUtf8(Common::g_build_name), QString::fromUtf8(Common::g_scm_branch), @@ -887,13 +887,14 @@ void GRenderWindow::resizeEvent(QResizeEvent* event) { std::unique_ptr GRenderWindow::CreateSharedContext() const { #ifdef HAS_OPENGL - if (Settings::values.renderer_backend.GetValue() == Settings::RendererBackend::OpenGL_GLSL - || Settings::values.renderer_backend.GetValue() == Settings::RendererBackend::OpenGL_GLASM - || Settings::values.renderer_backend.GetValue() == Settings::RendererBackend::OpenGL_SPIRV) { + if (Settings::values.renderer_backend.GetValue() == Settings::RendererBackend::OpenGL_GLSL || + Settings::values.renderer_backend.GetValue() == Settings::RendererBackend::OpenGL_GLASM || + Settings::values.renderer_backend.GetValue() == Settings::RendererBackend::OpenGL_SPIRV) { auto c = static_cast(main_context.get()); // Bind the shared contexts to the main surface in case the backend wants to take over // presentation - return std::make_unique(c->GetShareContext(), child_widget->windowHandle()); + return std::make_unique(c->GetShareContext(), + child_widget->windowHandle()); } #endif return std::make_unique(); @@ -940,9 +941,9 @@ bool GRenderWindow::InitRenderTarget() { OnFramebufferSizeChanged(); BackupGeometry(); - if (Settings::values.renderer_backend.GetValue() == Settings::RendererBackend::OpenGL_GLSL - || Settings::values.renderer_backend.GetValue() == Settings::RendererBackend::OpenGL_GLASM - || Settings::values.renderer_backend.GetValue() == Settings::RendererBackend::OpenGL_SPIRV) + if (Settings::values.renderer_backend.GetValue() == Settings::RendererBackend::OpenGL_GLSL || + Settings::values.renderer_backend.GetValue() == Settings::RendererBackend::OpenGL_GLASM || + Settings::values.renderer_backend.GetValue() == Settings::RendererBackend::OpenGL_SPIRV) return LoadOpenGL(); return true; } @@ -1050,21 +1051,23 @@ bool GRenderWindow::LoadOpenGL() { } // Display various warnings (but not fatal errors) for missing OpenGL extensions or lack of // OpenGL 4.6 support - const QString renderer = QString::fromUtf8(reinterpret_cast(glGetString(GL_RENDERER))); + const QString renderer = + QString::fromUtf8(reinterpret_cast(glGetString(GL_RENDERER))); if (!GLAD_GL_VERSION_4_6) { QMessageBox::warning(this, tr("Error while initializing OpenGL 4.6!"), - tr("Your GPU may not support OpenGL 4.6, or you do not have the " - "latest graphics driver.

GL Renderer:
%1") - .arg(renderer)); + tr("Your GPU may not support OpenGL 4.6, or you do not have the " + "latest graphics driver.

GL Renderer:
%1") + .arg(renderer)); return false; } if (QStringList missing_ext = GetUnsupportedGLExtensions(); !missing_ext.empty()) { QMessageBox::warning( this, tr("Error while initializing OpenGL!"), tr("Your GPU may not support one or more required OpenGL extensions. Please ensure you " - "have the latest graphics driver.

GL Renderer:
%1

Unsupported " - "extensions:
%2") - .arg(renderer).arg(missing_ext.join(QStringLiteral("
")))); + "have the latest graphics driver.

GL Renderer:
%1

Unsupported " + "extensions:
%2") + .arg(renderer) + .arg(missing_ext.join(QStringLiteral("
")))); // Non fatal } return true; diff --git a/src/yuzu/configuration/addon/mod_select_dialog.cpp b/src/yuzu/configuration/addon/mod_select_dialog.cpp index e6c361b94f..467de5a764 100644 --- a/src/yuzu/configuration/addon/mod_select_dialog.cpp +++ b/src/yuzu/configuration/addon/mod_select_dialog.cpp @@ -43,7 +43,8 @@ ModSelectDialog::ModSelectDialog(const QStringList& mods, QWidget* parent) width = qMax(width, item_model->item(i)->sizeHint().width()); } - width += ui->treeView->contentsMargins().left() * 4 + ui->treeView->contentsMargins().right() * 4; + width += + ui->treeView->contentsMargins().left() * 4 + ui->treeView->contentsMargins().right() * 4; ui->treeView->setMinimumHeight(qMin(height, 600)); ui->treeView->setMinimumWidth(qMin(width, 700)); adjustSize(); diff --git a/src/yuzu/configuration/addon/mod_select_dialog.h b/src/yuzu/configuration/addon/mod_select_dialog.h index d23c435e7a..ab6d4686b0 100644 --- a/src/yuzu/configuration/addon/mod_select_dialog.h +++ b/src/yuzu/configuration/addon/mod_select_dialog.h @@ -14,11 +14,12 @@ class ModSelectDialog : public QDialog { Q_OBJECT public: - explicit ModSelectDialog(const QStringList &mods, QWidget* parent = nullptr); + explicit ModSelectDialog(const QStringList& mods, QWidget* parent = nullptr); ~ModSelectDialog(); signals: - void modsSelected(const QStringList &mods); + void modsSelected(const QStringList& mods); + private: Ui::ModSelectDialog* ui; diff --git a/src/yuzu/configuration/configure_audio.cpp b/src/yuzu/configuration/configure_audio.cpp index 10eacf39cb..65b8b16301 100644 --- a/src/yuzu/configuration/configure_audio.cpp +++ b/src/yuzu/configuration/configure_audio.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project @@ -16,12 +16,12 @@ #include "common/settings.h" #include "common/settings_common.h" #include "core/core.h" +#include "qt_common/config/shared_translation.h" +#include "qt_common/config/uisettings.h" #include "ui_configure_audio.h" #include "yuzu/configuration/configuration_shared.h" #include "yuzu/configuration/configure_audio.h" -#include "qt_common/config/shared_translation.h" #include "yuzu/configuration/shared_widget.h" -#include "qt_common/config/uisettings.h" ConfigureAudio::ConfigureAudio(const Core::System& system_, std::shared_ptr> group_, @@ -188,8 +188,8 @@ void ConfigureAudio::SetOutputSinkFromSinkID() { const std::string new_sink_id = []() -> const std::string { const Settings::AudioEngine sink_id = Settings::values.sink_id.GetValue(); - const auto canonicalizations - = Settings::EnumMetadata::Canonicalizations(); + const auto canonicalizations = + Settings::EnumMetadata::Canonicalizations(); for (u32 i = 0; i < canonicalizations.size(); ++i) { const Settings::AudioEngine value = canonicalizations[i].second; @@ -242,8 +242,8 @@ void ConfigureAudio::ApplyConfiguration() { const u32 new_sink_id = [this]() { const std::string sink_id = sink_combo_box->currentText().toStdString(); - const auto canonicalizations - = Settings::EnumMetadata::Canonicalizations(); + const auto canonicalizations = + Settings::EnumMetadata::Canonicalizations(); for (u32 i = 0; i < canonicalizations.size(); ++i) { if (sink_id == canonicalizations[i].first) @@ -291,7 +291,8 @@ void ConfigureAudio::InitializeAudioSinkComboBox() { sink_combo_box->clear(); sink_combo_box->addItem(QString::fromUtf8(AudioCore::Sink::auto_device_name)); for (const auto& id : AudioCore::Sink::GetSinkIDs()) - sink_combo_box->addItem(QString::fromStdString(std::string{Settings::CanonicalizeEnum(id)})); + sink_combo_box->addItem( + QString::fromStdString(std::string{Settings::CanonicalizeEnum(id)})); } void ConfigureAudio::RetranslateUI() { diff --git a/src/yuzu/configuration/configure_cpu.cpp b/src/yuzu/configuration/configure_cpu.cpp index bc1140d835..eee1c677b7 100644 --- a/src/yuzu/configuration/configure_cpu.cpp +++ b/src/yuzu/configuration/configure_cpu.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project @@ -76,9 +76,9 @@ void ConfigureCpu::Setup(const ConfigurationShared::Builder& builder) { } else if (setting->Id() == Settings::values.cpu_backend.Id()) { backend_layout->addWidget(widget); backend_combobox = widget->combobox; - } else if (setting->Id() == Settings::values.fast_cpu_time.Id() - || setting->Id() == Settings::values.vtable_bouncing.Id() - || setting->Id() == Settings::values.cpu_ticks.Id()) { + } else if (setting->Id() == Settings::values.fast_cpu_time.Id() || + setting->Id() == Settings::values.vtable_bouncing.Id() || + setting->Id() == Settings::values.cpu_ticks.Id()) { ui->general_layout->addWidget(widget); } else { // Presently, all other settings here are unsafe checkboxes @@ -93,12 +93,12 @@ void ConfigureCpu::Setup(const ConfigurationShared::Builder& builder) { UpdateGroup(); } -void ConfigureCpu::UpdateGroup() -{ +void ConfigureCpu::UpdateGroup() { const u32 accuracy = accuracy_combobox->currentIndex(); const u32 backend = backend_combobox->currentIndex(); // TODO(crueter): see if this works on NCE - ui->unsafe_group->setVisible(accuracy == (u32) Settings::CpuAccuracy::Unsafe && backend == (u32) Settings::CpuBackend::Dynarmic); + ui->unsafe_group->setVisible(accuracy == (u32)Settings::CpuAccuracy::Unsafe && + backend == (u32)Settings::CpuBackend::Dynarmic); } void ConfigureCpu::ApplyConfiguration() { diff --git a/src/yuzu/configuration/configure_cpu.h b/src/yuzu/configuration/configure_cpu.h index 461ca7f85e..2b0ae890d7 100644 --- a/src/yuzu/configuration/configure_cpu.h +++ b/src/yuzu/configuration/configure_cpu.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project @@ -9,8 +9,8 @@ #include #include #include -#include "yuzu/configuration/configuration_shared.h" #include "qt_common/config/shared_translation.h" +#include "yuzu/configuration/configuration_shared.h" class QComboBox; diff --git a/src/yuzu/configuration/configure_debug.cpp b/src/yuzu/configuration/configure_debug.cpp index e0bdbaeaa1..287bfbb338 100644 --- a/src/yuzu/configuration/configure_debug.cpp +++ b/src/yuzu/configuration/configure_debug.cpp @@ -13,10 +13,10 @@ #include "common/settings.h" #include "core/core.h" #include "core/crypto/key_manager.h" +#include "qt_common/config/uisettings.h" #include "ui_configure_debug.h" #include "yuzu/configuration/configure_debug.h" #include "yuzu/debugger/console.h" -#include "qt_common/config/uisettings.h" ConfigureDebug::ConfigureDebug(const Core::System& system_, QWidget* parent) : QScrollArea(parent), ui{std::make_unique()}, system{system_} { @@ -60,7 +60,8 @@ void ConfigureDebug::SetConfiguration() { // Immutable after starting ui->homebrew_args_edit->setEnabled(runtime_lock); - ui->homebrew_args_edit->setText(QString::fromStdString(Settings::values.program_args.GetValue())); + ui->homebrew_args_edit->setText( + QString::fromStdString(Settings::values.program_args.GetValue())); ui->toggle_console->setEnabled(runtime_lock); ui->toggle_console->setChecked(UISettings::values.show_console.GetValue()); ui->fs_access_log->setEnabled(runtime_lock); @@ -84,7 +85,8 @@ void ConfigureDebug::SetConfiguration() { ui->disable_macro_hle->setEnabled(runtime_lock); ui->disable_macro_hle->setChecked(Settings::values.disable_macro_hle.GetValue()); ui->disable_loop_safety_checks->setEnabled(runtime_lock); - ui->disable_loop_safety_checks->setChecked(Settings::values.disable_shader_loop_safety_checks.GetValue()); + ui->disable_loop_safety_checks->setChecked( + Settings::values.disable_shader_loop_safety_checks.GetValue()); ui->perform_vulkan_check->setChecked(Settings::values.perform_vulkan_check.GetValue()); ui->debug_knobs_spinbox->setValue(Settings::values.debug_knobs.GetValue()); #ifdef YUZU_USE_QT_WEB_ENGINE @@ -118,7 +120,8 @@ void ConfigureDebug::ApplyConfiguration() { Settings::values.enable_nsight_aftermath = ui->enable_nsight_aftermath->isChecked(); Settings::values.dump_shaders = ui->dump_shaders->isChecked(); Settings::values.dump_macros = ui->dump_macros->isChecked(); - Settings::values.disable_shader_loop_safety_checks = ui->disable_loop_safety_checks->isChecked(); + Settings::values.disable_shader_loop_safety_checks = + ui->disable_loop_safety_checks->isChecked(); Settings::values.disable_macro_jit = ui->disable_macro_jit->isChecked(); Settings::values.disable_macro_hle = ui->disable_macro_hle->isChecked(); Settings::values.extended_logging = ui->extended_logging->isChecked(); diff --git a/src/yuzu/configuration/configure_dialog.cpp b/src/yuzu/configuration/configure_dialog.cpp index 1107c77e8c..2e3107d3dc 100644 --- a/src/yuzu/configuration/configure_dialog.cpp +++ b/src/yuzu/configuration/configure_dialog.cpp @@ -9,6 +9,7 @@ #include "common/settings.h" #include "common/settings_enums.h" #include "core/core.h" +#include "qt_common/config/uisettings.h" #include "ui_configure.h" #include "vk_device_info.h" #include "yuzu/configuration/configure_applets.h" @@ -30,15 +31,14 @@ #include "yuzu/configuration/configure_ui.h" #include "yuzu/configuration/configure_web.h" #include "yuzu/hotkeys.h" -#include "qt_common/config/uisettings.h" ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry_, InputCommon::InputSubsystem* input_subsystem, std::vector& vk_device_records, Core::System& system_, bool enable_web_config) - : QDialog(parent), ui{std::make_unique()}, - registry(registry_), system{system_}, builder{std::make_unique( - this, !system_.IsPoweredOn())}, + : QDialog(parent), ui{std::make_unique()}, registry(registry_), + system{system_}, + builder{std::make_unique(this, !system_.IsPoweredOn())}, applets_tab{std::make_unique(system_, nullptr, *builder, this)}, audio_tab{std::make_unique(system_, nullptr, *builder, this)}, cpu_tab{std::make_unique(system_, nullptr, *builder, this)}, @@ -46,9 +46,9 @@ ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry_, filesystem_tab{std::make_unique(this)}, general_tab{std::make_unique(system_, nullptr, *builder, this)}, graphics_advanced_tab{ - std::make_unique(system_, nullptr, *builder, this)}, + std::make_unique(system_, nullptr, *builder, this)}, graphics_extensions_tab{ - std::make_unique(system_, nullptr, *builder, this)}, + std::make_unique(system_, nullptr, *builder, this)}, ui_tab{std::make_unique(system_, this)}, graphics_tab{std::make_unique( system_, vk_device_records, [&]() { graphics_advanced_tab->ExposeComputeOption(); }, @@ -113,7 +113,7 @@ ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry_, adjustSize(); ui->selectorList->setCurrentRow(0); - // Selects the leftmost button on the bottom bar (Cancel as of writing) + // Selects the leftmost button on the bottom bar (Cancel as of writing) ui->buttonBox->setFocus(); } @@ -172,16 +172,17 @@ Q_DECLARE_METATYPE(QList); void ConfigureDialog::PopulateSelectionList() { const std::array>, 6> items{ - {{tr("General"), - {general_tab.get(), hotkeys_tab.get(), ui_tab.get(), web_tab.get(), debug_tab_tab.get()}}, - {tr("System"), - {system_tab.get(), profile_tab.get(), network_tab.get(), filesystem_tab.get(), - applets_tab.get()}}, - {tr("CPU"), {cpu_tab.get()}}, - {tr("Graphics"), {graphics_tab.get(), graphics_advanced_tab.get(), graphics_extensions_tab.get()}}, - {tr("Audio"), {audio_tab.get()}}, - {tr("Controls"), input_tab->GetSubTabs()}}, - }; + {{tr("General"), + {general_tab.get(), hotkeys_tab.get(), ui_tab.get(), web_tab.get(), debug_tab_tab.get()}}, + {tr("System"), + {system_tab.get(), profile_tab.get(), network_tab.get(), filesystem_tab.get(), + applets_tab.get()}}, + {tr("CPU"), {cpu_tab.get()}}, + {tr("Graphics"), + {graphics_tab.get(), graphics_advanced_tab.get(), graphics_extensions_tab.get()}}, + {tr("Audio"), {audio_tab.get()}}, + {tr("Controls"), input_tab->GetSubTabs()}}, + }; [[maybe_unused]] const QSignalBlocker blocker(ui->selectorList); diff --git a/src/yuzu/configuration/configure_dialog.h b/src/yuzu/configuration/configure_dialog.h index 9d79e6f0ac..5c504c9a16 100644 --- a/src/yuzu/configuration/configure_dialog.h +++ b/src/yuzu/configuration/configure_dialog.h @@ -10,8 +10,8 @@ #include #include #include "configuration/shared_widget.h" -#include "yuzu/configuration/configuration_shared.h" #include "qt_common/config/shared_translation.h" +#include "yuzu/configuration/configuration_shared.h" #include "yuzu/vk_device_info.h" namespace Core { diff --git a/src/yuzu/configuration/configure_filesystem.cpp b/src/yuzu/configuration/configure_filesystem.cpp index 27af4c8055..ee1e4bbc20 100644 --- a/src/yuzu/configuration/configure_filesystem.cpp +++ b/src/yuzu/configuration/configure_filesystem.cpp @@ -4,7 +4,6 @@ // SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include "yuzu/configuration/configure_filesystem.h" #include #include #include @@ -12,10 +11,11 @@ #include "common/fs/fs.h" #include "common/fs/path_util.h" #include "common/settings.h" +#include "qt_common/config/uisettings.h" #include "qt_common/qt_compat.h" #include "qt_common/util/game.h" -#include "qt_common/config/uisettings.h" #include "ui_configure_filesystem.h" +#include "yuzu/configuration/configure_filesystem.h" ConfigureFilesystem::ConfigureFilesystem(QWidget* parent) : QWidget(parent), ui(std::make_unique()) { @@ -26,8 +26,7 @@ ConfigureFilesystem::ConfigureFilesystem(QWidget* parent) [this] { SetDirectory(DirectoryTarget::NAND, ui->nand_directory_edit); }); connect(ui->sdmc_directory_button, &QToolButton::pressed, this, [this] { SetDirectory(DirectoryTarget::SD, ui->sdmc_directory_edit); }); - connect(ui->save_directory_button, &QToolButton::pressed, this, - [this] { SetSaveDirectory(); }); + connect(ui->save_directory_button, &QToolButton::pressed, this, [this] { SetSaveDirectory(); }); connect(ui->gamecard_path_button, &QToolButton::pressed, this, [this] { SetDirectory(DirectoryTarget::Gamecard, ui->gamecard_path_edit); }); connect(ui->dump_path_button, &QToolButton::pressed, this, @@ -221,9 +220,9 @@ void ConfigureFilesystem::PromptSaveMigration(const QString& from_path, const QS .arg(QString::fromStdString(dest_save_dir.string())); } - QMessageBox::StandardButton reply = QMessageBox::question( - this, tr("Migrate Save Data"), message, - QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); + QMessageBox::StandardButton reply = + QMessageBox::question(this, tr("Migrate Save Data"), message, + QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); if (reply != QMessageBox::Yes) { return; @@ -249,17 +248,17 @@ void ConfigureFilesystem::PromptSaveMigration(const QString& from_path, const QS progress.close(); if (ec) { - QMessageBox::warning(this, tr("Migration Failed"), - tr("Failed to migrate save data:\n%1") - .arg(QString::fromStdString(ec.message()))); + QMessageBox::warning( + this, tr("Migration Failed"), + tr("Failed to migrate save data:\n%1").arg(QString::fromStdString(ec.message()))); return; } - QMessageBox::StandardButton deleteReply = QMessageBox::question( - this, tr("Migration Complete"), - tr("Save data has been migrated successfully.\n\n" - "Would you like to delete the old save data?"), - QMessageBox::Yes | QMessageBox::No, QMessageBox::No); + QMessageBox::StandardButton deleteReply = + QMessageBox::question(this, tr("Migration Complete"), + tr("Save data has been migrated successfully.\n\n" + "Would you like to delete the old save data?"), + QMessageBox::Yes | QMessageBox::No, QMessageBox::No); if (deleteReply == QMessageBox::Yes) { Common::FS::RemoveDirRecursively(source_save_dir); @@ -278,7 +277,6 @@ void ConfigureFilesystem::UpdateEnabledControls() { !ui->gamecard_current_game->isChecked()); } - void ConfigureFilesystem::RetranslateUI() { ui->retranslateUi(this); } diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp index f628abeab3..a311765f2f 100644 --- a/src/yuzu/configuration/configure_general.cpp +++ b/src/yuzu/configuration/configure_general.cpp @@ -13,11 +13,11 @@ #include #include "common/settings.h" #include "core/core.h" +#include "qt_common/config/uisettings.h" #include "ui_configure_general.h" #include "yuzu/configuration/configuration_shared.h" #include "yuzu/configuration/configure_general.h" #include "yuzu/configuration/shared_widget.h" -#include "qt_common/config/uisettings.h" ConfigureGeneral::ConfigureGeneral(const Core::System& system_, std::shared_ptr> group_, diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp index b0c63aff4f..475b9b60ac 100644 --- a/src/yuzu/configuration/configure_graphics.cpp +++ b/src/yuzu/configuration/configure_graphics.cpp @@ -39,12 +39,12 @@ #include "common/settings.h" #include "common/settings_enums.h" #include "core/core.h" +#include "qt_common/config/uisettings.h" +#include "qt_common/qt_common.h" #include "ui_configure_graphics.h" #include "yuzu/configuration/configuration_shared.h" #include "yuzu/configuration/configure_graphics.h" #include "yuzu/configuration/shared_widget.h" -#include "qt_common/qt_common.h" -#include "qt_common/config/uisettings.h" #include "yuzu/vk_device_info.h" static const std::vector default_present_modes{VK_PRESENT_MODE_IMMEDIATE_KHR, @@ -91,8 +91,7 @@ ConfigureGraphics::ConfigureGraphics( : ConfigurationShared::Tab(group_, parent), ui{std::make_unique()}, records{records_}, expose_compute_option{expose_compute_option_}, update_aspect_ratio{update_aspect_ratio_}, system{system_}, - combobox_translations{builder.ComboboxTranslations()} -{ + combobox_translations{builder.ComboboxTranslations()} { vulkan_device = Settings::values.vulkan_device.GetValue(); RetrieveVulkanDevices(); @@ -215,9 +214,9 @@ void ConfigureGraphics::PopulateVSyncModeSelection(bool use_setting) { const Settings::VSyncMode global_vsync_mode = Settings::values.vsync_mode.GetValue(true); vsync_restore_global_button->setEnabled( - ((backend == Settings::RendererBackend::OpenGL_GLSL - || backend == Settings::RendererBackend::OpenGL_GLASM - || backend == Settings::RendererBackend::OpenGL_SPIRV) && + ((backend == Settings::RendererBackend::OpenGL_GLSL || + backend == Settings::RendererBackend::OpenGL_GLASM || + backend == Settings::RendererBackend::OpenGL_SPIRV) && (global_vsync_mode == Settings::VSyncMode::Immediate || global_vsync_mode == Settings::VSyncMode::Fifo)) || backend == Settings::RendererBackend::Vulkan); @@ -286,7 +285,9 @@ void ConfigureGraphics::Setup(const ConfigurationShared::Builder& builder) { api_combobox = widget->combobox; api_restore_global_button = widget->restore_button; if (!Settings::IsConfiguringGlobal()) { - api_restore_global_button->connect(api_restore_global_button, &QAbstractButton::clicked, [this](bool) { UpdateAPILayout(); }); + api_restore_global_button->connect(api_restore_global_button, + &QAbstractButton::clicked, + [this](bool) { UpdateAPILayout(); }); // Detach API's restore button and place it where we want // Lets us put it on the side, and it will automatically scale if there's a // second combobox (vulkan_device) @@ -312,20 +313,21 @@ void ConfigureGraphics::Setup(const ConfigurationShared::Builder& builder) { widget->layout()->addWidget(restore_button); restore_button->connect(restore_button, &QAbstractButton::clicked, - [restore_button, this](bool) { - Settings::values.vsync_mode.SetGlobal(true); - PopulateVSyncModeSelection(true); + [restore_button, this](bool) { + Settings::values.vsync_mode.SetGlobal(true); + PopulateVSyncModeSelection(true); - restore_button->setVisible(false); - }); + restore_button->setVisible(false); + }); std::function set_non_global = [restore_button, this]() { Settings::values.vsync_mode.SetGlobal(false); UpdateVsyncSetting(); restore_button->setVisible(true); }; - widget->combobox->connect(widget->combobox, QOverload::of(&QComboBox::activated), - [set_non_global]() { set_non_global(); }); + widget->combobox->connect(widget->combobox, + QOverload::of(&QComboBox::activated), + [set_non_global]() { set_non_global(); }); vsync_restore_global_button = restore_button; } hold_graphics.emplace(setting->Id(), widget); @@ -364,15 +366,15 @@ void ConfigureGraphics::Setup(const ConfigurationShared::Builder& builder) { ui->bg_widget->layout()->addWidget(bg_restore_button); bg_restore_button->connect(bg_restore_button, &QAbstractButton::clicked, - [bg_restore_button, this](bool) { - const int r = Settings::values.bg_red.GetValue(true); - const int g = Settings::values.bg_green.GetValue(true); - const int b = Settings::values.bg_blue.GetValue(true); - UpdateBackgroundColorButton(QColor::fromRgb(r, g, b)); + [bg_restore_button, this](bool) { + const int r = Settings::values.bg_red.GetValue(true); + const int g = Settings::values.bg_green.GetValue(true); + const int b = Settings::values.bg_blue.GetValue(true); + UpdateBackgroundColorButton(QColor::fromRgb(r, g, b)); - bg_restore_button->setVisible(false); - bg_restore_button->setEnabled(false); - }); + bg_restore_button->setVisible(false); + bg_restore_button->setEnabled(false); + }); ui->bg_button->connect(ui->bg_button, &QAbstractButton::clicked, [bg_restore_button](bool) { bg_restore_button->setVisible(true); @@ -397,17 +399,19 @@ const QString ConfigureGraphics::TranslateVSyncMode(VkPresentModeKHR mode, Settings::RendererBackend backend) const { switch (mode) { case VK_PRESENT_MODE_IMMEDIATE_KHR: - return (backend == Settings::RendererBackend::OpenGL_GLSL - || backend == Settings::RendererBackend::OpenGL_GLASM - || backend == Settings::RendererBackend::OpenGL_SPIRV) - ? tr("Off") : QStringLiteral("Immediate (%1)").arg(tr("VSync Off")); + return (backend == Settings::RendererBackend::OpenGL_GLSL || + backend == Settings::RendererBackend::OpenGL_GLASM || + backend == Settings::RendererBackend::OpenGL_SPIRV) + ? tr("Off") + : QStringLiteral("Immediate (%1)").arg(tr("VSync Off")); case VK_PRESENT_MODE_MAILBOX_KHR: return QStringLiteral("Mailbox (%1)").arg(tr("Recommended")); case VK_PRESENT_MODE_FIFO_KHR: - return (backend == Settings::RendererBackend::OpenGL_GLSL - || backend == Settings::RendererBackend::OpenGL_GLASM - || backend == Settings::RendererBackend::OpenGL_SPIRV) - ? tr("On") : QStringLiteral("FIFO (%1)").arg(tr("VSync On")); + return (backend == Settings::RendererBackend::OpenGL_GLSL || + backend == Settings::RendererBackend::OpenGL_GLASM || + backend == Settings::RendererBackend::OpenGL_SPIRV) + ? tr("On") + : QStringLiteral("FIFO (%1)").arg(tr("VSync On")); case VK_PRESENT_MODE_FIFO_RELAXED_KHR: return QStringLiteral("FIFO Relaxed"); default: @@ -416,7 +420,9 @@ const QString ConfigureGraphics::TranslateVSyncMode(VkPresentModeKHR mode, } int ConfigureGraphics::FindIndex(u32 enumeration, int value) const { - for (u32 i = 0; enumeration < combobox_translations.size() && i < combobox_translations.at(enumeration).size(); i++) + for (u32 i = 0; enumeration < combobox_translations.size() && + i < combobox_translations.at(enumeration).size(); + i++) if (combobox_translations.at(enumeration)[i].first == u32(value)) return i; return -1; @@ -432,10 +438,14 @@ void ConfigureGraphics::ApplyConfiguration() { Settings::values.vulkan_device.SetGlobal(true); auto const index = Settings::EnumMetadata::Index(); - if (Settings::IsConfiguringGlobal() || (!Settings::IsConfiguringGlobal() && api_restore_global_button->isEnabled())) { - auto backend = index >= combobox_translations.size() || size_t(api_combobox->currentIndex()) >= combobox_translations.at(index).size() - ? Settings::values.renderer_backend.GetValue() - : Settings::RendererBackend(combobox_translations.at(index)[api_combobox->currentIndex()].first); + if (Settings::IsConfiguringGlobal() || + (!Settings::IsConfiguringGlobal() && api_restore_global_button->isEnabled())) { + auto backend = + index >= combobox_translations.size() || + size_t(api_combobox->currentIndex()) >= combobox_translations.at(index).size() + ? Settings::values.renderer_backend.GetValue() + : Settings::RendererBackend( + combobox_translations.at(index)[api_combobox->currentIndex()].first); switch (backend) { case Settings::RendererBackend::Vulkan: Settings::values.vulkan_device.SetGlobal(Settings::IsConfiguringGlobal()); @@ -506,12 +516,15 @@ Settings::RendererBackend ConfigureGraphics::GetCurrentGraphicsBackend() const { auto const index = Settings::EnumMetadata::Index(); if (!Settings::IsConfiguringGlobal() && !api_restore_global_button->isEnabled()) return Settings::values.renderer_backend.GetValue(true); - return index >= combobox_translations.size() || size_t(api_combobox->currentIndex()) >= combobox_translations.at(index).size() - ? Settings::values.renderer_backend.GetValue() - : Settings::RendererBackend(combobox_translations.at(index).at(api_combobox->currentIndex()).first); + return index >= combobox_translations.size() || size_t(api_combobox->currentIndex()) >= + combobox_translations.at(index).size() + ? Settings::values.renderer_backend.GetValue() + : Settings::RendererBackend( + combobox_translations.at(index).at(api_combobox->currentIndex()).first); }(); - if (selected_backend == Settings::RendererBackend::Vulkan && UISettings::values.has_broken_vulkan) + if (selected_backend == Settings::RendererBackend::Vulkan && + UISettings::values.has_broken_vulkan) return Settings::RendererBackend::OpenGL_GLSL; return selected_backend; } diff --git a/src/yuzu/configuration/configure_graphics_advanced.cpp b/src/yuzu/configuration/configure_graphics_advanced.cpp index 9096e3252d..2ffb3a0b30 100644 --- a/src/yuzu/configuration/configure_graphics_advanced.cpp +++ b/src/yuzu/configuration/configure_graphics_advanced.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project @@ -9,10 +9,10 @@ #include #include "common/settings.h" #include "core/core.h" +#include "qt_common/config/shared_translation.h" #include "ui_configure_graphics_advanced.h" #include "yuzu/configuration/configuration_shared.h" #include "yuzu/configuration/configure_graphics_advanced.h" -#include "qt_common/config/shared_translation.h" #include "yuzu/configuration/shared_widget.h" ConfigureGraphicsAdvanced::ConfigureGraphicsAdvanced( diff --git a/src/yuzu/configuration/configure_graphics_extensions.cpp b/src/yuzu/configuration/configure_graphics_extensions.cpp index 7334eccc97..8154dfa6ca 100644 --- a/src/yuzu/configuration/configure_graphics_extensions.cpp +++ b/src/yuzu/configuration/configure_graphics_extensions.cpp @@ -1,26 +1,27 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include -#include -#include #include +#include #include +#include #include "common/settings.h" #include "core/core.h" +#include "qt_common/config/shared_translation.h" #include "ui_configure_graphics_extensions.h" #include "yuzu/configuration/configuration_shared.h" #include "yuzu/configuration/configure_graphics_extensions.h" -#include "qt_common/config/shared_translation.h" #include "yuzu/configuration/shared_widget.h" ConfigureGraphicsExtensions::ConfigureGraphicsExtensions( const Core::System& system_, std::shared_ptr> group_, const ConfigurationShared::Builder& builder, QWidget* parent) - : Tab(group_, parent), ui{std::make_unique()}, system{system_} { + : Tab(group_, parent), ui{std::make_unique()}, + system{system_} { ui->setupUi(this); @@ -44,8 +45,8 @@ void ConfigureGraphicsExtensions::Setup(const ConfigurationShared::Builder& buil if (setting->Id() == Settings::values.sample_shading.Id()) { // TODO(crueter): should support this natively perhaps? return builder.BuildWidget( - setting, apply_funcs, ConfigurationShared::RequestType::Slider, true, - 1.0f, nullptr, tr("%", "Sample Shading percentage (e.g. 50%)")); + setting, apply_funcs, ConfigurationShared::RequestType::Slider, true, 1.0f, + nullptr, tr("%", "Sample Shading percentage (e.g. 50%)")); } else { return builder.BuildWidget(setting, apply_funcs); } @@ -64,7 +65,8 @@ void ConfigureGraphicsExtensions::Setup(const ConfigurationShared::Builder& buil #ifdef __APPLE__ if (setting->Id() == Settings::values.dyna_state.Id()) { widget->setEnabled(false); - widget->setToolTip(tr("Extended Dynamic State is disabled on macOS due to MoltenVK compatibility issues that cause black screens.")); + widget->setToolTip(tr("Extended Dynamic State is disabled on macOS due to MoltenVK " + "compatibility issues that cause black screens.")); } #endif } diff --git a/src/yuzu/configuration/configure_hotkeys.cpp b/src/yuzu/configuration/configure_hotkeys.cpp index dfd3727120..9e19cb49bf 100644 --- a/src/yuzu/configuration/configure_hotkeys.cpp +++ b/src/yuzu/configuration/configure_hotkeys.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: 2017 Citra Emulator Project @@ -13,10 +13,10 @@ #include "hid_core/hid_core.h" #include "frontend_common/config.h" +#include "qt_common/config/uisettings.h" #include "ui_configure_hotkeys.h" #include "yuzu/configuration/configure_hotkeys.h" #include "yuzu/hotkeys.h" -#include "qt_common/config/uisettings.h" #include "yuzu/util/sequence_dialog/sequence_dialog.h" constexpr int name_column = 0; diff --git a/src/yuzu/configuration/configure_input.cpp b/src/yuzu/configuration/configure_input.cpp index 1a2d36efe6..4473df901e 100644 --- a/src/yuzu/configuration/configure_input.cpp +++ b/src/yuzu/configuration/configure_input.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: 2016 Citra Emulator Project @@ -15,10 +15,10 @@ #include "core/hle/service/sm/sm.h" #include "hid_core/frontend/emulated_controller.h" #include "hid_core/hid_core.h" +#include "qt_common/qt_compat.h" #include "ui_configure_input.h" #include "ui_configure_input_advanced.h" #include "ui_configure_input_player.h" -#include "qt_common/qt_compat.h" #include "yuzu/configuration/configure_camera.h" #include "yuzu/configuration/configure_debug_controller.h" #include "yuzu/configuration/configure_input.h" @@ -102,7 +102,7 @@ void ConfigureInput::Initialize(InputCommon::InputSubsystem* input_subsystem, }; for (std::size_t i = 0; i < player_tabs.size(); ++i) { - QHBoxLayout *tab_layout = new QHBoxLayout(player_tabs[i]); + QHBoxLayout* tab_layout = new QHBoxLayout(player_tabs[i]); tab_layout->addWidget(player_controllers[i]); connect(player_controllers[i], &ConfigureInputPlayer::Connected, [this, i](bool checked) { // Ensures that connecting a controller changes the number of players @@ -125,10 +125,11 @@ void ConfigureInput::Initialize(InputCommon::InputSubsystem* input_subsystem, &ConfigureInput::UpdateAllInputDevices); connect(player_controllers[i], &ConfigureInputPlayer::RefreshInputProfiles, this, &ConfigureInput::UpdateAllInputProfiles, Qt::QueuedConnection); - connect(connected_controller_checkboxes[i], &QCheckBox::STATE_CHANGED, [this, i](int state) { - // Keep activated controllers synced with the "Connected Controllers" checkboxes - player_controllers[i]->ConnectPlayer(state == Qt::Checked); - }); + connect(connected_controller_checkboxes[i], &QCheckBox::STATE_CHANGED, + [this, i](int state) { + // Keep activated controllers synced with the "Connected Controllers" checkboxes + player_controllers[i]->ConnectPlayer(state == Qt::Checked); + }); // Remove/hide all the elements that exceed max_players, if applicable. if (i >= max_players) { diff --git a/src/yuzu/configuration/configure_input_advanced.cpp b/src/yuzu/configuration/configure_input_advanced.cpp index b1c19114bf..d8f0ab7e6c 100644 --- a/src/yuzu/configuration/configure_input_advanced.cpp +++ b/src/yuzu/configuration/configure_input_advanced.cpp @@ -9,8 +9,8 @@ #include "core/core.h" #include "hid_core/frontend/emulated_controller.h" #include "hid_core/hid_core.h" -#include "ui_configure_input_advanced.h" #include "qt_common/qt_compat.h" +#include "ui_configure_input_advanced.h" #include "yuzu/configuration/configure_input_advanced.h" ConfigureInputAdvanced::ConfigureInputAdvanced(Core::HID::HIDCore& hid_core_, QWidget* parent) diff --git a/src/yuzu/configuration/configure_input_per_game.h b/src/yuzu/configuration/configure_input_per_game.h index a1b6098dca..1e389a7a69 100644 --- a/src/yuzu/configuration/configure_input_per_game.h +++ b/src/yuzu/configuration/configure_input_per_game.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: 2022 yuzu Emulator Project @@ -10,9 +10,9 @@ #include +#include "qt_common/config/qt_config.h" #include "ui_configure_input_per_game.h" #include "yuzu/configuration/input_profiles.h" -#include "qt_common/config/qt_config.h" class QComboBox; diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index 6bc37d4347..821825f6e1 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: 2016 Citra Emulator Project @@ -14,13 +14,13 @@ #include #include "common/assert.h" #include "common/param_package.h" -#include "qt_common/config/qt_config.h" #include "hid_core/frontend/emulated_controller.h" #include "hid_core/hid_core.h" #include "hid_core/hid_types.h" #include "input_common/drivers/keyboard.h" #include "input_common/drivers/mouse.h" #include "input_common/main.h" +#include "qt_common/config/qt_config.h" #include "ui_configure_input_player.h" #include "yuzu/bootmanager.h" #include "yuzu/configuration/configure_input_player.h" @@ -294,11 +294,11 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i InputCommon::InputSubsystem* input_subsystem_, InputProfiles* profiles_, Core::HID::HIDCore& hid_core_, bool is_powered_on_, bool debug_) - : QWidget(parent), - ui(std::make_unique()), player_index{player_index_}, debug{debug_}, - is_powered_on{is_powered_on_}, input_subsystem{input_subsystem_}, profiles(profiles_), - timeout_timer(std::make_unique()), - poll_timer(std::make_unique()), bottom_row{bottom_row_}, hid_core{hid_core_} { + : QWidget(parent), ui(std::make_unique()), + player_index{player_index_}, debug{debug_}, is_powered_on{is_powered_on_}, + input_subsystem{input_subsystem_}, profiles(profiles_), + timeout_timer(std::make_unique()), poll_timer(std::make_unique()), + bottom_row{bottom_row_}, hid_core{hid_core_} { if (player_index == 0) { auto* emulated_controller_p1 = hid_core.GetEmulatedController(Core::HID::NpadIdType::Player1); @@ -1215,10 +1215,8 @@ void ConfigureInputPlayer::UpdateControllerAvailableButtons() { case Core::HID::NpadStyleIndex::Fullkey: case Core::HID::NpadStyleIndex::Handheld: layout_hidden = { - ui->buttonShoulderButtonsSLSRLeft, - ui->buttonShoulderButtonsSLSRRight, - ui->horizontalSpacerShoulderButtonsWidget2, - ui->horizontalSpacerShoulderButtonsWidget4, + ui->buttonShoulderButtonsSLSRLeft, ui->buttonShoulderButtonsSLSRRight, + ui->horizontalSpacerShoulderButtonsWidget2, ui->horizontalSpacerShoulderButtonsWidget4, ui->buttonMiscButtonsScreenshotGroup, }; break; diff --git a/src/yuzu/configuration/configure_input_player_widget.cpp b/src/yuzu/configuration/configure_input_player_widget.cpp index 3228b5f17f..790a860002 100644 --- a/src/yuzu/configuration/configure_input_player_widget.cpp +++ b/src/yuzu/configuration/configure_input_player_widget.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project @@ -2432,7 +2432,8 @@ void PlayerControlPreview::DrawProJoystick(QPainter& p, const QPointF center, co 1.0 - std::sqrt((offset.x() * offset.x()) + (offset.y() * offset.y())) * 0.1f); const float rotation = - ((offset.x() == 0.f) ? std::atan(1.f) * 2.f : std::atan(offset.y() / offset.x())) * (180.f / (std::atan(1.f) * 4.f)); + ((offset.x() == 0.f) ? std::atan(1.f) * 2.f : std::atan(offset.y() / offset.x())) * + (180.f / (std::atan(1.f) * 4.f)); p.save(); p.translate(offset_center); diff --git a/src/yuzu/configuration/configure_network.cpp b/src/yuzu/configuration/configure_network.cpp index 62a097117e..b1fdd018fd 100644 --- a/src/yuzu/configuration/configure_network.cpp +++ b/src/yuzu/configuration/configure_network.cpp @@ -12,10 +12,7 @@ #include "yuzu/configuration/configure_network.h" ConfigureNetwork::ConfigureNetwork(const Core::System& system_, QWidget* parent) - : QWidget(parent) - , ui(std::make_unique()) - , system{system_} -{ + : QWidget(parent), ui(std::make_unique()), system{system_} { ui->setupUi(this); for (const auto& iface : Network::GetAvailableNetworkInterfaces()) ui->network_interface->addItem(QString::fromStdString(iface.name)); diff --git a/src/yuzu/configuration/configure_per_game.cpp b/src/yuzu/configuration/configure_per_game.cpp index 00e0a14aa3..dcf40d678f 100644 --- a/src/yuzu/configuration/configure_per_game.cpp +++ b/src/yuzu/configuration/configure_per_game.cpp @@ -29,28 +29,28 @@ #include "core/file_sys/xts_archive.h" #include "core/loader/loader.h" #include "frontend_common/config.h" +#include "qt_common/config/uisettings.h" #include "ui_configure_per_game.h" #include "yuzu/configuration/configuration_shared.h" +#include "yuzu/configuration/configure_applets.h" #include "yuzu/configuration/configure_audio.h" #include "yuzu/configuration/configure_cpu.h" #include "yuzu/configuration/configure_graphics.h" #include "yuzu/configuration/configure_graphics_advanced.h" #include "yuzu/configuration/configure_graphics_extensions.h" #include "yuzu/configuration/configure_input_per_game.h" +#include "yuzu/configuration/configure_network.h" #include "yuzu/configuration/configure_per_game.h" #include "yuzu/configuration/configure_per_game_addons.h" #include "yuzu/configuration/configure_system.h" -#include "yuzu/configuration/configure_network.h" -#include "yuzu/configuration/configure_applets.h" -#include "qt_common/config/uisettings.h" #include "yuzu/util/util.h" #include "yuzu/vk_device_info.h" ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id_, const std::string& file_name, std::vector& vk_device_records, Core::System& system_) - : QDialog(parent), - ui(std::make_unique()), title_id{title_id_}, system{system_}, + : QDialog(parent), ui(std::make_unique()), title_id{title_id_}, + system{system_}, builder{std::make_unique(this, !system_.IsPoweredOn())}, tab_group{std::make_shared>()} { const auto file_path = std::filesystem::path(Common::FS::ToU8String(file_name)); diff --git a/src/yuzu/configuration/configure_per_game.h b/src/yuzu/configuration/configure_per_game.h index 442daab9cb..ca973db8b0 100644 --- a/src/yuzu/configuration/configure_per_game.h +++ b/src/yuzu/configuration/configure_per_game.h @@ -16,10 +16,10 @@ #include "configuration/shared_widget.h" #include "core/file_sys/vfs/vfs_types.h" #include "frontend_common/config.h" -#include "vk_device_info.h" -#include "yuzu/configuration/configuration_shared.h" #include "qt_common/config/qt_config.h" #include "qt_common/config/shared_translation.h" +#include "vk_device_info.h" +#include "yuzu/configuration/configuration_shared.h" namespace Core { class System; diff --git a/src/yuzu/configuration/configure_per_game_addons.cpp b/src/yuzu/configuration/configure_per_game_addons.cpp index 1d2d358672..7d0e15accc 100644 --- a/src/yuzu/configuration/configure_per_game_addons.cpp +++ b/src/yuzu/configuration/configure_per_game_addons.cpp @@ -80,7 +80,8 @@ ConfigurePerGameAddons::ConfigurePerGameAddons(Core::System& system_, QWidget* p connect(ui->folder, &QAbstractButton::clicked, this, &ConfigurePerGameAddons::InstallModFolder); connect(ui->zip, &QAbstractButton::clicked, this, &ConfigurePerGameAddons::InstallModZip); - connect(tree_view, &QTreeView::customContextMenuRequested, this, &ConfigurePerGameAddons::showContextMenu); + connect(tree_view, &QTreeView::customContextMenuRequested, this, + &ConfigurePerGameAddons::showContextMenu); } ConfigurePerGameAddons::~ConfigurePerGameAddons() = default; @@ -92,10 +93,10 @@ void ConfigurePerGameAddons::OnItemChanged(QStandardItem* item) { for (auto* update_item : update_items) { if (update_item != item && update_item->checkState() == Qt::Checked) { disconnect(item_model, &QStandardItemModel::itemChanged, this, - &ConfigurePerGameAddons::OnItemChanged); + &ConfigurePerGameAddons::OnItemChanged); update_item->setCheckState(Qt::Unchecked); connect(item_model, &QStandardItemModel::itemChanged, this, - &ConfigurePerGameAddons::OnItemChanged); + &ConfigurePerGameAddons::OnItemChanged); } } } @@ -109,7 +110,8 @@ void ConfigurePerGameAddons::ApplyConfiguration() { const auto disabled = item.front()->checkState() == Qt::Unchecked; if (disabled) { QVariant userData = item.front()->data(Qt::UserRole); - if (userData.isValid() && userData.canConvert() && item.front()->text() == QStringLiteral("Update")) { + if (userData.isValid() && userData.canConvert() && + item.front()->text() == QStringLiteral("Update")) { quint32 numeric_version = userData.toUInt(); disabled_addons.push_back(fmt::format("Update@{}", numeric_version)); } else { @@ -164,7 +166,7 @@ void ConfigurePerGameAddons::InstallMods(const QStringList& mods) { } } -void ConfigurePerGameAddons::InstallModPath(const QString& path, const QString &fallbackName) { +void ConfigurePerGameAddons::InstallModPath(const QString& path, const QString& fallbackName) { const auto mods = QtCommon::Mod::GetModFolders(path, fallbackName); if (mods.size() > 1) { @@ -203,8 +205,9 @@ void ConfigurePerGameAddons::InstallModZip() { void ConfigurePerGameAddons::AddonDeleteRequested(QList selected) { QList filtered; - for (const QModelIndex &index : selected) { - if (!index.data(PATCH_LOCATION).toString().isEmpty()) filtered << index; + for (const QModelIndex& index : selected) { + if (!index.data(PATCH_LOCATION).toString().isEmpty()) + filtered << index; } if (filtered.empty()) { @@ -215,10 +218,9 @@ void ConfigurePerGameAddons::AddonDeleteRequested(QList selected) { return; } - const auto header = tr("You are about to delete the following installed mods:\n"); QString selected_str; - for (const QModelIndex &index : filtered) { + for (const QModelIndex& index : filtered) { selected_str = selected_str % index.data().toString() % QStringLiteral("\n"); } @@ -231,9 +233,10 @@ void ConfigurePerGameAddons::AddonDeleteRequested(QList selected) { QtCommon::Frontend::StandardButton::Yes | QtCommon::Frontend::StandardButton::No); - if (choice == QtCommon::Frontend::StandardButton::No) return; + if (choice == QtCommon::Frontend::StandardButton::No) + return; - for (const QModelIndex &index : filtered) { + for (const QModelIndex& index : filtered) { std::filesystem::remove_all(index.data(PATCH_LOCATION).toString().toStdString()); } @@ -252,17 +255,18 @@ void ConfigurePerGameAddons::showContextMenu(const QPoint& pos) { auto selected = tree_view->selectionModel()->selectedRows(); if (index.isValid() && selected.empty()) { QModelIndex idx = item_model->index(index.row(), 0); - if (idx.isValid()) selected << idx; + if (idx.isValid()) + selected << idx; } - if (selected.empty()) return; + if (selected.empty()) + return; QMenu menu(this); - QAction *remove = menu.addAction(tr("&Delete")); - connect(remove, &QAction::triggered, this, [this, selected]() { - AddonDeleteRequested(selected); - }); + QAction* remove = menu.addAction(tr("&Delete")); + connect(remove, &QAction::triggered, this, + [this, selected]() { AddonDeleteRequested(selected); }); if (selected.length() == 1) { auto loc = selected.at(0).data(PATCH_LOCATION).toString(); @@ -333,9 +337,11 @@ void ConfigurePerGameAddons::LoadConfiguration() { bool patch_disabled = false; if (is_external_update) { std::string disabled_key = fmt::format("Update@{}", patch.numeric_version); - patch_disabled = std::find(disabled.begin(), disabled.end(), disabled_key) != disabled.end(); + patch_disabled = + std::find(disabled.begin(), disabled.end(), disabled_key) != disabled.end(); } else { - patch_disabled = std::find(disabled.begin(), disabled.end(), name.toStdString()) != disabled.end(); + patch_disabled = + std::find(disabled.begin(), disabled.end(), name.toStdString()) != disabled.end(); } bool should_enable = !patch_disabled; diff --git a/src/yuzu/configuration/configure_per_game_addons.h b/src/yuzu/configuration/configure_per_game_addons.h index 20ab39541b..9dd3b06928 100644 --- a/src/yuzu/configuration/configure_per_game_addons.h +++ b/src/yuzu/configuration/configure_per_game_addons.h @@ -32,10 +32,7 @@ class ConfigurePerGameAddons : public QWidget { Q_OBJECT public: - enum PatchData { - NUMERIC_VERSION = Qt::UserRole, - PATCH_LOCATION - }; + enum PatchData { NUMERIC_VERSION = Qt::UserRole, PATCH_LOCATION }; explicit ConfigurePerGameAddons(Core::System& system_, QWidget* parent = nullptr); ~ConfigurePerGameAddons() override; @@ -48,7 +45,7 @@ public: void SetTitleId(u64 id); public slots: - void InstallMods(const QStringList &mods); + void InstallMods(const QStringList& mods); void InstallModPath(const QString& path, const QString& fallbackName = {}); void InstallModFolder(); diff --git a/src/yuzu/configuration/configure_profile_manager.cpp b/src/yuzu/configuration/configure_profile_manager.cpp index aa19203498..0d86fb5ef9 100644 --- a/src/yuzu/configuration/configure_profile_manager.cpp +++ b/src/yuzu/configuration/configure_profile_manager.cpp @@ -106,7 +106,8 @@ ConfigureProfileManager::ConfigureProfileManager(Core::System& system_, QWidget* ui->scrollArea->setLayout(layout); - connect(tree_view, &QTreeView::customContextMenuRequested, this, &ConfigureProfileManager::showContextMenu); + connect(tree_view, &QTreeView::customContextMenuRequested, this, + &ConfigureProfileManager::showContextMenu); connect(tree_view, &QTreeView::clicked, this, &ConfigureProfileManager::SelectUser); @@ -229,8 +230,7 @@ void ConfigureProfileManager::showContextMenu(const QPoint& pos) { QAction* edit = menu.addAction(tr("&Edit")); QAction* remove = menu.addAction(tr("&Delete")); - QAction* chosen = - menu.exec(tree_view->viewport()->mapToGlobal(pos)); + QAction* chosen = menu.exec(tree_view->viewport()->mapToGlobal(pos)); if (!chosen) return; @@ -250,7 +250,7 @@ void ConfigureProfileManager::SelectUser(const QModelIndex& index) { } void ConfigureProfileManager::AddUser() { - NewUserDialog *dialog = new NewUserDialog(this); + NewUserDialog* dialog = new NewUserDialog(this); connect(dialog, &NewUserDialog::userAdded, this, [dialog, this](User user) { auto uuid = user.uuid; @@ -285,35 +285,37 @@ void ConfigureProfileManager::EditUser() { std::string username; username.reserve(32); - std::ranges::copy_if(profile.username, std::back_inserter(username), [](u8 byte) { return byte != 0; }); + std::ranges::copy_if(profile.username, std::back_inserter(username), + [](u8 byte) { return byte != 0; }); - NewUserDialog *dialog = new NewUserDialog(uuid.value(), username, tr("Edit User"), this); + NewUserDialog* dialog = new NewUserDialog(uuid.value(), username, tr("Edit User"), this); - connect(dialog, &NewUserDialog::userAdded, this, [dialog, profile, user_idx, uuid, this](User user) mutable { - // TODO: MOVE UUID - // auto new_uuid = user.uuid; - auto new_username = user.username; - auto pixmap = user.pixmap; + connect(dialog, &NewUserDialog::userAdded, this, + [dialog, profile, user_idx, uuid, this](User user) mutable { + // TODO: MOVE UUID + // auto new_uuid = user.uuid; + auto new_username = user.username; + auto pixmap = user.pixmap; - auto const uuid_val = uuid.value(); + auto const uuid_val = uuid.value(); - const auto username_std = new_username.toStdString(); - std::fill(profile.username.begin(), profile.username.end(), '\0'); - std::copy(username_std.begin(), username_std.end(), profile.username.begin()); + const auto username_std = new_username.toStdString(); + std::fill(profile.username.begin(), profile.username.end(), '\0'); + std::copy(username_std.begin(), username_std.end(), profile.username.begin()); - profile_manager.SetProfileBase(uuid_val, profile); - profile_manager.WriteUserSaveFile(); + profile_manager.SetProfileBase(uuid_val, profile); + profile_manager.WriteUserSaveFile(); - item_model->setItem( - user_idx, 0, - new QStandardItem{pixmap, - FormatUserEntryText(QString::fromStdString(username_std), uuid_val)}); + item_model->setItem( + user_idx, 0, + new QStandardItem{pixmap, FormatUserEntryText( + QString::fromStdString(username_std), uuid_val)}); - saveImage(pixmap, uuid_val); - UpdateCurrentUser(); + saveImage(pixmap, uuid_val); + UpdateCurrentUser(); - dialog->deleteLater(); - }); + dialog->deleteLater(); + }); connect(dialog, &QDialog::rejected, dialog, &QObject::deleteLater); diff --git a/src/yuzu/configuration/configure_profile_manager.h b/src/yuzu/configuration/configure_profile_manager.h index 6e8c762452..48cd5d215f 100644 --- a/src/yuzu/configuration/configure_profile_manager.h +++ b/src/yuzu/configuration/configure_profile_manager.h @@ -47,8 +47,7 @@ public: explicit ConfigureProfileManagerDeleteDialog(QWidget* parent); ~ConfigureProfileManagerDeleteDialog(); - void SetInfo(const QString& username, const Common::UUID& uuid, - int index); + void SetInfo(const QString& username, const Common::UUID& uuid, int index); signals: void deleteUser(int index); @@ -71,7 +70,7 @@ public: private slots: void saveImage(QPixmap pixmap, Common::UUID uuid); - void showContextMenu(const QPoint &pos); + void showContextMenu(const QPoint& pos); void DeleteUser(const int index); private: diff --git a/src/yuzu/configuration/configure_ringcon.cpp b/src/yuzu/configuration/configure_ringcon.cpp index dfb1540584..4c842bd069 100644 --- a/src/yuzu/configuration/configure_ringcon.cpp +++ b/src/yuzu/configuration/configure_ringcon.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project @@ -11,12 +11,12 @@ #include #include -#include "qt_common/config/qt_config.h" #include "hid_core/frontend/emulated_controller.h" #include "hid_core/hid_core.h" #include "input_common/drivers/keyboard.h" #include "input_common/drivers/mouse.h" #include "input_common/main.h" +#include "qt_common/config/qt_config.h" #include "ui_configure_ringcon.h" #include "yuzu/bootmanager.h" #include "yuzu/configuration/configure_ringcon.h" diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index 56e3e29f90..36920b1ff9 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: 2016 Citra Emulator Project @@ -19,8 +19,8 @@ #include "common/settings.h" #include "core/core.h" -#include "ui_configure_system.h" #include "qt_common/qt_compat.h" +#include "ui_configure_system.h" #include "yuzu/configuration/configuration_shared.h" #include "yuzu/configuration/configure_system.h" #include "yuzu/configuration/shared_widget.h" @@ -87,7 +87,8 @@ ConfigureSystem::ConfigureSystem(Core::System& system_, connect(combo_language, qOverload(&QComboBox::currentIndexChanged), this, locale_check); connect(combo_region, qOverload(&QComboBox::currentIndexChanged), this, locale_check); - connect(checkbox_rtc, qOverload(&QCheckBox::STATE_CHANGED), this, update_rtc_date); + connect(checkbox_rtc, qOverload(&QCheckBox::STATE_CHANGED), this, + update_rtc_date); connect(date_rtc_offset, qOverload(&QSpinBox::valueChanged), this, update_rtc_date); connect(date_rtc, &QDateTimeEdit::dateTimeChanged, this, update_date_offset); diff --git a/src/yuzu/configuration/configure_tas.cpp b/src/yuzu/configuration/configure_tas.cpp index 75d5a5eeaf..d737b46d2c 100644 --- a/src/yuzu/configuration/configure_tas.cpp +++ b/src/yuzu/configuration/configure_tas.cpp @@ -9,9 +9,9 @@ #include "common/fs/fs.h" #include "common/fs/path_util.h" #include "common/settings.h" +#include "qt_common/config/uisettings.h" #include "ui_configure_tas.h" #include "yuzu/configuration/configure_tas.h" -#include "qt_common/config/uisettings.h" ConfigureTasDialog::ConfigureTasDialog(QWidget* parent) : QDialog(parent), ui(std::make_unique()) { @@ -35,7 +35,8 @@ void ConfigureTasDialog::LoadConfiguration() { ui->tas_enable->setChecked(Settings::values.tas_enable.GetValue()); ui->tas_loop_script->setChecked(Settings::values.tas_loop.GetValue()); ui->tas_pause_on_load->setChecked(Settings::values.pause_tas_on_load.GetValue()); - ui->tas_show_recording_dialog->setChecked(Settings::values.tas_show_recording_dialog.GetValue()); + ui->tas_show_recording_dialog->setChecked( + Settings::values.tas_show_recording_dialog.GetValue()); } void ConfigureTasDialog::ApplyConfiguration() { diff --git a/src/yuzu/configuration/configure_touch_from_button.cpp b/src/yuzu/configuration/configure_touch_from_button.cpp index 2a4ae3bc89..bbd52e4bfa 100644 --- a/src/yuzu/configuration/configure_touch_from_button.cpp +++ b/src/yuzu/configuration/configure_touch_from_button.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later #include @@ -548,9 +548,8 @@ bool TouchScreenPreview::eventFilter(QObject* obj, QEvent* event) { } const auto mouse_event = static_cast(event); if (!drag_state.active) { - drag_state.active = - (mouse_event->globalPosition().toPoint() - drag_state.start_pos).manhattanLength() >= - QApplication::startDragDistance(); + drag_state.active = (mouse_event->globalPosition().toPoint() - drag_state.start_pos) + .manhattanLength() >= QApplication::startDragDistance(); if (!drag_state.active) { break; } diff --git a/src/yuzu/configuration/configure_ui.cpp b/src/yuzu/configuration/configure_ui.cpp index 0e91a1a9fd..af8d9fecce 100644 --- a/src/yuzu/configuration/configure_ui.cpp +++ b/src/yuzu/configuration/configure_ui.cpp @@ -26,8 +26,8 @@ #include "core/frontend/framebuffer_layout.h" #include "ui_configure_ui.h" -#include "qt_common/qt_compat.h" #include "qt_common/config/uisettings.h" +#include "qt_common/qt_compat.h" namespace { diff --git a/src/yuzu/configuration/configure_web.cpp b/src/yuzu/configuration/configure_web.cpp index c5e9256a48..987de5989a 100644 --- a/src/yuzu/configuration/configure_web.cpp +++ b/src/yuzu/configuration/configure_web.cpp @@ -1,12 +1,12 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: 2017 Citra Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include "yuzu/configuration/configure_web.h" #include #include +#include "yuzu/configuration/configure_web.h" #if QT_VERSION_MAJOR >= 6 #include @@ -16,28 +16,25 @@ #include #include "common/settings.h" -#include "ui_configure_web.h" #include "qt_common/config/uisettings.h" +#include "ui_configure_web.h" ConfigureWeb::ConfigureWeb(QWidget* parent) - : QWidget(parent) - , ui(std::make_unique()) - , m_rng{QRandomGenerator::system()} -{ + : QWidget(parent), ui(std::make_unique()), m_rng{QRandomGenerator::system()} { ui->setupUi(this); QString user_regex = QStringLiteral(".{4,20}"); QString token_regex = QStringLiteral("[a-z]{48}"); #if QT_VERSION_MAJOR >= 6 - QRegularExpressionValidator *username_validator = new QRegularExpressionValidator(this); - QRegularExpressionValidator *token_validator = new QRegularExpressionValidator(this); + QRegularExpressionValidator* username_validator = new QRegularExpressionValidator(this); + QRegularExpressionValidator* token_validator = new QRegularExpressionValidator(this); username_validator->setRegularExpression(QRegularExpression(user_regex)); token_validator->setRegularExpression(QRegularExpression(token_regex)); #else - QRegExpValidator *username_validator = new QRegExpValidator(this); - QRegExpValidator *token_validator = new QRegExpValidator(this); + QRegExpValidator* username_validator = new QRegExpValidator(this); + QRegExpValidator* token_validator = new QRegExpValidator(this); username_validator->setRegExp(QRegExp(user_regex)); token_validator->setRegExp(QRegExp(token_regex)); @@ -121,7 +118,8 @@ void ConfigureWeb::VerifyLogin() { ui->label_token_verified->setToolTip(tr("All Good", "Tooltip")); } else { ui->label_token_verified->setPixmap(failed); - ui->label_token_verified->setToolTip(tr("Must be 48 characters, and lowercase a-z", "Tooltip")); + ui->label_token_verified->setToolTip( + tr("Must be 48 characters, and lowercase a-z", "Tooltip")); } } diff --git a/src/yuzu/configuration/configure_web.h b/src/yuzu/configuration/configure_web.h index 3da7e5eccc..d37db5c020 100644 --- a/src/yuzu/configuration/configure_web.h +++ b/src/yuzu/configuration/configure_web.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: 2017 Citra Emulator Project @@ -8,8 +8,8 @@ #include -#include #include +#include namespace Ui { class ConfigureWeb; @@ -32,7 +32,7 @@ private: void SetConfiguration(); std::unique_ptr ui; - QRandomGenerator *m_rng; + QRandomGenerator* m_rng; private slots: void GenerateToken(); diff --git a/src/yuzu/configuration/shared_widget.cpp b/src/yuzu/configuration/shared_widget.cpp index b663ac51ee..3b425e7200 100644 --- a/src/yuzu/configuration/shared_widget.cpp +++ b/src/yuzu/configuration/shared_widget.cpp @@ -45,8 +45,8 @@ #include "common/logging/log.h" #include "common/settings.h" #include "common/settings_common.h" -#include "qt_common/qt_compat.h" #include "qt_common/config/shared_translation.h" +#include "qt_common/qt_compat.h" namespace ConfigurationShared { @@ -170,7 +170,7 @@ QWidget* Widget::CreateCombobox(std::function& serializer, if (!Settings::IsConfiguringGlobal()) { combobox->connect(combobox, QOverload::of(&QComboBox::activated), - [touch]() { touch(); }); + [touch]() { touch(); }); } return combobox; @@ -413,13 +413,13 @@ QWidget* Widget::CreateDoubleSpinBox(const QString& given_suffix, }; if (!Settings::IsConfiguringGlobal()) { - double_spinbox->connect(double_spinbox, QOverload::of(&QDoubleSpinBox::valueChanged), - [this, touch]() { - if (double_spinbox->value() != - std::strtod(setting.ToStringGlobal().c_str(), nullptr)) { - touch(); - } - }); + double_spinbox->connect( + double_spinbox, QOverload::of(&QDoubleSpinBox::valueChanged), [this, touch]() { + if (double_spinbox->value() != + std::strtod(setting.ToStringGlobal().c_str(), nullptr)) { + touch(); + } + }); } return double_spinbox; @@ -491,11 +491,11 @@ QWidget* Widget::CreateDateTimeEdit(bool disabled, bool restrict, if (!Settings::IsConfiguringGlobal()) { date_time_edit->connect(date_time_edit, &QDateTimeEdit::editingFinished, - [this, get_clear_val, touch]() { - if (date_time_edit->dateTime() != get_clear_val()) { - touch(); - } - }); + [this, get_clear_val, touch]() { + if (date_time_edit->dateTime() != get_clear_val()) { + touch(); + } + }); } return date_time_edit; @@ -570,7 +570,8 @@ void Widget::SetupComponent(const QString& label, std::function& load_fu } if (require_checkbox) { - QWidget* lhs = CreateCheckBox(other_setting, label, checkbox_serializer, checkbox_restore_func, touch); + QWidget* lhs = + CreateCheckBox(other_setting, label, checkbox_serializer, checkbox_restore_func, touch); layout->addWidget(lhs, 1); } else if (type_id != "bool") { QLabel* qt_label = CreateLabel(label); @@ -665,16 +666,16 @@ void Widget::SetupComponent(const QString& label, std::function& load_fu layout->addWidget(restore_button); restore_button->connect(restore_button, &QAbstractButton::clicked, - [this, restore_func, checkbox_restore_func](bool) { - LOG_DEBUG(Frontend, "Restore global state for \"{}\"", - setting.GetLabel()); + [this, restore_func, checkbox_restore_func](bool) { + LOG_DEBUG(Frontend, "Restore global state for \"{}\"", + setting.GetLabel()); - restore_button->setEnabled(false); - restore_button->setVisible(false); + restore_button->setEnabled(false); + restore_button->setVisible(false); - checkbox_restore_func(); - restore_func(); - }); + checkbox_restore_func(); + restore_func(); + }); load_func = [this, serializer, require_checkbox, checkbox_serializer, other_setting]() { bool using_global = !restore_button->isEnabled(); @@ -766,8 +767,8 @@ Widget::Widget(Settings::BasicSetting* setting_, const TranslationMap& translati Builder::Builder(QWidget* parent_, bool runtime_lock_) : translations{InitializeTranslations(parent_)}, - combobox_translations{ComboboxEnumeration(parent_)}, parent{parent_}, runtime_lock{ - runtime_lock_} {} + combobox_translations{ComboboxEnumeration(parent_)}, parent{parent_}, + runtime_lock{runtime_lock_} {} Builder::~Builder() = default; diff --git a/src/yuzu/configuration/shared_widget.h b/src/yuzu/configuration/shared_widget.h index b07804ac00..f687d0b20c 100644 --- a/src/yuzu/configuration/shared_widget.h +++ b/src/yuzu/configuration/shared_widget.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project @@ -10,10 +10,10 @@ #include #include #include +#include #include #include #include -#include #include #include "qt_common/config/shared_translation.h" diff --git a/src/yuzu/configuration/system/new_user_dialog.h b/src/yuzu/configuration/system/new_user_dialog.h index 656d8d7290..e81007aefe 100644 --- a/src/yuzu/configuration/system/new_user_dialog.h +++ b/src/yuzu/configuration/system/new_user_dialog.h @@ -20,15 +20,15 @@ struct User { QPixmap pixmap; }; -class NewUserDialog : public QDialog -{ +class NewUserDialog : public QDialog { Q_OBJECT Q_PROPERTY(bool isDefaultAvatar READ isDefaultAvatar WRITE setIsDefaultAvatar NOTIFY isDefaultAvatarChanged FINAL) public: - explicit NewUserDialog(QWidget *parent = nullptr); - explicit NewUserDialog(Common::UUID uuid, const std::string &username, const QString &title, QWidget *parent = nullptr); + explicit NewUserDialog(QWidget* parent = nullptr); + explicit NewUserDialog(Common::UUID uuid, const std::string& username, const QString& title, + QWidget* parent = nullptr); ~NewUserDialog(); bool isDefaultAvatar() const; @@ -39,8 +39,8 @@ public: static QPixmap DefaultAvatar(); private: - Ui::NewUserDialog *ui; - QGraphicsScene *m_scene; + Ui::NewUserDialog* ui; + QGraphicsScene* m_scene; QPixmap m_pixmap; ProfileAvatarDialog* avatar_dialog; @@ -48,12 +48,12 @@ private: bool m_isDefaultAvatar = true; bool m_editing = false; - void setup(Common::UUID uuid, const std::string &username, const QString &title); + void setup(Common::UUID uuid, const std::string& username, const QString& title); bool LoadAvatarData(); std::vector DecompressYaz0(const FileSys::VirtualFile& file); public slots: - void setImage(const QPixmap &pixmap); + void setImage(const QPixmap& pixmap); void selectImage(); void setAvatar(); diff --git a/src/yuzu/data_dialog.cpp b/src/yuzu/data_dialog.cpp index 8caa362bdf..bbe5d43e05 100644 --- a/src/yuzu/data_dialog.cpp +++ b/src/yuzu/data_dialog.cpp @@ -1,10 +1,10 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later #include "data_dialog.h" #include "frontend_common/data_manager.h" -#include "qt_common/util/content.h" #include "qt_common/qt_string_lookup.h" +#include "qt_common/util/content.h" #include "ui_data_dialog.h" #include "util/util.h" @@ -18,18 +18,14 @@ #include -DataDialog::DataDialog(QWidget *parent) - : QDialog(parent) - , ui(std::make_unique()) -{ +DataDialog::DataDialog(QWidget* parent) : QDialog(parent), ui(std::make_unique()) { ui->setupUi(this); // TODO: Should we make this a single widget that pulls data from a model? -#define WIDGET(label, name) \ - ui->page->addWidget(new DataWidget(FrontendCommon::DataManager::DataDir::name, \ - QtCommon::StringLookup::DataManager##name##Tooltip, \ - QStringLiteral(#name), \ - this)); \ +#define WIDGET(label, name) \ + ui->page->addWidget(new DataWidget(FrontendCommon::DataManager::DataDir::name, \ + QtCommon::StringLookup::DataManager##name##Tooltip, \ + QStringLiteral(#name), this)); \ ui->labels->addItem(label); WIDGET(tr("Shaders"), Shaders) @@ -53,14 +49,10 @@ DataDialog::DataDialog(QWidget *parent) DataDialog::~DataDialog() = default; DataWidget::DataWidget(FrontendCommon::DataManager::DataDir data_dir, - QtCommon::StringLookup::StringKey tooltip, - const QString &exportName, - QWidget *parent) - : QWidget(parent) - , ui(std::make_unique()) - , m_dir(data_dir) - , m_exportName(exportName) -{ + QtCommon::StringLookup::StringKey tooltip, const QString& exportName, + QWidget* parent) + : QWidget(parent), ui(std::make_unique()), m_dir(data_dir), + m_exportName(exportName) { ui->setupUi(this); ui->tooltip->setText(QtCommon::StringLookup::Lookup(tooltip)); @@ -78,28 +70,24 @@ DataWidget::DataWidget(FrontendCommon::DataManager::DataDir data_dir, scan(); } -void DataWidget::clear() -{ +void DataWidget::clear() { std::string user_id = selectProfile(); QtCommon::Content::ClearDataDir(m_dir, user_id); scan(); } -void DataWidget::open() -{ +void DataWidget::open() { std::string user_id = selectProfile(); QDesktopServices::openUrl(QUrl::fromLocalFile( QString::fromStdString(FrontendCommon::DataManager::GetDataDirString(m_dir, user_id)))); } -void DataWidget::upload() -{ +void DataWidget::upload() { std::string user_id = selectProfile(); QtCommon::Content::ExportDataDir(m_dir, user_id, m_exportName); } -void DataWidget::download() -{ +void DataWidget::download() { std::string user_id = selectProfile(); QtCommon::Content::ImportDataDir(m_dir, user_id, std::bind(&DataWidget::scan, this)); } @@ -107,7 +95,7 @@ void DataWidget::download() void DataWidget::scan() { ui->size->setText(tr("Calculating...")); - QFutureWatcher *watcher = new QFutureWatcher(this); + QFutureWatcher* watcher = new QFutureWatcher(this); connect(watcher, &QFutureWatcher::finished, this, [=, this]() { u64 size = watcher->result(); @@ -120,8 +108,7 @@ void DataWidget::scan() { QtConcurrent::run([this]() { return FrontendCommon::DataManager::DataDirSize(m_dir); })); } -std::string DataWidget::selectProfile() -{ +std::string DataWidget::selectProfile() { std::string user_id{}; if (m_dir == FrontendCommon::DataManager::DataDir::Saves) { user_id = GetProfileIDString(); diff --git a/src/yuzu/data_dialog.h b/src/yuzu/data_dialog.h index 70714be7cb..7f988f6047 100644 --- a/src/yuzu/data_dialog.h +++ b/src/yuzu/data_dialog.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later #ifndef DATA_DIALOG_H @@ -14,26 +14,23 @@ namespace Ui { class DataDialog; } -class DataDialog : public QDialog -{ +class DataDialog : public QDialog { Q_OBJECT public: - explicit DataDialog(QWidget *parent = nullptr); + explicit DataDialog(QWidget* parent = nullptr); ~DataDialog(); private: std::unique_ptr ui; }; -class DataWidget : public QWidget -{ +class DataWidget : public QWidget { Q_OBJECT public: explicit DataWidget(FrontendCommon::DataManager::DataDir data_dir, - QtCommon::StringLookup::StringKey tooltip, - const QString &exportName, - QWidget *parent = nullptr); + QtCommon::StringLookup::StringKey tooltip, const QString& exportName, + QWidget* parent = nullptr); public slots: void clear(); diff --git a/src/yuzu/debugger/console.cpp b/src/yuzu/debugger/console.cpp index e93a8b9265..44d4e1db7b 100644 --- a/src/yuzu/debugger/console.cpp +++ b/src/yuzu/debugger/console.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project @@ -11,8 +11,8 @@ #endif #include "common/logging/backend.h" -#include "yuzu/debugger/console.h" #include "qt_common/config/uisettings.h" +#include "yuzu/debugger/console.h" namespace Debugger { void ToggleConsole() { diff --git a/src/yuzu/deps_dialog.cpp b/src/yuzu/deps_dialog.cpp index ffbd0a0e74..e490bfc163 100644 --- a/src/yuzu/deps_dialog.cpp +++ b/src/yuzu/deps_dialog.cpp @@ -1,24 +1,21 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later -#include "yuzu/deps_dialog.h" #include #include #include #include #include #include +#include #include "dep_hashes.h" #include "ui_deps_dialog.h" -#include +#include "yuzu/deps_dialog.h" -DepsDialog::DepsDialog(QWidget* parent) - : QDialog(parent) - , ui{std::make_unique()} -{ +DepsDialog::DepsDialog(QWidget* parent) : QDialog(parent), ui{std::make_unique()} { ui->setupUi(this); - constexpr int rows = (int) Common::dep_hashes.size(); + constexpr int rows = (int)Common::dep_hashes.size(); ui->tableDeps->setRowCount(rows); QStringList labels; @@ -36,8 +33,8 @@ DepsDialog::DepsDialog(QWidget* parent) std::string dependency = fmt::format("{}", url, name); - QTableWidgetItem *nameItem = new QTableWidgetItem(QString::fromStdString(dependency)); - QTableWidgetItem *shaItem = new QTableWidgetItem(QString::fromStdString(sha)); + QTableWidgetItem* nameItem = new QTableWidgetItem(QString::fromStdString(dependency)); + QTableWidgetItem* shaItem = new QTableWidgetItem(QString::fromStdString(sha)); ui->tableDeps->setItem(i, 0, nameItem); ui->tableDeps->setItem(i, 1, shaItem); @@ -48,14 +45,10 @@ DepsDialog::DepsDialog(QWidget* parent) DepsDialog::~DepsDialog() = default; -LinkItemDelegate::LinkItemDelegate(QObject *parent) - : QStyledItemDelegate(parent) -{} +LinkItemDelegate::LinkItemDelegate(QObject* parent) : QStyledItemDelegate(parent) {} -void LinkItemDelegate::paint(QPainter *painter, - const QStyleOptionViewItem &option, - const QModelIndex &index) const -{ +void LinkItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, + const QModelIndex& index) const { auto options = option; initStyleOption(&options, index); @@ -71,8 +64,8 @@ void LinkItemDelegate::paint(QPainter *painter, painter->restore(); } -QSize LinkItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const -{ +QSize LinkItemDelegate::sizeHint(const QStyleOptionViewItem& option, + const QModelIndex& index) const { QStyleOptionViewItem options = option; initStyleOption(&options, index); @@ -82,13 +75,10 @@ QSize LinkItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QMode return QSize(doc.idealWidth(), doc.size().height()); } -bool LinkItemDelegate::editorEvent(QEvent *event, - QAbstractItemModel *model, - const QStyleOptionViewItem &option, - const QModelIndex &index) -{ +bool LinkItemDelegate::editorEvent(QEvent* event, QAbstractItemModel* model, + const QStyleOptionViewItem& option, const QModelIndex& index) { if (event->type() == QEvent::MouseButtonRelease) { - QMouseEvent *mouseEvent = static_cast(event); + QMouseEvent* mouseEvent = static_cast(event); if (mouseEvent->button() == Qt::LeftButton) { QString html = index.data(Qt::DisplayRole).toString(); QTextDocument doc; @@ -96,7 +86,7 @@ bool LinkItemDelegate::editorEvent(QEvent *event, doc.setTextWidth(option.rect.width()); // this is kinda silly but it werks - QAbstractTextDocumentLayout *layout = doc.documentLayout(); + QAbstractTextDocumentLayout* layout = doc.documentLayout(); QPoint pos = mouseEvent->pos() - option.rect.topLeft(); int charPos = layout->hitTest(pos, Qt::ExactHit); diff --git a/src/yuzu/deps_dialog.h b/src/yuzu/deps_dialog.h index f8e7f1d987..fab2f0b1ca 100644 --- a/src/yuzu/deps_dialog.h +++ b/src/yuzu/deps_dialog.h @@ -1,41 +1,38 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later #pragma once +#include #include #include #include -#include -namespace Ui { class DepsDialog; } +namespace Ui { +class DepsDialog; +} -class DepsDialog : public QDialog -{ +class DepsDialog : public QDialog { Q_OBJECT public: - explicit DepsDialog(QWidget *parent); + explicit DepsDialog(QWidget* parent); ~DepsDialog() override; private: std::unique_ptr ui; }; -class LinkItemDelegate : public QStyledItemDelegate -{ +class LinkItemDelegate : public QStyledItemDelegate { Q_OBJECT public: - explicit LinkItemDelegate(QObject *parent = 0); + explicit LinkItemDelegate(QObject* parent = 0); protected: - void paint(QPainter *painter, - const QStyleOptionViewItem &option, - const QModelIndex &index) const override; - QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; - bool editorEvent(QEvent *event, - QAbstractItemModel *model, - const QStyleOptionViewItem &option, - const QModelIndex &index) override; + void paint(QPainter* painter, const QStyleOptionViewItem& option, + const QModelIndex& index) const override; + QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override; + bool editorEvent(QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, + const QModelIndex& index) override; }; diff --git a/src/yuzu/game/game_card.cpp b/src/yuzu/game/game_card.cpp index 26ab99faaf..ba60b54fcc 100644 --- a/src/yuzu/game/game_card.cpp +++ b/src/yuzu/game/game_card.cpp @@ -73,9 +73,7 @@ void GameCard::paint(QPainter* painter, const QStyleOptionViewItem& option, painter->restore(); } else { // if there is no icon just draw a blank rect - iconRect = QRect(cardRect.left() + padding, - cardRect.top() + padding, - _iconsize, _iconsize); + iconRect = QRect(cardRect.left() + padding, cardRect.top() + padding, _iconsize, _iconsize); } if (UISettings::values.show_game_name.GetValue()) { diff --git a/src/yuzu/game/game_card.h b/src/yuzu/game/game_card.h index 9fd0ec081a..86387452b6 100644 --- a/src/yuzu/game/game_card.h +++ b/src/yuzu/game/game_card.h @@ -14,12 +14,10 @@ class GameCard : public QStyledItemDelegate { public: explicit GameCard(QObject* parent = nullptr); - void paint(QPainter *painter, - const QStyleOptionViewItem &option, - const QModelIndex &index) const override; + void paint(QPainter* painter, const QStyleOptionViewItem& option, + const QModelIndex& index) const override; - QSize sizeHint(const QStyleOptionViewItem &option, - const QModelIndex &index) const override; + QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override; void setSize(const QSize& newSize, const int padding); private: diff --git a/src/yuzu/game/game_list.cpp b/src/yuzu/game/game_list.cpp index c57198848f..344cff445c 100644 --- a/src/yuzu/game/game_list.cpp +++ b/src/yuzu/game/game_list.cpp @@ -218,11 +218,13 @@ void GameList::OnTextChanged(const QString& new_text) { for (int i = 0; i < row_count; ++i) { QStandardItem* item = item_model->item(i, 0); - if (!item) continue; + if (!item) + continue; children_total++; - const QString file_path = item->data(GameListItemPath::FullPathRole).toString().toLower(); + const QString file_path = + item->data(GameListItemPath::FullPathRole).toString().toLower(); const QString file_title = item->data(GameListItemPath::TitleRole).toString().toLower(); const QString file_name = file_path.mid(file_path.lastIndexOf(QLatin1Char{'/'}) + 1) + QLatin1Char{' '} + file_title; @@ -236,7 +238,8 @@ void GameList::OnTextChanged(const QString& new_text) { } search_field->setFilterResult(result_count, children_total); } else if (edit_filter_text.isEmpty()) { - hide(0, UISettings::values.favorited_ids.size() == 0, item_model->invisibleRootItem()->index()); + hide(0, UISettings::values.favorited_ids.size() == 0, + item_model->invisibleRootItem()->index()); for (int i = 1; i < item_model->rowCount() - 1; ++i) { folder = item_model->item(i, 0); const QModelIndex folder_index = folder->index(); @@ -362,7 +365,8 @@ GameList::GameList(FileSys::VirtualFilesystem vfs_, FileSys::ManualContentProvid external_watcher = new QFileSystemWatcher(this); ResetExternalWatcher(); - connect(external_watcher, &QFileSystemWatcher::directoryChanged, this, &GameList::RefreshExternalContent); + connect(external_watcher, &QFileSystemWatcher::directoryChanged, this, + &GameList::RefreshExternalContent); this->main_window = parent; layout = new QVBoxLayout; @@ -471,7 +475,7 @@ bool GameList::IsTreeMode() { } void GameList::ResetViewMode() { - auto &setting = UISettings::values.game_list_mode; + auto& setting = UISettings::values.game_list_mode; bool newTreeMode = false; switch (setting.GetValue()) { @@ -678,7 +682,7 @@ void GameList::PopupContextMenu(const QPoint& menu_location) { return; QMenu blank_menu; - QAction *addGameDirAction = blank_menu.addAction(tr("&Add New Game Directory")); + QAction* addGameDirAction = blank_menu.addAction(tr("&Add New Game Directory")); connect(addGameDirAction, &QAction::triggered, this, &GameList::AddDirectory); blank_menu.exec(m_currentView->viewport()->mapToGlobal(menu_location)); @@ -1113,8 +1117,7 @@ const QStringList GameList::supported_file_extensions = { QStringLiteral("nso"), QStringLiteral("nro"), QStringLiteral("nca"), QStringLiteral("xci"), QStringLiteral("nsp"), QStringLiteral("kip")}; -void GameList::RefreshGameDirectory() -{ +void GameList::RefreshGameDirectory() { // Reset the externals watcher whenever the game list is reloaded, // primarily ensures that new titles and external dirs are caught. ResetExternalWatcher(); @@ -1142,7 +1145,7 @@ void GameList::ResetExternalWatcher() { external_watcher->removePaths(watch_dirs); } - for (const std::string &dir : Settings::values.external_content_dirs) { + for (const std::string& dir : Settings::values.external_content_dirs) { external_watcher->addPath(QString::fromStdString(dir)); } } @@ -1286,8 +1289,8 @@ bool GameList::eventFilter(QObject* obj, QEvent* event) { horizontal_scroll_target = m_currentView->horizontalScrollBar()->value(); horizontal_scroll_target -= deltaX; - horizontal_scroll_target = - qBound(0, horizontal_scroll_target, m_currentView->horizontalScrollBar()->maximum()); + horizontal_scroll_target = qBound(0, horizontal_scroll_target, + m_currentView->horizontalScrollBar()->maximum()); horizontal_scroll->stop(); horizontal_scroll->setStartValue(m_currentView->horizontalScrollBar()->value()); diff --git a/src/yuzu/game/game_list.h b/src/yuzu/game/game_list.h index 7de622b714..42efcbdc3b 100644 --- a/src/yuzu/game/game_list.h +++ b/src/yuzu/game/game_list.h @@ -21,10 +21,10 @@ #include "common/common_types.h" #include "core/core.h" +#include "frontend_common/play_time_manager.h" #include "qt_common/config/uisettings.h" #include "qt_common/util/game.h" #include "yuzu/compatibility_list.h" -#include "frontend_common/play_time_manager.h" class QVariantAnimation; @@ -124,7 +124,7 @@ signals: void NavigateToGamedbEntryRequested(u64 program_id, const CompatibilityList& compatibility_list); void OpenPerGameGeneralRequested(const std::string& file); - void LinkToRyujinxRequested(const u64 &program_id); + void LinkToRyujinxRequested(const u64& program_id); void OpenDirectory(const QString& directory); void AddDirectory(); void ShowList(bool show); @@ -170,8 +170,8 @@ private: QVBoxLayout* layout = nullptr; QTreeView* tree_view = nullptr; - QListView *list_view = nullptr; - GameCard *m_gameCard = nullptr; + QListView* list_view = nullptr; + GameCard* m_gameCard = nullptr; QStandardItemModel* item_model = nullptr; std::unique_ptr current_worker; @@ -194,7 +194,7 @@ private: Core::System& system; bool m_isTreeMode = true; - QAbstractItemView *m_currentView = tree_view; + QAbstractItemView* m_currentView = tree_view; }; class GameListPlaceholder : public QWidget { diff --git a/src/yuzu/game/game_list_p.h b/src/yuzu/game/game_list_p.h index 9bae5b9e01..004f8917ad 100644 --- a/src/yuzu/game/game_list_p.h +++ b/src/yuzu/game/game_list_p.h @@ -14,10 +14,10 @@ #include #include #include +#include #include #include #include -#include #include "common/common_types.h" #include "common/logging/log.h" @@ -77,7 +77,7 @@ public: GameListItemPath() = default; GameListItemPath(const QString& game_path, const std::vector& picture_data, const QString& game_name, const QString& game_type, u64 program_id, - u64 play_time, const QString &patch_versions) { + u64 play_time, const QString& patch_versions) { setData(type(), TypeRole); setData(game_path, FullPathRole); setData(game_name, TitleRole); @@ -85,14 +85,15 @@ public: setData(game_type, FileTypeRole); const auto readable_play_time = - play_time > 0 - ? QObject::tr("Play Time: %1").arg(QString::fromStdString(PlayTime::PlayTimeManager::GetReadablePlayTime(play_time))) - : QObject::tr("Never Played"); + play_time > 0 ? QObject::tr("Play Time: %1") + .arg(QString::fromStdString( + PlayTime::PlayTimeManager::GetReadablePlayTime(play_time))) + : QObject::tr("Never Played"); const auto enabled_update = [patch_versions]() -> QString { const QStringList lines = patch_versions.split(QLatin1Char('\n')); const QRegularExpression regex{QStringLiteral(R"(^Update \(([0-9\.]+)\))")}; - for (const QString &line : std::as_const(lines)) { + for (const QString& line : std::as_const(lines)) { const auto match = regex.match(line); if (match.hasMatch() && match.hasCaptured(1)) return QObject::tr("Version: %1").arg(match.captured(1)); @@ -100,9 +101,7 @@ public: return QObject::tr("Version: 1.0.0"); }(); - const auto tooltip = QStringLiteral("%1\n%2").arg( - readable_play_time, - enabled_update); + const auto tooltip = QStringLiteral("%1\n%2").arg(readable_play_time, enabled_update); setData(tooltip, Qt::ToolTipRole); @@ -145,7 +144,7 @@ public: return row1.toLower(); } - // None + // None if (row2_id == 4) { return row1; } @@ -163,7 +162,6 @@ public: default: break; } - } return GameListItem::data(role); diff --git a/src/yuzu/game/game_list_worker.cpp b/src/yuzu/game/game_list_worker.cpp index 81012e4374..777122e135 100644 --- a/src/yuzu/game/game_list_worker.cpp +++ b/src/yuzu/game/game_list_worker.cpp @@ -30,11 +30,11 @@ #include "core/file_sys/romfs.h" #include "core/file_sys/submission_package.h" #include "core/loader/loader.h" +#include "qt_common/config/uisettings.h" #include "yuzu/compatibility_list.h" #include "yuzu/game/game_list.h" #include "yuzu/game/game_list_p.h" #include "yuzu/game/game_list_worker.h" -#include "qt_common/config/uisettings.h" namespace { @@ -198,26 +198,24 @@ QString FormatPatchNameVersions(const FileSys::PatchManager& patch_manager, return out; } -QList MakeGameListEntry(const std::string& path, - const std::string& name, - const std::size_t size, - const std::vector& icon, - Loader::AppLoader& loader, - u64 program_id, +QList MakeGameListEntry(const std::string& path, const std::string& name, + const std::size_t size, const std::vector& icon, + Loader::AppLoader& loader, u64 program_id, const CompatibilityList& compatibility_list, const PlayTime::PlayTimeManager& play_time_manager, - const FileSys::PatchManager& patch) -{ + const FileSys::PatchManager& patch) { auto const it = FindMatchingCompatibilityEntry(compatibility_list, program_id); // The game list uses 99 as compatibility number for untested games - QString compatibility = it != compatibility_list.end() ? it->second.first : QStringLiteral("99"); + QString compatibility = + it != compatibility_list.end() ? it->second.first : QStringLiteral("99"); auto const file_type = loader.GetFileType(); auto const file_type_string = QString::fromStdString(Loader::GetFileTypeString(file_type)); - QString patch_versions = GetGameListCachedObject(fmt::format("{:016X}", patch.GetTitleID()), "pv.txt", [&patch, &loader] { - return FormatPatchNameVersions(patch, loader, loader.IsRomFSUpdatable()); - }); + QString patch_versions = GetGameListCachedObject( + fmt::format("{:016X}", patch.GetTitleID()), "pv.txt", [&patch, &loader] { + return FormatPatchNameVersions(patch, loader, loader.IsRomFSUpdatable()); + }); u64 play_time = play_time_manager.GetPlayTime(program_id); return QList{ @@ -238,13 +236,9 @@ GameListWorker::GameListWorker(FileSys::VirtualFilesystem vfs_, const CompatibilityList& compatibility_list_, const PlayTime::PlayTimeManager& play_time_manager_, Core::System& system_) - : vfs{std::move(vfs_)} - , provider{provider_} - , game_dirs{game_dirs_} - , compatibility_list{compatibility_list_} - , play_time_manager{play_time_manager_} - , system{system_} -{ + : vfs{std::move(vfs_)}, provider{provider_}, game_dirs{game_dirs_}, + compatibility_list{compatibility_list_}, play_time_manager{play_time_manager_}, + system{system_} { // We want the game list to manage our lifetime. setAutoDelete(false); } @@ -338,15 +332,8 @@ void GameListWorker::AddTitlesToGameList(GameListDir* parent_dir) { GetMetadataFromControlNCA(patch, *control, icon, name); } - auto entry = MakeGameListEntry(file->GetFullPath(), - name, - file->GetSize(), - icon, - *loader, - program_id, - compatibility_list, - play_time_manager, - patch); + auto entry = MakeGameListEntry(file->GetFullPath(), name, file->GetSize(), icon, *loader, + program_id, compatibility_list, play_time_manager, patch); RecordEvent([=](GameList* game_list) { game_list->AddEntry(entry, parent_dir); }); } } @@ -424,15 +411,9 @@ void GameListWorker::ScanFileSystem(ScanTarget target, const std::string& dir_pa const FileSys::PatchManager patch{id, system.GetFileSystemController(), system.GetContentProvider()}; - auto entry = MakeGameListEntry(physical_name, - name, - Common::FS::GetSize(physical_name), - icon, - *loader, - id, - compatibility_list, - play_time_manager, - patch); + auto entry = MakeGameListEntry( + physical_name, name, Common::FS::GetSize(physical_name), icon, *loader, + id, compatibility_list, play_time_manager, patch); RecordEvent( [=](GameList* game_list) { game_list->AddEntry(entry, parent_dir); }); @@ -447,15 +428,9 @@ void GameListWorker::ScanFileSystem(ScanTarget target, const std::string& dir_pa const FileSys::PatchManager patch{program_id, system.GetFileSystemController(), system.GetContentProvider()}; - auto entry = MakeGameListEntry(physical_name, - name, - Common::FS::GetSize(physical_name), - icon, - *loader, - program_id, - compatibility_list, - play_time_manager, - patch); + auto entry = MakeGameListEntry( + physical_name, name, Common::FS::GetSize(physical_name), icon, *loader, + program_id, compatibility_list, play_time_manager, patch); RecordEvent( [=](GameList* game_list) { game_list->AddEntry(entry, parent_dir); }); diff --git a/src/yuzu/game/game_list_worker.h b/src/yuzu/game/game_list_worker.h index 76153f7917..bf67585fe6 100644 --- a/src/yuzu/game/game_list_worker.h +++ b/src/yuzu/game/game_list_worker.h @@ -18,9 +18,9 @@ #include "common/thread.h" #include "core/file_sys/registered_cache.h" +#include "frontend_common/play_time_manager.h" #include "qt_common/config/uisettings.h" #include "yuzu/compatibility_list.h" -#include "frontend_common/play_time_manager.h" namespace Core { class System; diff --git a/src/yuzu/hotkeys.cpp b/src/yuzu/hotkeys.cpp index 10e407402b..5ca437a597 100644 --- a/src/yuzu/hotkeys.cpp +++ b/src/yuzu/hotkeys.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: 2014 Citra Emulator Project @@ -10,8 +10,8 @@ #include #include "hid_core/frontend/emulated_controller.h" -#include "yuzu/hotkeys.h" #include "qt_common/config/uisettings.h" +#include "yuzu/hotkeys.h" HotkeyRegistry::HotkeyRegistry() = default; HotkeyRegistry::~HotkeyRegistry() = default; diff --git a/src/yuzu/install_dialog.cpp b/src/yuzu/install_dialog.cpp index 1b772a0eba..de42297618 100644 --- a/src/yuzu/install_dialog.cpp +++ b/src/yuzu/install_dialog.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project @@ -10,8 +10,8 @@ #include #include #include -#include "yuzu/install_dialog.h" #include "qt_common/config/uisettings.h" +#include "yuzu/install_dialog.h" InstallDialog::InstallDialog(QWidget* parent, const QStringList& files) : QDialog(parent) { file_list = new QListWidget(this); diff --git a/src/yuzu/libqt_common.cpp b/src/yuzu/libqt_common.cpp index 6da75033af..198d1b66be 100644 --- a/src/yuzu/libqt_common.cpp +++ b/src/yuzu/libqt_common.cpp @@ -1,11 +1,11 @@ // SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later +#include #include #include #include #include -#include #include "libqt_common.h" #include "qt_common/abstract/frontend.h" @@ -14,10 +14,11 @@ namespace QtCommon::Frontend { -StandardButton ShowMessage( - Icon icon, const QString &title, const QString &text, StandardButtons buttons, QObject *parent) -{ - QMessageBox *box = new QMessageBox(QMessageBox::Icon(int(icon)), title, text, QMessageBox::StandardButtons(int(buttons)), (QWidget *) parent); +StandardButton ShowMessage(Icon icon, const QString& title, const QString& text, + StandardButtons buttons, QObject* parent) { + QMessageBox* box = + new QMessageBox(QMessageBox::Icon(int(icon)), title, text, + QMessageBox::StandardButtons(int(buttons)), (QWidget*)parent); return StandardButton(box->exec()); } @@ -81,15 +82,15 @@ void WidgetsProgressDialog::show() { m_dialog->show(); } -std::unique_ptr newProgressDialog(const QString& labelText, const QString& cancelButtonText, - int minimum, int maximum, Qt::WindowFlags f) { +std::unique_ptr newProgressDialog(const QString& labelText, + const QString& cancelButtonText, int minimum, + int maximum, Qt::WindowFlags f) { return std::make_unique(labelText, cancelButtonText, minimum, maximum, (QWidget*)rootObject, f); } QtProgressDialog* newProgressDialogPtr(const QString& labelText, const QString& cancelButtonText, - int minimum, int maximum, - Qt::WindowFlags f) { + int minimum, int maximum, Qt::WindowFlags f) { return new WidgetsProgressDialog(labelText, cancelButtonText, minimum, maximum, (QWidget*)rootObject, f); } @@ -115,5 +116,4 @@ const QString GetTextInput(const QString& title, const QString& caption, return QInputDialog::getText(rootObject, title, caption, QLineEdit::Normal, defaultText); } - } // namespace QtCommon::Frontend diff --git a/src/yuzu/libqt_common.h b/src/yuzu/libqt_common.h index 9fb0add154..356fd65d2b 100644 --- a/src/yuzu/libqt_common.h +++ b/src/yuzu/libqt_common.h @@ -34,4 +34,4 @@ private: QProgressDialog* m_dialog; }; -} +} // namespace QtCommon::Frontend diff --git a/src/yuzu/loading_screen.cpp b/src/yuzu/loading_screen.cpp index d6550a2c81..d67667a91d 100644 --- a/src/yuzu/loading_screen.cpp +++ b/src/yuzu/loading_screen.cpp @@ -4,7 +4,6 @@ // SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include #include #include #include @@ -14,6 +13,7 @@ #include #include #include +#include #include "core/frontend/framebuffer_layout.h" #include "core/loader/loader.h" #include "ui_loading_screen.h" diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index c6b4fde83e..f8528d9671 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -5,8 +5,8 @@ #include "startup_checks.h" #if YUZU_ROOM -#include "dedicated_room/yuzu_room.h" #include +#include "dedicated_room/yuzu_room.h" #endif #include @@ -62,9 +62,8 @@ static Qt::HighDpiScaleFactorRoundingPolicy GetHighDpiRoundingPolicy() { // Get the lower of the 2 ratios and truncate, this is the maximum integer scale. const qreal max_ratio = std::trunc(std::min(width_ratio, height_ratio)); - return max_ratio > real_ratio - ? Qt::HighDpiScaleFactorRoundingPolicy::Round - : Qt::HighDpiScaleFactorRoundingPolicy::Floor; + return max_ratio > real_ratio ? Qt::HighDpiScaleFactorRoundingPolicy::Round + : Qt::HighDpiScaleFactorRoundingPolicy::Floor; #else // Other OSes should be better than Windows at fractional scaling. return Qt::HighDpiScaleFactorRoundingPolicy::PassThrough; @@ -174,7 +173,7 @@ int main(int argc, char* argv[]) { main_window.show(); app.connect(&app, &QGuiApplication::applicationStateChanged, &main_window, - &MainWindow::OnAppFocusStateChanged); + &MainWindow::OnAppFocusStateChanged); int result = app.exec(); detached_tasks.WaitForAllTasks(); diff --git a/src/yuzu/main_window.cpp b/src/yuzu/main_window.cpp index aaac46bffb..a251451bea 100644 --- a/src/yuzu/main_window.cpp +++ b/src/yuzu/main_window.cpp @@ -19,8 +19,8 @@ #include "ui_main.h" // Other Yuzu stuff // -#include "debugger/controller.h" #include "debugger/console.h" +#include "debugger/controller.h" #include "about_dialog.h" #include "data_dialog.h" @@ -28,18 +28,18 @@ #include "install_dialog.h" #include "bootmanager.h" -#include "yuzu/game/game_list.h" #include "loading_screen.h" #include "ryujinx_dialog.h" #include "set_play_time_dialog.h" #include "util/util.h" #include "vk_device_info.h" +#include "yuzu/game/game_list.h" #include "applets/qt_amiibo_settings.h" #include "applets/qt_controller.h" +#include "applets/qt_error.h" #include "applets/qt_profile_select.h" #include "applets/qt_software_keyboard.h" -#include "applets/qt_error.h" #include "applets/qt_web_browser.h" #include "configuration/configure_dialog.h" @@ -48,8 +48,8 @@ #include "configuration/configure_tas.h" #include "util/clickable_label.h" -#include "util/overlay_dialog.h" #include "util/controller_navigation.h" +#include "util/overlay_dialog.h" #include "multiplayer/state.h" @@ -60,6 +60,7 @@ #include #endif +#include #include #include #include @@ -68,32 +69,32 @@ #include #include #include +#include #include #include #include #include #include #include -#include -#include // Qt Common // -#include "qt_common/config/uisettings.h" #include "qt_common/config/shared_translation.h" +#include "qt_common/config/uisettings.h" #include "qt_common/abstract/frontend.h" #include "qt_common/qt_common.h" -#include "qt_common/util/path.h" -#include "qt_common/util/meta.h" #include "qt_common/util/content.h" #include "qt_common/util/fs.h" +#include "qt_common/util/meta.h" #include "qt_common/util/mod.h" +#include "qt_common/util/path.h" // These are wrappers to avoid the calls to CreateDirectory and CreateFile because of the Windows // defines. -static FileSys::VirtualDir VfsFilesystemCreateDirectoryWrapper(const std::string& path, FileSys::OpenMode mode) { +static FileSys::VirtualDir VfsFilesystemCreateDirectoryWrapper(const std::string& path, + FileSys::OpenMode mode) { return QtCommon::vfs->CreateDirectory(path, mode); } @@ -122,14 +123,14 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual #endif // Core // -#include "core/frontend/applets/software_keyboard.h" -#include "core/frontend/applets/mii_edit.h" #include "core/frontend/applets/general.h" +#include "core/frontend/applets/mii_edit.h" +#include "core/frontend/applets/software_keyboard.h" +#include "core/hle/kernel/k_process.h" #include "core/hle/service/acc/profile_manager.h" #include "core/hle/service/am/applet_manager.h" #include "core/hle/service/am/frontend/applet_web_browser_types.h" -#include "core/hle/kernel/k_process.h" #include "core/file_sys/card_image.h" #include "core/file_sys/romfs.h" @@ -142,8 +143,8 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual #include "core/crypto/key_manager.h" // Input // -#include "hid_core/hid_core.h" #include "hid_core/frontend/emulated_controller.h" +#include "hid_core/hid_core.h" #include "input_common/drivers/virtual_amiibo.h" // Video Core // @@ -165,17 +166,17 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual #ifdef __unix__ #include +#include #include #include "qt_common/gui_settings.h" -#include #endif #include "qt_common/gamemode.h" #ifdef _WIN32 -#include "core/core_timing.h" #include "common/windows/timer_resolution.h" +#include "core/core_timing.h" #include #include @@ -381,7 +382,7 @@ static QString PrettyProductName() { namespace { -constexpr std::array, 5> default_game_icon_sizes{ +constexpr std::array, 5> default_game_icon_sizes{ std::make_pair(0, QT_TRANSLATE_NOOP("MainWindow", "None")), std::make_pair(32, QT_TRANSLATE_NOOP("MainWindow", "Small (32x32)")), std::make_pair(64, QT_TRANSLATE_NOOP("MainWindow", "Standard (64x64)")), @@ -393,7 +394,7 @@ QString GetTranslatedGameIconSize(size_t index) { return QCoreApplication::translate("MainWindow", default_game_icon_sizes[index].second); } -} +} // namespace #ifndef _WIN32 // TODO(crueter): carboxyl does this, is it needed in qml? @@ -412,7 +413,7 @@ inline static bool isDarkMode() { MainWindow::MainWindow(bool has_broken_vulkan) : ui{std::make_unique()}, - input_subsystem{std::make_shared()}, user_data_migrator{this} { + input_subsystem{std::make_shared()}, user_data_migrator{this} { QtCommon::Init(this); Common::FS::CreateEdenPaths(); @@ -423,17 +424,14 @@ MainWindow::MainWindow(bool has_broken_vulkan) using namespace Common::FS; - static constexpr const std::array paths = {EdenPath::NANDDir, - EdenPath::SDMCDir, - EdenPath::DumpDir, - EdenPath::LoadDir}; + static constexpr const std::array paths = { + EdenPath::NANDDir, EdenPath::SDMCDir, EdenPath::DumpDir, EdenPath::LoadDir}; for (const EdenPath& path : paths) { std::string str_path = Common::FS::GetEdenPathString(path); if (str_path.starts_with(user_data_migrator.selected_emu.get_user_dir())) { - boost::replace_all(str_path, - user_data_migrator.selected_emu.lower_name().toStdString(), - "eden"); + boost::replace_all( + str_path, user_data_migrator.selected_emu.lower_name().toStdString(), "eden"); Common::FS::SetEdenPath(path, str_path); } } @@ -531,7 +529,8 @@ MainWindow::MainWindow(bool has_broken_vulkan) std::chrono::duration_cast>( Common::Windows::SetCurrentTimerResolutionToMaximum()) .count()); - QtCommon::system->CoreTiming().SetTimerResolutionNs(Common::Windows::GetCurrentTimerResolution()); + QtCommon::system->CoreTiming().SetTimerResolutionNs( + Common::Windows::GetCurrentTimerResolution()); #endif UpdateWindowTitle(); @@ -539,9 +538,8 @@ MainWindow::MainWindow(bool has_broken_vulkan) #ifdef ENABLE_UPDATE_CHECKER if (UISettings::values.check_for_updates) { - update_future = QtConcurrent::run([]() -> std::optional { - return UpdateChecker::GetUpdate(); - }); + update_future = QtConcurrent::run( + []() -> std::optional { return UpdateChecker::GetUpdate(); }); update_watcher.connect(&update_watcher, &QFutureWatcher::finished, this, &MainWindow::OnEmulatorUpdateAvailable); update_watcher.setFuture(update_future); @@ -590,7 +588,8 @@ MainWindow::MainWindow(bool has_broken_vulkan) if (has_broken_vulkan) { UISettings::values.has_broken_vulkan = true; - QMessageBox::warning(this, tr("Broken Vulkan Installation Detected"), tr("Vulkan initialization failed during boot.")); + QMessageBox::warning(this, tr("Broken Vulkan Installation Detected"), + tr("Vulkan initialization failed during boot.")); #ifdef HAS_OPENGL Settings::values.renderer_backend = Settings::RendererBackend::OpenGL_GLSL; #else @@ -652,7 +651,8 @@ MainWindow::MainWindow(bool has_broken_vulkan) if (!argument_ok) { // try to look it up by username, only finds the first username that matches. std::string const user_arg_str = args[user_arg_idx].toStdString(); - auto const user_idx = QtCommon::system->GetProfileManager().GetUserIndex(user_arg_str); + auto const user_idx = + QtCommon::system->GetProfileManager().GetUserIndex(user_arg_str); if (user_idx != std::nullopt) { selected_user = user_idx.value(); } else { @@ -711,7 +711,7 @@ MainWindow::~MainWindow() { } void MainWindow::AmiiboSettingsShowDialog(const Core::Frontend::CabinetParameters& parameters, - std::shared_ptr nfp_device) { + std::shared_ptr nfp_device) { cabinet_applet = new QtAmiiboSettingsDialog(this, parameters, input_subsystem.get(), nfp_device); SCOPE_EXIT { @@ -915,7 +915,7 @@ void MainWindow::SoftwareKeyboardExit() { } void MainWindow::WebBrowserOpenWebPage(const std::string& main_url, - const std::string& additional_args, bool is_local) { + const std::string& additional_args, bool is_local) { #ifdef YUZU_USE_QT_WEB_ENGINE // Raw input breaks with the web applet, Disable web applets if enabled @@ -1072,7 +1072,8 @@ void MainWindow::InitializeWidgets() { render_window = new GRenderWindow(this, emu_thread.get(), input_subsystem, *QtCommon::system); render_window->hide(); - game_list = new GameList(QtCommon::vfs, QtCommon::provider.get(), *play_time_manager, *QtCommon::system, this); + game_list = new GameList(QtCommon::vfs, QtCommon::provider.get(), *play_time_manager, + *QtCommon::system, this); ui->horizontalLayout->addWidget(game_list); game_list_placeholder = new GameListPlaceholder(this); @@ -1229,8 +1230,7 @@ void MainWindow::InitializeWidgets() { filter_status_button = new QPushButton(); filter_status_button->setObjectName(QStringLiteral("TogglableStatusBarButton")); filter_status_button->setFocusPolicy(Qt::NoFocus); - connect(filter_status_button, &QPushButton::clicked, this, - &MainWindow::OnToggleAdaptingFilter); + connect(filter_status_button, &QPushButton::clicked, this, &MainWindow::OnToggleAdaptingFilter); UpdateFilterText(); filter_status_button->setCheckable(true); filter_status_button->setChecked(true); @@ -1369,7 +1369,7 @@ void MainWindow::InitializeRecentFileMenuActions() { } void MainWindow::LinkActionShortcut(QAction* action, const QString& action_name, - const bool tas_allowed) { + const bool tas_allowed) { static const auto main_window = std::string("Main Window"); action->setShortcut(hotkey_registry.GetKeySequence(main_window, action_name.toStdString())); action->setShortcutContext( @@ -1378,7 +1378,8 @@ void MainWindow::LinkActionShortcut(QAction* action, const QString& action_name, this->addAction(action); - auto* controller = QtCommon::system->HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1); + auto* controller = + QtCommon::system->HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1); const auto* controller_hotkey = hotkey_registry.GetControllerHotkey(main_window, action_name.toStdString(), controller); connect( @@ -1404,17 +1405,16 @@ void MainWindow::InitializeHotkeys() { LinkActionShortcut(ui->action_Stop, QStringLiteral("Stop Emulation")); LinkActionShortcut(ui->action_Show_Filter_Bar, QStringLiteral("Toggle Filter Bar")); LinkActionShortcut(ui->action_Show_Status_Bar, QStringLiteral("Toggle Status Bar")); - LinkActionShortcut(ui->action_Show_Performance_Overlay, QStringLiteral("Toggle Performance Overlay")); + LinkActionShortcut(ui->action_Show_Performance_Overlay, + QStringLiteral("Toggle Performance Overlay")); LinkActionShortcut(ui->action_Fullscreen, QStringLiteral("Fullscreen")); LinkActionShortcut(ui->action_Capture_Screenshot, QStringLiteral("Capture Screenshot")); LinkActionShortcut(ui->action_TAS_Start, QStringLiteral("TAS Start/Stop"), true); LinkActionShortcut(ui->action_TAS_Record, QStringLiteral("TAS Record"), true); LinkActionShortcut(ui->action_TAS_Reset, QStringLiteral("TAS Reset"), true); - LinkActionShortcut(ui->action_View_Lobby, - QStringLiteral("Browse Public Game Lobby")); + LinkActionShortcut(ui->action_View_Lobby, QStringLiteral("Browse Public Game Lobby")); LinkActionShortcut(ui->action_Start_Room, QStringLiteral("Create Room")); - LinkActionShortcut(ui->action_Connect_To_Room, - QStringLiteral("Direct Connect to Room")); + LinkActionShortcut(ui->action_Connect_To_Room, QStringLiteral("Direct Connect to Room")); LinkActionShortcut(ui->action_Show_Room, QStringLiteral("Show Current Room")); LinkActionShortcut(ui->action_Leave_Room, QStringLiteral("Leave Room")); LinkActionShortcut(ui->action_Configure, QStringLiteral("Configure")); @@ -1424,7 +1424,8 @@ void MainWindow::InitializeHotkeys() { const auto connect_shortcut = [&](const QString& action_name, const Fn& function) { const auto* hotkey = hotkey_registry.GetHotkey(main_window.toStdString(), action_name.toStdString(), this); - auto* controller = QtCommon::system->HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1); + auto* controller = + QtCommon::system->HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1); const auto* controller_hotkey = hotkey_registry.GetControllerHotkey( main_window.toStdString(), action_name.toStdString(), controller); connect(hotkey, &QShortcut::activated, this, function); @@ -1438,8 +1439,7 @@ void MainWindow::InitializeHotkeys() { ToggleFullscreen(); } }); - connect_shortcut(QStringLiteral("Change Adapting Filter"), - &MainWindow::OnToggleAdaptingFilter); + connect_shortcut(QStringLiteral("Change Adapting Filter"), &MainWindow::OnToggleAdaptingFilter); connect_shortcut(QStringLiteral("Change Docked Mode"), &MainWindow::OnToggleDockedMode); connect_shortcut(QStringLiteral("Change GPU Mode"), &MainWindow::OnToggleGpuAccuracy); connect_shortcut(QStringLiteral("Audio Mute/Unmute"), &MainWindow::OnMute); @@ -1513,8 +1513,10 @@ void MainWindow::RestoreUIState() { ui->action_Show_Status_Bar->setChecked(UISettings::values.show_status_bar.GetValue()); statusBar()->setVisible(ui->action_Show_Status_Bar->isChecked()); - ui->action_Show_Performance_Overlay->setChecked(UISettings::values.show_perf_overlay.GetValue()); - if (perf_overlay) perf_overlay->setVisible(ui->action_Show_Performance_Overlay->isChecked()); + ui->action_Show_Performance_Overlay->setChecked( + UISettings::values.show_perf_overlay.GetValue()); + if (perf_overlay) + perf_overlay->setVisible(ui->action_Show_Performance_Overlay->isChecked()); Debugger::ToggleConsole(); } @@ -1554,16 +1556,14 @@ void MainWindow::ConnectWidgetEvents() { connect(game_list, &GameList::GameChosen, this, &MainWindow::OnGameListLoadFile); connect(game_list, &GameList::OpenDirectory, this, &MainWindow::OnGameListOpenDirectory); connect(game_list, &GameList::OpenFolderRequested, this, &MainWindow::OnGameListOpenFolder); - connect(game_list, &GameList::OpenTransferableShaderCacheRequested, this, [this](u64 program_id) { - QtCommon::Path::OpenShaderCache(program_id, this); - }); + connect(game_list, &GameList::OpenTransferableShaderCacheRequested, this, + [this](u64 program_id) { QtCommon::Path::OpenShaderCache(program_id, this); }); connect(game_list, &GameList::RemoveInstalledEntryRequested, this, &MainWindow::OnGameListRemoveInstalledEntry); connect(game_list, &GameList::RemoveFileRequested, this, &MainWindow::OnGameListRemoveFile); connect(game_list, &GameList::RemovePlayTimeRequested, this, &MainWindow::OnGameListRemovePlayTimeData); - connect(game_list, &GameList::SetPlayTimeRequested, this, - &MainWindow::OnGameListSetPlayTime); + connect(game_list, &GameList::SetPlayTimeRequested, this, &MainWindow::OnGameListSetPlayTime); connect(game_list, &GameList::DumpRomFSRequested, this, &MainWindow::OnGameListDumpRomFS); connect(game_list, &GameList::VerifyIntegrityRequested, this, &MainWindow::OnGameListVerifyIntegrity); @@ -1581,11 +1581,9 @@ void MainWindow::ConnectWidgetEvents() { connect(game_list, &GameList::OpenPerGameGeneralRequested, this, &MainWindow::OnGameListOpenPerGameProperties); - connect(game_list, &GameList::LinkToRyujinxRequested, this, - &MainWindow::OnLinkToRyujinx); + connect(game_list, &GameList::LinkToRyujinxRequested, this, &MainWindow::OnLinkToRyujinx); - connect(this, &MainWindow::UpdateInstallProgress, this, - &MainWindow::IncrementInstallProgress); + connect(this, &MainWindow::UpdateInstallProgress, this, &MainWindow::IncrementInstallProgress); connect(this, &MainWindow::EmulationStarting, render_window, &GRenderWindow::OnEmulationStarting); @@ -1652,10 +1650,11 @@ void MainWindow::ConnectMenuEvents() { for (size_t i = 0; i < default_game_icon_sizes.size(); i++) { const auto current_size = UISettings::values.game_icon_size.GetValue(); const auto size = default_game_icon_sizes[i].first; - QAction *action = ui->menuGame_Icon_Size->addAction(GetTranslatedGameIconSize(i)); + QAction* action = ui->menuGame_Icon_Size->addAction(GetTranslatedGameIconSize(i)); action->setCheckable(true); - if (current_size == size) action->setChecked(true); + if (current_size == size) + action->setChecked(true); game_size_actions->addAction(action); @@ -1687,35 +1686,38 @@ void MainWindow::ConnectMenuEvents() { connect(multiplayer_state, &MultiplayerState::SaveConfig, this, &MainWindow::OnSaveConfig); // Tools - connect_menu(ui->action_Launch_PhotoViewer, [this]{ + connect_menu(ui->action_Launch_PhotoViewer, [this] { LaunchFirmwareApplet(u64(Service::AM::AppletProgramId::PhotoViewer), std::nullopt); }); - connect_menu(ui->action_Launch_MiiEdit, [this]{ + connect_menu(ui->action_Launch_MiiEdit, [this] { LaunchFirmwareApplet(u64(Service::AM::AppletProgramId::MiiEdit), std::nullopt); }); - connect_menu(ui->action_Launch_Controller, [this]{ + connect_menu(ui->action_Launch_Controller, [this] { LaunchFirmwareApplet(u64(Service::AM::AppletProgramId::Controller), std::nullopt); }); - connect_menu(ui->action_Launch_QLaunch, [this]{ + connect_menu(ui->action_Launch_QLaunch, [this] { LaunchFirmwareApplet(u64(Service::AM::AppletProgramId::QLaunch), std::nullopt); }); // Tools (cabinet) - connect_menu(ui->action_Launch_Cabinet_Nickname_Owner, [this]{ - LaunchFirmwareApplet(u64(Service::AM::AppletProgramId::Cabinet), {Service::NFP::CabinetMode::StartNicknameAndOwnerSettings}); + connect_menu(ui->action_Launch_Cabinet_Nickname_Owner, [this] { + LaunchFirmwareApplet(u64(Service::AM::AppletProgramId::Cabinet), + {Service::NFP::CabinetMode::StartNicknameAndOwnerSettings}); }); - connect_menu(ui->action_Launch_Cabinet_Eraser, [this]{ - LaunchFirmwareApplet(u64(Service::AM::AppletProgramId::Cabinet), {Service::NFP::CabinetMode::StartGameDataEraser}); + connect_menu(ui->action_Launch_Cabinet_Eraser, [this] { + LaunchFirmwareApplet(u64(Service::AM::AppletProgramId::Cabinet), + {Service::NFP::CabinetMode::StartGameDataEraser}); }); - connect_menu(ui->action_Launch_Cabinet_Restorer, [this]{ - LaunchFirmwareApplet(u64(Service::AM::AppletProgramId::Cabinet), {Service::NFP::CabinetMode::StartRestorer}); + connect_menu(ui->action_Launch_Cabinet_Restorer, [this] { + LaunchFirmwareApplet(u64(Service::AM::AppletProgramId::Cabinet), + {Service::NFP::CabinetMode::StartRestorer}); }); - connect_menu(ui->action_Launch_Cabinet_Formatter, [this]{ - LaunchFirmwareApplet(u64(Service::AM::AppletProgramId::Cabinet), {Service::NFP::CabinetMode::StartFormatter}); + connect_menu(ui->action_Launch_Cabinet_Formatter, [this] { + LaunchFirmwareApplet(u64(Service::AM::AppletProgramId::Cabinet), + {Service::NFP::CabinetMode::StartFormatter}); }); connect_menu(ui->action_Desktop, &MainWindow::OnCreateHomeMenuDesktopShortcut); - connect_menu(ui->action_Application_Menu, - &MainWindow::OnCreateHomeMenuApplicationMenuShortcut); + connect_menu(ui->action_Application_Menu, &MainWindow::OnCreateHomeMenuApplicationMenuShortcut); connect_menu(ui->action_Capture_Screenshot, &MainWindow::OnCaptureScreenshot); // TAS @@ -1754,15 +1756,10 @@ void MainWindow::UpdateMenuState() { }; const std::array applet_actions{ - ui->action_Launch_PhotoViewer, - ui->action_Launch_Cabinet_Nickname_Owner, - ui->action_Launch_Cabinet_Eraser, - ui->action_Launch_Cabinet_Restorer, - ui->action_Launch_Cabinet_Formatter, - ui->action_Launch_MiiEdit, - ui->action_Launch_QLaunch, - ui->action_Launch_Controller - }; + ui->action_Launch_PhotoViewer, ui->action_Launch_Cabinet_Nickname_Owner, + ui->action_Launch_Cabinet_Eraser, ui->action_Launch_Cabinet_Restorer, + ui->action_Launch_Cabinet_Formatter, ui->action_Launch_MiiEdit, + ui->action_Launch_QLaunch, ui->action_Launch_Controller}; for (QAction* action : running_actions) { action->setEnabled(emulation_running); @@ -1795,17 +1792,16 @@ void MainWindow::SetupPrepareForSleep() { const auto dbus_logind_service = QStringLiteral("org.freedesktop.login1"); const auto dbus_logind_path = QStringLiteral("/org/freedesktop/login1"); const auto dbus_logind_manager_if = QStringLiteral("org.freedesktop.login1.Manager"); - //const auto dbus_logind_session_if = QStringLiteral("org.freedesktop.login1.Session"); + // const auto dbus_logind_session_if = QStringLiteral("org.freedesktop.login1.Session"); #else const auto dbus_logind_service = QStringLiteral("org.freedesktop.ConsoleKit"); const auto dbus_logind_path = QStringLiteral("/org/freedesktop/ConsoleKit/Manager"); const auto dbus_logind_manager_if = QStringLiteral("org.freedesktop.ConsoleKit.Manager"); - //const auto dbus_logind_session_if = QStringLiteral("org.freedesktop.ConsoleKit.Session"); + // const auto dbus_logind_session_if = QStringLiteral("org.freedesktop.ConsoleKit.Session"); #endif - const bool success = bus.connect( - dbus_logind_service, dbus_logind_path, - dbus_logind_manager_if, QStringLiteral("PrepareForSleep"), - QStringLiteral("b"), this, SLOT(OnPrepareForSleep(bool))); + const bool success = bus.connect(dbus_logind_service, dbus_logind_path, + dbus_logind_manager_if, QStringLiteral("PrepareForSleep"), + QStringLiteral("b"), this, SLOT(OnPrepareForSleep(bool))); if (!success) LOG_WARNING(Frontend, "Couldn't register PrepareForSleep signal"); } else { @@ -1934,13 +1930,14 @@ bool MainWindow::LoadROM(const QString& filename, Service::AM::FrontendAppletPar /** Exec */ const Core::SystemResultStatus result{ - QtCommon::system->Load(*render_window, filename.toStdString(), params)}; + QtCommon::system->Load(*render_window, filename.toStdString(), params)}; const auto drd_callout = (UISettings::values.callout_flags.GetValue() & static_cast(CalloutFlag::DRDDeprecation)) == 0; if (result == Core::SystemResultStatus::Success && - QtCommon::system->GetAppLoader().GetFileType() == Loader::FileType::DeconstructedRomDirectory && + QtCommon::system->GetAppLoader().GetFileType() == + Loader::FileType::DeconstructedRomDirectory && drd_callout) { UISettings::values.callout_flags = UISettings::values.callout_flags.GetValue() | static_cast(CalloutFlag::DRDDeprecation); @@ -2047,7 +2044,7 @@ void MainWindow::ConfigureFilesystemProvider(const std::string& filepath) { } void MainWindow::BootGame(const QString& filename, Service::AM::FrontendAppletParameters params, - StartGameType type) { + StartGameType type) { LOG_INFO(Frontend, "Eden starting..."); if (params.program_id == 0 || @@ -2066,7 +2063,8 @@ void MainWindow::BootGame(const QString& filename, Service::AM::FrontendAppletPa ConfigureFilesystemProvider(filename.toStdString()); const auto v_file = Core::GetGameFileFromPath(QtCommon::vfs, filename.toUtf8().constData()); - const auto loader = Loader::GetLoader(*QtCommon::system, v_file, params.program_id, params.program_index); + const auto loader = + Loader::GetLoader(*QtCommon::system, v_file, params.program_id, params.program_index); if (loader != nullptr && loader->ReadProgramId(title_id) == Loader::ResultStatus::Success && type == StartGameType::Normal) { @@ -2085,11 +2083,11 @@ void MainWindow::BootGame(const QString& filename, Service::AM::FrontendAppletPa if (UISettings::values.select_user_on_boot && !user_flag_cmd_line) { const Core::Frontend::ProfileSelectParameters parameters{ - .mode = Service::AM::Frontend::UiMode::UserSelector, - .invalid_uid_list = {}, - .display_options = {}, - .purpose = Service::AM::Frontend::UserSelectionPurpose::General, - }; + .mode = Service::AM::Frontend::UiMode::UserSelector, + .invalid_uid_list = {}, + .display_options = {}, + .purpose = Service::AM::Frontend::UserSelectionPurpose::General, + }; if (SelectAndSetCurrentUser(parameters) == false) { return; } @@ -2246,8 +2244,9 @@ bool MainWindow::OnShutdownBegin() { } void MainWindow::OnShutdownBeginDialog() { - shutdown_dialog = new OverlayDialog(this, *QtCommon::system, QString{}, tr("Closing software..."), - QString{}, QString{}, Qt::AlignHCenter | Qt::AlignVCenter); + shutdown_dialog = + new OverlayDialog(this, *QtCommon::system, QString{}, tr("Closing software..."), QString{}, + QString{}, Qt::AlignHCenter | Qt::AlignVCenter); shutdown_dialog->open(); } @@ -2384,7 +2383,7 @@ void MainWindow::OnGameListLoadFile(QString game_path, u64 program_id) { // TODO(crueter): Common profile selector void MainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target, - const std::string& game_path) { + const std::string& game_path) { std::filesystem::path path; QString open_target; @@ -2414,8 +2413,8 @@ void MainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target, case GameListOpenTarget::SaveData: { open_target = tr("Save Data"); const auto save_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::SaveDir); - auto vfs_save_dir = - QtCommon::vfs->OpenDirectory(Common::FS::PathToUTF8String(save_dir), FileSys::OpenMode::Read); + auto vfs_save_dir = QtCommon::vfs->OpenDirectory(Common::FS::PathToUTF8String(save_dir), + FileSys::OpenMode::Read); if (has_user_save) { // User save data @@ -2530,7 +2529,8 @@ static bool RomFSRawCopy(size_t total_size, size_t& read_size, QProgressDialog& // TODO(crueter): All this can be transfered to qt_common // Aldoe I need to decide re: message boxes for QML // translations_common? strings_common? qt_strings? who knows -void MainWindow::OnGameListRemoveInstalledEntry(u64 program_id, QtCommon::Game::InstalledEntryType type) { +void MainWindow::OnGameListRemoveInstalledEntry(u64 program_id, + QtCommon::Game::InstalledEntryType type) { const QString entry_question = [type] { switch (type) { case QtCommon::Game::InstalledEntryType::Game: @@ -2570,7 +2570,7 @@ void MainWindow::OnGameListRemoveInstalledEntry(u64 program_id, QtCommon::Game:: } void MainWindow::OnGameListRemoveFile(u64 program_id, QtCommon::Game::GameListRemoveTarget target, - const std::string& game_path) { + const std::string& game_path) { const QString question = [target] { switch (target) { case QtCommon::Game::GameListRemoveTarget::GlShaderCache: @@ -2588,8 +2588,8 @@ void MainWindow::OnGameListRemoveFile(u64 program_id, QtCommon::Game::GameListRe } }(); - if (!MainWindow::question(this, tr("Remove File"), question, - QMessageBox::Yes | QMessageBox::No, QMessageBox::No)) { + if (!MainWindow::question(this, tr("Remove File"), question, QMessageBox::Yes | QMessageBox::No, + QMessageBox::No)) { return; } @@ -2624,7 +2624,6 @@ void MainWindow::OnGameListSetPlayTime(u64 program_id) { } } - void MainWindow::OnGameListRemovePlayTimeData(u64 program_id) { if (QMessageBox::question(this, tr("Remove Play Time Data"), tr("Reset play time?"), QMessageBox::Yes | QMessageBox::No, @@ -2637,15 +2636,15 @@ void MainWindow::OnGameListRemovePlayTimeData(u64 program_id) { } void MainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_path, - DumpRomFSTarget target) { + DumpRomFSTarget target) { const auto failed = [this] { QMessageBox::warning(this, tr("RomFS Extraction Failed!"), tr("There was an error copying the RomFS files or the user " "cancelled the operation.")); }; - const auto loader = - Loader::GetLoader(*QtCommon::system, QtCommon::vfs->OpenFile(game_path, FileSys::OpenMode::Read)); + const auto loader = Loader::GetLoader( + *QtCommon::system, QtCommon::vfs->OpenFile(game_path, FileSys::OpenMode::Read)); if (loader == nullptr) { failed(); return; @@ -2686,7 +2685,8 @@ void MainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pat const auto path = Common::FS::PathToUTF8String(dump_dir / romfs_dir); - const FileSys::PatchManager pm{title_id, QtCommon::system->GetFileSystemController(), installed}; + const FileSys::PatchManager pm{title_id, QtCommon::system->GetFileSystemController(), + installed}; auto romfs = pm.PatchRomFS(base_nca.get(), base_romfs, type, packed_update_raw, false); const auto out = VfsFilesystemCreateDirectoryWrapper(path, FileSys::OpenMode::ReadWrite); @@ -2762,7 +2762,7 @@ void MainWindow::OnGameListCopyTID(u64 program_id) { } void MainWindow::OnGameListNavigateToGamedbEntry(u64 program_id, - const CompatibilityList& compatibility_list) { + const CompatibilityList& compatibility_list) { const auto it = FindMatchingCompatibilityEntry(compatibility_list, program_id); QString directory; @@ -2770,11 +2770,14 @@ void MainWindow::OnGameListNavigateToGamedbEntry(u64 program_id, directory = it->second.second; } - QDesktopServices::openUrl(QUrl(QStringLiteral("https://www.emuready.com/listings?emulatorIds=43bfc023-ec22-422d-8324-048a8ec9f28f") + directory)); + QDesktopServices::openUrl(QUrl( + QStringLiteral( + "https://www.emuready.com/listings?emulatorIds=43bfc023-ec22-422d-8324-048a8ec9f28f") + + directory)); } void MainWindow::OnGameListCreateShortcut(u64 program_id, const std::string& game_path, - const QtCommon::Game::ShortcutTarget target) { + const QtCommon::Game::ShortcutTarget target) { // Create shortcu std::string arguments = fmt::format("-g \"{:s}\"", game_path); @@ -2846,8 +2849,7 @@ void MainWindow::OnGameListOpenPerGameProperties(const std::string& file) { OpenPerGameConfiguration(title_id, file); } -void MainWindow::OnLinkToRyujinx(const u64& program_id) -{ +void MainWindow::OnLinkToRyujinx(const u64& program_id) { namespace fs = std::filesystem; fs::path ryu_dir; @@ -2862,10 +2864,12 @@ void MainWindow::OnLinkToRyujinx(const u64& program_id) // this function also prompts the user to manually specify a portable location ryu_dir = QtCommon::FS::GetRyujinxSavePath(existing_path, program_id); - if (ryu_dir.empty()) return; + if (ryu_dir.empty()) + return; const std::string user_id = GetProfileIDString(); - if (user_id.empty()) return; + if (user_id.empty()) + return; const std::string hex_program = fmt::format("{:016X}", program_id); @@ -2873,7 +2877,6 @@ void MainWindow::OnLinkToRyujinx(const u64& program_id) FrontendCommon::DataManager::DataDir::Saves, user_id) / hex_program; - // CheckUnlink basically just checks to see if one or both are linked, and prompts the user to // unlink if this is the case. // If it returns false, neither dir is linked so it's fine to continue @@ -3008,8 +3011,8 @@ void MainWindow::OnMenuInstallToNAND() { return false; }; future = QtConcurrent::run([&file, progress_callback] { - return ContentManager::InstallNSP(*QtCommon::system, *QtCommon::vfs, file.toStdString(), - progress_callback); + return ContentManager::InstallNSP(*QtCommon::system, *QtCommon::vfs, + file.toStdString(), progress_callback); }); while (!future.isFinished()) { @@ -3220,9 +3223,8 @@ void MainWindow::OnLoadComplete() { perf_overlay = new PerformanceOverlay(this); perf_overlay->setVisible(ui->action_Show_Performance_Overlay->isChecked()); - connect(perf_overlay, &PerformanceOverlay::closed, perf_overlay, [this]() { - ui->action_Show_Performance_Overlay->setChecked(false); - }); + connect(perf_overlay, &PerformanceOverlay::closed, perf_overlay, + [this]() { ui->action_Show_Performance_Overlay->setChecked(false); }); } void MainWindow::OnExecuteProgram(std::size_t program_index) { @@ -3244,8 +3246,8 @@ void MainWindow::OnSaveConfig() { } void MainWindow::ErrorDisplayDisplayError(QString error_code, QString error_text) { - error_applet = new OverlayDialog(render_window, *QtCommon::system, error_code, error_text, QString{}, - tr("OK"), Qt::AlignLeft | Qt::AlignVCenter); + error_applet = new OverlayDialog(render_window, *QtCommon::system, error_code, error_text, + QString{}, tr("OK"), Qt::AlignLeft | Qt::AlignVCenter); SCOPE_EXIT { error_applet->deleteLater(); error_applet = nullptr; @@ -3266,37 +3268,41 @@ void MainWindow::OnMenuReportCompatibility() { tr("Function Disabled"), tr("Compatibility list reporting is currently disabled. Check back later!")); -// #if defined(ARCHITECTURE_x86_64) && !defined(__APPLE__) -// const auto& caps = Common::GetCPUCaps(); -// const bool has_fma = caps.fma || caps.fma4; -// const auto processor_count = std::thread::hardware_concurrency(); -// const bool has_4threads = processor_count == 0 || processor_count >= 4; -// const bool has_8gb_ram = Common::GetMemInfo().TotalPhysicalMemory >= 8_GiB; -// const bool has_broken_vulkan = UISettings::values.has_broken_vulkan; + // #if defined(ARCHITECTURE_x86_64) && !defined(__APPLE__) + // const auto& caps = Common::GetCPUCaps(); + // const bool has_fma = caps.fma || caps.fma4; + // const auto processor_count = std::thread::hardware_concurrency(); + // const bool has_4threads = processor_count == 0 || processor_count >= 4; + // const bool has_8gb_ram = Common::GetMemInfo().TotalPhysicalMemory >= 8_GiB; + // const bool has_broken_vulkan = UISettings::values.has_broken_vulkan; -// if (!has_fma || !has_4threads || !has_8gb_ram || has_broken_vulkan) { -// QMessageBox::critical(this, tr("Hardware requirements not met"), -// tr("Your system does not meet the recommended hardware requirements. " -// "Compatibility reporting has been disabled.")); -// return; -// } + // if (!has_fma || !has_4threads || !has_8gb_ram || has_broken_vulkan) { + // QMessageBox::critical(this, tr("Hardware requirements not met"), + // tr("Your system does not meet the recommended hardware + // requirements. " + // "Compatibility reporting has been disabled.")); + // return; + // } -// if (!Settings::values.eden_token.GetValue().empty() && -// !Settings::values.eden_username.GetValue().empty()) { -// } else { -// QMessageBox::critical( -// this, tr("Missing yuzu Account"), -// tr("In order to submit a game compatibility test case, you must set up your web token " -// "and " -// "username.

To link your eden account, go to Emulation > Configuration " -// "> " -// "Web.")); -// } -// #else -// QMessageBox::critical(this, tr("Hardware requirements not met"), -// tr("Your system does not meet the recommended hardware requirements. " -// "Compatibility reporting has been disabled.")); -// #endif + // if (!Settings::values.eden_token.GetValue().empty() && + // !Settings::values.eden_username.GetValue().empty()) { + // } else { + // QMessageBox::critical( + // this, tr("Missing yuzu Account"), + // tr("In order to submit a game compatibility test case, you must set up your web + // token " + // "and " + // "username.

To link your eden account, go to Emulation > + // Configuration " + // "> " + // "Web.")); + // } + // #else + // QMessageBox::critical(this, tr("Hardware requirements not met"), + // tr("Your system does not meet the recommended hardware + // requirements. " + // "Compatibility reporting has been disabled.")); + // #endif } void MainWindow::OpenURL(const QUrl& url) { @@ -3431,7 +3437,8 @@ void MainWindow::ToggleWindowMode() { } void MainWindow::ResetWindowSize(u32 width, u32 height) { - const auto aspect_ratio = Layout::EmulationAspectRatio(Settings::values.aspect_ratio.GetValue(), float(height) / width); + const auto aspect_ratio = Layout::EmulationAspectRatio(Settings::values.aspect_ratio.GetValue(), + float(height) / width); if (!ui->action_Single_Window_Mode->isChecked()) { render_window->resize(height / aspect_ratio, height); } else { @@ -3488,7 +3495,8 @@ void MainWindow::CheckIconSize() { for (size_t i = 0; i < default_game_icon_sizes.size(); i++) { const auto current_size = newSize; const auto size = default_game_icon_sizes[i].first; - if (current_size == size) actions.at(i)->setChecked(true); + if (current_size == size) + actions.at(i)->setChecked(true); } // Update this if you add anything before None. @@ -3499,7 +3507,7 @@ void MainWindow::CheckIconSize() { } void MainWindow::ToggleShowGameName() { - auto &setting = UISettings::values.show_game_name; + auto& setting = UISettings::values.show_game_name; const bool newValue = !setting.GetValue(); ui->action_Show_Game_Name->setChecked(newValue); setting.SetValue(newValue); @@ -3648,7 +3656,8 @@ void MainWindow::OnTasStartStop() { } // Disable system buttons to prevent TAS from executing a hotkey - auto* controller = QtCommon::system->HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1); + auto* controller = + QtCommon::system->HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1); controller->ResetSystemButtons(); input_subsystem->GetTas()->StartStop(); @@ -3664,7 +3673,8 @@ void MainWindow::OnTasRecord() { } // Disable system buttons to prevent TAS from recording a hotkey - auto* controller = QtCommon::system->HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1); + auto* controller = + QtCommon::system->HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1); controller->ResetSystemButtons(); const bool is_recording = input_subsystem->GetTas()->Record(); @@ -3690,8 +3700,10 @@ void MainWindow::OnTasReset() { void MainWindow::OnToggleDockedMode() { const bool is_docked = Settings::IsDockedMode(); - auto* player_1 = QtCommon::system->HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1); - auto* handheld = QtCommon::system->HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld); + auto* player_1 = + QtCommon::system->HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1); + auto* handheld = + QtCommon::system->HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld); if (!is_docked && handheld->IsConnected()) { QMessageBox::warning(this, tr("Invalid config detected"), @@ -3861,8 +3873,8 @@ void MainWindow::OnLoadAmiibo() { // TODO(crueter): does this need to be ported to QML? bool MainWindow::question(QWidget* parent, const QString& title, const QString& text, - QMessageBox::StandardButtons buttons, - QMessageBox::StandardButton defaultButton) { + QMessageBox::StandardButtons buttons, + QMessageBox::StandardButton defaultButton) { QMessageBox* box_dialog = new QMessageBox(parent); box_dialog->setWindowTitle(title); box_dialog->setText(text); @@ -3914,23 +3926,19 @@ void MainWindow::OnOpenRootDataFolder() { QtCommon::Game::OpenRootDataFolder(); } -void MainWindow::OnOpenNANDFolder() -{ +void MainWindow::OnOpenNANDFolder() { QtCommon::Game::OpenNANDFolder(); } -void MainWindow::OnOpenSDMCFolder() -{ +void MainWindow::OnOpenSDMCFolder() { QtCommon::Game::OpenSDMCFolder(); } -void MainWindow::OnOpenModFolder() -{ +void MainWindow::OnOpenModFolder() { QtCommon::Game::OpenModFolder(); } -void MainWindow::OnOpenLogFolder() -{ +void MainWindow::OnOpenLogFolder() { QtCommon::Game::OpenLogFolder(); } @@ -3993,7 +4001,8 @@ void MainWindow::OnInstallFirmwareFromZIP() { if (!qCacheDir.isEmpty()) { InstallFirmware(qCacheDir, true); std::error_code ec; - std::filesystem::remove_all(std::filesystem::temp_directory_path() / "eden" / "firmware", ec); + std::filesystem::remove_all(std::filesystem::temp_directory_path() / "eden" / "firmware", + ec); if (ec) { QMessageBox::warning(this, tr("Firmware cleanup failed"), @@ -4061,13 +4070,15 @@ void MainWindow::OnGameListRefresh() { SetFirmwareVersion(); } -void MainWindow::LaunchFirmwareApplet(u64 raw_program_id, std::optional cabinet_mode) { +void MainWindow::LaunchFirmwareApplet(u64 raw_program_id, + std::optional cabinet_mode) { auto const program_id = Service::AM::AppletProgramId(raw_program_id); auto result = FirmwareManager::VerifyFirmware(*QtCommon::system.get()); using namespace QtCommon::StringLookup; switch (result) { case FirmwareManager::ErrorFirmwareMissing: - QMessageBox::warning(this, tr("No firmware available"), Lookup(FwCheckErrorFirmwareMissing)); + QMessageBox::warning(this, tr("No firmware available"), + Lookup(FwCheckErrorFirmwareMissing)); return; case FirmwareManager::ErrorFirmwareCorrupted: QMessageBox::warning(this, tr("Firmware Corrupted"), Lookup(FwCheckErrorFirmwareCorrupted)); @@ -4076,33 +4087,58 @@ void MainWindow::LaunchFirmwareApplet(u64 raw_program_id, std::optionalGetFileSystemController().GetSystemNANDContents(); - if (auto applet_nca = bis_system->GetEntry(u64(program_id), FileSys::ContentRecordType::Program); applet_nca) { - if (auto const applet_id = [program_id] { - using namespace Service::AM; - switch (program_id) { - case AppletProgramId::OverlayDisplay: return AppletId::OverlayDisplay; - case AppletProgramId::QLaunch: return AppletId::QLaunch; - case AppletProgramId::Starter: return AppletId::Starter; - case AppletProgramId::Auth: return AppletId::Auth; - case AppletProgramId::Cabinet: return AppletId::Cabinet; - case AppletProgramId::Controller: return AppletId::Controller; - case AppletProgramId::DataErase: return AppletId::DataErase; - case AppletProgramId::Error: return AppletId::Error; - case AppletProgramId::NetConnect: return AppletId::NetConnect; - case AppletProgramId::ProfileSelect: return AppletId::ProfileSelect; - case AppletProgramId::SoftwareKeyboard: return AppletId::SoftwareKeyboard; - case AppletProgramId::MiiEdit: return AppletId::MiiEdit; - case AppletProgramId::Web: return AppletId::Web; - case AppletProgramId::Shop: return AppletId::Shop; - case AppletProgramId::PhotoViewer: return AppletId::PhotoViewer; - case AppletProgramId::Settings: return AppletId::Settings; - case AppletProgramId::OfflineWeb: return AppletId::OfflineWeb; - case AppletProgramId::LoginShare: return AppletId::LoginShare; - case AppletProgramId::WebAuth: return AppletId::WebAuth; - case AppletProgramId::MyPage: return AppletId::MyPage; - default: return AppletId::None; - } - }(); applet_id != Service::AM::AppletId::None) { + if (auto applet_nca = + bis_system->GetEntry(u64(program_id), FileSys::ContentRecordType::Program); + applet_nca) { + if (auto const applet_id = + [program_id] { + using namespace Service::AM; + switch (program_id) { + case AppletProgramId::OverlayDisplay: + return AppletId::OverlayDisplay; + case AppletProgramId::QLaunch: + return AppletId::QLaunch; + case AppletProgramId::Starter: + return AppletId::Starter; + case AppletProgramId::Auth: + return AppletId::Auth; + case AppletProgramId::Cabinet: + return AppletId::Cabinet; + case AppletProgramId::Controller: + return AppletId::Controller; + case AppletProgramId::DataErase: + return AppletId::DataErase; + case AppletProgramId::Error: + return AppletId::Error; + case AppletProgramId::NetConnect: + return AppletId::NetConnect; + case AppletProgramId::ProfileSelect: + return AppletId::ProfileSelect; + case AppletProgramId::SoftwareKeyboard: + return AppletId::SoftwareKeyboard; + case AppletProgramId::MiiEdit: + return AppletId::MiiEdit; + case AppletProgramId::Web: + return AppletId::Web; + case AppletProgramId::Shop: + return AppletId::Shop; + case AppletProgramId::PhotoViewer: + return AppletId::PhotoViewer; + case AppletProgramId::Settings: + return AppletId::Settings; + case AppletProgramId::OfflineWeb: + return AppletId::OfflineWeb; + case AppletProgramId::LoginShare: + return AppletId::LoginShare; + case AppletProgramId::WebAuth: + return AppletId::WebAuth; + case AppletProgramId::MyPage: + return AppletId::MyPage; + default: + return AppletId::None; + } + }(); + applet_id != Service::AM::AppletId::None) { QtCommon::system->GetFrontendAppletHolder().SetCurrentAppletId(applet_id); if (cabinet_mode) QtCommon::system->GetFrontendAppletHolder().SetCabinetMode(*cabinet_mode); @@ -4111,10 +4147,12 @@ void MainWindow::LaunchFirmwareApplet(u64 raw_program_id, std::optionalname))); + update_prompt.setText(tr("Download %1?").arg(QString::fromStdString(version->name))); update_prompt.exec(); if (update_prompt.button(QMessageBox::Yes) == update_prompt.clickedButton()) { - auto const full_url = fmt::format("{}/{}/releases/tag/", - std::string{Common::g_build_auto_update_website}, - std::string{Common::g_build_auto_update_repo} - ); + auto const full_url = + fmt::format("{}/{}/releases/tag/", std::string{Common::g_build_auto_update_website}, + std::string{Common::g_build_auto_update_repo}); QDesktopServices::openUrl(QUrl(QString::fromStdString(full_url + version->tag))); } } #endif -void MainWindow::UpdateWindowTitle(std::string_view title_name, std::string_view title_version, std::string_view gpu_vendor) { +void MainWindow::UpdateWindowTitle(std::string_view title_name, std::string_view title_version, + std::string_view gpu_vendor) { static const std::string build_id = std::string{Common::g_build_id}; - static const std::string yuzu_title = fmt::format("{} | {} | {}", - std::string{Common::g_build_name}, - std::string{Common::g_build_version}, - std::string{Common::g_compiler_id} - ); + static const std::string yuzu_title = + fmt::format("{} | {} | {}", std::string{Common::g_build_name}, + std::string{Common::g_build_version}, std::string{Common::g_compiler_id}); const auto override_title = fmt::format(fmt::runtime(std::string(Common::g_title_bar_format_idle)), build_id); @@ -4301,7 +4336,8 @@ void MainWindow::UpdateStatusBar() { } QString fpsText = tr("Game: %1 FPS").arg(std::round(results.average_game_fps), 0, 'f', 0); - if (!m_fpsSuffix.isEmpty()) fpsText = fpsText % QStringLiteral(" (%1)").arg(m_fpsSuffix); + if (!m_fpsSuffix.isEmpty()) + fpsText = fpsText % QStringLiteral(" (%1)").arg(m_fpsSuffix); game_fps_label->setText(fpsText); @@ -4444,7 +4480,9 @@ void MainWindow::OnCheckGraphicsBackend() { if (platformName == QStringLiteral("xcb") || qtPlatform == "xcb") return; - const bool isWayland = platformName.startsWith(QStringLiteral("wayland"), Qt::CaseInsensitive) || qtPlatform.startsWith("wayland"); + const bool isWayland = + platformName.startsWith(QStringLiteral("wayland"), Qt::CaseInsensitive) || + qtPlatform.startsWith("wayland"); if (!isWayland) return; @@ -4454,9 +4492,10 @@ void MainWindow::OnCheckGraphicsBackend() { QMessageBox msgbox(this); msgbox.setWindowTitle(tr("Wayland Detected!")); - msgbox.setText(tr("Wayland is known to have significant performance issues and mysterious bugs.\n" - "It's recommended to use X11 instead.\n\n" - "Would you like to force it for future launches?")); + msgbox.setText( + tr("Wayland is known to have significant performance issues and mysterious bugs.\n" + "It's recommended to use X11 instead.\n\n" + "Would you like to force it for future launches?")); msgbox.setIcon(QMessageBox::Warning); QPushButton* okButton = msgbox.addButton(tr("Use X11"), QMessageBox::AcceptRole); @@ -4477,8 +4516,7 @@ void MainWindow::OnCheckGraphicsBackend() { if (msgbox.clickedButton() == okButton) { UISettings::values.gui_force_x11.SetValue(true); GraphicsBackend::SetForceX11(true); - QMessageBox::information(this, - tr("Restart Required"), + QMessageBox::information(this, tr("Restart Required"), tr("Restart Eden to apply the X11 backend.")); } } @@ -4530,7 +4568,7 @@ void MainWindow::SetFPSSuffix() { } bool MainWindow::SelectRomFSDumpTarget(const FileSys::ContentProvider& installed, u64 program_id, - u64* selected_title_id, u8* selected_content_record_type) { + u64* selected_title_id, u8* selected_content_record_type) { using ContentInfo = std::tuple; boost::container::flat_set available_title_ids; @@ -4809,7 +4847,7 @@ void MainWindow::OnLanguageChanged(const QString& locale) { qApp->removeTranslator(&translator); } - QList actions = game_size_actions->actions(); + QList actions = game_size_actions->actions(); for (size_t i = 0; i < default_game_icon_sizes.size(); i++) { actions.at(i)->setText(GetTranslatedGameIconSize(i)); } diff --git a/src/yuzu/main_window.h b/src/yuzu/main_window.h index bb58191951..e85aadaa3d 100644 --- a/src/yuzu/main_window.h +++ b/src/yuzu/main_window.h @@ -24,15 +24,15 @@ #include "input_common/drivers/tas_input.h" #include "qt_common/config/qt_config.h" #include "qt_common/util/game.h" -#include "yuzu/user_data_migration.h" #include "yuzu/compatibility_list.h" #include "yuzu/hotkeys.h" +#include "yuzu/user_data_migration.h" #ifdef __unix__ #include +#include #include #include -#include #endif #ifdef ENABLE_UPDATE_CHECKER @@ -218,9 +218,10 @@ signals: void WebBrowserClosed(Service::AM::Frontend::WebExitReason exit_reason, std::string last_url); void SigInterrupt(); - void sizeChanged(const QSize &size); - void positionChanged(const QPoint &pos); - void statsUpdated(const Core::PerfStatsResults &results, const VideoCore::ShaderNotify &shaders); + void sizeChanged(const QSize& size); + void positionChanged(const QPoint& pos); + void statsUpdated(const Core::PerfStatsResults& results, + const VideoCore::ShaderNotify& shaders); public slots: void OnLoadComplete(); @@ -317,8 +318,8 @@ private: void RequestGameExit(); void changeEvent(QEvent* event) override; void closeEvent(QCloseEvent* event) override; - void resizeEvent(QResizeEvent *event) override; - void moveEvent(QMoveEvent *event) override; + void resizeEvent(QResizeEvent* event) override; + void moveEvent(QMoveEvent* event) override; std::string CreateTASFramesString( std::array frames) const; @@ -360,8 +361,7 @@ private slots: void OnGameListCopyTID(u64 program_id); void OnGameListNavigateToGamedbEntry(u64 program_id, const CompatibilityList& compatibility_list); - void OnGameListCreateShortcut(u64 program_id, - const std::string& game_path, + void OnGameListCreateShortcut(u64 program_id, const std::string& game_path, const QtCommon::Game::ShortcutTarget target); void OnGameListOpenDirectory(const QString& directory); void OnGameListAddDirectory(); @@ -483,7 +483,7 @@ private: */ bool question(QWidget* parent, const QString& title, const QString& text, QMessageBox::StandardButtons buttons = - QMessageBox::StandardButtons(QMessageBox::Yes | QMessageBox::No), + QMessageBox::StandardButtons(QMessageBox::Yes | QMessageBox::No), QMessageBox::StandardButton defaultButton = QMessageBox::NoButton); std::unique_ptr ui; @@ -504,7 +504,7 @@ private: LoadingScreen* loading_screen = nullptr; QTimer shutdown_timer; OverlayDialog* shutdown_dialog{}; - PerformanceOverlay *perf_overlay = nullptr; + PerformanceOverlay* perf_overlay = nullptr; GameListPlaceholder* game_list_placeholder = nullptr; @@ -551,7 +551,7 @@ private: QString startup_icon_theme; - QActionGroup *game_size_actions; + QActionGroup* game_size_actions; // Debugger panes ControllerDialog* controller_dialog = nullptr; @@ -595,12 +595,9 @@ private: std::filesystem::path GetEdenCommand(); - void CreateShortcut(const std::string& game_path, - const u64 program_id, - const std::string& game_title, - QtCommon::Game::ShortcutTarget target, - std::string arguments, - const bool needs_title); + void CreateShortcut(const std::string& game_path, const u64 program_id, + const std::string& game_title, QtCommon::Game::ShortcutTarget target, + std::string arguments, const bool needs_title); void InstallFirmware(const QString& location, bool recursive = false); diff --git a/src/yuzu/migration_dialog.cpp b/src/yuzu/migration_dialog.cpp index 9cc40841e8..ba6a14b156 100644 --- a/src/yuzu/migration_dialog.cpp +++ b/src/yuzu/migration_dialog.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + #include "migration_dialog.h" #include @@ -6,11 +9,8 @@ #include #include -MigrationDialog::MigrationDialog( - QWidget *parent) - : QDialog(parent) -{ - QVBoxLayout *layout = new QVBoxLayout(this); +MigrationDialog::MigrationDialog(QWidget* parent) : QDialog(parent) { + QVBoxLayout* layout = new QVBoxLayout(this); m_text = new QLabel(this); m_boxes = new QVBoxLayout; @@ -26,23 +26,16 @@ MigrationDialog::~MigrationDialog() { m_buttons->deleteLater(); } -void MigrationDialog::setText( - const QString &text) -{ +void MigrationDialog::setText(const QString& text) { m_text->setText(text); } -void MigrationDialog::addBox( - QWidget *box) -{ +void MigrationDialog::addBox(QWidget* box) { m_boxes->addWidget(box); - } -QAbstractButton *MigrationDialog::addButton( - const QString &text, const bool reject) -{ - QAbstractButton *button = new QPushButton(this); +QAbstractButton* MigrationDialog::addButton(const QString& text, const bool reject) { + QAbstractButton* button = new QPushButton(this); button->setText(text); m_buttons->addWidget(button, 1); @@ -58,7 +51,6 @@ QAbstractButton *MigrationDialog::addButton( return button; } -QAbstractButton *MigrationDialog::clickedButton() const -{ +QAbstractButton* MigrationDialog::clickedButton() const { return m_clickedButton; } diff --git a/src/yuzu/migration_dialog.h b/src/yuzu/migration_dialog.h index 7123fd6b87..a2a2c80358 100644 --- a/src/yuzu/migration_dialog.h +++ b/src/yuzu/migration_dialog.h @@ -1,30 +1,33 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + #ifndef MIGRATION_DIALOG_H #define MIGRATION_DIALOG_H -#include -#include #include +#include #include +#include class MigrationDialog : public QDialog { Q_OBJECT public: - MigrationDialog(QWidget *parent = nullptr); + MigrationDialog(QWidget* parent = nullptr); virtual ~MigrationDialog(); - void setText(const QString &text); - void addBox(QWidget *box); - QAbstractButton *addButton(const QString &text, const bool reject = false); + void setText(const QString& text); + void addBox(QWidget* box); + QAbstractButton* addButton(const QString& text, const bool reject = false); - QAbstractButton *clickedButton() const; + QAbstractButton* clickedButton() const; private: - QLabel *m_text; - QVBoxLayout *m_boxes; - QHBoxLayout *m_buttons; + QLabel* m_text; + QVBoxLayout* m_boxes; + QHBoxLayout* m_buttons; - QAbstractButton *m_clickedButton; + QAbstractButton* m_clickedButton; }; #endif // MIGRATION_DIALOG_H diff --git a/src/yuzu/migration_worker.cpp b/src/yuzu/migration_worker.cpp index 0149db4149..ba5e50e187 100644 --- a/src/yuzu/migration_worker.cpp +++ b/src/yuzu/migration_worker.cpp @@ -1,27 +1,22 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later -#include "migration_worker.h" #include "common/fs/symlink.h" +#include "migration_worker.h" +#include #include #include #include -#include #include "common/fs/path_util.h" -MigrationWorker::MigrationWorker(const Emulator selected_emu_, - const bool clear_shader_cache_, +MigrationWorker::MigrationWorker(const Emulator selected_emu_, const bool clear_shader_cache_, const MigrationStrategy strategy_) - : QObject() - , selected_emu(selected_emu_) - , clear_shader_cache(clear_shader_cache_) - , strategy(strategy_) -{} + : QObject(), selected_emu(selected_emu_), clear_shader_cache(clear_shader_cache_), + strategy(strategy_) {} -void MigrationWorker::process() -{ +void MigrationWorker::process() { namespace fs = std::filesystem; constexpr auto copy_options = fs::copy_options::update_existing | fs::copy_options::recursive; @@ -42,7 +37,7 @@ void MigrationWorker::process() try { fs::remove_all(eden_dir); - } catch (fs::filesystem_error &_) { + } catch (fs::filesystem_error& _) { // ignore because linux does stupid crap sometimes } @@ -53,7 +48,7 @@ void MigrationWorker::process() // Windows 11 has random permission nonsense to deal with. try { Common::FS::CreateSymlink(legacy_user_dir, eden_dir); - } catch (const fs::filesystem_error &e) { + } catch (const fs::filesystem_error& e) { emit error(tr("Linking the old directory failed. You may need to re-run with " "administrative privileges on Windows.\nOS gave error: %1") .arg(tr(e.what()))); @@ -74,8 +69,7 @@ void MigrationWorker::process() success_text.append(tr("\n\nNote that your configuration and data will be shared with %1.\n" "If this is not desirable, delete the following files:\n%2\n%3\n%4") - .arg(selected_emu.name(), - QString::fromStdString(eden_dir.string()), + .arg(selected_emu.name(), QString::fromStdString(eden_dir.string()), QString::fromStdString(config_dir.string()), QString::fromStdString(cache_dir.string()))); diff --git a/src/yuzu/migration_worker.h b/src/yuzu/migration_worker.h index 2db05570ea..42abedb9c8 100644 --- a/src/yuzu/migration_worker.h +++ b/src/yuzu/migration_worker.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later #ifndef MIGRATION_WORKER_H @@ -8,7 +8,7 @@ #include "common/fs/path_util.h" typedef struct Emulator { - const char *m_name; + const char* m_name; Common::FS::EmuPath e_user_dir; Common::FS::EmuPath e_config_dir; @@ -26,14 +26,20 @@ typedef struct Emulator { return Common::FS::GetLegacyPath(e_cache_dir).string(); } - const QString name() const { return QObject::tr(m_name); + const QString name() const { + return QObject::tr(m_name); } - const QString lower_name() const { return name().toLower(); + const QString lower_name() const { + return name().toLower(); } } Emulator; -#define STRUCT_EMU(name, enumName) Emulator{name, Common::FS::enumName##Dir, Common::FS::enumName##ConfigDir, Common::FS::enumName##CacheDir} +#define STRUCT_EMU(name, enumName) \ + Emulator { \ + name, Common::FS::enumName##Dir, Common::FS::enumName##ConfigDir, \ + Common::FS::enumName##CacheDir \ + } static constexpr std::array legacy_emus = { STRUCT_EMU(QT_TR_NOOP("Citron"), Citron), @@ -42,8 +48,7 @@ static constexpr std::array legacy_emus = { STRUCT_EMU(QT_TR_NOOP("Yuzu"), Yuzu), }; -class MigrationWorker : public QObject -{ +class MigrationWorker : public QObject { Q_OBJECT public: enum class MigrationStrategy { @@ -52,16 +57,15 @@ public: Link, }; - MigrationWorker(const Emulator selected_emu, - const bool clear_shader_cache, + MigrationWorker(const Emulator selected_emu, const bool clear_shader_cache, const MigrationStrategy strategy); public slots: void process(); signals: - void finished(const QString &success_text, const std::string &user_dir); - void error(const QString &error_message); + void finished(const QString& success_text, const std::string& user_dir); + void error(const QString& error_message); private: Emulator selected_emu; diff --git a/src/yuzu/multiplayer/chat_room.h b/src/yuzu/multiplayer/chat_room.h index a94683ef58..44ec8952d1 100644 --- a/src/yuzu/multiplayer/chat_room.h +++ b/src/yuzu/multiplayer/chat_room.h @@ -6,11 +6,11 @@ #pragma once #include -#include #include #include #include #include +#include #include "network/network.h" namespace Ui { diff --git a/src/yuzu/multiplayer/direct_connect.cpp b/src/yuzu/multiplayer/direct_connect.cpp index 486ab28213..eea906f16d 100644 --- a/src/yuzu/multiplayer/direct_connect.cpp +++ b/src/yuzu/multiplayer/direct_connect.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2017 Citra Emulator Project @@ -14,6 +14,7 @@ #include "core/core.h" #include "core/internal_network/network_interface.h" #include "network/network.h" +#include "qt_common/config/uisettings.h" #include "ui_direct_connect.h" #include "yuzu/main_window.h" #include "yuzu/multiplayer/client_room.h" @@ -21,7 +22,6 @@ #include "yuzu/multiplayer/message.h" #include "yuzu/multiplayer/state.h" #include "yuzu/multiplayer/validation.h" -#include "qt_common/config/uisettings.h" enum class ConnectionType : u8 { TraversalServer, IP }; diff --git a/src/yuzu/multiplayer/host_room.cpp b/src/yuzu/multiplayer/host_room.cpp index 3e5e42e442..65afcc3b7c 100644 --- a/src/yuzu/multiplayer/host_room.cpp +++ b/src/yuzu/multiplayer/host_room.cpp @@ -18,6 +18,7 @@ #include "core/core.h" #include "core/internal_network/network_interface.h" #include "network/announce_multiplayer_session.h" +#include "qt_common/config/uisettings.h" #include "ui_host_room.h" #include "yuzu/game/game_list_p.h" #include "yuzu/main_window.h" @@ -25,7 +26,6 @@ #include "yuzu/multiplayer/message.h" #include "yuzu/multiplayer/state.h" #include "yuzu/multiplayer/validation.h" -#include "qt_common/config/uisettings.h" #ifdef ENABLE_WEB_SERVICE #include "web_service/verify_user_jwt.h" #endif @@ -34,8 +34,7 @@ HostRoomWindow::HostRoomWindow(QWidget* parent, QStandardItemModel* list, std::shared_ptr session, Core::System& system_) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint), - ui(std::make_unique()), - announce_multiplayer_session(session), system{system_} { + ui(std::make_unique()), announce_multiplayer_session(session), system{system_} { ui->setupUi(this); // set up validation for all of the fields diff --git a/src/yuzu/multiplayer/lobby.cpp b/src/yuzu/multiplayer/lobby.cpp index f28374f75f..8c435af8b6 100644 --- a/src/yuzu/multiplayer/lobby.cpp +++ b/src/yuzu/multiplayer/lobby.cpp @@ -13,6 +13,7 @@ #include "core/hle/service/acc/profile_manager.h" #include "core/internal_network/network_interface.h" #include "network/network.h" +#include "qt_common/config/uisettings.h" #include "ui_lobby.h" #include "yuzu/game/game_list_p.h" #include "yuzu/main_window.h" @@ -22,7 +23,6 @@ #include "yuzu/multiplayer/message.h" #include "yuzu/multiplayer/state.h" #include "yuzu/multiplayer/validation.h" -#include "qt_common/config/uisettings.h" #ifdef ENABLE_WEB_SERVICE #include "web_service/web_backend.h" #endif @@ -30,8 +30,7 @@ Lobby::Lobby(QWidget* parent, QStandardItemModel* list, std::shared_ptr session, Core::System& system_) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint), - ui(std::make_unique()), - announce_multiplayer_session(session), system{system_} { + ui(std::make_unique()), announce_multiplayer_session(session), system{system_} { ui->setupUi(this); // setup the watcher for background connections diff --git a/src/yuzu/multiplayer/state.cpp b/src/yuzu/multiplayer/state.cpp index c344bcb8a3..b5f2326b44 100644 --- a/src/yuzu/multiplayer/state.cpp +++ b/src/yuzu/multiplayer/state.cpp @@ -11,6 +11,7 @@ #include "common/announce_multiplayer_room.h" #include "common/logging/log.h" #include "core/core.h" +#include "qt_common/config/uisettings.h" #include "yuzu/game/game_list.h" #include "yuzu/multiplayer/client_room.h" #include "yuzu/multiplayer/direct_connect.h" @@ -18,7 +19,6 @@ #include "yuzu/multiplayer/lobby.h" #include "yuzu/multiplayer/message.h" #include "yuzu/multiplayer/state.h" -#include "qt_common/config/uisettings.h" #include "yuzu/util/clickable_label.h" MultiplayerState::MultiplayerState(QWidget* parent, QStandardItemModel* game_list_model_, diff --git a/src/yuzu/render/performance_overlay.h b/src/yuzu/render/performance_overlay.h index 1d7fb46f26..a0325a10a3 100644 --- a/src/yuzu/render/performance_overlay.h +++ b/src/yuzu/render/performance_overlay.h @@ -34,13 +34,13 @@ protected: void mousePressEvent(QMouseEvent* event) override; void mouseMoveEvent(QMouseEvent* event) override; - void closeEvent(QCloseEvent *event) override; + void closeEvent(QCloseEvent* event) override; private: void resetPosition(const QPoint& pos); - void updateStats(const Core::PerfStatsResults &results, const VideoCore::ShaderNotify &shaders); + void updateStats(const Core::PerfStatsResults& results, const VideoCore::ShaderNotify& shaders); - MainWindow *m_mainWindow = nullptr; + MainWindow* m_mainWindow = nullptr; Ui::PerformanceOverlay* ui; // colors @@ -62,11 +62,11 @@ private: QPoint m_drag_start_pos; // fps chart - QLineSeries *m_fpsSeries = nullptr; - QChart *m_fpsChart = nullptr; - QChartView *m_fpsChartView = nullptr; - QValueAxis *m_fpsX = nullptr; - QValueAxis *m_fpsY = nullptr; + QLineSeries* m_fpsSeries = nullptr; + QChart* m_fpsChart = nullptr; + QChartView* m_fpsChartView = nullptr; + QValueAxis* m_fpsX = nullptr; + QValueAxis* m_fpsY = nullptr; signals: void closed(); diff --git a/src/yuzu/ryujinx_dialog.cpp b/src/yuzu/ryujinx_dialog.cpp index 563714f6be..f52f37b297 100644 --- a/src/yuzu/ryujinx_dialog.cpp +++ b/src/yuzu/ryujinx_dialog.cpp @@ -1,20 +1,16 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later -#include "qt_common/abstract/frontend.h" -#include "ryujinx_dialog.h" -#include "qt_common/util/fs.h" -#include "ui_ryujinx_dialog.h" #include +#include "qt_common/abstract/frontend.h" +#include "qt_common/util/fs.h" +#include "ryujinx_dialog.h" +#include "ui_ryujinx_dialog.h" -RyujinxDialog::RyujinxDialog(std::filesystem::path eden_path, - std::filesystem::path ryu_path, - QWidget *parent) - : QDialog(parent) - , ui(new Ui::RyujinxDialog) - , m_eden(eden_path.make_preferred()) - , m_ryu(ryu_path.make_preferred()) -{ +RyujinxDialog::RyujinxDialog(std::filesystem::path eden_path, std::filesystem::path ryu_path, + QWidget* parent) + : QDialog(parent), ui(new Ui::RyujinxDialog), m_eden(eden_path.make_preferred()), + m_ryu(ryu_path.make_preferred()) { ui->setupUi(this); connect(ui->eden, &QPushButton::clicked, this, &RyujinxDialog::fromEden); @@ -22,13 +18,11 @@ RyujinxDialog::RyujinxDialog(std::filesystem::path eden_path, connect(ui->cancel, &QPushButton::clicked, this, &RyujinxDialog::reject); } -RyujinxDialog::~RyujinxDialog() -{ +RyujinxDialog::~RyujinxDialog() { delete ui; } -void RyujinxDialog::fromEden() -{ +void RyujinxDialog::fromEden() { accept(); // Workaround: Ryujinx deletes and re-creates its directory structure??? @@ -38,17 +32,17 @@ void RyujinxDialog::fromEden() fs::remove_all(m_ryu); fs::create_directories(m_ryu); fs::copy(m_eden, m_ryu, fs::copy_options::recursive); - } catch (std::exception &e) { - QtCommon::Frontend::Critical(tr("Failed to link save data"), - tr("OS returned error: %1").arg(QString::fromStdString(e.what()))); + } catch (std::exception& e) { + QtCommon::Frontend::Critical( + tr("Failed to link save data"), + tr("OS returned error: %1").arg(QString::fromStdString(e.what()))); } // ?ploo QtCommon::FS::LinkRyujinx(m_ryu, m_eden); } -void RyujinxDialog::fromRyujinx() -{ +void RyujinxDialog::fromRyujinx() { accept(); QtCommon::FS::LinkRyujinx(m_ryu, m_eden); } diff --git a/src/yuzu/ryujinx_dialog.h b/src/yuzu/ryujinx_dialog.h index 63cebe483c..c067499cc1 100644 --- a/src/yuzu/ryujinx_dialog.h +++ b/src/yuzu/ryujinx_dialog.h @@ -1,22 +1,22 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later #ifndef RYUJINX_DIALOG_H #define RYUJINX_DIALOG_H -#include #include +#include namespace Ui { class RyujinxDialog; } -class RyujinxDialog : public QDialog -{ +class RyujinxDialog : public QDialog { Q_OBJECT public: - explicit RyujinxDialog(std::filesystem::path eden_path, std::filesystem::path ryu_path, QWidget *parent = nullptr); + explicit RyujinxDialog(std::filesystem::path eden_path, std::filesystem::path ryu_path, + QWidget* parent = nullptr); ~RyujinxDialog(); private slots: @@ -24,7 +24,7 @@ private slots: void fromRyujinx(); private: - Ui::RyujinxDialog *ui; + Ui::RyujinxDialog* ui; std::filesystem::path m_eden; std::filesystem::path m_ryu; }; diff --git a/src/yuzu/set_play_time_dialog.cpp b/src/yuzu/set_play_time_dialog.cpp index c0f1f0be22..38876abd6d 100644 --- a/src/yuzu/set_play_time_dialog.cpp +++ b/src/yuzu/set_play_time_dialog.cpp @@ -1,20 +1,23 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later -#include "yuzu/set_play_time_dialog.h" #include "frontend_common/play_time_manager.h" #include "ui_set_play_time_dialog.h" +#include "yuzu/set_play_time_dialog.h" SetPlayTimeDialog::SetPlayTimeDialog(QWidget* parent, u64 current_play_time) : QDialog(parent), ui{std::make_unique()} { ui->setupUi(this); ui->hoursSpinBox->setValue( - QString::fromStdString(PlayTime::PlayTimeManager::GetPlayTimeHours(current_play_time)).toInt()); + QString::fromStdString(PlayTime::PlayTimeManager::GetPlayTimeHours(current_play_time)) + .toInt()); ui->minutesSpinBox->setValue( - QString::fromStdString(PlayTime::PlayTimeManager::GetPlayTimeMinutes(current_play_time)).toInt()); + QString::fromStdString(PlayTime::PlayTimeManager::GetPlayTimeMinutes(current_play_time)) + .toInt()); ui->secondsSpinBox->setValue( - QString::fromStdString(PlayTime::PlayTimeManager::GetPlayTimeSeconds(current_play_time)).toInt()); + QString::fromStdString(PlayTime::PlayTimeManager::GetPlayTimeSeconds(current_play_time)) + .toInt()); connect(ui->hoursSpinBox, QOverload::of(&QSpinBox::valueChanged), this, &SetPlayTimeDialog::OnValueChanged); diff --git a/src/yuzu/set_play_time_dialog.h b/src/yuzu/set_play_time_dialog.h index 75513539e5..a66ceb7ced 100644 --- a/src/yuzu/set_play_time_dialog.h +++ b/src/yuzu/set_play_time_dialog.h @@ -1,10 +1,10 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later #pragma once -#include #include +#include #include "common/common_types.h" namespace Ui { diff --git a/src/yuzu/user_data_migration.cpp b/src/yuzu/user_data_migration.cpp index bc31c99e30..da8b0847c7 100644 --- a/src/yuzu/user_data_migration.cpp +++ b/src/yuzu/user_data_migration.cpp @@ -1,42 +1,41 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // Copyright Citra Emulator Project / Azahar Emulator Project // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include "user_data_migration.h" #include #include #include #include #include "common/fs/path_util.h" #include "qt_common/qt_string_lookup.h" +#include "user_data_migration.h" #include "yuzu/migration_dialog.h" // Needs to be included at the end due to https://bugreports.qt.io/browse/QTBUG-73263 +#include #include #include #include #include #include #include -#include -UserDataMigrator::UserDataMigrator(QMainWindow *main_window) -{ +UserDataMigrator::UserDataMigrator(QMainWindow* main_window) { // NOTE: Logging is not initialized yet, do not produce logs here. // Check migration if config directory does not exist - // TODO: ProfileManager messes with us a bit here, and force-creates the /nand/system/save/8000000000000010/su/avators/profiles.dat - // file. Find a way to reorder operations and have it create after this guy runs. + // TODO: ProfileManager messes with us a bit here, and force-creates the + // /nand/system/save/8000000000000010/su/avators/profiles.dat file. Find a way to reorder + // operations and have it create after this guy runs. if (!std::filesystem::is_directory(Common::FS::GetEdenPath(Common::FS::EdenPath::ConfigDir))) { ShowMigrationPrompt(main_window); } } -void UserDataMigrator::ShowMigrationPrompt(QMainWindow *main_window) -{ +void UserDataMigrator::ShowMigrationPrompt(QMainWindow* main_window) { namespace fs = std::filesystem; using namespace QtCommon::StringLookup; @@ -44,35 +43,36 @@ void UserDataMigrator::ShowMigrationPrompt(QMainWindow *main_window) migration_prompt.setWindowTitle(QObject::tr("Migration")); // mutually exclusive - QButtonGroup *group = new QButtonGroup(&migration_prompt); + QButtonGroup* group = new QButtonGroup(&migration_prompt); // MACRO MADNESS -#define BUTTON(clazz, name, text, tooltip, checkState) \ - clazz *name = new clazz(&migration_prompt); \ - name->setText(text); \ - name->setToolTip(Lookup(tooltip)); \ - name->setChecked(checkState); \ +#define BUTTON(clazz, name, text, tooltip, checkState) \ + clazz* name = new clazz(&migration_prompt); \ + name->setText(text); \ + name->setToolTip(Lookup(tooltip)); \ + name->setChecked(checkState); \ migration_prompt.addBox(name); - BUTTON(QCheckBox, clear_shaders, QObject::tr("Clear Shader Cache"), MigrationTooltipClearShader, true) + BUTTON(QCheckBox, clear_shaders, QObject::tr("Clear Shader Cache"), MigrationTooltipClearShader, + true) u32 id = 0; -#define RADIO(name, text, tooltip, checkState) \ - BUTTON(QRadioButton, name, text, tooltip, checkState) \ +#define RADIO(name, text, tooltip, checkState) \ + BUTTON(QRadioButton, name, text, tooltip, checkState) \ group->addButton(name, ++id); - RADIO(keep_old, QObject::tr("Keep Old Data"), MigrationTooltipKeepOld, true) + RADIO(keep_old, QObject::tr("Keep Old Data"), MigrationTooltipKeepOld, true) RADIO(clear_old, QObject::tr("Clear Old Data"), MigrationTooltipClearOld, false) - RADIO(link_old, QObject::tr("Link Old Directory"), MigrationTooltipLinkOld, false) + RADIO(link_old, QObject::tr("Link Old Directory"), MigrationTooltipLinkOld, false) #undef RADIO #undef BUTTON std::vector found{}; - for (const Emulator &emu : legacy_emus) + for (const Emulator& emu : legacy_emus) if (fs::is_directory(emu.get_user_dir())) found.emplace_back(emu); @@ -86,10 +86,10 @@ void UserDataMigrator::ShowMigrationPrompt(QMainWindow *main_window) QString prompt_text = Lookup(MigrationPromptPrefix); // natural language processing is a nightmare - for (const Emulator &emu : found) { + for (const Emulator& emu : found) { prompt_text = prompt_text % QStringLiteral("\n ") % emu.name(); - QAbstractButton *button = migration_prompt.addButton(emu.name()); + QAbstractButton* button = migration_prompt.addButton(emu.name()); // This is cursed, but it's actually the most efficient way by a mile button->setProperty("emulator", QVariant::fromValue(emu)); @@ -103,26 +103,22 @@ void UserDataMigrator::ShowMigrationPrompt(QMainWindow *main_window) migration_prompt.exec(); - QAbstractButton *button = migration_prompt.clickedButton(); + QAbstractButton* button = migration_prompt.clickedButton(); if (button->text() == QObject::tr("No")) { return ShowMigrationCancelledMessage(main_window); } - MigrationWorker::MigrationStrategy strategy = static_cast( - group->checkedId()); + MigrationWorker::MigrationStrategy strategy = + static_cast(group->checkedId()); selected_emu = button->property("emulator").value(); - MigrateUserData(main_window, - clear_shaders->isChecked(), - strategy); + MigrateUserData(main_window, clear_shaders->isChecked(), strategy); } -void UserDataMigrator::ShowMigrationCancelledMessage(QMainWindow *main_window) -{ - QMessageBox::information(main_window, - QObject::tr("Migration"), +void UserDataMigrator::ShowMigrationCancelledMessage(QMainWindow* main_window) { + QMessageBox::information(main_window, QObject::tr("Migration"), QObject::tr("You can manually re-trigger this prompt by deleting the " "new config directory:\n%1") .arg(QString::fromStdString(Common::FS::GetEdenPathString( @@ -130,33 +126,27 @@ void UserDataMigrator::ShowMigrationCancelledMessage(QMainWindow *main_window) QMessageBox::Ok); } -void UserDataMigrator::MigrateUserData(QMainWindow *main_window, - const bool clear_shader_cache, - const MigrationWorker::MigrationStrategy strategy) -{ +void UserDataMigrator::MigrateUserData(QMainWindow* main_window, const bool clear_shader_cache, + const MigrationWorker::MigrationStrategy strategy) { // Create a dialog to let the user know it's migrating - QProgressDialog *progress = new QProgressDialog(main_window); + QProgressDialog* progress = new QProgressDialog(main_window); progress->setWindowTitle(QObject::tr("Migrating")); progress->setLabelText(QObject::tr("Migrating, this may take a while...")); progress->setRange(0, 0); progress->setCancelButton(nullptr); progress->setWindowModality(Qt::WindowModality::ApplicationModal); - QThread *thread = new QThread(main_window); - MigrationWorker *worker = new MigrationWorker(selected_emu, clear_shader_cache, strategy); + QThread* thread = new QThread(main_window); + MigrationWorker* worker = new MigrationWorker(selected_emu, clear_shader_cache, strategy); worker->moveToThread(thread); thread->connect(thread, &QThread::started, worker, &MigrationWorker::process); - thread->connect(worker, - &MigrationWorker::finished, - progress, - [=, this](const QString &success_text, const std::string &path) { + thread->connect(worker, &MigrationWorker::finished, progress, + [=, this](const QString& success_text, const std::string& path) { progress->close(); - QMessageBox::information(main_window, - QObject::tr("Migration"), - success_text, - QMessageBox::Ok); + QMessageBox::information(main_window, QObject::tr("Migration"), + success_text, QMessageBox::Ok); migrated = true; thread->quit(); diff --git a/src/yuzu/user_data_migration.h b/src/yuzu/user_data_migration.h index 1cfeda3bca..df8057eaa5 100644 --- a/src/yuzu/user_data_migration.h +++ b/src/yuzu/user_data_migration.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // Copyright Citra Emulator Project / Azahar Emulator Project @@ -21,7 +21,6 @@ public: private: void ShowMigrationPrompt(QMainWindow* main_window); void ShowMigrationCancelledMessage(QMainWindow* main_window); - void MigrateUserData(QMainWindow* main_window, - const bool clear_shader_cache, + void MigrateUserData(QMainWindow* main_window, const bool clear_shader_cache, const MigrationWorker::MigrationStrategy strategy); }; diff --git a/src/yuzu/util/util.cpp b/src/yuzu/util/util.cpp index 307f121a49..3e9ebc2ad2 100644 --- a/src/yuzu/util/util.cpp +++ b/src/yuzu/util/util.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: 2015 Citra Emulator Project @@ -157,11 +157,11 @@ const std::optional GetProfileID() { const auto select_profile = [] { const Core::Frontend::ProfileSelectParameters parameters{ - .mode = Service::AM::Frontend::UiMode::UserSelector, - .invalid_uid_list = {}, - .display_options = {}, - .purpose = Service::AM::Frontend::UserSelectionPurpose::General, - }; + .mode = Service::AM::Frontend::UiMode::UserSelector, + .invalid_uid_list = {}, + .display_options = {}, + .purpose = Service::AM::Frontend::UserSelectionPurpose::General, + }; QtProfileSelectionDialog dialog(*QtCommon::system, QtCommon::rootObject, parameters); dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint); diff --git a/src/yuzu/vk_device_info.cpp b/src/yuzu/vk_device_info.cpp index 45faecb95d..2b87ccd3ca 100644 --- a/src/yuzu/vk_device_info.cpp +++ b/src/yuzu/vk_device_info.cpp @@ -62,12 +62,13 @@ void PopulateRecords(std::vector& records, QWindow* window) try { const auto driverID = driver_properties.driverID; - bool has_broken_compute{Vulkan::Device::CheckBrokenCompute( - driverID, properties.properties.driverVersion)}; + bool has_broken_compute{ + Vulkan::Device::CheckBrokenCompute(driverID, properties.properties.driverVersion)}; std::string driver_string = Vulkan::vk::GetDriverName(driver_properties); - if (driver_string.empty()) driver_string = "Unknown"; + if (driver_string.empty()) + driver_string = "Unknown"; name = fmt::format("{} ({})", name, driver_string); From d35fc7b7ee47993cf8e45d7fd09d13f30ab85adf Mon Sep 17 00:00:00 2001 From: lizzie Date: Wed, 11 Mar 2026 16:49:03 +0100 Subject: [PATCH 19/25] [docs] testing guidelines, unify controller guide, gamemode (#3709) Signed-off-by: lizzie Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3709 Reviewed-by: DraVee Reviewed-by: MaranBr Co-authored-by: lizzie Co-committed-by: lizzie --- docs/user/AlterDateTime.md | 6 +- docs/user/Basics.md | 9 +++ docs/user/ControllerProfiles.md | 49 ---------------- docs/user/Controllers.md | 65 +++++++++++++++++++++ docs/user/README.md | 8 ++- docs/user/RunOnMacOS.md | 16 +++-- docs/user/Settings.md | 3 +- docs/user/Testing.md | 100 +++++++++++++++++++++++++------- docs/user/ThirdParty.md | 7 ++- 9 files changed, 181 insertions(+), 82 deletions(-) delete mode 100644 docs/user/ControllerProfiles.md create mode 100644 docs/user/Controllers.md diff --git a/docs/user/AlterDateTime.md b/docs/user/AlterDateTime.md index 43bd3ed7b1..aeffa1a548 100644 --- a/docs/user/AlterDateTime.md +++ b/docs/user/AlterDateTime.md @@ -1,6 +1,6 @@ # Setting a Custom Date/Time in Eden -Use this guide whenever you want to modify the Date or Time that Eden reports to games. This can be useful for modifying RNG elements, skipping wait times in games, etc. +Use this guide whenever you want to modify the Date or Time that Eden reports to games. This can be useful for modifying RNG elements, skipping wait times in games, etc. **Click [Here](https://evilperson1337.notion.site/Setting-a-Custom-Date-Time-in-Eden-2b357c2edaf680acb8d4e63ccc126564) for a version of this guide with images & visual elements.** @@ -16,5 +16,5 @@ Use this guide whenever you want to modify the Date or Time that Eden reports to 1. Navigate to *Emulation → Configure*. 2. Click on the **System** item on the left-hand side navigation, then check the *Custom RTC Date* box. -3. The Date/Time option now becomes editable. Set it to the value you want and hit **OK**. -4. GREAT SCOTT! We have time traveled! You can of course go forward or backward in time (as long as it is not before the year 1970) and your game should update accordingly (e.g. certain *Super Mario Odyssey* moons that take time for flowers to grow will now be fully grown.). \ No newline at end of file +3. The Date/Time option now becomes editable. Set it to the value you want and hit **OK**. +4. GREAT SCOTT! We have time traveled! You can of course go forward or backward in time (as long as it is not before the year 1970) and your game should update accordingly (e.g. certain *Super Mario Odyssey* moons that take time for flowers to grow will now be fully grown.). \ No newline at end of file diff --git a/docs/user/Basics.md b/docs/user/Basics.md index 5101f4d9c3..794a0935d5 100644 --- a/docs/user/Basics.md +++ b/docs/user/Basics.md @@ -16,6 +16,15 @@ The CPU must support FMA for an optimal gameplay experience. The GPU needs to su If your GPU doesn't support or is just behind by a minor version, see Mesa environment variables below (*nix only). +## Releases and versions + +- Stable releases/Versioned releases: Has a version number and it's the versions we expect 3rd party repositories to host (package managers and such), these are, well, stable, have low amount of regressions (wrt. to master and nightlies) and generally focus on "keeping things without regressions", recommended for the average user. + - RC releases: Release candidate, generally "less stable but still stable" versions. + - Full release: "The stablest possible you could get". +- Nightly: Builds done around 2PM UTC (if there are any changes), generally stable, but not recommended for the average user. These contain daily updates and may contain critical fixes for some games. +- Master: Unstable builds, can lead from a game working exceptionally fine to absolute crashing in some systems because someone forgot to check if NixOS or Solaris worked. These contain straight from the oven fixes, please don't use them unless you plan to contribute something! They're very experimental! Still 95% of the time it will work just fine. +- PR builds: Highly experimental builds, testers may grab from these. The average user should treat them the same as master builds, except sometimes they straight up don't build/work. + ## User configuration ### Configuration directories diff --git a/docs/user/ControllerProfiles.md b/docs/user/ControllerProfiles.md deleted file mode 100644 index 3b4898f447..0000000000 --- a/docs/user/ControllerProfiles.md +++ /dev/null @@ -1,49 +0,0 @@ -# Configuring Controller Profiles - -Use this guide for when you want to configure specific controller settings to be reused. - -**Click [Here](https://evilperson1337.notion.site/Configuring-Controller-Profiles-2be57c2edaf680eabc3ac8c333ec75c4) for a version of this guide with images & visual elements.** - ---- - -### Pre-Requisites - -- Eden Set Up and Configured - ---- - -### Steps -1. Launch Eden and wait for it to load. -2. Navigate to *Emulation > Configure…* -3. Select **Controls** from the left-hand menu and configure your controller for the way you want it to be in game. -4. Select **New** and enter a name for the profile in the box that appears. Press **OK** to save the profile settings. -5. Select **OK** to close the settings menu. - -## Setting Controller Profiles By Game - -Use this guide when you want to set up specific controller profiles for specific games. This can be useful for certain games like *Captain Toad Treasure Tracker* where a blue dot appears in the middle of the screen when you have docked mode enabled, but not handheld mode. - -**Click [Here](https://evilperson1337.notion.site/Setting-Controller-Profiles-By-Game-2b057c2edaf681658a57f0c199cb6083) for a version of this guide with images & visual elements.** - ---- - -### Pre-Requisites - -- Eden Emulator set up and fully configured -- Controller Profile Created - - See [*Configuring Controller Profiles*](./ControllerProfiles.md) for instructions on how to do this if needed. - ---- - -### Steps - -1. *Right-Click* the game you want to apply the profile to in the main window and select **Properties.** -2. Navigate to the **Input Profiles** tab in the window that appears. Drop down on *Player 1 profile* (or whatever player profile you want to apply it to) and select the profile you want. - -

-1. Click **OK** to apply the profile mapping. -2. Launch the game and confirm that the profile is applied, regardless of what the global configuration is. diff --git a/docs/user/Controllers.md b/docs/user/Controllers.md new file mode 100644 index 0000000000..6aac9056ff --- /dev/null +++ b/docs/user/Controllers.md @@ -0,0 +1,65 @@ +# User Handbook - Controllers + +Most of the controls should work out of the box. If not, please use a joystick calibrator to ensure it's not an issue with your own controller, for example: + +- https://github.com/dkosmari/calibrate-joystick + +## Using external controllers on the Steamdeck + +In desktop mode ignore your pro controller/xbox contoller external controller and use **Steam Virtual Gamepad 0 as Player 1**. If you have multiple external controllers set **Player 2 to Steam Virtual Gamepad 1**. Steam app must not be closed on desktop mode. + +Here's the annoying part of it. When waking up the steam deck from sleep try not to touch any button on the Steamdeck and turn on your external controller. Then open the Eden.AppImage. If you're lucky you can get your external controller to be position 0 and also Steam Virtual Gamepad 0 in desktop mode. If not that is ok too unless you need to configure player 1 to have gyro. You might need to repeat this to get your external controller as Steam Virtual Gamepad 0 so you can config Player 1 having gyro. You might be able to config player 1 to have gyro with the Steamdeck itself. Or you can also config player 1, 2, 3, etc, to have gyro somehow. Make sure they are all using Virtual Gamepads though. + +Turn off controller then go to gaming mode. Try not to touch any buttons on the physical Steamdeck. When in gaming mode turn on the external controller. If lucky it will be assigned as Steam Virtual Gamepad 0. If not just use steam Gamemode feature to rearrange controller positions order. + +Basically the Steamdeck or the external controller is fighting for position 0 and it depends on what is touched first after waking from sleep. + +## Configuring Controller Profiles + +Use this guide for when you want to configure specific controller settings to be reused. + +**Click [Here](https://evilperson1337.notion.site/Configuring-Controller-Profiles-2be57c2edaf680eabc3ac8c333ec75c4) for a version of this guide with images & visual elements.** + +--- + +#### Pre-Requisites + +- Eden Set Up and Configured + +--- + +#### Steps +1. Launch Eden and wait for it to load. +2. Navigate to *Emulation > Configure…* +3. Select **Controls** from the left-hand menu and configure your controller for the way you want it to be in game. +4. Select **New** and enter a name for the profile in the box that appears. Press **OK** to save the profile settings. +5. Select **OK** to close the settings menu. + +### Setting Controller Profiles By Game + +Use this guide when you want to set up specific controller profiles for specific games. This can be useful for certain games like *Captain Toad Treasure Tracker* where a blue dot appears in the middle of the screen when you have docked mode enabled, but not handheld mode. + +**Click [Here](https://evilperson1337.notion.site/Setting-Controller-Profiles-By-Game-2b057c2edaf681658a57f0c199cb6083) for a version of this guide with images & visual elements.** + +--- + +#### Pre-Requisites + +- Eden Emulator set up and fully configured +- Controller Profile Created + - See [*Configuring Controller Profiles*](./ControllerProfiles.md) for instructions on how to do this if needed. + +--- + +#### Steps + +1. *Right-Click* the game you want to apply the profile to in the main window and select **Properties.** +2. Navigate to the **Input Profiles** tab in the window that appears. Drop down on *Player 1 profile* (or whatever player profile you want to apply it to) and select the profile you want. + + +1. Click **OK** to apply the profile mapping. +2. Launch the game and confirm that the profile is applied, regardless of what the global configuration is. diff --git a/docs/user/README.md b/docs/user/README.md index 9804f4d62f..c1c4cd200a 100644 --- a/docs/user/README.md +++ b/docs/user/README.md @@ -11,10 +11,12 @@ A copy of this handbook is [available online](https://git.eden-emu.dev/eden-emu/ - **[The Basics](Basics.md)** - **[Quickstart](./QuickStart.md)** - **[Settings](./Settings.md)** -- **[Installing Mods](./Mods.md)** -- **[Run On macOS](./RunOnMacOS.md)** +- **[Controllers](./Controllers.md)** + - **[Controller profiles](./Controllers.md#configuring-controller-profiles)** - **[Audio](Audio.md)** - **[Graphics](Graphics.md)** +- **[Installing Mods](./Mods.md)** +- **[Run On macOS](./RunOnMacOS.md)** - **[Data, Savefiles and Storage](Storage.md)** - **[Orphaned Profiles](Orphaned.md)** - **[Troubleshooting](./Troubleshoot.md)** @@ -23,7 +25,6 @@ A copy of this handbook is [available online](https://git.eden-emu.dev/eden-emu/ - **[Importing Saves](./ImportingSaves.md)** - **[Installing Atmosphere Mods](./InstallingAtmosphereMods.md)** - **[Installing Updates & DLCs](./InstallingUpdatesDLC.md)** -- **[Controller Profiles](./ControllerProfiles.md)** - **[Alter Date & Time](./AlterDateTime.md)** ## 3rd-party Integration @@ -35,6 +36,7 @@ A copy of this handbook is [available online](https://git.eden-emu.dev/eden-emu/ - **[Obtainium](./ThirdParty.md#configuring-obtainium)** - **[ES-DE](./ThirdParty.md#configuring-es-de)** - **[Mirrors](./ThirdParty.md#mirrors)** + - **[GameMode](./ThirdParty.md#configuring-gamemode)** ## Advanced diff --git a/docs/user/RunOnMacOS.md b/docs/user/RunOnMacOS.md index e01bf0253d..2729e13ced 100644 --- a/docs/user/RunOnMacOS.md +++ b/docs/user/RunOnMacOS.md @@ -1,4 +1,12 @@ -# Allowing Eden to Run on MacOS +# User Handbook - Run on macOS + +Current macOS support is still experimental and very reliant on MoltenVK developments, plans have shifted to properly provide support for KosmicKrisp and similar new GPU endeavours, but macOS users still are bound to MoltenVK itself. + +Users of macOS may wish to use [Asahi Linux](https://wiki.gentoo.org/wiki/Project:Asahi/Guide) for the rising KosmicKrisp support. + +As of writing, neither macOS nor Asahi has support for NCE; additionally Asahi has extraneous paging bugs with fastmem. + +## Allowing Eden to Run on MacOS Use this guide when you need to allow Eden to run on a Mac system, but are being blocked by Apple Security policy. @@ -6,19 +14,19 @@ Use this guide when you need to allow Eden to run on a Mac system, but are being --- -### Pre-Requisites +#### Pre-Requisites - Permissions to modify settings in MacOS --- -## Why am I Seeing This? +### Why am I Seeing This? Recent versions of MacOS (Catalina & newer) introduced the **Gatekeeper** security functionality, requiring software to be signed by Apple or a trusted (aka - paying) developer. If the signature isn’t on the list of trusted ones, it will stop the program from executing and display the message above. --- -## Steps +### Steps 1. Open the *System Settings* panel. 2. Navigate to *Privacy & Security*. diff --git a/docs/user/Settings.md b/docs/user/Settings.md index 35fcd0c9ef..9153a27e4d 100644 --- a/docs/user/Settings.md +++ b/docs/user/Settings.md @@ -50,5 +50,4 @@ See also [an extended breakdown of some options](./Graphics.md). ## Controls -Most of the controls should work out of the box. If not, please use a joystick calibrator to ensure it's not an issue with your own controller, for example: -- https://github.com/dkosmari/calibrate-joystick +See [controllers](./Controllers.md). diff --git a/docs/user/Testing.md b/docs/user/Testing.md index 6c3b7d3e15..eb3beeb37c 100644 --- a/docs/user/Testing.md +++ b/docs/user/Testing.md @@ -1,39 +1,99 @@ -# User Handbook - Testing - -While this is mainly aimed for testers - normal users can benefit from these guidelines to make their life easier when trying to outline and/or report an issue. - -## Getting logs - -In order to get more information, you can find logs in the following location: - - -## How to Test a PR Against the Based Master When Issues Arise +# Testing When you're testing a pull request (PR) and encounter unexpected behavior, it's important to determine whether the issue was introduced by the PR or if it already exists in the base code. To do this, compare the behavior against the based master branch. Even before an issue occurs, it is best practice to keep the same settings and delete the shader cache. Using an already made shader cache can make the PR look like it is having a regression in some rare cases. -### What to Do When Something Seems Off +Try not to test PRs which are for documentation or extremely trivial changes (like a PR that changes the app icon), unless you really want to; generally avoid any PRs marked `[docs]`. + +If a PR specifies it is for a given platform (i.e `linux`) then just test on Linux. If it says `NCE` then test on Android and Linux ARM64 (Raspberry Pi and such). macOS fixes may also affect Asahi, test that if you can too. + +You may also build artifacts yourself, be aware that the resulting builds are NOT the same as those from CI, because of package versioning and build environment differences. One famous example is FFmpeg randomly breaking on many Arch distros due to packaging differences. + +## Quickstart + +Think of the source code as a "tree", with the "trunk" of that tree being our `master` branch, any other branches are PRs or separate development branches, only our stable releases pull from `master` - all other branches are considered unstable and aren't recommended to pull from unless you're testing multiple branches at once. + +Here's some terminology you may want to familiarize yourself with: + +- PR: Pull request, a change in the codebase; from which the author of said change (the programmer) requests a pull of that branch into master (make it so the new code makes it into a release basically). +- Bisect: Bilinear method of searching regressions, some regressions may be sporadic and can't be bisected, but the overwhelming majority are. +- WIP: Work-in-progress. +- Regression: A new bug/glitch caused by new code, i.e "Zelda broke in android after commit xyz". +- Master: The "root" branch, this is where all merged code goes to, traditionally called `main`, `trunk` or just `master`, it contains all the code that eventually make it to stable releases. +- `HEAD`: Latest commit in a given branch, `HEAD` of `master` is the latest commit on branch `master`. +- `origin`: The default "remote", basically the URL from where git is located at, for most of the time that location is https://git.eden-emu.dev/eden-emu/eden. + +## Testing checklist + +For regressions/bugs from PRs or commits: + +- [ ] Occurs in master? + - If it occurs on master: + - [ ] Occurs on previous stable release? (before this particular PR). + - If it occurs on previous stable release: + - [ ] Occurs on previous-previous stable release? + - And so on and so forth... some bugs come from way before Eden was even conceived. + - Otherwise, try bisecting between the previous stable release AND the latest `HEAD` of master + - [ ] Occurs in given commit? +- [ ] Occurs in PR? + - If it occurs on PR: + - [ ] Bisected PR? (if it has commits) + - [ ] Found bisected commit? + +If an issue sporadically appears, try to do multiple runs, try if possible, to count the number of times it has failed and the number of times it has "worked just fine"; say it worked 3 times but failed 1. then there is a 1/4th chance every run that the issue is replicated - so every bisect step would require 4 runs to ensure there is atleast a chance of triggering the bug. + +## What to do when something seems off + If you notice something odd during testing: + - Reproduce the issue using the based master branch. - Observe whether the same behavior occurs. -### Two Possible Outcomes +From there onwards there can be two possible outcomes: + - If the issue exists in the based master: This means the problem was already present before the PR. The PR most likely did not introduce the regression. - If the issue does not exist in the based master: This suggests the PR most likely introduced the regression and needs further investigation. -### Report your findings +## Reporting Your Findings + When you report your results: + - Clearly state whether the behavior was observed in the based master. -- Indicate whether the result is good (expected behavior) or bad (unexpected or broken behavior). Without mentioning if your post/report/log is good or bad it may confuse the Developer of the PR. -- Example: -``` -1. "Tested on based master — issue not present. Bad result for PR, likely regression introduced." -2. "Tested on based master — issue already present. Good result for PR, not a regression." -``` +- Indicate whether the result is good (expected behavior) or bad (unexpected or broken behavior). Without mentioning if your post/report/log is good or bad it may confuse the developer of the PR. + +For example: + +1. "Bad result for PR: Tested on based master - issue not present. Likely regression introduced." +2. "Good result for PR: Tested on based master - issue already present. Not a regression." + +This approach helps maintain clarity and accountability in the testing process and ensures regressions are caught and addressed efficiently. + +If the behavior seems normal for a certain game/feature then it may not be always required to check against the based master. This approach helps maintain clarity and accountability in the testing process and ensures regressions are caught and addressed efficiently. If the behavior seems normal for a certain game/feature then it may not be always required to check against the based master. If a master build for the PR' based master does not exist. It will be helpful to just test past and future builds nearby. That would help with gathering more information about the problem. -**Always include [debugging info](../Debug.md) as needed**. \ No newline at end of file +**Always include [debugging info](../Debug.md) as needed**. + +## Bisecting + +One happy reminder, when testing, *know how to bisect!* + +Say you're trying to find an issue between 1st of Jan and 8th of Jan, you can search by dividing "in half" the time between each commit: +- Check for 4th of Jan +- If 4th of Jan is "working" then the issue must be in the future +- So then check 6th of Jan +- If 6th of Jan isn't working then the issue must be in the past +- So then check 5th of Jan +- If 5th of Jan worked, then the issue starts at 6th of Jan + +The faulty commit then, is 6th of Jan. This is called bisection https://git-scm.com/docs/git-bisect + +## Notes + +- PR's marked with **WIP** do NOT need to be tested unless explicitly asked (check the git in case) +- Sometimes license checks may fail, hover over the build icon to see if builds did succeed, as the CI will push builds even if license checks fail. +- All open PRs can be viewed [here](https://git.eden-emu.dev/eden-emu/eden/pulls/). +- If site is down use one of the [mirrors](./user/ThirdParty.md#mirrors). diff --git a/docs/user/ThirdParty.md b/docs/user/ThirdParty.md index 083542cd3e..5bd72ebe72 100644 --- a/docs/user/ThirdParty.md +++ b/docs/user/ThirdParty.md @@ -4,7 +4,6 @@ The Eden emulator by itself lacks some functionality - or otherwise requires ext While most of the links mentioned in this guide are relatively "safe"; we urge users to use their due diligence and appropriatedly verify the integrity of all files downloaded and ensure they're not compromised. -- [Nightly Eden builds](https://github.com/pflyly/eden-nightly) - [NixOS Eden Flake](https://github.com/Grantimatter/eden-flake) - [ES-DE Frontend Support](https://github.com/GlazedBelmont/es-de-android-custom-systems) @@ -66,3 +65,9 @@ Note: Even though the site isn't Codeberg, it uses the same Forgejo/Gitea backen ```xml %EMULATOR_EDEN% %ACTION%=android.nfc.action.TECH_DISCOVERED %DATA%=%ROMPROVIDER% ``` + +## Configuring GameMode + +There is a checkbox to enable gamemode automatically. The `libgamemode.so` library must be findable on the standard `LD_LIBRARY_PATH` otherwise it will not properly be enabled. If for whatever reason it doesn't work, see [Arch wiki: GameMode](https://wiki.archlinux.org/title/GameMode) for more info. + +You may launch the emulator directly via the wrapper `gamemode `, and things should work out of the box. From 5a0780b826d868f6ffb49b8faa951600b9b65547 Mon Sep 17 00:00:00 2001 From: lizzie Date: Wed, 11 Mar 2026 16:49:29 +0100 Subject: [PATCH 20/25] [video_core] Properly disable/avoid building OpenGL when it's disabled (#3692) - OpenGL symbols would still be included in builds without OpenGL, this pr fixes that - Same goes for Vulkan, but now with `ENABLE_VULKAN` - Add support to have OpenGL-only builds (why would you do this?) - Add support for headless runs (yes you could just select NULL backend, but why not compile it headless? :) Signed-off-by: lizzie Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3692 Reviewed-by: crueter Reviewed-by: DraVee Reviewed-by: MaranBr Co-authored-by: lizzie Co-committed-by: lizzie --- CMakeLists.txt | 2 +- docs/Options.md | 4 +- src/qt_common/CMakeLists.txt | 2 +- src/video_core/CMakeLists.txt | 158 ++++++++++++++++++---------------- src/video_core/video_core.cpp | 15 ++-- src/yuzu/bootmanager.cpp | 4 +- src/yuzu/main_window.cpp | 24 +++++- src/yuzu/startup_checks.cpp | 4 + src/yuzu/vk_device_info.cpp | 1 + 9 files changed, 125 insertions(+), 89 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4490df21cb..4ab08739f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -196,7 +196,7 @@ option(YUZU_USE_BUNDLED_SIRIT "Download bundled sirit" ${BUNDLED_SIRIT_DEFAULT}) # FreeBSD 15+ has libusb, versions below should disable it cmake_dependent_option(ENABLE_LIBUSB "Enable the use of LibUSB" ON "WIN32 OR PLATFORM_LINUX OR PLATFORM_FREEBSD OR APPLE" OFF) -cmake_dependent_option(ENABLE_OPENGL "Enable OpenGL" ON "NOT WIN32 OR NOT ARCHITECTURE_arm64" OFF) +cmake_dependent_option(ENABLE_OPENGL "Enable OpenGL" ON "NOT (WIN32 AND ARCHITECTURE_arm64) AND NOT APPLE" OFF) mark_as_advanced(FORCE ENABLE_OPENGL) option(ENABLE_WEB_SERVICE "Enable web services (telemetry, etc.)" ON) diff --git a/docs/Options.md b/docs/Options.md index 55aead805f..3eb6effe92 100644 --- a/docs/Options.md +++ b/docs/Options.md @@ -70,8 +70,8 @@ These options control executables and build flavors. The following options are desktop only. -- `ENABLE_LIBUSB` (ON) Enable the use of the libusb input frontend (HIGHLY RECOMMENDED) -- `ENABLE_OPENGL` (ON) Enable the OpenGL graphics frontend +- `ENABLE_LIBUSB` (ON) Enable the use of the libusb input backend (HIGHLY RECOMMENDED) +- `ENABLE_OPENGL` (ON) Enable the OpenGL graphics backend - Unavailable on Windows/ARM64 - You probably shouldn't turn this off. diff --git a/src/qt_common/CMakeLists.txt b/src/qt_common/CMakeLists.txt index f0522c07d2..904b03d288 100644 --- a/src/qt_common/CMakeLists.txt +++ b/src/qt_common/CMakeLists.txt @@ -84,7 +84,7 @@ target_link_libraries(qt_common PRIVATE core Qt6::Core Qt6::Concurrent SimpleIni target_link_libraries(qt_common PUBLIC frozen::frozen-headers) target_link_libraries(qt_common PRIVATE gamemode::headers frontend_common) -if (NOT APPLE AND ENABLE_OPENGL) +if (ENABLE_OPENGL) target_compile_definitions(qt_common PUBLIC HAS_OPENGL) endif() diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt index a58a73cd3c..3324682639 100644 --- a/src/video_core/CMakeLists.txt +++ b/src/video_core/CMakeLists.txt @@ -111,64 +111,14 @@ add_library(video_core STATIC rasterizer_interface.h renderer_base.cpp renderer_base.h + + # Null renderer_null/null_rasterizer.cpp renderer_null/null_rasterizer.h renderer_null/renderer_null.cpp renderer_null/renderer_null.h - renderer_opengl/present/filters.cpp - renderer_opengl/present/filters.h - renderer_opengl/present/fsr.cpp - renderer_opengl/present/fsr.h - renderer_opengl/present/fxaa.cpp - renderer_opengl/present/fxaa.h - renderer_opengl/present/layer.cpp - renderer_opengl/present/layer.h - renderer_opengl/present/present_uniforms.h - renderer_opengl/present/smaa.cpp - renderer_opengl/present/smaa.h - renderer_opengl/present/util.h - renderer_opengl/present/window_adapt_pass.cpp - renderer_opengl/present/window_adapt_pass.h - renderer_opengl/blit_image.cpp - renderer_opengl/blit_image.h - renderer_opengl/gl_blit_screen.cpp - renderer_opengl/gl_blit_screen.h - renderer_opengl/gl_buffer_cache_base.cpp - renderer_opengl/gl_buffer_cache.cpp - renderer_opengl/gl_buffer_cache.h - renderer_opengl/gl_compute_pipeline.cpp - renderer_opengl/gl_compute_pipeline.h - renderer_opengl/gl_device.cpp - renderer_opengl/gl_device.h - renderer_opengl/gl_fence_manager.cpp - renderer_opengl/gl_fence_manager.h - renderer_opengl/gl_graphics_pipeline.cpp - renderer_opengl/gl_graphics_pipeline.h - renderer_opengl/gl_rasterizer.cpp - renderer_opengl/gl_rasterizer.h - renderer_opengl/gl_resource_manager.cpp - renderer_opengl/gl_resource_manager.h - renderer_opengl/gl_shader_cache.cpp - renderer_opengl/gl_shader_cache.h - renderer_opengl/gl_shader_manager.cpp - renderer_opengl/gl_shader_manager.h - renderer_opengl/gl_shader_context.h - renderer_opengl/gl_shader_util.cpp - renderer_opengl/gl_shader_util.h - renderer_opengl/gl_state_tracker.cpp - renderer_opengl/gl_state_tracker.h - renderer_opengl/gl_staging_buffer_pool.cpp - renderer_opengl/gl_staging_buffer_pool.h - renderer_opengl/gl_texture_cache.cpp - renderer_opengl/gl_texture_cache.h - renderer_opengl/gl_texture_cache_base.cpp - renderer_opengl/gl_query_cache.cpp - renderer_opengl/gl_query_cache.h - renderer_opengl/maxwell_to_gl.h - renderer_opengl/renderer_opengl.cpp - renderer_opengl/renderer_opengl.h - renderer_opengl/util_shaders.cpp - renderer_opengl/util_shaders.h + + # Vulkan renderer_vulkan/present/anti_alias_pass.h renderer_vulkan/present/filters.cpp renderer_vulkan/present/filters.h @@ -244,6 +194,25 @@ add_library(video_core STATIC renderer_vulkan/vk_turbo_mode.h renderer_vulkan/vk_update_descriptor.cpp renderer_vulkan/vk_update_descriptor.h + vulkan_common/vulkan_debug_callback.cpp + vulkan_common/vulkan_debug_callback.h + vulkan_common/vulkan_device.cpp + vulkan_common/vulkan_device.h + vulkan_common/vulkan_instance.cpp + vulkan_common/vulkan_instance.h + vulkan_common/vulkan_library.cpp + vulkan_common/vulkan_library.h + vulkan_common/vulkan_memory_allocator.cpp + vulkan_common/vulkan_memory_allocator.h + vulkan_common/vulkan_surface.cpp + vulkan_common/vulkan_surface.h + vulkan_common/vulkan_wrapper.cpp + vulkan_common/vulkan_wrapper.h + vulkan_common/nsight_aftermath_tracker.cpp + vulkan_common/nsight_aftermath_tracker.h + vulkan_common/vma.h + vulkan_common/vulkan.h + shader_cache.cpp shader_cache.h shader_environment.cpp @@ -293,26 +262,67 @@ add_library(video_core STATIC transform_feedback.h video_core.cpp video_core.h - vulkan_common/vulkan_debug_callback.cpp - vulkan_common/vulkan_debug_callback.h - vulkan_common/vulkan_device.cpp - vulkan_common/vulkan_device.h - vulkan_common/vulkan_instance.cpp - vulkan_common/vulkan_instance.h - vulkan_common/vulkan_library.cpp - vulkan_common/vulkan_library.h - vulkan_common/vulkan_memory_allocator.cpp - vulkan_common/vulkan_memory_allocator.h - vulkan_common/vulkan_surface.cpp - vulkan_common/vulkan_surface.h - vulkan_common/vulkan_wrapper.cpp - vulkan_common/vulkan_wrapper.h - vulkan_common/nsight_aftermath_tracker.cpp - vulkan_common/nsight_aftermath_tracker.h - vulkan_common/vma.h - vulkan_common/vulkan.h ) +if (ENABLE_OPENGL) + target_sources(video_core PRIVATE + renderer_opengl/present/filters.cpp + renderer_opengl/present/filters.h + renderer_opengl/present/fsr.cpp + renderer_opengl/present/fsr.h + renderer_opengl/present/fxaa.cpp + renderer_opengl/present/fxaa.h + renderer_opengl/present/layer.cpp + renderer_opengl/present/layer.h + renderer_opengl/present/present_uniforms.h + renderer_opengl/present/smaa.cpp + renderer_opengl/present/smaa.h + renderer_opengl/present/util.h + renderer_opengl/present/window_adapt_pass.cpp + renderer_opengl/present/window_adapt_pass.h + renderer_opengl/blit_image.cpp + renderer_opengl/blit_image.h + renderer_opengl/gl_blit_screen.cpp + renderer_opengl/gl_blit_screen.h + renderer_opengl/gl_buffer_cache_base.cpp + renderer_opengl/gl_buffer_cache.cpp + renderer_opengl/gl_buffer_cache.h + renderer_opengl/gl_compute_pipeline.cpp + renderer_opengl/gl_compute_pipeline.h + renderer_opengl/gl_device.cpp + renderer_opengl/gl_device.h + renderer_opengl/gl_fence_manager.cpp + renderer_opengl/gl_fence_manager.h + renderer_opengl/gl_graphics_pipeline.cpp + renderer_opengl/gl_graphics_pipeline.h + renderer_opengl/gl_rasterizer.cpp + renderer_opengl/gl_rasterizer.h + renderer_opengl/gl_resource_manager.cpp + renderer_opengl/gl_resource_manager.h + renderer_opengl/gl_shader_cache.cpp + renderer_opengl/gl_shader_cache.h + renderer_opengl/gl_shader_manager.cpp + renderer_opengl/gl_shader_manager.h + renderer_opengl/gl_shader_context.h + renderer_opengl/gl_shader_util.cpp + renderer_opengl/gl_shader_util.h + renderer_opengl/gl_state_tracker.cpp + renderer_opengl/gl_state_tracker.h + renderer_opengl/gl_staging_buffer_pool.cpp + renderer_opengl/gl_staging_buffer_pool.h + renderer_opengl/gl_texture_cache.cpp + renderer_opengl/gl_texture_cache.h + renderer_opengl/gl_texture_cache_base.cpp + renderer_opengl/gl_query_cache.cpp + renderer_opengl/gl_query_cache.h + renderer_opengl/maxwell_to_gl.h + renderer_opengl/renderer_opengl.cpp + renderer_opengl/renderer_opengl.h + renderer_opengl/util_shaders.cpp + renderer_opengl/util_shaders.h + ) +endif() + target_link_libraries(video_core PUBLIC common core) target_link_libraries(video_core PUBLIC glad shader_recompiler stb bc_decoder gpu_logging) @@ -371,6 +381,10 @@ else() endif() endif() +if (ENABLE_OPENGL) + target_compile_definitions(video_core PUBLIC HAS_OPENGL) +endif() + if (ARCHITECTURE_x86_64) target_link_libraries(video_core PUBLIC xbyak::xbyak) endif() diff --git a/src/video_core/video_core.cpp b/src/video_core/video_core.cpp index 4a9751e208..fd91ee1667 100644 --- a/src/video_core/video_core.cpp +++ b/src/video_core/video_core.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: 2014 Citra Emulator Project @@ -9,26 +9,29 @@ #include "common/logging/log.h" #include "common/settings.h" #include "core/core.h" +#include "core/frontend/emu_window.h" +#include "core/frontend/graphics_context.h" #include "video_core/host1x/gpu_device_memory_manager.h" #include "video_core/host1x/host1x.h" #include "video_core/renderer_base.h" #include "video_core/renderer_null/renderer_null.h" +#ifdef HAS_OPENGL #include "video_core/renderer_opengl/renderer_opengl.h" +#endif #include "video_core/renderer_vulkan/renderer_vulkan.h" #include "video_core/video_core.h" namespace { -std::unique_ptr CreateRenderer( - Core::System& system, Core::Frontend::EmuWindow& emu_window, Tegra::GPU& gpu, - std::unique_ptr context) { - auto& device_memory = system.Host1x().MemoryManager(); - +std::unique_ptr CreateRenderer(Core::System& system, Core::Frontend::EmuWindow& emu_window, Tegra::GPU& gpu, std::unique_ptr context) { + [[maybe_unused]] auto& device_memory = system.Host1x().MemoryManager(); switch (Settings::values.renderer_backend.GetValue()) { +#ifdef HAS_OPENGL case Settings::RendererBackend::OpenGL_GLSL: case Settings::RendererBackend::OpenGL_GLASM: case Settings::RendererBackend::OpenGL_SPIRV: return std::make_unique(emu_window, device_memory, gpu, std::move(context)); +#endif case Settings::RendererBackend::Vulkan: return std::make_unique(emu_window, device_memory, gpu, std::move(context)); case Settings::RendererBackend::Null: diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index 69b3681d0a..0c0ce6e90c 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp @@ -1020,8 +1020,7 @@ bool GRenderWindow::InitializeOpenGL() { return true; #else - QMessageBox::warning(this, tr("OpenGL not available!"), - tr("Eden has not been compiled with OpenGL support.")); + QMessageBox::warning(this, tr("OpenGL not available!"), tr("Eden has not been compiled with OpenGL support.")); return false; #endif } @@ -1031,7 +1030,6 @@ bool GRenderWindow::InitializeVulkan() { child_widget = child; child_widget->windowHandle()->create(); main_context = std::make_unique(); - return true; } diff --git a/src/yuzu/main_window.cpp b/src/yuzu/main_window.cpp index a251451bea..029826dfa3 100644 --- a/src/yuzu/main_window.cpp +++ b/src/yuzu/main_window.cpp @@ -3784,14 +3784,30 @@ void MainWindow::OnToggleAdaptingFilter() { void MainWindow::OnToggleGraphicsAPI() { auto api = Settings::values.renderer_backend.GetValue(); - if (api != Settings::RendererBackend::Vulkan) { - api = Settings::RendererBackend::Vulkan; - } else { + switch (api) { #ifdef HAS_OPENGL + case Settings::RendererBackend::Vulkan: api = Settings::RendererBackend::OpenGL_GLSL; -#else + break; + case Settings::RendererBackend::OpenGL_GLSL: + api = Settings::RendererBackend::OpenGL_GLSL; + break; + case Settings::RendererBackend::OpenGL_SPIRV: + api = Settings::RendererBackend::OpenGL_GLASM; + break; + case Settings::RendererBackend::OpenGL_GLASM: api = Settings::RendererBackend::Null; + break; +#else + case Settings::RendererBackend::Vulkan: + api = Settings::RendererBackend::Null; + break; #endif + case Settings::RendererBackend::Null: + api = Settings::RendererBackend::Vulkan; + break; + default: + break; } Settings::values.renderer_backend.SetValue(api); renderer_status_button->setChecked(api == Settings::RendererBackend::Vulkan); diff --git a/src/yuzu/startup_checks.cpp b/src/yuzu/startup_checks.cpp index 2e77c7cd06..f54992d19a 100644 --- a/src/yuzu/startup_checks.cpp +++ b/src/yuzu/startup_checks.cpp @@ -1,6 +1,10 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +// Don't move this! put it below and MSVC will get angry! #include "video_core/vulkan_common/vulkan_wrapper.h" #ifdef _WIN32 diff --git a/src/yuzu/vk_device_info.cpp b/src/yuzu/vk_device_info.cpp index 2b87ccd3ca..53dacdc090 100644 --- a/src/yuzu/vk_device_info.cpp +++ b/src/yuzu/vk_device_info.cpp @@ -77,4 +77,5 @@ void PopulateRecords(std::vector& records, QWindow* window) try { } catch (const Vulkan::vk::Exception& exception) { LOG_ERROR(Frontend, "Failed to enumerate devices with error: {}", exception.what()); } + } // namespace VkDeviceInfo From 0dad29698e637b6d913be35dfdf922cc3bf759fe Mon Sep 17 00:00:00 2001 From: lizzie Date: Wed, 11 Mar 2026 16:50:00 +0100 Subject: [PATCH 21/25] [frontend] allow to specify input profile name for first player on command line (#3684) Signed-off-by: lizzie Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3684 Reviewed-by: DraVee Reviewed-by: MaranBr Co-authored-by: lizzie Co-committed-by: lizzie --- docs/user/CommandLine.md | 2 ++ src/yuzu/main_window.cpp | 3 +++ src/yuzu_cmd/yuzu.cpp | 15 +++++++++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/docs/user/CommandLine.md b/docs/user/CommandLine.md index 4b3a5bdf58..cd98d88b19 100644 --- a/docs/user/CommandLine.md +++ b/docs/user/CommandLine.md @@ -7,6 +7,7 @@ There are two main applications, an SDL2 based app (`eden-cli`) and a Qt based a - `-g `: Alternate way to specify what to load, overrides. However let it be noted that arguments that use `-` will be treated as options/ignored, if your game, for some reason, starts with `-`, in order to safely handle it you may need to specify it as an argument. - `-f`: Use fullscreen. - `-u `: Select the index of the user to load as. +- `-input-profile `: Specifies input profile name to use (for player #0 only). - `-qlaunch`: Launch QLaunch. - `-setup`: Launch setup applet. @@ -20,3 +21,4 @@ There are two main applications, an SDL2 based app (`eden-cli`) and a Qt based a - `--program/-p`: Specify the program arguments to pass (optional). - `--user/-u`: Specify the user index. - `--version/-v`: Display version and quit. +- `--input-profile/-i`: Specifies input profile name to use (for player #0 only). diff --git a/src/yuzu/main_window.cpp b/src/yuzu/main_window.cpp index 029826dfa3..c0f757f697 100644 --- a/src/yuzu/main_window.cpp +++ b/src/yuzu/main_window.cpp @@ -670,6 +670,9 @@ MainWindow::MainWindow(bool has_broken_vulkan) // Launch game at path game_path = args[++i]; has_gamepath = true; + } else if (args[i] == QStringLiteral("-input-profile") && i < args.size() - 1) { + auto& players = Settings::values.players.GetValue(); + players[0].profile_name = args[++i].toStdString(); } else if (args[i] == QStringLiteral("-qlaunch")) { should_launch_qlaunch = true; } else if (args[i] == QStringLiteral("-setup")) { diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index b292b4886b..8124c91ea1 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: 2014 Citra Emulator Project @@ -208,6 +208,7 @@ int main(int argc, char** argv) { std::string nickname{}; std::string password{}; std::string address{}; + std::string input_profile{}; u16 port = Network::DefaultRoomPort; static struct option long_options[] = { @@ -221,12 +222,13 @@ int main(int argc, char** argv) { {"program", optional_argument, 0, 'p'}, {"user", required_argument, 0, 'u'}, {"version", no_argument, 0, 'v'}, + {"input-profile", no_argument, 0, 'i'}, {0, 0, 0, 0}, // clang-format on }; while (optind < argc) { - int arg = getopt_long(argc, argv, "g:fhvp::c:u:d:", long_options, &option_index); + int arg = getopt_long(argc, argv, "g:fhvcip::c:u:d:", long_options, &option_index); if (arg != -1) { switch (char(arg)) { case 'd': @@ -245,6 +247,10 @@ int main(int argc, char** argv) { case 'g': filepath = std::string(optarg); break; + case 'i': { + input_profile = std::string(optarg); + break; + } case 'm': { use_multiplayer = true; const std::string str_arg(optarg); @@ -311,6 +317,11 @@ int main(int argc, char** argv) { Settings::values.program_args = program_args; } + if (!input_profile.empty()) { + auto& players = Settings::values.players.GetValue(); + players[0].profile_name = input_profile; + } + if (selected_user.has_value()) { Settings::values.current_user = std::clamp(*selected_user, 0, 7); } From 2896fa3835c4042b0878b2bb6c66a7d343f20180 Mon Sep 17 00:00:00 2001 From: xbzk Date: Wed, 11 Mar 2026 22:47:16 +0100 Subject: [PATCH 22/25] [android,ui] chore: settings subscreens transition and other minor conformances (#3699) - Fix black screen in transition animations - Adjustments to about fragment made about text more label and less button like, header transparency, spacing adjustments, word Contributors replaced by People in Contributors field for de-duplication. - installable actions code de-duplication Extracted install/update/import firmware/user data flows into InstallableActions.kt and reused it from MainActivity and InstallableFragment, reducing duplicated logic, ensuring single source of truth. Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3699 Reviewed-by: DraVee Reviewed-by: Lizzie Co-authored-by: xbzk Co-committed-by: xbzk --- src/android/app/src/main/AndroidManifest.xml | 5 + .../yuzu/yuzu_emu/adapters/AppletAdapter.kt | 14 +- .../features/settings/ui/SettingsActivity.kt | 12 +- .../settings/ui/SettingsSubscreenActivity.kt | 152 ++++++++ .../yuzu/yuzu_emu/fragments/AboutFragment.kt | 12 +- .../yuzu/yuzu_emu/fragments/AddonsFragment.kt | 3 +- .../fragments/AppletLauncherFragment.kt | 5 +- .../fragments/DriverFetcherFragment.kt | 3 +- .../fragments/DriverManagerFragment.kt | 12 +- .../yuzu_emu/fragments/GameFoldersFragment.kt | 71 +++- .../yuzu_emu/fragments/GameInfoFragment.kt | 5 +- .../fragments/GamePropertiesFragment.kt | 28 +- .../fragments/HomeSettingsFragment.kt | 50 ++- .../yuzu_emu/fragments/InstallableFragment.kt | 163 ++++++++- .../yuzu_emu/fragments/LicensesFragment.kt | 5 +- .../fragments/ProfileManagerFragment.kt | 2 +- .../org/yuzu/yuzu_emu/ui/main/MainActivity.kt | 304 ++-------------- .../yuzu/yuzu_emu/utils/InstallableActions.kt | 327 ++++++++++++++++++ .../main/res/layout-w600dp/fragment_about.xml | 80 ++--- .../src/main/res/layout/fragment_about.xml | 88 +++-- .../res/navigation/emulation_navigation.xml | 6 +- .../main/res/navigation/home_navigation.xml | 52 +-- .../settings_subscreen_navigation.xml | 139 ++++++++ .../app/src/main/res/values/strings.xml | 2 +- 24 files changed, 1064 insertions(+), 476 deletions(-) create mode 100644 src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsSubscreenActivity.kt create mode 100644 src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/InstallableActions.kt create mode 100644 src/android/app/src/main/res/navigation/settings_subscreen_navigation.xml diff --git a/src/android/app/src/main/AndroidManifest.xml b/src/android/app/src/main/AndroidManifest.xml index c642dbdcda..b899ca07fa 100644 --- a/src/android/app/src/main/AndroidManifest.xml +++ b/src/android/app/src/main/AndroidManifest.xml @@ -73,6 +73,11 @@ SPDX-License-Identifier: GPL-3.0-or-later android:theme="@style/Theme.Yuzu.Main" android:label="@string/preferences_settings"/> + + ) : title = YuzuApplication.appContext.getString(applet.titleId), path = appletPath ) - val action = HomeNavigationDirections.actionGlobalEmulationActivity(appletGame) - binding.root.findNavController().navigate(action) + binding.root.findNavController().navigate( + R.id.action_global_emulationActivity, + bundleOf( + "game" to appletGame, + "custom" to false + ) + ) } } } diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsActivity.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsActivity.kt index 11be703536..d33bbc3d7d 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsActivity.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsActivity.kt @@ -111,18 +111,10 @@ class SettingsActivity : AppCompatActivity() { if (navHostFragment.childFragmentManager.backStackEntryCount > 0) { navHostFragment.navController.popBackStack() } else { - finishWithFragmentLikeAnimation() + finish() } } - private fun finishWithFragmentLikeAnimation() { - finish() - overridePendingTransition( - androidx.navigation.ui.R.anim.nav_default_pop_enter_anim, - androidx.navigation.ui.R.anim.nav_default_pop_exit_anim - ) - } - override fun onStart() { super.onStart() if (!DirectoryInitialization.areDirectoriesReady) { @@ -178,7 +170,7 @@ class SettingsActivity : AppCompatActivity() { getString(R.string.settings_reset), Toast.LENGTH_LONG ).show() - finishWithFragmentLikeAnimation() + finish() } private fun setInsets() { diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsSubscreenActivity.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsSubscreenActivity.kt new file mode 100644 index 0000000000..11ecd355fb --- /dev/null +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsSubscreenActivity.kt @@ -0,0 +1,152 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + +package org.yuzu.yuzu_emu.features.settings.ui + +import android.content.Context +import android.os.Bundle +import android.view.View +import android.view.ViewGroup.MarginLayoutParams +import androidx.activity.OnBackPressedCallback +import androidx.appcompat.app.AppCompatActivity +import androidx.core.os.bundleOf +import androidx.core.view.ViewCompat +import androidx.core.view.WindowCompat +import androidx.core.view.WindowInsetsCompat +import androidx.navigation.fragment.NavHostFragment +import androidx.navigation.navArgs +import com.google.android.material.color.MaterialColors +import org.yuzu.yuzu_emu.R +import org.yuzu.yuzu_emu.YuzuApplication +import org.yuzu.yuzu_emu.databinding.ActivitySettingsBinding +import org.yuzu.yuzu_emu.utils.DirectoryInitialization +import org.yuzu.yuzu_emu.utils.InsetsHelper +import org.yuzu.yuzu_emu.utils.ThemeHelper + +enum class SettingsSubscreen { + PROFILE_MANAGER, + DRIVER_MANAGER, + DRIVER_FETCHER, + FREEDRENO_SETTINGS, + APPLET_LAUNCHER, + INSTALLABLE, + GAME_FOLDERS, + ABOUT, + LICENSES, + GAME_INFO, + ADDONS, +} + +class SettingsSubscreenActivity : AppCompatActivity() { + private lateinit var binding: ActivitySettingsBinding + + private val args by navArgs() + + override fun attachBaseContext(base: Context) { + super.attachBaseContext(YuzuApplication.applyLanguage(base)) + } + + override fun onCreate(savedInstanceState: Bundle?) { + ThemeHelper.setTheme(this) + + super.onCreate(savedInstanceState) + + binding = ActivitySettingsBinding.inflate(layoutInflater) + setContentView(binding.root) + + val navHostFragment = + supportFragmentManager.findFragmentById(R.id.fragment_container) as NavHostFragment + if (savedInstanceState == null) { + val navController = navHostFragment.navController + val navGraph = navController.navInflater.inflate( + R.navigation.settings_subscreen_navigation + ) + navGraph.setStartDestination(resolveStartDestination()) + navController.setGraph(navGraph, createStartDestinationArgs()) + } + + WindowCompat.setDecorFitsSystemWindows(window, false) + + if (InsetsHelper.getSystemGestureType(applicationContext) != + InsetsHelper.GESTURE_NAVIGATION + ) { + binding.navigationBarShade.setBackgroundColor( + ThemeHelper.getColorWithOpacity( + MaterialColors.getColor( + binding.navigationBarShade, + com.google.android.material.R.attr.colorSurface + ), + ThemeHelper.SYSTEM_BAR_ALPHA + ) + ) + } + + onBackPressedDispatcher.addCallback( + this, + object : OnBackPressedCallback(true) { + override fun handleOnBackPressed() = navigateBack() + } + ) + + setInsets() + } + + override fun onStart() { + super.onStart() + if (!DirectoryInitialization.areDirectoriesReady) { + DirectoryInitialization.start() + } + } + + fun navigateBack() { + val navHostFragment = + supportFragmentManager.findFragmentById(R.id.fragment_container) as NavHostFragment + if (!navHostFragment.navController.popBackStack()) { + finish() + } + } + + private fun resolveStartDestination(): Int = + when (args.destination) { + SettingsSubscreen.PROFILE_MANAGER -> R.id.profileManagerFragment + SettingsSubscreen.DRIVER_MANAGER -> R.id.driverManagerFragment + SettingsSubscreen.DRIVER_FETCHER -> R.id.driverFetcherFragment + SettingsSubscreen.FREEDRENO_SETTINGS -> R.id.freedrenoSettingsFragment + SettingsSubscreen.APPLET_LAUNCHER -> R.id.appletLauncherFragment + SettingsSubscreen.INSTALLABLE -> R.id.installableFragment + SettingsSubscreen.GAME_FOLDERS -> R.id.gameFoldersFragment + SettingsSubscreen.ABOUT -> R.id.aboutFragment + SettingsSubscreen.LICENSES -> R.id.licensesFragment + SettingsSubscreen.GAME_INFO -> R.id.gameInfoFragment + SettingsSubscreen.ADDONS -> R.id.addonsFragment + } + + private fun createStartDestinationArgs(): Bundle = + when (args.destination) { + SettingsSubscreen.DRIVER_MANAGER, + SettingsSubscreen.FREEDRENO_SETTINGS -> bundleOf("game" to args.game) + + SettingsSubscreen.GAME_INFO, + SettingsSubscreen.ADDONS -> bundleOf( + "game" to requireNotNull(args.game) { + "Game is required for ${args.destination}" + } + ) + + else -> Bundle() + } + + private fun setInsets() { + ViewCompat.setOnApplyWindowInsetsListener( + binding.navigationBarShade + ) { _: View, windowInsets: WindowInsetsCompat -> + val barInsets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()) + + val mlpNavShade = binding.navigationBarShade.layoutParams as MarginLayoutParams + mlpNavShade.height = barInsets.bottom + binding.navigationBarShade.layoutParams = mlpNavShade + + windowInsets + } + } +} diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AboutFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AboutFragment.kt index 7fec413b66..aa2b3c7df2 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AboutFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AboutFragment.kt @@ -21,9 +21,10 @@ import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels import androidx.navigation.findNavController import com.google.android.material.transition.MaterialSharedAxis -import org.yuzu.yuzu_emu.BuildConfig +import org.yuzu.yuzu_emu.HomeNavigationDirections import org.yuzu.yuzu_emu.R import org.yuzu.yuzu_emu.databinding.FragmentAboutBinding +import org.yuzu.yuzu_emu.features.settings.ui.SettingsSubscreen import org.yuzu.yuzu_emu.model.HomeViewModel import org.yuzu.yuzu_emu.utils.ViewUtils.updateMargins import org.yuzu.yuzu_emu.NativeLibrary @@ -54,7 +55,7 @@ class AboutFragment : Fragment() { super.onViewCreated(view, savedInstanceState) homeViewModel.setStatusBarShadeVisibility(visible = false) binding.toolbarAbout.setNavigationOnClickListener { - binding.root.findNavController().popBackStack() + requireActivity().onBackPressedDispatcher.onBackPressed() } binding.imageLogo.setOnLongClickListener { @@ -72,8 +73,11 @@ class AboutFragment : Fragment() { ) } binding.buttonLicenses.setOnClickListener { - exitTransition = MaterialSharedAxis(MaterialSharedAxis.X, true) - binding.root.findNavController().navigate(R.id.action_aboutFragment_to_licensesFragment) + val action = HomeNavigationDirections.actionGlobalSettingsSubscreenActivity( + SettingsSubscreen.LICENSES, + null + ) + binding.root.findNavController().navigate(action) } val buildName = getString(R.string.app_name_suffixed) diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AddonsFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AddonsFragment.kt index 96b7a8cce2..b20d75ef0a 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AddonsFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AddonsFragment.kt @@ -15,7 +15,6 @@ import androidx.core.view.updatePadding import androidx.documentfile.provider.DocumentFile import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels -import androidx.navigation.findNavController import androidx.navigation.fragment.navArgs import androidx.recyclerview.widget.LinearLayoutManager import com.google.android.material.transition.MaterialSharedAxis @@ -61,7 +60,7 @@ class AddonsFragment : Fragment() { homeViewModel.setStatusBarShadeVisibility(false) binding.toolbarAddons.setNavigationOnClickListener { - binding.root.findNavController().popBackStack() + requireActivity().onBackPressedDispatcher.onBackPressed() } binding.toolbarAddons.title = getString(R.string.addons_game, args.game.title) diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AppletLauncherFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AppletLauncherFragment.kt index 3ab171a8d4..49237cb756 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AppletLauncherFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AppletLauncherFragment.kt @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later package org.yuzu.yuzu_emu.fragments @@ -12,7 +12,6 @@ import androidx.core.view.WindowInsetsCompat import androidx.core.view.updatePadding import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels -import androidx.navigation.findNavController import androidx.recyclerview.widget.GridLayoutManager import com.google.android.material.transition.MaterialSharedAxis import org.yuzu.yuzu_emu.R @@ -50,7 +49,7 @@ class AppletLauncherFragment : Fragment() { homeViewModel.setStatusBarShadeVisibility(visible = false) binding.toolbarApplets.setNavigationOnClickListener { - binding.root.findNavController().popBackStack() + requireActivity().onBackPressedDispatcher.onBackPressed() } val applets = listOf( diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/DriverFetcherFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/DriverFetcherFragment.kt index e2b652dc60..eacc64a63e 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/DriverFetcherFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/DriverFetcherFragment.kt @@ -13,7 +13,6 @@ import androidx.core.view.WindowInsetsCompat import androidx.core.view.isVisible import androidx.core.view.updatePadding import androidx.fragment.app.activityViewModels -import androidx.navigation.findNavController import androidx.recyclerview.widget.LinearLayoutManager import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper @@ -142,7 +141,7 @@ class DriverFetcherFragment : Fragment() { super.onViewCreated(view, savedInstanceState) homeViewModel.setStatusBarShadeVisibility(visible = false) binding.toolbarDrivers.setNavigationOnClickListener { - binding.root.findNavController().popBackStack() + requireActivity().onBackPressedDispatcher.onBackPressed() } binding.listDrivers.layoutManager = LinearLayoutManager(context) diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/DriverManagerFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/DriverManagerFragment.kt index 23334f05eb..89a6362dc6 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/DriverManagerFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/DriverManagerFragment.kt @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later package org.yuzu.yuzu_emu.fragments @@ -19,6 +19,7 @@ import androidx.navigation.fragment.navArgs import androidx.preference.PreferenceManager import androidx.recyclerview.widget.GridLayoutManager import com.google.android.material.transition.MaterialSharedAxis +import org.yuzu.yuzu_emu.HomeNavigationDirections import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext @@ -27,6 +28,7 @@ import org.yuzu.yuzu_emu.adapters.DriverAdapter import org.yuzu.yuzu_emu.databinding.FragmentDriverManagerBinding import org.yuzu.yuzu_emu.features.settings.model.Settings import org.yuzu.yuzu_emu.features.settings.model.StringSetting +import org.yuzu.yuzu_emu.features.settings.ui.SettingsSubscreen import org.yuzu.yuzu_emu.model.Driver.Companion.toDriver import org.yuzu.yuzu_emu.model.DriverViewModel import org.yuzu.yuzu_emu.model.HomeViewModel @@ -105,7 +107,7 @@ class DriverManagerFragment : Fragment() { } binding.toolbarDrivers.setNavigationOnClickListener { - binding.root.findNavController().popBackStack() + requireActivity().onBackPressedDispatcher.onBackPressed() } binding.buttonInstall.setOnClickListener { @@ -113,9 +115,11 @@ class DriverManagerFragment : Fragment() { } binding.buttonFetch.setOnClickListener { - binding.root.findNavController().navigate( - R.id.action_driverManagerFragment_to_driverFetcherFragment + val action = HomeNavigationDirections.actionGlobalSettingsSubscreenActivity( + SettingsSubscreen.DRIVER_FETCHER, + null ) + binding.root.findNavController().navigate(action) } binding.listDrivers.apply { diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GameFoldersFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GameFoldersFragment.kt index 9c43d2c6e1..6e05df799b 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GameFoldersFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GameFoldersFragment.kt @@ -4,20 +4,21 @@ package org.yuzu.yuzu_emu.fragments import android.content.Intent +import android.net.Uri import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.widget.Toast +import androidx.activity.result.contract.ActivityResultContracts import androidx.core.view.ViewCompat import androidx.core.view.WindowInsetsCompat import androidx.core.view.updatePadding import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels -import androidx.navigation.findNavController import androidx.recyclerview.widget.GridLayoutManager import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.transition.MaterialSharedAxis -import kotlinx.coroutines.launch import org.yuzu.yuzu_emu.R import org.yuzu.yuzu_emu.adapters.FolderAdapter import org.yuzu.yuzu_emu.databinding.FragmentFoldersBinding @@ -25,7 +26,6 @@ import org.yuzu.yuzu_emu.model.DirectoryType import org.yuzu.yuzu_emu.model.GameDir import org.yuzu.yuzu_emu.model.GamesViewModel import org.yuzu.yuzu_emu.model.HomeViewModel -import org.yuzu.yuzu_emu.ui.main.MainActivity import org.yuzu.yuzu_emu.utils.ViewUtils.updateMargins import org.yuzu.yuzu_emu.utils.collect @@ -36,6 +36,20 @@ class GameFoldersFragment : Fragment() { private val homeViewModel: HomeViewModel by activityViewModels() private val gamesViewModel: GamesViewModel by activityViewModels() + private val getGamesDirectory = + registerForActivityResult(ActivityResultContracts.OpenDocumentTree()) { result -> + if (result != null) { + processGamesDir(result) + } + } + + private val getExternalContentDirectory = + registerForActivityResult(ActivityResultContracts.OpenDocumentTree()) { result -> + if (result != null) { + processExternalContentDir(result) + } + } + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) enterTransition = MaterialSharedAxis(MaterialSharedAxis.X, true) @@ -59,7 +73,7 @@ class GameFoldersFragment : Fragment() { homeViewModel.setStatusBarShadeVisibility(visible = false) binding.toolbarFolders.setNavigationOnClickListener { - binding.root.findNavController().popBackStack() + requireActivity().onBackPressedDispatcher.onBackPressed() } binding.listFolders.apply { @@ -74,7 +88,6 @@ class GameFoldersFragment : Fragment() { (binding.listFolders.adapter as FolderAdapter).submitList(it) } - val mainActivity = requireActivity() as MainActivity binding.buttonAdd.setOnClickListener { // Show a model to choose between Game and External Content val options = arrayOf( @@ -87,10 +100,10 @@ class GameFoldersFragment : Fragment() { .setItems(options) { _, which -> when (which) { 0 -> { // Game Folder - mainActivity.getGamesDirectory.launch(Intent(Intent.ACTION_OPEN_DOCUMENT_TREE).data) + getGamesDirectory.launch(Intent(Intent.ACTION_OPEN_DOCUMENT_TREE).data) } 1 -> { // External Content Folder - mainActivity.getExternalContentDirectory.launch(null) + getExternalContentDirectory.launch(null) } } } @@ -105,6 +118,50 @@ class GameFoldersFragment : Fragment() { gamesViewModel.onCloseGameFoldersFragment() } + private fun processGamesDir(result: Uri) { + requireContext().contentResolver.takePersistableUriPermission( + result, + Intent.FLAG_GRANT_READ_URI_PERMISSION + ) + + val uriString = result.toString() + val folder = gamesViewModel.folders.value.firstOrNull { it.uriString == uriString } + if (folder != null) { + Toast.makeText( + requireContext().applicationContext, + R.string.folder_already_added, + Toast.LENGTH_SHORT + ).show() + return + } + + AddGameFolderDialogFragment.newInstance(uriString, calledFromGameFragment = false) + .show(parentFragmentManager, AddGameFolderDialogFragment.TAG) + } + + private fun processExternalContentDir(result: Uri) { + requireContext().contentResolver.takePersistableUriPermission( + result, + Intent.FLAG_GRANT_READ_URI_PERMISSION + ) + + val uriString = result.toString() + val folder = gamesViewModel.folders.value.firstOrNull { + it.uriString == uriString && it.type == DirectoryType.EXTERNAL_CONTENT + } + if (folder != null) { + Toast.makeText( + requireContext().applicationContext, + R.string.folder_already_added, + Toast.LENGTH_SHORT + ).show() + return + } + + val externalContentDir = GameDir(uriString, deepScan = false, DirectoryType.EXTERNAL_CONTENT) + gamesViewModel.addFolder(externalContentDir, savedFromGameFragment = false) + } + private fun setInsets() = ViewCompat.setOnApplyWindowInsetsListener( binding.root diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GameInfoFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GameInfoFragment.kt index 7863e40ff5..5d6238e5a1 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GameInfoFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GameInfoFragment.kt @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later package org.yuzu.yuzu_emu.fragments @@ -18,7 +18,6 @@ import androidx.core.view.WindowInsetsCompat import androidx.core.view.updatePadding import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels -import androidx.navigation.findNavController import androidx.navigation.fragment.navArgs import com.google.android.material.transition.MaterialSharedAxis import org.yuzu.yuzu_emu.NativeLibrary @@ -64,7 +63,7 @@ class GameInfoFragment : Fragment() { binding.apply { toolbarInfo.title = args.game.title toolbarInfo.setNavigationOnClickListener { - view.findNavController().popBackStack() + requireActivity().onBackPressedDispatcher.onBackPressed() } val pathString = Uri.parse(args.game.path).path ?: "" diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GamePropertiesFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GamePropertiesFragment.kt index 9e55297846..46b75197d5 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GamePropertiesFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GamePropertiesFragment.kt @@ -35,6 +35,7 @@ import org.yuzu.yuzu_emu.adapters.GamePropertiesAdapter import org.yuzu.yuzu_emu.databinding.FragmentGamePropertiesBinding import org.yuzu.yuzu_emu.features.DocumentProvider import org.yuzu.yuzu_emu.features.settings.model.Settings +import org.yuzu.yuzu_emu.features.settings.ui.SettingsSubscreen import org.yuzu.yuzu_emu.model.DriverViewModel import org.yuzu.yuzu_emu.model.GameProperty import org.yuzu.yuzu_emu.model.GamesViewModel @@ -250,8 +251,10 @@ class GamePropertiesFragment : Fragment() { R.string.info_description, R.drawable.ic_info_outline, action = { - val action = GamePropertiesFragmentDirections - .actionPerGamePropertiesFragmentToGameInfoFragment(args.game) + val action = HomeNavigationDirections.actionGlobalSettingsSubscreenActivity( + SettingsSubscreen.GAME_INFO, + args.game + ) binding.root.findNavController().navigate(action) } ) @@ -317,8 +320,11 @@ class GamePropertiesFragment : Fragment() { R.string.add_ons_description, R.drawable.ic_edit, action = { - val action = GamePropertiesFragmentDirections - .actionPerGamePropertiesFragmentToAddonsFragment(args.game) + val action = + HomeNavigationDirections.actionGlobalSettingsSubscreenActivity( + SettingsSubscreen.ADDONS, + args.game + ) binding.root.findNavController().navigate(action) } ) @@ -333,8 +339,11 @@ class GamePropertiesFragment : Fragment() { R.drawable.ic_build, detailsFlow = driverViewModel.selectedDriverTitle, action = { - val action = GamePropertiesFragmentDirections - .actionPerGamePropertiesFragmentToDriverManagerFragment(args.game) + val action = + HomeNavigationDirections.actionGlobalSettingsSubscreenActivity( + SettingsSubscreen.DRIVER_MANAGER, + args.game + ) binding.root.findNavController().navigate(action) } ) @@ -347,8 +356,11 @@ class GamePropertiesFragment : Fragment() { R.string.freedreno_per_game_description, R.drawable.ic_graphics, action = { - val action = GamePropertiesFragmentDirections - .actionPerGamePropertiesFragmentToFreedrenoSettingsFragment(args.game) + val action = + HomeNavigationDirections.actionGlobalSettingsSubscreenActivity( + SettingsSubscreen.FREEDRENO_SETTINGS, + args.game + ) binding.root.findNavController().navigate(action) } ) diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/HomeSettingsFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/HomeSettingsFragment.kt index 6f4bf858ea..37eda22c69 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/HomeSettingsFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/HomeSettingsFragment.kt @@ -36,6 +36,7 @@ import org.yuzu.yuzu_emu.databinding.FragmentHomeSettingsBinding import org.yuzu.yuzu_emu.features.DocumentProvider import org.yuzu.yuzu_emu.features.fetcher.SpacingItemDecoration import org.yuzu.yuzu_emu.features.settings.model.Settings +import org.yuzu.yuzu_emu.features.settings.ui.SettingsSubscreen import org.yuzu.yuzu_emu.model.DriverViewModel import org.yuzu.yuzu_emu.model.HomeSetting import org.yuzu.yuzu_emu.model.HomeViewModel @@ -126,8 +127,11 @@ class HomeSettingsFragment : Fragment() { R.string.profile_manager_description, R.drawable.ic_account_circle, { - binding.root.findNavController() - .navigate(R.id.action_homeSettingsFragment_to_profileManagerFragment) + val action = HomeNavigationDirections.actionGlobalSettingsSubscreenActivity( + SettingsSubscreen.PROFILE_MANAGER, + null + ) + binding.root.findNavController().navigate(action) } ) ) @@ -137,8 +141,10 @@ class HomeSettingsFragment : Fragment() { R.string.install_gpu_driver_description, R.drawable.ic_build, { - val action = HomeSettingsFragmentDirections - .actionHomeSettingsFragmentToDriverManagerFragment(null) + val action = HomeNavigationDirections.actionGlobalSettingsSubscreenActivity( + SettingsSubscreen.DRIVER_MANAGER, + null + ) binding.root.findNavController().navigate(action) }, { true }, @@ -154,7 +160,12 @@ class HomeSettingsFragment : Fragment() { R.string.gpu_driver_settings, R.drawable.ic_graphics, { - binding.root.findNavController().navigate(R.id.freedrenoSettingsFragment) + val action = + HomeNavigationDirections.actionGlobalSettingsSubscreenActivity( + SettingsSubscreen.FREEDRENO_SETTINGS, + null + ) + binding.root.findNavController().navigate(action) } ) ) @@ -175,8 +186,11 @@ class HomeSettingsFragment : Fragment() { R.string.applets_description, R.drawable.ic_applet, { - binding.root.findNavController() - .navigate(R.id.action_homeSettingsFragment_to_appletLauncherFragment) + val action = HomeNavigationDirections.actionGlobalSettingsSubscreenActivity( + SettingsSubscreen.APPLET_LAUNCHER, + null + ) + binding.root.findNavController().navigate(action) }, { NativeLibrary.isFirmwareAvailable() }, R.string.applets_error_firmware, @@ -189,8 +203,11 @@ class HomeSettingsFragment : Fragment() { R.string.manage_yuzu_data_description, R.drawable.ic_install, { - binding.root.findNavController() - .navigate(R.id.action_homeSettingsFragment_to_installableFragment) + val action = HomeNavigationDirections.actionGlobalSettingsSubscreenActivity( + SettingsSubscreen.INSTALLABLE, + null + ) + binding.root.findNavController().navigate(action) } ) ) @@ -200,8 +217,11 @@ class HomeSettingsFragment : Fragment() { R.string.select_games_folder_description, R.drawable.ic_add, { - binding.root.findNavController() - .navigate(R.id.action_homeSettingsFragment_to_gameFoldersFragment) + val action = HomeNavigationDirections.actionGlobalSettingsSubscreenActivity( + SettingsSubscreen.GAME_FOLDERS, + null + ) + binding.root.findNavController().navigate(action) } ) ) @@ -284,9 +304,11 @@ class HomeSettingsFragment : Fragment() { R.string.about_description, R.drawable.ic_info_outline, { - exitTransition = MaterialSharedAxis(MaterialSharedAxis.X, true) - parentFragmentManager.primaryNavigationFragment?.findNavController() - ?.navigate(R.id.action_homeSettingsFragment_to_aboutFragment) + val action = HomeNavigationDirections.actionGlobalSettingsSubscreenActivity( + SettingsSubscreen.ABOUT, + null + ) + binding.root.findNavController().navigate(action) } ) ) diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/InstallableFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/InstallableFragment.kt index 1b94d5f1a6..10862c37b4 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/InstallableFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/InstallableFragment.kt @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later package org.yuzu.yuzu_emu.fragments @@ -14,23 +14,23 @@ import androidx.core.view.WindowInsetsCompat import androidx.core.view.updatePadding import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels -import androidx.navigation.findNavController import androidx.recyclerview.widget.GridLayoutManager import com.google.android.material.transition.MaterialSharedAxis import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import org.yuzu.yuzu_emu.NativeLibrary import org.yuzu.yuzu_emu.R import org.yuzu.yuzu_emu.YuzuApplication import org.yuzu.yuzu_emu.adapters.InstallableAdapter import org.yuzu.yuzu_emu.databinding.FragmentInstallablesBinding +import org.yuzu.yuzu_emu.model.AddonViewModel +import org.yuzu.yuzu_emu.model.DriverViewModel +import org.yuzu.yuzu_emu.model.GamesViewModel import org.yuzu.yuzu_emu.model.HomeViewModel import org.yuzu.yuzu_emu.model.Installable import org.yuzu.yuzu_emu.model.TaskState -import org.yuzu.yuzu_emu.ui.main.MainActivity -import org.yuzu.yuzu_emu.utils.DirectoryInitialization import org.yuzu.yuzu_emu.utils.FileUtil +import org.yuzu.yuzu_emu.utils.InstallableActions import org.yuzu.yuzu_emu.utils.NativeConfig import org.yuzu.yuzu_emu.utils.ViewUtils.updateMargins import org.yuzu.yuzu_emu.utils.collect @@ -45,6 +45,9 @@ class InstallableFragment : Fragment() { private val binding get() = _binding!! private val homeViewModel: HomeViewModel by activityViewModels() + private val gamesViewModel: GamesViewModel by activityViewModels() + private val addonViewModel: AddonViewModel by activityViewModels() + private val driverViewModel: DriverViewModel by activityViewModels() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -65,12 +68,10 @@ class InstallableFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - val mainActivity = requireActivity() as MainActivity - homeViewModel.setStatusBarShadeVisibility(visible = false) binding.toolbarInstallables.setNavigationOnClickListener { - binding.root.findNavController().popBackStack() + requireActivity().onBackPressedDispatcher.onBackPressed() } homeViewModel.openImportSaves.collect(viewLifecycleOwner) { @@ -84,8 +85,8 @@ class InstallableFragment : Fragment() { Installable( R.string.user_data, R.string.user_data_description, - install = { mainActivity.importUserData.launch(arrayOf("application/zip")) }, - export = { mainActivity.exportUserData.launch("export.zip") } + install = { importUserDataLauncher.launch(arrayOf("application/zip")) }, + export = { exportUserDataLauncher.launch("export.zip") } ), Installable( R.string.manage_save_data, @@ -127,27 +128,33 @@ class InstallableFragment : Fragment() { Installable( R.string.install_game_content, R.string.install_game_content_description, - install = { mainActivity.installGameUpdate.launch(arrayOf("*/*")) } + install = { installGameUpdateLauncher.launch(arrayOf("*/*")) } ), Installable( R.string.install_firmware, R.string.install_firmware_description, - install = { mainActivity.getFirmware.launch(arrayOf("application/zip")) } + install = { getFirmwareLauncher.launch(arrayOf("application/zip")) } ), Installable( R.string.uninstall_firmware, R.string.uninstall_firmware_description, - install = { mainActivity.uninstallFirmware() } + install = { + InstallableActions.uninstallFirmware( + activity = requireActivity(), + fragmentManager = parentFragmentManager, + homeViewModel = homeViewModel + ) + } ), Installable( R.string.install_prod_keys, R.string.install_prod_keys_description, - install = { mainActivity.getProdKey.launch(arrayOf("*/*")) } + install = { getProdKeyLauncher.launch(arrayOf("*/*")) } ), Installable( R.string.install_amiibo_keys, R.string.install_amiibo_keys_description, - install = { mainActivity.getAmiiboKey.launch(arrayOf("*/*")) } + install = { getAmiiboKeyLauncher.launch(arrayOf("*/*")) } ) ) @@ -180,6 +187,132 @@ class InstallableFragment : Fragment() { windowInsets } + private val getProdKeyLauncher = + registerForActivityResult(ActivityResultContracts.OpenDocument()) { result -> + if (result != null) { + InstallableActions.processKey( + activity = requireActivity(), + fragmentManager = parentFragmentManager, + gamesViewModel = gamesViewModel, + result = result, + extension = "keys" + ) + } + } + + private val getAmiiboKeyLauncher = + registerForActivityResult(ActivityResultContracts.OpenDocument()) { result -> + if (result != null) { + InstallableActions.processKey( + activity = requireActivity(), + fragmentManager = parentFragmentManager, + gamesViewModel = gamesViewModel, + result = result, + extension = "bin" + ) + } + } + + private val getFirmwareLauncher = + registerForActivityResult(ActivityResultContracts.OpenDocument()) { result -> + if (result != null) { + InstallableActions.processFirmware( + activity = requireActivity(), + fragmentManager = parentFragmentManager, + homeViewModel = homeViewModel, + result = result + ) + } + } + + private val installGameUpdateLauncher = + registerForActivityResult(ActivityResultContracts.OpenMultipleDocuments()) { documents -> + if (documents.isEmpty()) { + return@registerForActivityResult + } + + if (addonViewModel.game == null) { + InstallableActions.installContent( + activity = requireActivity(), + fragmentManager = parentFragmentManager, + addonViewModel = addonViewModel, + documents = documents + ) + return@registerForActivityResult + } + + ProgressDialogFragment.newInstance( + requireActivity(), + R.string.verifying_content, + false + ) { _, _ -> + var updatesMatchProgram = true + for (document in documents) { + val valid = NativeLibrary.doesUpdateMatchProgram( + addonViewModel.game!!.programId, + document.toString() + ) + if (!valid) { + updatesMatchProgram = false + break + } + } + + if (updatesMatchProgram) { + requireActivity().runOnUiThread { + InstallableActions.installContent( + activity = requireActivity(), + fragmentManager = parentFragmentManager, + addonViewModel = addonViewModel, + documents = documents + ) + } + } else { + requireActivity().runOnUiThread { + MessageDialogFragment.newInstance( + requireActivity(), + titleId = R.string.content_install_notice, + descriptionId = R.string.content_install_notice_description, + positiveAction = { + InstallableActions.installContent( + activity = requireActivity(), + fragmentManager = parentFragmentManager, + addonViewModel = addonViewModel, + documents = documents + ) + }, + negativeAction = {} + ).show(parentFragmentManager, MessageDialogFragment.TAG) + } + } + return@newInstance Any() + }.show(parentFragmentManager, ProgressDialogFragment.TAG) + } + + private val importUserDataLauncher = + registerForActivityResult(ActivityResultContracts.OpenDocument()) { result -> + if (result != null) { + InstallableActions.importUserData( + activity = requireActivity(), + fragmentManager = parentFragmentManager, + gamesViewModel = gamesViewModel, + driverViewModel = driverViewModel, + result = result + ) + } + } + + private val exportUserDataLauncher = + registerForActivityResult(ActivityResultContracts.CreateDocument("application/zip")) { result -> + if (result != null) { + InstallableActions.exportUserData( + activity = requireActivity(), + fragmentManager = parentFragmentManager, + result = result + ) + } + } + private val importSaves = registerForActivityResult(ActivityResultContracts.OpenDocument()) { result -> if (result == null) { diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/LicensesFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/LicensesFragment.kt index aa18aa2482..32b72fe38f 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/LicensesFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/LicensesFragment.kt @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later package org.yuzu.yuzu_emu.fragments @@ -13,7 +13,6 @@ import androidx.core.view.WindowInsetsCompat import androidx.core.view.updatePadding import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels -import androidx.navigation.findNavController import androidx.recyclerview.widget.LinearLayoutManager import com.google.android.material.transition.MaterialSharedAxis import org.yuzu.yuzu_emu.R @@ -48,7 +47,7 @@ class LicensesFragment : Fragment() { homeViewModel.setStatusBarShadeVisibility(visible = false) binding.toolbarLicenses.setNavigationOnClickListener { - binding.root.findNavController().popBackStack() + requireActivity().onBackPressedDispatcher.onBackPressed() } val licenses = listOf( diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/ProfileManagerFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/ProfileManagerFragment.kt index 6ee34105e7..2786906f6b 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/ProfileManagerFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/ProfileManagerFragment.kt @@ -51,7 +51,7 @@ class ProfileManagerFragment : Fragment() { homeViewModel.setStatusBarShadeVisibility(visible = false) binding.toolbarProfiles.setNavigationOnClickListener { - findNavController().popBackStack() + requireActivity().onBackPressedDispatcher.onBackPressed() } setupRecyclerView() diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt index 74a171cf1f..f0806df786 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt @@ -26,7 +26,6 @@ import androidx.preference.PreferenceManager import com.google.android.material.color.MaterialColors import com.google.android.material.dialog.MaterialAlertDialogBuilder import java.io.File -import java.io.FilenameFilter import org.yuzu.yuzu_emu.NativeLibrary import org.yuzu.yuzu_emu.R import org.yuzu.yuzu_emu.databinding.ActivityMainBinding @@ -39,16 +38,10 @@ import org.yuzu.yuzu_emu.model.AddonViewModel import org.yuzu.yuzu_emu.model.DriverViewModel import org.yuzu.yuzu_emu.model.GamesViewModel import org.yuzu.yuzu_emu.model.HomeViewModel -import org.yuzu.yuzu_emu.model.InstallResult import android.os.Build -import org.yuzu.yuzu_emu.model.TaskState import org.yuzu.yuzu_emu.model.TaskViewModel import org.yuzu.yuzu_emu.utils.* import org.yuzu.yuzu_emu.utils.ViewUtils.setVisible -import java.io.BufferedInputStream -import java.io.BufferedOutputStream -import java.util.zip.ZipEntry -import java.util.zip.ZipInputStream import androidx.core.content.edit import org.yuzu.yuzu_emu.activities.EmulationActivity import kotlin.text.compareTo @@ -453,35 +446,13 @@ class MainActivity : AppCompatActivity(), ThemeProvider { } fun processKey(result: Uri, extension: String = "keys") { - contentResolver.takePersistableUriPermission( - result, - Intent.FLAG_GRANT_READ_URI_PERMISSION + InstallableActions.processKey( + activity = this, + fragmentManager = supportFragmentManager, + gamesViewModel = gamesViewModel, + result = result, + extension = extension ) - - val resultCode: Int = NativeLibrary.installKeys(result.toString(), extension) - - if (resultCode == 0) { - // TODO(crueter): It may be worth it to switch some of these Toasts to snackbars, - // since most of it is foreground-only anyways. - Toast.makeText( - applicationContext, - R.string.keys_install_success, - Toast.LENGTH_SHORT - ).show() - - gamesViewModel.reloadGames(true) - - return - } - - val resultString: String = - resources.getStringArray(R.array.installKeysResults)[resultCode] - - MessageDialogFragment.newInstance( - titleId = R.string.keys_failed, - descriptionString = resultString, - helpLinkId = R.string.keys_missing_help - ).show(supportFragmentManager, MessageDialogFragment.TAG) } val getFirmware = registerForActivityResult(ActivityResultContracts.OpenDocument()) { result -> @@ -491,75 +462,21 @@ class MainActivity : AppCompatActivity(), ThemeProvider { } fun processFirmware(result: Uri, onComplete: (() -> Unit)? = null) { - val filterNCA = FilenameFilter { _, dirName -> dirName.endsWith(".nca") } - - val firmwarePath = - File(NativeConfig.getNandDir() + "/system/Contents/registered/") - val cacheFirmwareDir = File("${cacheDir.path}/registered/") - - ProgressDialogFragment.newInstance( - this, - R.string.firmware_installing - ) { progressCallback, _ -> - var messageToShow: Any - try { - FileUtil.unzipToInternalStorage( - result.toString(), - cacheFirmwareDir, - progressCallback - ) - val unfilteredNumOfFiles = cacheFirmwareDir.list()?.size ?: -1 - val filteredNumOfFiles = cacheFirmwareDir.list(filterNCA)?.size ?: -2 - messageToShow = if (unfilteredNumOfFiles != filteredNumOfFiles) { - MessageDialogFragment.newInstance( - this, - titleId = R.string.firmware_installed_failure, - descriptionId = R.string.firmware_installed_failure_description - ) - } else { - firmwarePath.deleteRecursively() - cacheFirmwareDir.copyRecursively(firmwarePath, true) - NativeLibrary.initializeSystem(true) - homeViewModel.setCheckKeys(true) - getString(R.string.save_file_imported_success) - } - } catch (e: Exception) { - Log.error("[MainActivity] Firmware install failed - ${e.message}") - messageToShow = getString(R.string.fatal_error) - } finally { - cacheFirmwareDir.deleteRecursively() - } - messageToShow - }.apply { - onDialogComplete = onComplete - }.show(supportFragmentManager, ProgressDialogFragment.TAG) + InstallableActions.processFirmware( + activity = this, + fragmentManager = supportFragmentManager, + homeViewModel = homeViewModel, + result = result, + onComplete = onComplete + ) } fun uninstallFirmware() { - val firmwarePath = - File(NativeConfig.getNandDir() + "/system/Contents/registered/") - ProgressDialogFragment.newInstance( - this, - R.string.firmware_uninstalling - ) { progressCallback, _ -> - var messageToShow: Any - try { - // Ensure the firmware directory exists before attempting to delete - if (firmwarePath.exists()) { - firmwarePath.deleteRecursively() - // Optionally reinitialize the system or perform other necessary steps - NativeLibrary.initializeSystem(true) - homeViewModel.setCheckKeys(true) - messageToShow = getString(R.string.firmware_uninstalled_success) - } else { - messageToShow = getString(R.string.firmware_uninstalled_failure) - } - } catch (e: Exception) { - Log.error("[MainActivity] Firmware uninstall failed - ${e.message}") - messageToShow = getString(R.string.fatal_error) - } - messageToShow - }.show(supportFragmentManager, ProgressDialogFragment.TAG) + InstallableActions.uninstallFirmware( + activity = this, + fragmentManager = supportFragmentManager, + homeViewModel = homeViewModel + ) } val installGameUpdate = registerForActivityResult( @@ -606,101 +523,12 @@ class MainActivity : AppCompatActivity(), ThemeProvider { } private fun installContent(documents: List) { - ProgressDialogFragment.newInstance( - this@MainActivity, - R.string.installing_game_content - ) { progressCallback, messageCallback -> - var installSuccess = 0 - var installOverwrite = 0 - var errorBaseGame = 0 - var error = 0 - documents.forEach { - messageCallback.invoke(FileUtil.getFilename(it)) - when ( - InstallResult.from( - NativeLibrary.installFileToNand( - it.toString(), - progressCallback - ) - ) - ) { - InstallResult.Success -> { - installSuccess += 1 - } - - InstallResult.Overwrite -> { - installOverwrite += 1 - } - - InstallResult.BaseInstallAttempted -> { - errorBaseGame += 1 - } - - InstallResult.Failure -> { - error += 1 - } - } - } - - addonViewModel.refreshAddons(force = true) - - val separator = System.lineSeparator() ?: "\n" - val installResult = StringBuilder() - if (installSuccess > 0) { - installResult.append( - getString( - R.string.install_game_content_success_install, - installSuccess - ) - ) - installResult.append(separator) - } - if (installOverwrite > 0) { - installResult.append( - getString( - R.string.install_game_content_success_overwrite, - installOverwrite - ) - ) - installResult.append(separator) - } - val errorTotal: Int = errorBaseGame + error - if (errorTotal > 0) { - installResult.append(separator) - installResult.append( - getString( - R.string.install_game_content_failed_count, - errorTotal - ) - ) - installResult.append(separator) - if (errorBaseGame > 0) { - installResult.append(separator) - installResult.append( - getString(R.string.install_game_content_failure_base) - ) - installResult.append(separator) - } - if (error > 0) { - installResult.append( - getString(R.string.install_game_content_failure_description) - ) - installResult.append(separator) - } - return@newInstance MessageDialogFragment.newInstance( - this, - titleId = R.string.install_game_content_failure, - descriptionString = installResult.toString().trim(), - helpLinkId = R.string.install_game_content_help_link - ) - } else { - return@newInstance MessageDialogFragment.newInstance( - this, - titleId = R.string.install_game_content_success, - descriptionString = installResult.toString().trim() - ) - } - }.show(supportFragmentManager, ProgressDialogFragment.TAG) + InstallableActions.installContent( + activity = this, + fragmentManager = supportFragmentManager, + addonViewModel = addonViewModel, + documents = documents + ) } val exportUserData = registerForActivityResult( @@ -709,25 +537,11 @@ class MainActivity : AppCompatActivity(), ThemeProvider { if (result == null) { return@registerForActivityResult } - - ProgressDialogFragment.newInstance( - this, - R.string.exporting_user_data, - true - ) { progressCallback, _ -> - val zipResult = FileUtil.zipFromInternalStorage( - File(DirectoryInitialization.userDirectory!!), - DirectoryInitialization.userDirectory!!, - BufferedOutputStream(contentResolver.openOutputStream(result)), - progressCallback, - compression = false - ) - return@newInstance when (zipResult) { - TaskState.Completed -> getString(R.string.user_data_export_success) - TaskState.Failed -> R.string.export_failed - TaskState.Cancelled -> R.string.user_data_export_cancelled - } - }.show(supportFragmentManager, ProgressDialogFragment.TAG) + InstallableActions.exportUserData( + activity = this, + fragmentManager = supportFragmentManager, + result = result + ) } val importUserData = @@ -735,58 +549,12 @@ class MainActivity : AppCompatActivity(), ThemeProvider { if (result == null) { return@registerForActivityResult } - - ProgressDialogFragment.newInstance( - this, - R.string.importing_user_data - ) { progressCallback, _ -> - val checkStream = - ZipInputStream(BufferedInputStream(contentResolver.openInputStream(result))) - var isYuzuBackup = false - checkStream.use { stream -> - var ze: ZipEntry? = null - while (stream.nextEntry?.also { ze = it } != null) { - val itemName = ze!!.name.trim() - if (itemName == "/config/config.ini" || itemName == "config/config.ini") { - isYuzuBackup = true - return@use - } - } - } - if (!isYuzuBackup) { - return@newInstance MessageDialogFragment.newInstance( - this, - titleId = R.string.invalid_yuzu_backup, - descriptionId = R.string.user_data_import_failed_description - ) - } - - // Clear existing user data - NativeConfig.unloadGlobalConfig() - File(DirectoryInitialization.userDirectory!!).deleteRecursively() - - // Copy archive to internal storage - try { - FileUtil.unzipToInternalStorage( - result.toString(), - File(DirectoryInitialization.userDirectory!!), - progressCallback - ) - } catch (e: Exception) { - return@newInstance MessageDialogFragment.newInstance( - this, - titleId = R.string.import_failed, - descriptionId = R.string.user_data_import_failed_description - ) - } - - // Reinitialize relevant data - NativeLibrary.initializeSystem(true) - NativeConfig.initializeGlobalConfig() - gamesViewModel.reloadGames(false) - driverViewModel.reloadDriverData() - - return@newInstance getString(R.string.user_data_import_success) - }.show(supportFragmentManager, ProgressDialogFragment.TAG) + InstallableActions.importUserData( + activity = this, + fragmentManager = supportFragmentManager, + gamesViewModel = gamesViewModel, + driverViewModel = driverViewModel, + result = result + ) } } diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/InstallableActions.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/InstallableActions.kt new file mode 100644 index 0000000000..d385e2a095 --- /dev/null +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/InstallableActions.kt @@ -0,0 +1,327 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + +package org.yuzu.yuzu_emu.utils + +import android.content.Intent +import android.net.Uri +import android.widget.Toast +import androidx.fragment.app.FragmentActivity +import androidx.fragment.app.FragmentManager +import org.yuzu.yuzu_emu.NativeLibrary +import org.yuzu.yuzu_emu.R +import org.yuzu.yuzu_emu.fragments.MessageDialogFragment +import org.yuzu.yuzu_emu.fragments.ProgressDialogFragment +import org.yuzu.yuzu_emu.model.AddonViewModel +import org.yuzu.yuzu_emu.model.DriverViewModel +import org.yuzu.yuzu_emu.model.GamesViewModel +import org.yuzu.yuzu_emu.model.HomeViewModel +import org.yuzu.yuzu_emu.model.InstallResult +import org.yuzu.yuzu_emu.model.TaskState +import java.io.BufferedInputStream +import java.io.BufferedOutputStream +import java.io.File +import java.io.FilenameFilter +import java.util.zip.ZipEntry +import java.util.zip.ZipInputStream + +object InstallableActions { + fun processKey( + activity: FragmentActivity, + fragmentManager: FragmentManager, + gamesViewModel: GamesViewModel, + result: Uri, + extension: String = "keys" + ) { + activity.contentResolver.takePersistableUriPermission( + result, + Intent.FLAG_GRANT_READ_URI_PERMISSION + ) + + val resultCode = NativeLibrary.installKeys(result.toString(), extension) + if (resultCode == 0) { + Toast.makeText( + activity.applicationContext, + R.string.keys_install_success, + Toast.LENGTH_SHORT + ).show() + gamesViewModel.reloadGames(true) + return + } + + val resultString = activity.resources.getStringArray(R.array.installKeysResults)[resultCode] + MessageDialogFragment.newInstance( + titleId = R.string.keys_failed, + descriptionString = resultString, + helpLinkId = R.string.keys_missing_help + ).show(fragmentManager, MessageDialogFragment.TAG) + } + + fun processFirmware( + activity: FragmentActivity, + fragmentManager: FragmentManager, + homeViewModel: HomeViewModel, + result: Uri, + onComplete: (() -> Unit)? = null + ) { + val filterNCA = FilenameFilter { _, dirName -> dirName.endsWith(".nca") } + val firmwarePath = File(NativeConfig.getNandDir() + "/system/Contents/registered/") + val cacheFirmwareDir = File("${activity.cacheDir.path}/registered/") + + ProgressDialogFragment.newInstance( + activity, + R.string.firmware_installing + ) { progressCallback, _ -> + var messageToShow: Any + try { + FileUtil.unzipToInternalStorage( + result.toString(), + cacheFirmwareDir, + progressCallback + ) + val unfilteredNumOfFiles = cacheFirmwareDir.list()?.size ?: -1 + val filteredNumOfFiles = cacheFirmwareDir.list(filterNCA)?.size ?: -2 + messageToShow = if (unfilteredNumOfFiles != filteredNumOfFiles) { + MessageDialogFragment.newInstance( + activity, + titleId = R.string.firmware_installed_failure, + descriptionId = R.string.firmware_installed_failure_description + ) + } else { + firmwarePath.deleteRecursively() + cacheFirmwareDir.copyRecursively(firmwarePath, overwrite = true) + NativeLibrary.initializeSystem(true) + homeViewModel.setCheckKeys(true) + activity.getString(R.string.save_file_imported_success) + } + } catch (_: Exception) { + messageToShow = activity.getString(R.string.fatal_error) + } finally { + cacheFirmwareDir.deleteRecursively() + } + messageToShow + }.apply { + onDialogComplete = onComplete + }.show(fragmentManager, ProgressDialogFragment.TAG) + } + + fun uninstallFirmware( + activity: FragmentActivity, + fragmentManager: FragmentManager, + homeViewModel: HomeViewModel + ) { + val firmwarePath = File(NativeConfig.getNandDir() + "/system/Contents/registered/") + ProgressDialogFragment.newInstance( + activity, + R.string.firmware_uninstalling + ) { _, _ -> + val messageToShow: Any = try { + if (firmwarePath.exists()) { + firmwarePath.deleteRecursively() + NativeLibrary.initializeSystem(true) + homeViewModel.setCheckKeys(true) + activity.getString(R.string.firmware_uninstalled_success) + } else { + activity.getString(R.string.firmware_uninstalled_failure) + } + } catch (_: Exception) { + activity.getString(R.string.fatal_error) + } + messageToShow + }.show(fragmentManager, ProgressDialogFragment.TAG) + } + + fun installContent( + activity: FragmentActivity, + fragmentManager: FragmentManager, + addonViewModel: AddonViewModel, + documents: List + ) { + ProgressDialogFragment.newInstance( + activity, + R.string.installing_game_content + ) { progressCallback, messageCallback -> + var installSuccess = 0 + var installOverwrite = 0 + var errorBaseGame = 0 + var error = 0 + documents.forEach { + messageCallback.invoke(FileUtil.getFilename(it)) + when ( + InstallResult.from( + NativeLibrary.installFileToNand( + it.toString(), + progressCallback + ) + ) + ) { + InstallResult.Success -> installSuccess += 1 + InstallResult.Overwrite -> installOverwrite += 1 + InstallResult.BaseInstallAttempted -> errorBaseGame += 1 + InstallResult.Failure -> error += 1 + } + } + + addonViewModel.refreshAddons(force = true) + + val separator = System.lineSeparator() ?: "\n" + val installResult = StringBuilder() + if (installSuccess > 0) { + installResult.append( + activity.getString( + R.string.install_game_content_success_install, + installSuccess + ) + ) + installResult.append(separator) + } + if (installOverwrite > 0) { + installResult.append( + activity.getString( + R.string.install_game_content_success_overwrite, + installOverwrite + ) + ) + installResult.append(separator) + } + val errorTotal = errorBaseGame + error + if (errorTotal > 0) { + installResult.append(separator) + installResult.append( + activity.getString( + R.string.install_game_content_failed_count, + errorTotal + ) + ) + installResult.append(separator) + if (errorBaseGame > 0) { + installResult.append(separator) + installResult.append(activity.getString(R.string.install_game_content_failure_base)) + installResult.append(separator) + } + if (error > 0) { + installResult.append( + activity.getString(R.string.install_game_content_failure_description) + ) + installResult.append(separator) + } + return@newInstance MessageDialogFragment.newInstance( + activity, + titleId = R.string.install_game_content_failure, + descriptionString = installResult.toString().trim(), + helpLinkId = R.string.install_game_content_help_link + ) + } else { + return@newInstance MessageDialogFragment.newInstance( + activity, + titleId = R.string.install_game_content_success, + descriptionString = installResult.toString().trim() + ) + } + }.show(fragmentManager, ProgressDialogFragment.TAG) + } + + fun exportUserData( + activity: FragmentActivity, + fragmentManager: FragmentManager, + result: Uri + ) { + val userDirectory = DirectoryInitialization.userDirectory + if (userDirectory == null) { + Toast.makeText( + activity.applicationContext, + R.string.fatal_error, + Toast.LENGTH_SHORT + ).show() + return + } + + ProgressDialogFragment.newInstance( + activity, + R.string.exporting_user_data, + true + ) { progressCallback, _ -> + val zipResult = FileUtil.zipFromInternalStorage( + File(userDirectory), + userDirectory, + BufferedOutputStream(activity.contentResolver.openOutputStream(result)), + progressCallback, + compression = false + ) + return@newInstance when (zipResult) { + TaskState.Completed -> activity.getString(R.string.user_data_export_success) + TaskState.Failed -> R.string.export_failed + TaskState.Cancelled -> R.string.user_data_export_cancelled + } + }.show(fragmentManager, ProgressDialogFragment.TAG) + } + + fun importUserData( + activity: FragmentActivity, + fragmentManager: FragmentManager, + gamesViewModel: GamesViewModel, + driverViewModel: DriverViewModel, + result: Uri + ) { + val userDirectory = DirectoryInitialization.userDirectory + if (userDirectory == null) { + Toast.makeText( + activity.applicationContext, + R.string.fatal_error, + Toast.LENGTH_SHORT + ).show() + return + } + + ProgressDialogFragment.newInstance( + activity, + R.string.importing_user_data + ) { progressCallback, _ -> + val checkStream = ZipInputStream( + BufferedInputStream(activity.contentResolver.openInputStream(result)) + ) + var isYuzuBackup = false + checkStream.use { stream -> + var ze: ZipEntry? = null + while (stream.nextEntry?.also { ze = it } != null) { + val itemName = ze!!.name.trim() + if (itemName == "/config/config.ini" || itemName == "config/config.ini") { + isYuzuBackup = true + return@use + } + } + } + if (!isYuzuBackup) { + return@newInstance MessageDialogFragment.newInstance( + activity, + titleId = R.string.invalid_yuzu_backup, + descriptionId = R.string.user_data_import_failed_description + ) + } + + NativeConfig.unloadGlobalConfig() + File(userDirectory).deleteRecursively() + + try { + FileUtil.unzipToInternalStorage( + result.toString(), + File(userDirectory), + progressCallback + ) + } catch (_: Exception) { + return@newInstance MessageDialogFragment.newInstance( + activity, + titleId = R.string.import_failed, + descriptionId = R.string.user_data_import_failed_description + ) + } + + NativeLibrary.initializeSystem(true) + NativeConfig.initializeGlobalConfig() + gamesViewModel.reloadGames(false) + driverViewModel.reloadDriverData() + + return@newInstance activity.getString(R.string.user_data_import_success) + }.show(fragmentManager, ProgressDialogFragment.TAG) + } +} diff --git a/src/android/app/src/main/res/layout-w600dp/fragment_about.xml b/src/android/app/src/main/res/layout-w600dp/fragment_about.xml index ae2b3e3637..cc8d26dd58 100644 --- a/src/android/app/src/main/res/layout-w600dp/fragment_about.xml +++ b/src/android/app/src/main/res/layout-w600dp/fragment_about.xml @@ -10,12 +10,11 @@ + android:touchscreenBlocksFocus="false"> + android:paddingBottom="24dp" + android:paddingStart="24dp" + android:paddingTop="0dp" + android:paddingEnd="24dp"> - + android:gravity="center_horizontal" + android:orientation="vertical"> + + + + + + + + - - - - - - - - - - diff --git a/src/android/app/src/main/res/layout/fragment_about.xml b/src/android/app/src/main/res/layout/fragment_about.xml index da823bcc25..b1b896f169 100644 --- a/src/android/app/src/main/res/layout/fragment_about.xml +++ b/src/android/app/src/main/res/layout/fragment_about.xml @@ -10,12 +10,11 @@ + android:touchscreenBlocksFocus="false"> - - - - + + + + + android:text="@string/app_name" + android:textAlignment="center" /> - + - - - - + @@ -220,7 +206,9 @@ app:icon="@drawable/ic_discord" app:iconSize="24dp" app:iconGravity="textStart" - app:iconPadding="0dp" /> + app:iconPadding="0dp" + app:strokeColor="?attr/colorOutline" + app:strokeWidth="1dp" /> + app:iconPadding="0dp" + app:strokeColor="?attr/colorOutline" + app:strokeWidth="1dp" /> + app:iconPadding="0dp" + app:strokeColor="?attr/colorOutline" + app:strokeWidth="1dp" /> + app:iconPadding="0dp" + app:strokeColor="?attr/colorOutline" + app:strokeWidth="1dp" /> + app:iconPadding="0dp" + app:strokeColor="?attr/colorOutline" + app:strokeWidth="1dp" /> diff --git a/src/android/app/src/main/res/navigation/emulation_navigation.xml b/src/android/app/src/main/res/navigation/emulation_navigation.xml index 5e6a49501d..2adc60a47c 100644 --- a/src/android/app/src/main/res/navigation/emulation_navigation.xml +++ b/src/android/app/src/main/res/navigation/emulation_navigation.xml @@ -40,10 +40,6 @@ + app:destination="@id/settingsActivity" /> diff --git a/src/android/app/src/main/res/navigation/home_navigation.xml b/src/android/app/src/main/res/navigation/home_navigation.xml index 7d04a19f36..dd567abc1a 100644 --- a/src/android/app/src/main/res/navigation/home_navigation.xml +++ b/src/android/app/src/main/res/navigation/home_navigation.xml @@ -20,26 +20,7 @@ - - - - - - - + android:label="HomeSettingsFragment" /> - - + android:label="AboutFragment" /> + app:destination="@id/settingsActivity" /> + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml index 7d094effcb..83c04ad40e 100644 --- a/src/android/app/src/main/res/values/strings.xml +++ b/src/android/app/src/main/res/values/strings.xml @@ -400,7 +400,7 @@ Copied to clipboard An open-source Switch emulator Contributors - Contributors who made Eden for Android possible + People who made Eden for Android possible https://git.eden-emu.dev/eden-emu/eden/activity/contributors Projects that make Eden for Android possible Build From e010ba503cee1edd87a8e0495c31dbc9cf67df49 Mon Sep 17 00:00:00 2001 From: lizzie Date: Wed, 4 Mar 2026 20:31:09 +0000 Subject: [PATCH 23/25] [audio_core, hle/services, video_core/compute] Inline std::unique_ptr<> allocs into std::optional<> Signed-off-by: lizzie --- src/audio_core/audio_core.cpp | 5 +- src/audio_core/audio_core.h | 20 ++---- src/audio_core/audio_in_manager.cpp | 3 +- src/audio_core/audio_out_manager.cpp | 3 +- src/core/core.cpp | 2 +- src/core/hle/service/am/applet_manager.cpp | 2 +- src/core/hle/service/am/process_creation.cpp | 52 ++++++---------- src/core/hle/service/am/process_creation.h | 9 +-- .../am/service/application_creator.cpp | 24 +++---- .../am/service/library_applet_creator.cpp | 35 +++++------ .../hle/service/audio/audio_out_manager.cpp | 4 +- .../hle/service/audio/audio_out_manager.h | 2 +- .../service/audio/audio_renderer_manager.cpp | 4 +- .../service/audio/audio_renderer_manager.h | 2 +- src/core/hle/service/os/process.cpp | 8 --- src/core/hle/service/os/process.h | 6 +- .../renderer_vulkan/vk_query_cache.cpp | 62 ++++++------------- .../renderer_vulkan/vk_update_descriptor.h | 15 ++--- 18 files changed, 92 insertions(+), 166 deletions(-) diff --git a/src/audio_core/audio_core.cpp b/src/audio_core/audio_core.cpp index fcaab2b320..28d38c8881 100644 --- a/src/audio_core/audio_core.cpp +++ b/src/audio_core/audio_core.cpp @@ -8,10 +8,11 @@ namespace AudioCore { -AudioCore::AudioCore(Core::System& system) : audio_manager{std::make_unique()} { +AudioCore::AudioCore(Core::System& system) { + audio_manager.emplace(); CreateSinks(); // Must be created after the sinks - adsp = std::make_unique(system, *output_sink); + adsp.emplace(system, *output_sink); } AudioCore ::~AudioCore() { diff --git a/src/audio_core/audio_core.h b/src/audio_core/audio_core.h index e4e27fc661..e4771d7656 100644 --- a/src/audio_core/audio_core.h +++ b/src/audio_core/audio_core.h @@ -15,10 +15,7 @@ class System; namespace AudioCore { -class AudioManager; -/** - * Main audio class, stored inside the core, and holding the audio manager, all sinks, and the ADSP. - */ +/// @brief Main audio class, stored inside the core, and holding the audio manager, all sinks, and the ADSP. class AudioCore { public: explicit AudioCore(Core::System& system); @@ -50,27 +47,22 @@ public: */ Sink::Sink& GetInputSink(); - /** - * Get the ADSP. - * - * @return Ref to the ADSP. - */ + /// @brief Get the ADSP. + /// @return Ref to the ADSP. ADSP::ADSP& ADSP(); private: - /** - * Create the sinks on startup. - */ + /// @brief Create the sinks on startup. void CreateSinks(); /// Main audio manager for audio in/out - std::unique_ptr audio_manager; + std::optional audio_manager; /// Sink used for audio renderer and audio out std::unique_ptr output_sink; /// Sink used for audio input std::unique_ptr input_sink; /// The ADSP in the sysmodule - std::unique_ptr adsp; + std::optional adsp; }; } // namespace AudioCore diff --git a/src/audio_core/audio_in_manager.cpp b/src/audio_core/audio_in_manager.cpp index 63b064922a..c11e88b317 100644 --- a/src/audio_core/audio_in_manager.cpp +++ b/src/audio_core/audio_in_manager.cpp @@ -41,8 +41,7 @@ void Manager::ReleaseSessionId(const size_t session_id) { Result Manager::LinkToManager() { std::scoped_lock l{mutex}; if (!linked_to_manager) { - AudioManager& manager{system.AudioCore().GetAudioManager()}; - manager.SetInManager(std::bind(&Manager::BufferReleaseAndRegister, this)); + system.AudioCore().GetAudioManager().SetInManager(std::bind(&Manager::BufferReleaseAndRegister, this)); linked_to_manager = true; } diff --git a/src/audio_core/audio_out_manager.cpp b/src/audio_core/audio_out_manager.cpp index 316ea7c817..dee3d493e5 100644 --- a/src/audio_core/audio_out_manager.cpp +++ b/src/audio_core/audio_out_manager.cpp @@ -40,8 +40,7 @@ void Manager::ReleaseSessionId(const size_t session_id) { Result Manager::LinkToManager() { std::scoped_lock l{mutex}; if (!linked_to_manager) { - AudioManager& manager{system.AudioCore().GetAudioManager()}; - manager.SetOutManager(std::bind(&Manager::BufferReleaseAndRegister, this)); + system.AudioCore().GetAudioManager().SetOutManager(std::bind(&Manager::BufferReleaseAndRegister, this)); linked_to_manager = true; } diff --git a/src/core/core.cpp b/src/core/core.cpp index 9db4589ceb..6ec656cf8c 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -347,7 +347,7 @@ struct System::Impl { // Register with applet manager // All threads are started, begin main process execution, now that we're in the clear - applet_manager.CreateAndInsertByFrontendAppletParameters(std::move(process), params); + applet_manager.CreateAndInsertByFrontendAppletParameters(std::make_unique(*std::move(process)), params); if (Settings::values.gamecard_inserted) { if (Settings::values.gamecard_current_game) { diff --git a/src/core/hle/service/am/applet_manager.cpp b/src/core/hle/service/am/applet_manager.cpp index c2920f91ae..2bedce03cb 100644 --- a/src/core/hle/service/am/applet_manager.cpp +++ b/src/core/hle/service/am/applet_manager.cpp @@ -268,7 +268,7 @@ void AppletManager::SetWindowSystem(WindowSystem* window_system) { if (Settings::values.enable_overlay && m_window_system->GetOverlayDisplayApplet() == nullptr) { if (auto overlay_process = CreateProcess(m_system, static_cast(AppletProgramId::OverlayDisplay), 0, 0)) { - auto overlay_applet = std::make_shared(m_system, std::move(overlay_process), false); + auto overlay_applet = std::make_shared(m_system, std::make_unique(*std::move(overlay_process)), false); overlay_applet->program_id = static_cast(AppletProgramId::OverlayDisplay); overlay_applet->applet_id = AppletId::OverlayDisplay; overlay_applet->type = AppletType::OverlayApplet; diff --git a/src/core/hle/service/am/process_creation.cpp b/src/core/hle/service/am/process_creation.cpp index b5e31353a2..cd537062d7 100644 --- a/src/core/hle/service/am/process_creation.cpp +++ b/src/core/hle/service/am/process_creation.cpp @@ -1,6 +1,7 @@ // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include #include "core/core.h" #include "core/file_sys/content_archive.h" #include "core/file_sys/nca_metadata.h" @@ -36,31 +37,23 @@ FileSys::StorageId GetStorageIdForFrontendSlot( } } -std::unique_ptr CreateProcessImpl(std::unique_ptr& out_loader, - Loader::ResultStatus& out_load_result, - Core::System& system, FileSys::VirtualFile file, - u64 program_id, u64 program_index) { +std::optional CreateProcessImpl(std::unique_ptr& out_loader, Loader::ResultStatus& out_load_result, Core::System& system, FileSys::VirtualFile file, u64 program_id, u64 program_index) { // Get the appropriate loader to parse this NCA. out_loader = Loader::GetLoader(system, file, program_id, program_index); - // Ensure we have a loader which can parse the NCA. - if (!out_loader) { - return nullptr; + if (out_loader) { + // Try to load the process. + auto process = std::optional(system); + if (process->Initialize(*out_loader, out_load_result)) { + return process; + } } - - // Try to load the process. - auto process = std::make_unique(system); - if (process->Initialize(*out_loader, out_load_result)) { - return process; - } - - return nullptr; + return std::nullopt; } } // Anonymous namespace -std::unique_ptr CreateProcess(Core::System& system, u64 program_id, - u8 minimum_key_generation, u8 maximum_key_generation) { +std::optional CreateProcess(Core::System& system, u64 program_id, u8 minimum_key_generation, u8 maximum_key_generation) { // Attempt to load program NCA. FileSys::VirtualFile nca_raw{}; @@ -70,7 +63,7 @@ std::unique_ptr CreateProcess(Core::System& system, u64 program_id, // Ensure we retrieved a program NCA. if (!nca_raw) { - return nullptr; + return std::nullopt; } // Ensure we have a suitable version. @@ -79,9 +72,8 @@ std::unique_ptr CreateProcess(Core::System& system, u64 program_id, if (nca.GetStatus() == Loader::ResultStatus::Success && (nca.GetKeyGeneration() < minimum_key_generation || nca.GetKeyGeneration() > maximum_key_generation)) { - LOG_WARNING(Service_LDR, "Skipping program {:016X} with generation {}", program_id, - nca.GetKeyGeneration()); - return nullptr; + LOG_WARNING(Service_LDR, "Skipping program {:016X} with generation {}", program_id, nca.GetKeyGeneration()); + return std::nullopt; } } @@ -90,15 +82,10 @@ std::unique_ptr CreateProcess(Core::System& system, u64 program_id, return CreateProcessImpl(loader, status, system, nca_raw, program_id, 0); } -std::unique_ptr CreateApplicationProcess(std::vector& out_control, - std::unique_ptr& out_loader, - Loader::ResultStatus& out_load_result, - Core::System& system, FileSys::VirtualFile file, - u64 program_id, u64 program_index) { - auto process = - CreateProcessImpl(out_loader, out_load_result, system, file, program_id, program_index); +std::optional CreateApplicationProcess(std::vector& out_control, std::unique_ptr& out_loader, Loader::ResultStatus& out_load_result, Core::System& system, FileSys::VirtualFile file, u64 program_id, u64 program_index) { + auto process = CreateProcessImpl(out_loader, out_load_result, system, file, program_id, program_index); if (!process) { - return nullptr; + return std::nullopt; } FileSys::NACP nacp; @@ -118,13 +105,10 @@ std::unique_ptr CreateApplicationProcess(std::vector& out_control, // TODO(DarkLordZach): When FSController/Game Card Support is added, if // current_process_game_card use correct StorageId - launch.base_game_storage_id = GetStorageIdForFrontendSlot( - storage.GetSlotForEntry(launch.title_id, FileSys::ContentRecordType::Program)); - launch.update_storage_id = GetStorageIdForFrontendSlot(storage.GetSlotForEntry( - FileSys::GetUpdateTitleID(launch.title_id), FileSys::ContentRecordType::Program)); + launch.base_game_storage_id = GetStorageIdForFrontendSlot(storage.GetSlotForEntry(launch.title_id, FileSys::ContentRecordType::Program)); + launch.update_storage_id = GetStorageIdForFrontendSlot(storage.GetSlotForEntry(FileSys::GetUpdateTitleID(launch.title_id), FileSys::ContentRecordType::Program)); system.GetARPManager().Register(launch.title_id, launch, out_control); - return process; } diff --git a/src/core/hle/service/am/process_creation.h b/src/core/hle/service/am/process_creation.h index 8cfb9e0c9e..40c3d36aff 100644 --- a/src/core/hle/service/am/process_creation.h +++ b/src/core/hle/service/am/process_creation.h @@ -24,12 +24,7 @@ class Process; namespace Service::AM { -std::unique_ptr CreateProcess(Core::System& system, u64 program_id, - u8 minimum_key_generation, u8 maximum_key_generation); -std::unique_ptr CreateApplicationProcess(std::vector& out_control, - std::unique_ptr& out_loader, - Loader::ResultStatus& out_load_result, - Core::System& system, FileSys::VirtualFile file, - u64 program_id, u64 program_index); +std::optional CreateProcess(Core::System& system, u64 program_id, u8 minimum_key_generation, u8 maximum_key_generation); +std::optional CreateApplicationProcess(std::vector& out_control, std::unique_ptr& out_loader, Loader::ResultStatus& out_load_result, Core::System& system, FileSys::VirtualFile file, u64 program_id, u64 program_index); } // namespace Service::AM diff --git a/src/core/hle/service/am/service/application_creator.cpp b/src/core/hle/service/am/service/application_creator.cpp index d16fd7dd84..4fece53119 100644 --- a/src/core/hle/service/am/service/application_creator.cpp +++ b/src/core/hle/service/am/service/application_creator.cpp @@ -21,8 +21,7 @@ namespace Service::AM { namespace { -Result CreateGuestApplication(SharedPointer* out_application_accessor, - Core::System& system, WindowSystem& window_system, u64 program_id) { +Result CreateGuestApplication(SharedPointer* out_application_accessor, Core::System& system, WindowSystem& window_system, u64 program_id) { FileSys::VirtualFile nca_raw{}; // Get the program NCA from storage. @@ -35,11 +34,10 @@ Result CreateGuestApplication(SharedPointer* out_applicati std::vector control; std::unique_ptr loader; Loader::ResultStatus result; - auto process = - CreateApplicationProcess(control, loader, result, system, nca_raw, program_id, 0); - R_UNLESS(process != nullptr, ResultUnknown); + auto process = CreateApplicationProcess(control, loader, result, system, nca_raw, program_id, 0); + R_UNLESS(process != std::nullopt, ResultUnknown); - const auto applet = std::make_shared(system, std::move(process), true); + const auto applet = std::make_shared(system, std::make_unique(*std::move(process)), true); applet->program_id = program_id; applet->applet_id = AppletId::Application; applet->type = AppletType::Application; @@ -47,8 +45,7 @@ Result CreateGuestApplication(SharedPointer* out_applicati window_system.TrackApplet(applet, true); - *out_application_accessor = - std::make_shared(system, applet, window_system); + *out_application_accessor = std::make_shared(system, applet, window_system); R_SUCCEED(); } @@ -90,12 +87,10 @@ Result IApplicationCreator::CreateSystemApplication( std::vector control; std::unique_ptr loader; + auto process = CreateProcess(system, application_id, 1, 21); + R_UNLESS(process != std::nullopt, ResultUnknown); - auto process = - CreateProcess(system, application_id, 1, 21); - R_UNLESS(process != nullptr, ResultUnknown); - - const auto applet = std::make_shared(system, std::move(process), true); + const auto applet = std::make_shared(system, std::make_unique(*std::move(process)), true); applet->program_id = application_id; applet->applet_id = AppletId::Starter; applet->type = AppletType::LibraryApplet; @@ -103,8 +98,7 @@ Result IApplicationCreator::CreateSystemApplication( m_window_system.TrackApplet(applet, true); - *out_application_accessor = - std::make_shared(system, applet, m_window_system); + *out_application_accessor = std::make_shared(system, applet, m_window_system); Core::LaunchTimestampCache::SaveLaunchTimestamp(application_id); R_SUCCEED(); } diff --git a/src/core/hle/service/am/service/library_applet_creator.cpp b/src/core/hle/service/am/service/library_applet_creator.cpp index e38729e70a..17db4b35d3 100644 --- a/src/core/hle/service/am/service/library_applet_creator.cpp +++ b/src/core/hle/service/am/service/library_applet_creator.cpp @@ -121,26 +121,23 @@ std::shared_ptr CreateGuestApplet(Core::System& system, }; auto process = CreateProcess(system, program_id, Firmware1400, Firmware2100); - if (!process) { - // Couldn't initialize the guest process - return {}; + if (process) { + const auto applet = std::make_shared(system, std::make_unique(*std::move(process)), false); + applet->program_id = program_id; + applet->applet_id = applet_id; + applet->type = AppletType::LibraryApplet; + applet->library_applet_mode = mode; + applet->window_visible = mode != LibraryAppletMode::AllForegroundInitiallyHidden; + + auto broker = std::make_shared(system); + applet->caller_applet = caller_applet; + applet->caller_applet_broker = broker; + caller_applet->child_applets.push_back(applet); + window_system.TrackApplet(applet, false); + return std::make_shared(system, broker, applet); } - - const auto applet = std::make_shared(system, std::move(process), false); - applet->program_id = program_id; - applet->applet_id = applet_id; - applet->type = AppletType::LibraryApplet; - applet->library_applet_mode = mode; - applet->window_visible = mode != LibraryAppletMode::AllForegroundInitiallyHidden; - - auto broker = std::make_shared(system); - applet->caller_applet = caller_applet; - applet->caller_applet_broker = broker; - caller_applet->child_applets.push_back(applet); - - window_system.TrackApplet(applet, false); - - return std::make_shared(system, broker, applet); + // Couldn't initialize the guest process + return {}; } std::shared_ptr CreateFrontendApplet(Core::System& system, diff --git a/src/core/hle/service/audio/audio_out_manager.cpp b/src/core/hle/service/audio/audio_out_manager.cpp index 0a8e1ec256..a5a05a1b76 100644 --- a/src/core/hle/service/audio/audio_out_manager.cpp +++ b/src/core/hle/service/audio/audio_out_manager.cpp @@ -14,7 +14,9 @@ namespace Service::Audio { using namespace AudioCore::AudioOut; IAudioOutManager::IAudioOutManager(Core::System& system_) - : ServiceFramework{system_, "audout:u"}, impl{std::make_unique(system_)} { + : ServiceFramework{system_, "audout:u"} + , impl(system_) +{ // clang-format off static const FunctionInfo functions[] = { {0, D<&IAudioOutManager::ListAudioOuts>, "ListAudioOuts"}, diff --git a/src/core/hle/service/audio/audio_out_manager.h b/src/core/hle/service/audio/audio_out_manager.h index 791274d5e9..57d1eb1e58 100644 --- a/src/core/hle/service/audio/audio_out_manager.h +++ b/src/core/hle/service/audio/audio_out_manager.h @@ -43,7 +43,7 @@ private: AudioCore::AudioOut::AudioOutParameter parameter, InCopyHandle process_handle, ClientAppletResourceUserId aruid); - std::unique_ptr impl; + std::optional impl; }; } // namespace Service::Audio diff --git a/src/core/hle/service/audio/audio_renderer_manager.cpp b/src/core/hle/service/audio/audio_renderer_manager.cpp index 6a1345c074..4f0bf0f3b9 100644 --- a/src/core/hle/service/audio/audio_renderer_manager.cpp +++ b/src/core/hle/service/audio/audio_renderer_manager.cpp @@ -15,7 +15,9 @@ namespace Service::Audio { using namespace AudioCore::Renderer; IAudioRendererManager::IAudioRendererManager(Core::System& system_) - : ServiceFramework{system_, "audren:u"}, impl{std::make_unique(system_)} { + : ServiceFramework{system_, "audren:u"} + , impl(system_) +{ // clang-format off static const FunctionInfo functions[] = { {0, D<&IAudioRendererManager::OpenAudioRenderer>, "OpenAudioRenderer"}, diff --git a/src/core/hle/service/audio/audio_renderer_manager.h b/src/core/hle/service/audio/audio_renderer_manager.h index 69eee664c3..3f25ad6df1 100644 --- a/src/core/hle/service/audio/audio_renderer_manager.h +++ b/src/core/hle/service/audio/audio_renderer_manager.h @@ -30,7 +30,7 @@ private: Result GetAudioDeviceServiceWithRevisionInfo(Out> out_audio_device, u32 revision, ClientAppletResourceUserId aruid); - std::unique_ptr impl; + std::optional impl; u32 num_audio_devices{0}; }; diff --git a/src/core/hle/service/os/process.cpp b/src/core/hle/service/os/process.cpp index 0dbadc315e..ec00af1433 100644 --- a/src/core/hle/service/os/process.cpp +++ b/src/core/hle/service/os/process.cpp @@ -10,14 +10,6 @@ namespace Service { -Process::Process(Core::System& system) - : m_system(system), m_process(), m_main_thread_priority(), m_main_thread_stack_size(), - m_process_started() {} - -Process::~Process() { - this->Finalize(); -} - bool Process::Initialize(Loader::AppLoader& loader, Loader::ResultStatus& out_load_result) { // First, ensure we are not holding another process. this->Finalize(); diff --git a/src/core/hle/service/os/process.h b/src/core/hle/service/os/process.h index 9109b7d0a5..cec61c76c7 100644 --- a/src/core/hle/service/os/process.h +++ b/src/core/hle/service/os/process.h @@ -22,8 +22,8 @@ namespace Service { class Process { public: - explicit Process(Core::System& system); - ~Process(); + inline explicit Process(Core::System& system) noexcept : m_system(system) {} + inline ~Process() { this->Finalize(); } bool Initialize(Loader::AppLoader& loader, Loader::ResultStatus& out_load_result); void Finalize(); @@ -50,8 +50,8 @@ public: private: Core::System& m_system; Kernel::KProcess* m_process{}; - s32 m_main_thread_priority{}; u64 m_main_thread_stack_size{}; + s32 m_main_thread_priority{}; bool m_process_started{}; }; diff --git a/src/video_core/renderer_vulkan/vk_query_cache.cpp b/src/video_core/renderer_vulkan/vk_query_cache.cpp index 7cdb3acadd..7bb632cedc 100644 --- a/src/video_core/renderer_vulkan/vk_query_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_query_cache.cpp @@ -126,16 +126,14 @@ public: current_query = nullptr; amend_value = 0; accumulation_value = 0; - queries_prefix_scan_pass = std::make_unique( - device, scheduler, descriptor_pool, compute_pass_descriptor_queue); + queries_prefix_scan_pass.emplace(device, scheduler, descriptor_pool, compute_pass_descriptor_queue); const VkBufferCreateInfo buffer_ci = { .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, .pNext = nullptr, .flags = 0, .size = 8, - .usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_TRANSFER_SRC_BIT | - VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, + .usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, .sharingMode = VK_SHARING_MODE_EXCLUSIVE, .queueFamilyIndexCount = 0, .pQueueFamilyIndices = nullptr, @@ -592,8 +590,7 @@ private: VideoCommon::HostQueryBase* current_query; bool has_started{}; std::mutex flush_guard; - - std::unique_ptr queries_prefix_scan_pass; + std::optional queries_prefix_scan_pass; }; // Transform feedback queries @@ -1176,35 +1173,21 @@ private: } // namespace struct QueryCacheRuntimeImpl { - QueryCacheRuntimeImpl(QueryCacheRuntime& runtime, VideoCore::RasterizerInterface* rasterizer_, - Tegra::MaxwellDeviceMemoryManager& device_memory_, - Vulkan::BufferCache& buffer_cache_, const Device& device_, - const MemoryAllocator& memory_allocator_, Scheduler& scheduler_, - StagingBufferPool& staging_pool_, - ComputePassDescriptorQueue& compute_pass_descriptor_queue, - DescriptorPool& descriptor_pool, TextureCache& texture_cache_) - : rasterizer{rasterizer_}, device_memory{device_memory_}, buffer_cache{buffer_cache_}, - device{device_}, memory_allocator{memory_allocator_}, scheduler{scheduler_}, - staging_pool{staging_pool_}, guest_streamer(0, runtime), - sample_streamer(static_cast(QueryType::ZPassPixelCount64), runtime, rasterizer, - texture_cache_, device, scheduler, memory_allocator, - compute_pass_descriptor_queue, descriptor_pool), - tfb_streamer(static_cast(QueryType::StreamingByteCount), runtime, device, - scheduler, memory_allocator, staging_pool), - primitives_succeeded_streamer( - static_cast(QueryType::StreamingPrimitivesSucceeded), runtime, tfb_streamer, - device_memory_), - primitives_needed_minus_succeeded_streamer( - static_cast(QueryType::StreamingPrimitivesNeededMinusSucceeded), runtime, 0u), - hcr_setup{}, hcr_is_set{}, is_hcr_running{}, maxwell3d{} { + QueryCacheRuntimeImpl(QueryCacheRuntime& runtime, VideoCore::RasterizerInterface* rasterizer_, Tegra::MaxwellDeviceMemoryManager& device_memory_, Vulkan::BufferCache& buffer_cache_, const Device& device_, const MemoryAllocator& memory_allocator_, Scheduler& scheduler_, StagingBufferPool& staging_pool_, ComputePassDescriptorQueue& compute_pass_descriptor_queue, DescriptorPool& descriptor_pool, TextureCache& texture_cache_) + : rasterizer{rasterizer_}, device_memory{device_memory_}, buffer_cache{buffer_cache_} + , device{device_}, memory_allocator{memory_allocator_}, scheduler{scheduler_} + , staging_pool{staging_pool_}, guest_streamer(0, runtime) + , sample_streamer(size_t(QueryType::ZPassPixelCount64), runtime, rasterizer, texture_cache_, device, scheduler, memory_allocator, compute_pass_descriptor_queue, descriptor_pool) + , tfb_streamer(size_t(QueryType::StreamingByteCount), runtime, device, scheduler, memory_allocator, staging_pool) + , primitives_succeeded_streamer(size_t(QueryType::StreamingPrimitivesSucceeded), runtime, tfb_streamer, device_memory_) + , primitives_needed_minus_succeeded_streamer(size_t(QueryType::StreamingPrimitivesNeededMinusSucceeded), runtime, 0u) + , hcr_setup{}, hcr_is_set{}, is_hcr_running{}, maxwell3d{} { hcr_setup.sType = VK_STRUCTURE_TYPE_CONDITIONAL_RENDERING_BEGIN_INFO_EXT; hcr_setup.pNext = nullptr; hcr_setup.flags = 0; - conditional_resolve_pass = std::make_unique( - device, scheduler, descriptor_pool, compute_pass_descriptor_queue); - + conditional_resolve_pass.emplace(device, scheduler, descriptor_pool, compute_pass_descriptor_queue); const VkBufferCreateInfo buffer_ci = { .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, .pNext = nullptr, @@ -1241,7 +1224,7 @@ struct QueryCacheRuntimeImpl { std::vector> copies_setup; // Host conditional rendering data - std::unique_ptr conditional_resolve_pass; + std::optional conditional_resolve_pass; vk::Buffer hcr_resolve_buffer; VkConditionalRenderingBeginInfoEXT hcr_setup; VkBuffer hcr_buffer; @@ -1253,13 +1236,7 @@ struct QueryCacheRuntimeImpl { Maxwell3D* maxwell3d; }; -QueryCacheRuntime::QueryCacheRuntime(VideoCore::RasterizerInterface* rasterizer, - Tegra::MaxwellDeviceMemoryManager& device_memory_, - Vulkan::BufferCache& buffer_cache_, const Device& device_, - const MemoryAllocator& memory_allocator_, - Scheduler& scheduler_, StagingBufferPool& staging_pool_, - ComputePassDescriptorQueue& compute_pass_descriptor_queue, - DescriptorPool& descriptor_pool, TextureCache& texture_cache_) { +QueryCacheRuntime::QueryCacheRuntime(VideoCore::RasterizerInterface* rasterizer, Tegra::MaxwellDeviceMemoryManager& device_memory_, Vulkan::BufferCache& buffer_cache_, const Device& device_, const MemoryAllocator& memory_allocator_, Scheduler& scheduler_, StagingBufferPool& staging_pool_, ComputePassDescriptorQueue& compute_pass_descriptor_queue, DescriptorPool& descriptor_pool, TextureCache& texture_cache_) { impl = std::make_unique( *this, rasterizer, device_memory_, buffer_cache_, device_, memory_allocator_, scheduler_, staging_pool_, compute_pass_descriptor_queue, descriptor_pool, texture_cache_); @@ -1484,13 +1461,11 @@ void QueryCacheRuntime::Barriers(bool is_prebarrier) { impl->scheduler.RequestOutsideRenderPassOperationContext(); if (is_prebarrier) { impl->scheduler.Record([](vk::CommandBuffer cmdbuf) { - cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, - VK_PIPELINE_STAGE_TRANSFER_BIT, 0, READ_BARRIER); + cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, READ_BARRIER); }); } else { impl->scheduler.Record([](vk::CommandBuffer cmdbuf) { - cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, - VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, WRITE_BARRIER); + cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, WRITE_BARRIER); }); } } @@ -1583,8 +1558,7 @@ void QueryCacheRuntime::SyncValues(std::span values, VkBuffer ba } impl->scheduler.RequestOutsideRenderPassOperationContext(); - impl->scheduler.Record([src_buffer, dst_buffers = std::move(impl->buffers_to_upload_to), - vk_copies = std::move(impl->copies_setup)](vk::CommandBuffer cmdbuf) { + impl->scheduler.Record([src_buffer, dst_buffers = std::move(impl->buffers_to_upload_to), vk_copies = std::move(impl->copies_setup)](vk::CommandBuffer cmdbuf) { size_t size = dst_buffers.size(); for (size_t i = 0; i < size; i++) { cmdbuf.CopyBuffer(src_buffer, dst_buffers[i].first, vk_copies[i]); diff --git a/src/video_core/renderer_vulkan/vk_update_descriptor.h b/src/video_core/renderer_vulkan/vk_update_descriptor.h index 82fce298da..3a1343e02e 100644 --- a/src/video_core/renderer_vulkan/vk_update_descriptor.h +++ b/src/video_core/renderer_vulkan/vk_update_descriptor.h @@ -12,20 +12,15 @@ namespace Vulkan { class Device; class Scheduler; -struct DescriptorUpdateEntry { - struct Empty {}; - +union DescriptorUpdateEntry { DescriptorUpdateEntry() = default; DescriptorUpdateEntry(VkDescriptorImageInfo image_) : image{image_} {} DescriptorUpdateEntry(VkDescriptorBufferInfo buffer_) : buffer{buffer_} {} DescriptorUpdateEntry(VkBufferView texel_buffer_) : texel_buffer{texel_buffer_} {} - - union { - Empty empty{}; - VkDescriptorImageInfo image; - VkDescriptorBufferInfo buffer; - VkBufferView texel_buffer; - }; + std::monostate empty{}; + VkDescriptorImageInfo image; + VkDescriptorBufferInfo buffer; + VkBufferView texel_buffer; }; class UpdateDescriptorQueue final { From a4280a5831cc9926ced81f93ef74a7cd98ff892a Mon Sep 17 00:00:00 2001 From: lizzie Date: Wed, 11 Mar 2026 23:44:55 +0000 Subject: [PATCH 24/25] fx --- src/audio_core/audio_core.cpp | 3 + src/audio_core/audio_core.h | 3 + src/audio_core/audio_in_manager.cpp | 3 + src/audio_core/audio_manager.cpp | 100 +++++++++--------- src/audio_core/audio_manager.h | 10 +- src/audio_core/audio_out_manager.cpp | 3 + src/core/hle/service/am/button_poller.cpp | 71 ++++++------- src/core/hle/service/am/button_poller.h | 32 +++--- src/core/hle/service/am/event_observer.cpp | 31 +++--- src/core/hle/service/am/event_observer.h | 3 - src/core/hle/service/am/process_creation.cpp | 59 ++++++----- src/core/hle/service/am/process_creation.h | 3 + .../am/service/application_creator.cpp | 2 +- .../am/service/library_applet_creator.cpp | 2 +- .../hle/service/audio/audio_out_manager.cpp | 2 +- .../hle/service/audio/audio_out_manager.h | 2 +- .../service/audio/audio_renderer_manager.cpp | 3 + .../service/audio/audio_renderer_manager.h | 3 + src/core/hle/service/os/process.cpp | 3 + src/core/hle/service/os/process.h | 3 + src/input_common/drivers/udp_client.cpp | 78 +++++++------- .../renderer_vulkan/vk_update_descriptor.h | 5 +- 22 files changed, 216 insertions(+), 208 deletions(-) diff --git a/src/audio_core/audio_core.cpp b/src/audio_core/audio_core.cpp index 28d38c8881..234c831ac0 100644 --- a/src/audio_core/audio_core.cpp +++ b/src/audio_core/audio_core.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/audio_core/audio_core.h b/src/audio_core/audio_core.h index e4771d7656..ababd780b1 100644 --- a/src/audio_core/audio_core.h +++ b/src/audio_core/audio_core.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/audio_core/audio_in_manager.cpp b/src/audio_core/audio_in_manager.cpp index c11e88b317..6b528e9db0 100644 --- a/src/audio_core/audio_in_manager.cpp +++ b/src/audio_core/audio_in_manager.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/audio_core/audio_manager.cpp b/src/audio_core/audio_manager.cpp index 10b56f2140..93142a53fb 100644 --- a/src/audio_core/audio_manager.cpp +++ b/src/audio_core/audio_manager.cpp @@ -1,81 +1,77 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include "audio_core/audio_manager.h" +#include "common/thread.h" #include "core/core.h" #include "core/hle/service/audio/errors.h" namespace AudioCore { AudioManager::AudioManager() { - thread = std::jthread([this]() { ThreadFunc(); }); + thread = std::jthread([this](std::stop_token stop_token) { + Common::SetCurrentThreadName("AudioManager"); + std::unique_lock l{events.GetAudioEventLock()}; + events.ClearEvents(); + while (!stop_token.stop_requested()) { + const auto timed_out{events.Wait(l, std::chrono::seconds(2))}; + if (events.CheckAudioEventSet(Event::Type::Max)) { + break; + } + for (size_t i = 0; i < buffer_events.size(); i++) { + const auto event_type = Event::Type(i); + if (events.CheckAudioEventSet(event_type) || timed_out) { + if (buffer_events[i]) { + buffer_events[i](); + } + } + events.SetAudioEvent(event_type, false); + } + } + }); } void AudioManager::Shutdown() { - running = false; events.SetAudioEvent(Event::Type::Max, true); - thread.join(); + if (thread.joinable()) { + thread.request_stop(); + thread.join(); + } } Result AudioManager::SetOutManager(BufferEventFunc buffer_func) { - if (!running) { - return Service::Audio::ResultOperationFailed; + if (thread.joinable()) { + std::scoped_lock l{lock}; + const auto index{events.GetManagerIndex(Event::Type::AudioOutManager)}; + if (buffer_events[index] == nullptr) { + buffer_events[index] = std::move(buffer_func); + needs_update = true; + events.SetAudioEvent(Event::Type::AudioOutManager, true); + } + return ResultSuccess; } - - std::scoped_lock l{lock}; - - const auto index{events.GetManagerIndex(Event::Type::AudioOutManager)}; - if (buffer_events[index] == nullptr) { - buffer_events[index] = std::move(buffer_func); - needs_update = true; - events.SetAudioEvent(Event::Type::AudioOutManager, true); - } - return ResultSuccess; + return Service::Audio::ResultOperationFailed; } Result AudioManager::SetInManager(BufferEventFunc buffer_func) { - if (!running) { - return Service::Audio::ResultOperationFailed; + if (thread.joinable()) { + std::scoped_lock l{lock}; + const auto index{events.GetManagerIndex(Event::Type::AudioInManager)}; + if (buffer_events[index] == nullptr) { + buffer_events[index] = std::move(buffer_func); + needs_update = true; + events.SetAudioEvent(Event::Type::AudioInManager, true); + } + return ResultSuccess; } - - std::scoped_lock l{lock}; - - const auto index{events.GetManagerIndex(Event::Type::AudioInManager)}; - if (buffer_events[index] == nullptr) { - buffer_events[index] = std::move(buffer_func); - needs_update = true; - events.SetAudioEvent(Event::Type::AudioInManager, true); - } - return ResultSuccess; + return Service::Audio::ResultOperationFailed; } void AudioManager::SetEvent(const Event::Type type, const bool signalled) { events.SetAudioEvent(type, signalled); } -void AudioManager::ThreadFunc() { - std::unique_lock l{events.GetAudioEventLock()}; - events.ClearEvents(); - running = true; - - while (running) { - const auto timed_out{events.Wait(l, std::chrono::seconds(2))}; - - if (events.CheckAudioEventSet(Event::Type::Max)) { - break; - } - - for (size_t i = 0; i < buffer_events.size(); i++) { - const auto event_type = static_cast(i); - - if (events.CheckAudioEventSet(event_type) || timed_out) { - if (buffer_events[i]) { - buffer_events[i](); - } - } - events.SetAudioEvent(event_type, false); - } - } -} - } // namespace AudioCore diff --git a/src/audio_core/audio_manager.h b/src/audio_core/audio_manager.h index 02270242ac..0194aa16db 100644 --- a/src/audio_core/audio_manager.h +++ b/src/audio_core/audio_manager.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -66,13 +69,6 @@ public: void SetEvent(Event::Type type, bool signalled); private: - /** - * Main thread, waiting on a manager signal and calling the registered function. - */ - void ThreadFunc(); - - /// Is the main thread running? - std::atomic running{}; /// Unused bool needs_update{}; /// Events to be set and signalled diff --git a/src/audio_core/audio_out_manager.cpp b/src/audio_core/audio_out_manager.cpp index dee3d493e5..569df8d1e0 100644 --- a/src/audio_core/audio_out_manager.cpp +++ b/src/audio_core/audio_out_manager.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/core/hle/service/am/button_poller.cpp b/src/core/hle/service/am/button_poller.cpp index 069a1934d4..6999acfa12 100644 --- a/src/core/hle/service/am/button_poller.cpp +++ b/src/core/hle/service/am/button_poller.cpp @@ -1,9 +1,11 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include +#include "common/thread.h" #include "core/core.h" #include "core/hle/service/am/am_types.h" #include "core/hle/service/am/button_poller.h" @@ -34,16 +36,15 @@ ButtonPressDuration ClassifyPressDuration(std::chrono::steady_clock::time_point } // namespace -ButtonPoller::ButtonPoller(Core::System& system, WindowSystem& window_system) - : m_window_system(window_system) { +ButtonPoller::ButtonPoller(Core::System& system, WindowSystem& window_system) { // TODO: am reads this from the home button state in hid, which is controller-agnostic. Core::HID::ControllerUpdateCallback engine_callback{ - .on_change = - [this](Core::HID::ControllerTriggerType type) { - if (type == Core::HID::ControllerTriggerType::Button) { - this->OnButtonStateChanged(); - } - }, + .on_change = [this, &window_system](Core::HID::ControllerTriggerType type) { + if (type == Core::HID::ControllerTriggerType::Button) { + std::unique_lock lk{m_mutex}; + OnButtonStateChanged(window_system); + } + }, .is_npad_service = true, }; @@ -52,25 +53,35 @@ ButtonPoller::ButtonPoller(Core::System& system, WindowSystem& window_system) m_player1 = system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1); m_player1_key = m_player1->SetCallback(engine_callback); - m_thread = std::thread([this] { this->ThreadLoop(); }); + m_thread = std::jthread([this, &window_system](std::stop_token stop_token) { + Common::SetCurrentThreadName("ButtonPoller"); + while (!stop_token.stop_requested()) { + using namespace std::chrono_literals; + std::unique_lock lk{m_mutex}; + m_cv.wait_for(lk, 50ms); + if (stop_token.stop_requested()) + break; + OnButtonStateChanged(window_system); + std::this_thread::sleep_for(5ms); + } + }); } ButtonPoller::~ButtonPoller() { m_handheld->DeleteCallback(m_handheld_key); m_player1->DeleteCallback(m_player1_key); - m_stop = true; m_cv.notify_all(); if (m_thread.joinable()) { + m_thread.request_stop(); m_thread.join(); } } -void ButtonPoller::OnButtonStateChanged() { - std::lock_guard lk{m_mutex}; - const bool home_button = - m_handheld->GetHomeButtons().home.Value() || m_player1->GetHomeButtons().home.Value(); - const bool capture_button = m_handheld->GetCaptureButtons().capture.Value() || - m_player1->GetCaptureButtons().capture.Value(); +void ButtonPoller::OnButtonStateChanged(WindowSystem& window_system) { + auto const home_button = m_handheld->GetHomeButtons().home.Value() + || m_player1->GetHomeButtons().home.Value(); + auto const capture_button = m_handheld->GetCaptureButtons().capture.Value() + || m_player1->GetCaptureButtons().capture.Value(); // Buttons pressed which were not previously pressed if (home_button && !m_home_button_press_start) { @@ -90,7 +101,7 @@ void ButtonPoller::OnButtonStateChanged() { if (home_button && m_home_button_press_start && !m_home_button_long_sent) { const auto duration = ClassifyPressDuration(*m_home_button_press_start); if (duration != ButtonPressDuration::ShortPressing) { - m_window_system.OnSystemButtonPress(SystemButtonType::HomeButtonLongPressing); + window_system.OnSystemButtonPress(SystemButtonType::HomeButtonLongPressing); m_home_button_long_sent = true; } } @@ -98,7 +109,7 @@ void ButtonPoller::OnButtonStateChanged() { if (capture_button && m_capture_button_press_start && !m_capture_button_long_sent) { const auto duration = ClassifyPressDuration(*m_capture_button_press_start); if (duration != ButtonPressDuration::ShortPressing) { - m_window_system.OnSystemButtonPress(SystemButtonType::CaptureButtonLongPressing); + window_system.OnSystemButtonPress(SystemButtonType::CaptureButtonLongPressing); m_capture_button_long_sent = true; } } @@ -107,9 +118,8 @@ void ButtonPoller::OnButtonStateChanged() { if (!home_button && m_home_button_press_start) { if(!m_home_button_long_sent) { const auto duration = ClassifyPressDuration(*m_home_button_press_start); - m_window_system.OnSystemButtonPress( - duration == ButtonPressDuration::ShortPressing ? SystemButtonType::HomeButtonShortPressing - : SystemButtonType::HomeButtonLongPressing); + window_system.OnSystemButtonPress(duration == ButtonPressDuration::ShortPressing + ? SystemButtonType::HomeButtonShortPressing : SystemButtonType::HomeButtonLongPressing); } m_home_button_press_start = std::nullopt; m_home_button_long_sent = false; @@ -117,9 +127,8 @@ void ButtonPoller::OnButtonStateChanged() { if (!capture_button && m_capture_button_press_start) { if (!m_capture_button_long_sent) { const auto duration = ClassifyPressDuration(*m_capture_button_press_start); - m_window_system.OnSystemButtonPress( - duration == ButtonPressDuration::ShortPressing ? SystemButtonType::CaptureButtonShortPressing - : SystemButtonType::CaptureButtonLongPressing); + window_system.OnSystemButtonPress(duration == ButtonPressDuration::ShortPressing + ? SystemButtonType::CaptureButtonShortPressing : SystemButtonType::CaptureButtonLongPressing); } m_capture_button_press_start = std::nullopt; m_capture_button_long_sent = false; @@ -130,16 +139,4 @@ void ButtonPoller::OnButtonStateChanged() { // } } -void ButtonPoller::ThreadLoop() { - using namespace std::chrono_literals; - std::unique_lock lk{m_mutex}; - while (!m_stop) { - m_cv.wait_for(lk, 50ms); - if (m_stop) break; - lk.unlock(); - OnButtonStateChanged(); - lk.lock(); - } -} - } // namespace Service::AM diff --git a/src/core/hle/service/am/button_poller.h b/src/core/hle/service/am/button_poller.h index 12e7035aa1..11d147d328 100644 --- a/src/core/hle/service/am/button_poller.h +++ b/src/core/hle/service/am/button_poller.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project @@ -30,31 +30,23 @@ class ButtonPoller { public: explicit ButtonPoller(Core::System& system, WindowSystem& window_system); ~ButtonPoller(); + void OnButtonStateChanged(WindowSystem& window_system); private: - void OnButtonStateChanged(); - void ThreadLoop(); - -private: - WindowSystem& m_window_system; - - Core::HID::EmulatedController* m_handheld{}; - int m_handheld_key{}; - Core::HID::EmulatedController* m_player1{}; - int m_player1_key{}; - + std::mutex m_mutex; + std::condition_variable m_cv; + std::jthread m_thread; std::optional m_home_button_press_start{}; std::optional m_capture_button_press_start{}; std::optional m_power_button_press_start{}; - bool m_home_button_long_sent{}; - bool m_capture_button_long_sent{}; - bool m_power_button_long_sent{}; - - std::thread m_thread; - std::atomic m_stop{false}; - std::condition_variable m_cv; - std::mutex m_mutex; + Core::HID::EmulatedController* m_handheld{}; + Core::HID::EmulatedController* m_player1{}; + int32_t m_handheld_key{}; + int32_t m_player1_key{}; + bool m_home_button_long_sent : 1 = false; + bool m_capture_button_long_sent : 1 = false; + bool m_power_button_long_sent : 1 = false; }; } // namespace Service::AM diff --git a/src/core/hle/service/am/event_observer.cpp b/src/core/hle/service/am/event_observer.cpp index 5d1d303ed3..9ea8b1f920 100644 --- a/src/core/hle/service/am/event_observer.cpp +++ b/src/core/hle/service/am/event_observer.cpp @@ -15,12 +15,24 @@ enum class UserDataTag : u32 { }; EventObserver::EventObserver(Core::System& system, WindowSystem& window_system) - : m_system(system), m_context(system, "am:EventObserver"), m_window_system(window_system), - m_wakeup_event(m_context), m_wakeup_holder(m_wakeup_event.GetHandle()) { + : m_system(system), m_context(system, "am:EventObserver") + , m_window_system(window_system) + , m_wakeup_event(m_context) + , m_wakeup_holder(m_wakeup_event.GetHandle()) +{ m_window_system.SetEventObserver(this); m_wakeup_holder.SetUserData(static_cast(UserDataTag::WakeupEvent)); m_wakeup_holder.LinkToMultiWait(std::addressof(m_multi_wait)); - m_thread = std::thread([&] { this->ThreadFunc(); }); + m_thread = std::thread([this] { + Common::SetCurrentThreadName("am:EventObserver"); + while (true) { + auto* signaled_holder = this->WaitSignaled(); + if (!signaled_holder) { + break; + } + this->Process(signaled_holder); + } + }); } EventObserver::~EventObserver() { @@ -146,17 +158,4 @@ void EventObserver::DestroyAppletProcessHolderLocked(ProcessHolder* holder) { delete holder; } -void EventObserver::ThreadFunc() { - Common::SetCurrentThreadName("am:EventObserver"); - - while (true) { - auto* signaled_holder = this->WaitSignaled(); - if (!signaled_holder) { - break; - } - - this->Process(signaled_holder); - } -} - } // namespace Service::AM diff --git a/src/core/hle/service/am/event_observer.h b/src/core/hle/service/am/event_observer.h index 3e52e8494d..602939094b 100644 --- a/src/core/hle/service/am/event_observer.h +++ b/src/core/hle/service/am/event_observer.h @@ -41,9 +41,6 @@ private: private: void DestroyAppletProcessHolderLocked(ProcessHolder* holder); -private: - void ThreadFunc(); - private: // System reference and context. Core::System& m_system; diff --git a/src/core/hle/service/am/process_creation.cpp b/src/core/hle/service/am/process_creation.cpp index cd537062d7..e34e86a82c 100644 --- a/src/core/hle/service/am/process_creation.cpp +++ b/src/core/hle/service/am/process_creation.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -17,7 +20,7 @@ namespace Service::AM { namespace { -FileSys::StorageId GetStorageIdForFrontendSlot( +[[nodiscard]] FileSys::StorageId GetStorageIdForFrontendSlot( std::optional slot) { if (!slot.has_value()) { return FileSys::StorageId::None; @@ -37,13 +40,13 @@ FileSys::StorageId GetStorageIdForFrontendSlot( } } -std::optional CreateProcessImpl(std::unique_ptr& out_loader, Loader::ResultStatus& out_load_result, Core::System& system, FileSys::VirtualFile file, u64 program_id, u64 program_index) { +[[nodiscard]] inline std::optional CreateProcessImpl(std::unique_ptr& out_loader, Loader::ResultStatus& out_load_result, Core::System& system, FileSys::VirtualFile file, u64 program_id, u64 program_index) { // Get the appropriate loader to parse this NCA. out_loader = Loader::GetLoader(system, file, program_id, program_index); // Ensure we have a loader which can parse the NCA. if (out_loader) { // Try to load the process. - auto process = std::optional(system); + auto process = std::make_optional(system); if (process->Initialize(*out_loader, out_load_result)) { return process; } @@ -83,33 +86,31 @@ std::optional CreateProcess(Core::System& system, u64 program_id, u8 mi } std::optional CreateApplicationProcess(std::vector& out_control, std::unique_ptr& out_loader, Loader::ResultStatus& out_load_result, Core::System& system, FileSys::VirtualFile file, u64 program_id, u64 program_index) { - auto process = CreateProcessImpl(out_loader, out_load_result, system, file, program_id, program_index); - if (!process) { - return std::nullopt; + if (auto process = CreateProcessImpl(out_loader, out_load_result, system, file, program_id, program_index); process) { + FileSys::NACP nacp; + if (out_loader->ReadControlData(nacp) == Loader::ResultStatus::Success) { + out_control = nacp.GetRawBytes(); + } else { + out_control.resize(sizeof(FileSys::RawNACP)); + std::fill(out_control.begin(), out_control.end(), (u8) 0); + } + + auto& storage = system.GetContentProviderUnion(); + Service::Glue::ApplicationLaunchProperty launch{}; + launch.title_id = process->GetProgramId(); + + FileSys::PatchManager pm{launch.title_id, system.GetFileSystemController(), storage}; + launch.version = pm.GetGameVersion().value_or(0); + + // TODO(DarkLordZach): When FSController/Game Card Support is added, if + // current_process_game_card use correct StorageId + launch.base_game_storage_id = GetStorageIdForFrontendSlot(storage.GetSlotForEntry(launch.title_id, FileSys::ContentRecordType::Program)); + launch.update_storage_id = GetStorageIdForFrontendSlot(storage.GetSlotForEntry(FileSys::GetUpdateTitleID(launch.title_id), FileSys::ContentRecordType::Program)); + + system.GetARPManager().Register(launch.title_id, launch, out_control); + return process; } - - FileSys::NACP nacp; - if (out_loader->ReadControlData(nacp) == Loader::ResultStatus::Success) { - out_control = nacp.GetRawBytes(); - } else { - out_control.resize(sizeof(FileSys::RawNACP)); - std::fill(out_control.begin(), out_control.end(), (u8) 0); - } - - auto& storage = system.GetContentProviderUnion(); - Service::Glue::ApplicationLaunchProperty launch{}; - launch.title_id = process->GetProgramId(); - - FileSys::PatchManager pm{launch.title_id, system.GetFileSystemController(), storage}; - launch.version = pm.GetGameVersion().value_or(0); - - // TODO(DarkLordZach): When FSController/Game Card Support is added, if - // current_process_game_card use correct StorageId - launch.base_game_storage_id = GetStorageIdForFrontendSlot(storage.GetSlotForEntry(launch.title_id, FileSys::ContentRecordType::Program)); - launch.update_storage_id = GetStorageIdForFrontendSlot(storage.GetSlotForEntry(FileSys::GetUpdateTitleID(launch.title_id), FileSys::ContentRecordType::Program)); - - system.GetARPManager().Register(launch.title_id, launch, out_control); - return process; + return std::nullopt; } } // namespace Service::AM diff --git a/src/core/hle/service/am/process_creation.h b/src/core/hle/service/am/process_creation.h index 40c3d36aff..57d8b8f815 100644 --- a/src/core/hle/service/am/process_creation.h +++ b/src/core/hle/service/am/process_creation.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/core/hle/service/am/service/application_creator.cpp b/src/core/hle/service/am/service/application_creator.cpp index 4fece53119..e8e4a103c2 100644 --- a/src/core/hle/service/am/service/application_creator.cpp +++ b/src/core/hle/service/am/service/application_creator.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project diff --git a/src/core/hle/service/am/service/library_applet_creator.cpp b/src/core/hle/service/am/service/library_applet_creator.cpp index 17db4b35d3..9f0359ed2b 100644 --- a/src/core/hle/service/am/service/library_applet_creator.cpp +++ b/src/core/hle/service/am/service/library_applet_creator.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project diff --git a/src/core/hle/service/audio/audio_out_manager.cpp b/src/core/hle/service/audio/audio_out_manager.cpp index a5a05a1b76..3b2087932c 100644 --- a/src/core/hle/service/audio/audio_out_manager.cpp +++ b/src/core/hle/service/audio/audio_out_manager.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project diff --git a/src/core/hle/service/audio/audio_out_manager.h b/src/core/hle/service/audio/audio_out_manager.h index 57d1eb1e58..ec974aaba4 100644 --- a/src/core/hle/service/audio/audio_out_manager.h +++ b/src/core/hle/service/audio/audio_out_manager.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project diff --git a/src/core/hle/service/audio/audio_renderer_manager.cpp b/src/core/hle/service/audio/audio_renderer_manager.cpp index 4f0bf0f3b9..972e930a89 100644 --- a/src/core/hle/service/audio/audio_renderer_manager.cpp +++ b/src/core/hle/service/audio/audio_renderer_manager.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/core/hle/service/audio/audio_renderer_manager.h b/src/core/hle/service/audio/audio_renderer_manager.h index 3f25ad6df1..fdce8b6ffa 100644 --- a/src/core/hle/service/audio/audio_renderer_manager.h +++ b/src/core/hle/service/audio/audio_renderer_manager.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/core/hle/service/os/process.cpp b/src/core/hle/service/os/process.cpp index ec00af1433..2d5d7def64 100644 --- a/src/core/hle/service/os/process.cpp +++ b/src/core/hle/service/os/process.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/core/hle/service/os/process.h b/src/core/hle/service/os/process.h index cec61c76c7..ca10945f84 100644 --- a/src/core/hle/service/os/process.h +++ b/src/core/hle/service/os/process.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/input_common/drivers/udp_client.cpp b/src/input_common/drivers/udp_client.cpp index 9e29d56cba..ba781a827b 100644 --- a/src/input_common/drivers/udp_client.cpp +++ b/src/input_common/drivers/udp_client.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: 2018 Citra Emulator Project @@ -12,6 +12,7 @@ #include "common/logging/log.h" #include "common/param_package.h" #include "common/settings.h" +#include "common/thread.h" #include "input_common/drivers/udp_client.h" #include "input_common/helpers/udp_protocol.h" @@ -135,6 +136,7 @@ private: }; static void SocketLoop(Socket* socket) { + Common::SetCurrentThreadName("cemuhookWorker"); socket->StartReceive(); socket->StartSend(Socket::clock::now()); socket->Loop(); @@ -330,9 +332,11 @@ void UDPClient::OnPadData(Response::PadData data, std::size_t client) { } void UDPClient::StartCommunication(std::size_t client, const std::string& host, u16 port) { - SocketCallback callback{[this](Response::Version version) { OnVersion(version); }, - [this](Response::PortInfo info) { OnPortInfo(info); }, - [this, client](Response::PadData data) { OnPadData(data, client); }}; + SocketCallback callback{ + [this](Response::Version version) { OnVersion(version); }, + [this](Response::PortInfo info) { OnPortInfo(info); }, + [this, client](Response::PadData data) { OnPadData(data, client); } + }; LOG_INFO(Input, "Starting communication with UDP input server on {}:{}", host, port); clients[client].uuid = GetHostUUID(host); clients[client].host = host; @@ -570,9 +574,7 @@ bool UDPClient::IsStickInverted(const Common::ParamPackage& params) { return true; } -void TestCommunication(const std::string& host, u16 port, - const std::function& success_callback, - const std::function& failure_callback) { +void TestCommunication(const std::string& host, u16 port, const std::function& success_callback, const std::function& failure_callback) { std::thread([=] { Common::Event success_event; SocketCallback callback{ @@ -605,40 +607,38 @@ CalibrationConfigurationJob::CalibrationConfigurationJob( u16 max_y{}; Status current_status{Status::Initialized}; - SocketCallback callback{[](Response::Version) {}, [](Response::PortInfo) {}, - [&](Response::PadData data) { - constexpr u16 CALIBRATION_THRESHOLD = 100; + SocketCallback callback{[](Response::Version) {}, [](Response::PortInfo) {}, [&](Response::PadData data) { + constexpr u16 CALIBRATION_THRESHOLD = 100; - if (current_status == Status::Initialized) { - // Receiving data means the communication is ready now - current_status = Status::Ready; - status_callback(current_status); - } - if (data.touch[0].is_active == 0) { - return; - } - LOG_DEBUG(Input, "Current touch: {} {}", data.touch[0].x, - data.touch[0].y); - min_x = (std::min)(min_x, static_cast(data.touch[0].x)); - min_y = (std::min)(min_y, static_cast(data.touch[0].y)); - if (current_status == Status::Ready) { - // First touch - min data (min_x/min_y) - current_status = Status::Stage1Completed; - status_callback(current_status); - } - if (data.touch[0].x - min_x > CALIBRATION_THRESHOLD && - data.touch[0].y - min_y > CALIBRATION_THRESHOLD) { - // Set the current position as max value and finishes - // configuration - max_x = data.touch[0].x; - max_y = data.touch[0].y; - current_status = Status::Completed; - data_callback(min_x, min_y, max_x, max_y); - status_callback(current_status); + if (current_status == Status::Initialized) { + // Receiving data means the communication is ready now + current_status = Status::Ready; + status_callback(current_status); + } + if (data.touch[0].is_active == 0) { + return; + } + LOG_DEBUG(Input, "Current touch: {} {}", data.touch[0].x, data.touch[0].y); + min_x = (std::min)(min_x, u16(data.touch[0].x)); + min_y = (std::min)(min_y, u16(data.touch[0].y)); + if (current_status == Status::Ready) { + // First touch - min data (min_x/min_y) + current_status = Status::Stage1Completed; + status_callback(current_status); + } + if (data.touch[0].x - min_x > CALIBRATION_THRESHOLD && + data.touch[0].y - min_y > CALIBRATION_THRESHOLD) { + // Set the current position as max value and finishes + // configuration + max_x = data.touch[0].x; + max_y = data.touch[0].y; + current_status = Status::Completed; + data_callback(min_x, min_y, max_x, max_y); + status_callback(current_status); - complete_event.Set(); - } - }}; + complete_event.Set(); + } + }}; Socket socket{host, port, std::move(callback)}; std::thread worker_thread{SocketLoop, &socket}; complete_event.Wait(); diff --git a/src/video_core/renderer_vulkan/vk_update_descriptor.h b/src/video_core/renderer_vulkan/vk_update_descriptor.h index 3a1343e02e..1497108b16 100644 --- a/src/video_core/renderer_vulkan/vk_update_descriptor.h +++ b/src/video_core/renderer_vulkan/vk_update_descriptor.h @@ -1,10 +1,13 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #pragma once #include - +#include #include "video_core/vulkan_common/vulkan_wrapper.h" namespace Vulkan { From fad664b88a42cdaa7c218e3b3ca1e1f8551e31e6 Mon Sep 17 00:00:00 2001 From: lizzie Date: Wed, 11 Mar 2026 23:45:09 +0000 Subject: [PATCH 25/25] llicense fix --- src/core/hle/service/am/event_observer.cpp | 3 +++ src/core/hle/service/am/event_observer.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/core/hle/service/am/event_observer.cpp b/src/core/hle/service/am/event_observer.cpp index 9ea8b1f920..ef944c1993 100644 --- a/src/core/hle/service/am/event_observer.cpp +++ b/src/core/hle/service/am/event_observer.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/core/hle/service/am/event_observer.h b/src/core/hle/service/am/event_observer.h index 602939094b..a0fa13f823 100644 --- a/src/core/hle/service/am/event_observer.h +++ b/src/core/hle/service/am/event_observer.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later