diff options
Diffstat (limited to 'src')
64 files changed, 770 insertions, 336 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 04cf3f5b9..c28abc24c 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -393,6 +393,8 @@ add_library(core STATIC | |||
| 393 | hle/service/hid/xcd.cpp | 393 | hle/service/hid/xcd.cpp |
| 394 | hle/service/hid/xcd.h | 394 | hle/service/hid/xcd.h |
| 395 | hle/service/hid/errors.h | 395 | hle/service/hid/errors.h |
| 396 | hle/service/hid/controllers/console_sixaxis.cpp | ||
| 397 | hle/service/hid/controllers/console_sixaxis.h | ||
| 396 | hle/service/hid/controllers/controller_base.cpp | 398 | hle/service/hid/controllers/controller_base.cpp |
| 397 | hle/service/hid/controllers/controller_base.h | 399 | hle/service/hid/controllers/controller_base.h |
| 398 | hle/service/hid/controllers/debug_pad.cpp | 400 | hle/service/hid/controllers/debug_pad.cpp |
diff --git a/src/core/frontend/applets/web_browser.cpp b/src/core/frontend/applets/web_browser.cpp index 50db6a654..be4736f47 100644 --- a/src/core/frontend/applets/web_browser.cpp +++ b/src/core/frontend/applets/web_browser.cpp | |||
| @@ -12,7 +12,7 @@ WebBrowserApplet::~WebBrowserApplet() = default; | |||
| 12 | DefaultWebBrowserApplet::~DefaultWebBrowserApplet() = default; | 12 | DefaultWebBrowserApplet::~DefaultWebBrowserApplet() = default; |
| 13 | 13 | ||
| 14 | void DefaultWebBrowserApplet::OpenLocalWebPage( | 14 | void DefaultWebBrowserApplet::OpenLocalWebPage( |
| 15 | std::string_view local_url, std::function<void()> extract_romfs_callback, | 15 | const std::string& local_url, std::function<void()> extract_romfs_callback, |
| 16 | std::function<void(Service::AM::Applets::WebExitReason, std::string)> callback) const { | 16 | std::function<void(Service::AM::Applets::WebExitReason, std::string)> callback) const { |
| 17 | LOG_WARNING(Service_AM, "(STUBBED) called, backend requested to open local web page at {}", | 17 | LOG_WARNING(Service_AM, "(STUBBED) called, backend requested to open local web page at {}", |
| 18 | local_url); | 18 | local_url); |
| @@ -21,7 +21,7 @@ void DefaultWebBrowserApplet::OpenLocalWebPage( | |||
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | void DefaultWebBrowserApplet::OpenExternalWebPage( | 23 | void DefaultWebBrowserApplet::OpenExternalWebPage( |
| 24 | std::string_view external_url, | 24 | const std::string& external_url, |
| 25 | std::function<void(Service::AM::Applets::WebExitReason, std::string)> callback) const { | 25 | std::function<void(Service::AM::Applets::WebExitReason, std::string)> callback) const { |
| 26 | LOG_WARNING(Service_AM, "(STUBBED) called, backend requested to open external web page at {}", | 26 | LOG_WARNING(Service_AM, "(STUBBED) called, backend requested to open external web page at {}", |
| 27 | external_url); | 27 | external_url); |
diff --git a/src/core/frontend/applets/web_browser.h b/src/core/frontend/applets/web_browser.h index 1c5ef19a9..d7bd44c27 100644 --- a/src/core/frontend/applets/web_browser.h +++ b/src/core/frontend/applets/web_browser.h | |||
| @@ -16,11 +16,11 @@ public: | |||
| 16 | virtual ~WebBrowserApplet(); | 16 | virtual ~WebBrowserApplet(); |
| 17 | 17 | ||
| 18 | virtual void OpenLocalWebPage( | 18 | virtual void OpenLocalWebPage( |
| 19 | std::string_view local_url, std::function<void()> extract_romfs_callback, | 19 | const std::string& local_url, std::function<void()> extract_romfs_callback, |
| 20 | std::function<void(Service::AM::Applets::WebExitReason, std::string)> callback) const = 0; | 20 | std::function<void(Service::AM::Applets::WebExitReason, std::string)> callback) const = 0; |
| 21 | 21 | ||
| 22 | virtual void OpenExternalWebPage( | 22 | virtual void OpenExternalWebPage( |
| 23 | std::string_view external_url, | 23 | const std::string& external_url, |
| 24 | std::function<void(Service::AM::Applets::WebExitReason, std::string)> callback) const = 0; | 24 | std::function<void(Service::AM::Applets::WebExitReason, std::string)> callback) const = 0; |
| 25 | }; | 25 | }; |
| 26 | 26 | ||
| @@ -28,11 +28,12 @@ class DefaultWebBrowserApplet final : public WebBrowserApplet { | |||
| 28 | public: | 28 | public: |
| 29 | ~DefaultWebBrowserApplet() override; | 29 | ~DefaultWebBrowserApplet() override; |
| 30 | 30 | ||
| 31 | void OpenLocalWebPage(std::string_view local_url, std::function<void()> extract_romfs_callback, | 31 | void OpenLocalWebPage(const std::string& local_url, |
| 32 | std::function<void()> extract_romfs_callback, | ||
| 32 | std::function<void(Service::AM::Applets::WebExitReason, std::string)> | 33 | std::function<void(Service::AM::Applets::WebExitReason, std::string)> |
| 33 | callback) const override; | 34 | callback) const override; |
| 34 | 35 | ||
| 35 | void OpenExternalWebPage(std::string_view external_url, | 36 | void OpenExternalWebPage(const std::string& external_url, |
| 36 | std::function<void(Service::AM::Applets::WebExitReason, std::string)> | 37 | std::function<void(Service::AM::Applets::WebExitReason, std::string)> |
| 37 | callback) const override; | 38 | callback) const override; |
| 38 | }; | 39 | }; |
diff --git a/src/core/frontend/input.h b/src/core/frontend/input.h index 88ebc6497..0c5d2b3b0 100644 --- a/src/core/frontend/input.h +++ b/src/core/frontend/input.h | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #include <utility> | 11 | #include <utility> |
| 12 | #include "common/logging/log.h" | 12 | #include "common/logging/log.h" |
| 13 | #include "common/param_package.h" | 13 | #include "common/param_package.h" |
| 14 | #include "common/quaternion.h" | ||
| 14 | #include "common/vector_math.h" | 15 | #include "common/vector_math.h" |
| 15 | 16 | ||
| 16 | namespace Input { | 17 | namespace Input { |
| @@ -143,9 +144,10 @@ using VibrationDevice = InputDevice<u8>; | |||
| 143 | 144 | ||
| 144 | /** | 145 | /** |
| 145 | * A motion status is an object that returns a tuple of accelerometer state vector, | 146 | * A motion status is an object that returns a tuple of accelerometer state vector, |
| 146 | * gyroscope state vector, rotation state vector and orientation state matrix. | 147 | * gyroscope state vector, rotation state vector, orientation state matrix and quaterion state |
| 148 | * vector. | ||
| 147 | * | 149 | * |
| 148 | * For both vectors: | 150 | * For both 3D vectors: |
| 149 | * x+ is the same direction as RIGHT on D-pad. | 151 | * x+ is the same direction as RIGHT on D-pad. |
| 150 | * y+ is normal to the touch screen, pointing outward. | 152 | * y+ is normal to the touch screen, pointing outward. |
| 151 | * z+ is the same direction as UP on D-pad. | 153 | * z+ is the same direction as UP on D-pad. |
| @@ -164,9 +166,13 @@ using VibrationDevice = InputDevice<u8>; | |||
| 164 | * x vector | 166 | * x vector |
| 165 | * y vector | 167 | * y vector |
| 166 | * z vector | 168 | * z vector |
| 169 | * | ||
| 170 | * For quaternion state vector | ||
| 171 | * xyz vector | ||
| 172 | * w float | ||
| 167 | */ | 173 | */ |
| 168 | using MotionStatus = std::tuple<Common::Vec3<float>, Common::Vec3<float>, Common::Vec3<float>, | 174 | using MotionStatus = std::tuple<Common::Vec3<float>, Common::Vec3<float>, Common::Vec3<float>, |
| 169 | std::array<Common::Vec3f, 3>>; | 175 | std::array<Common::Vec3f, 3>, Common::Quaternion<f32>>; |
| 170 | 176 | ||
| 171 | /** | 177 | /** |
| 172 | * A motion device is an input device that returns a motion status object | 178 | * A motion device is an input device that returns a motion status object |
diff --git a/src/core/hle/kernel/transfer_memory.cpp b/src/core/hle/kernel/transfer_memory.cpp index cad063e4d..1dd65468d 100644 --- a/src/core/hle/kernel/transfer_memory.cpp +++ b/src/core/hle/kernel/transfer_memory.cpp | |||
| @@ -36,6 +36,10 @@ std::shared_ptr<TransferMemory> TransferMemory::Create(KernelCore& kernel, | |||
| 36 | return transfer_memory; | 36 | return transfer_memory; |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | u8* TransferMemory::GetPointer() { | ||
| 40 | return memory.GetPointer(base_address); | ||
| 41 | } | ||
| 42 | |||
| 39 | const u8* TransferMemory::GetPointer() const { | 43 | const u8* TransferMemory::GetPointer() const { |
| 40 | return memory.GetPointer(base_address); | 44 | return memory.GetPointer(base_address); |
| 41 | } | 45 | } |
diff --git a/src/core/hle/kernel/transfer_memory.h b/src/core/hle/kernel/transfer_memory.h index 521951424..59328c0fe 100644 --- a/src/core/hle/kernel/transfer_memory.h +++ b/src/core/hle/kernel/transfer_memory.h | |||
| @@ -57,6 +57,9 @@ public: | |||
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | /// Gets a pointer to the backing block of this instance. | 59 | /// Gets a pointer to the backing block of this instance. |
| 60 | u8* GetPointer(); | ||
| 61 | |||
| 62 | /// Gets a pointer to the backing block of this instance. | ||
| 60 | const u8* GetPointer() const; | 63 | const u8* GetPointer() const; |
| 61 | 64 | ||
| 62 | /// Gets the size of the memory backing this instance in bytes. | 65 | /// Gets the size of the memory backing this instance in bytes. |
diff --git a/src/core/hle/service/am/applets/error.cpp b/src/core/hle/service/am/applets/error.cpp index 23e30aa45..0dd6ec68e 100644 --- a/src/core/hle/service/am/applets/error.cpp +++ b/src/core/hle/service/am/applets/error.cpp | |||
| @@ -158,11 +158,11 @@ void Error::Execute() { | |||
| 158 | break; | 158 | break; |
| 159 | case ErrorAppletMode::ShowSystemError: | 159 | case ErrorAppletMode::ShowSystemError: |
| 160 | case ErrorAppletMode::ShowApplicationError: { | 160 | case ErrorAppletMode::ShowApplicationError: { |
| 161 | const auto system = mode == ErrorAppletMode::ShowSystemError; | 161 | const auto is_system = mode == ErrorAppletMode::ShowSystemError; |
| 162 | const auto& main_text = | 162 | const auto& main_text = |
| 163 | system ? args->system_error.main_text : args->application_error.main_text; | 163 | is_system ? args->system_error.main_text : args->application_error.main_text; |
| 164 | const auto& detail_text = | 164 | const auto& detail_text = |
| 165 | system ? args->system_error.detail_text : args->application_error.detail_text; | 165 | is_system ? args->system_error.detail_text : args->application_error.detail_text; |
| 166 | 166 | ||
| 167 | const auto main_text_string = | 167 | const auto main_text_string = |
| 168 | Common::StringFromFixedZeroTerminatedBuffer(main_text.data(), main_text.size()); | 168 | Common::StringFromFixedZeroTerminatedBuffer(main_text.data(), main_text.size()); |
diff --git a/src/core/hle/service/am/applets/general_backend.cpp b/src/core/hle/service/am/applets/general_backend.cpp index b26abad36..b7483261e 100644 --- a/src/core/hle/service/am/applets/general_backend.cpp +++ b/src/core/hle/service/am/applets/general_backend.cpp | |||
| @@ -96,7 +96,7 @@ void Auth::Execute() { | |||
| 96 | 96 | ||
| 97 | switch (type) { | 97 | switch (type) { |
| 98 | case AuthAppletType::ShowParentalAuthentication: { | 98 | case AuthAppletType::ShowParentalAuthentication: { |
| 99 | const auto callback = [this](bool successful) { AuthFinished(successful); }; | 99 | const auto callback = [this](bool is_successful) { AuthFinished(is_successful); }; |
| 100 | 100 | ||
| 101 | if (arg0 == 1 && arg1 == 0 && arg2 == 1) { | 101 | if (arg0 == 1 && arg1 == 0 && arg2 == 1) { |
| 102 | // ShowAuthenticatorForConfiguration | 102 | // ShowAuthenticatorForConfiguration |
diff --git a/src/core/hle/service/bcat/backend/boxcat.cpp b/src/core/hle/service/bcat/backend/boxcat.cpp index 78c047bd2..cee1774d1 100644 --- a/src/core/hle/service/bcat/backend/boxcat.cpp +++ b/src/core/hle/service/bcat/backend/boxcat.cpp | |||
| @@ -415,9 +415,9 @@ std::optional<std::vector<u8>> Boxcat::GetLaunchParameter(TitleIDVersion title) | |||
| 415 | if (Settings::values.bcat_boxcat_local) { | 415 | if (Settings::values.bcat_boxcat_local) { |
| 416 | LOG_INFO(Service_BCAT, "Boxcat using local data by override, skipping download."); | 416 | LOG_INFO(Service_BCAT, "Boxcat using local data by override, skipping download."); |
| 417 | } else { | 417 | } else { |
| 418 | Boxcat::Client client{path, title.title_id, title.build_id}; | 418 | Client launch_client{path, title.title_id, title.build_id}; |
| 419 | 419 | ||
| 420 | const auto res = client.DownloadLaunchParam(); | 420 | const auto res = launch_client.DownloadLaunchParam(); |
| 421 | if (res != DownloadResult::Success) { | 421 | if (res != DownloadResult::Success) { |
| 422 | LOG_ERROR(Service_BCAT, "Boxcat synchronization failed with error '{}'!", res); | 422 | LOG_ERROR(Service_BCAT, "Boxcat synchronization failed with error '{}'!", res); |
| 423 | 423 | ||
diff --git a/src/core/hle/service/bcat/module.cpp b/src/core/hle/service/bcat/module.cpp index c7dd04a6e..285085f2a 100644 --- a/src/core/hle/service/bcat/module.cpp +++ b/src/core/hle/service/bcat/module.cpp | |||
| @@ -174,9 +174,9 @@ private: | |||
| 174 | }; | 174 | }; |
| 175 | 175 | ||
| 176 | std::shared_ptr<IDeliveryCacheProgressService> CreateProgressService(SyncType type) { | 176 | std::shared_ptr<IDeliveryCacheProgressService> CreateProgressService(SyncType type) { |
| 177 | auto& backend{progress.at(static_cast<std::size_t>(type))}; | 177 | auto& progress_backend{GetProgressBackend(type)}; |
| 178 | return std::make_shared<IDeliveryCacheProgressService>(system, backend.GetEvent(), | 178 | return std::make_shared<IDeliveryCacheProgressService>(system, progress_backend.GetEvent(), |
| 179 | backend.GetImpl()); | 179 | progress_backend.GetImpl()); |
| 180 | } | 180 | } |
| 181 | 181 | ||
| 182 | void RequestSyncDeliveryCache(Kernel::HLERequestContext& ctx) { | 182 | void RequestSyncDeliveryCache(Kernel::HLERequestContext& ctx) { |
| @@ -184,7 +184,7 @@ private: | |||
| 184 | 184 | ||
| 185 | backend.Synchronize({system.CurrentProcess()->GetTitleID(), | 185 | backend.Synchronize({system.CurrentProcess()->GetTitleID(), |
| 186 | GetCurrentBuildID(system.GetCurrentProcessBuildID())}, | 186 | GetCurrentBuildID(system.GetCurrentProcessBuildID())}, |
| 187 | progress.at(static_cast<std::size_t>(SyncType::Normal))); | 187 | GetProgressBackend(SyncType::Normal)); |
| 188 | 188 | ||
| 189 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 189 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 190 | rb.Push(RESULT_SUCCESS); | 190 | rb.Push(RESULT_SUCCESS); |
| @@ -201,8 +201,7 @@ private: | |||
| 201 | 201 | ||
| 202 | backend.SynchronizeDirectory({system.CurrentProcess()->GetTitleID(), | 202 | backend.SynchronizeDirectory({system.CurrentProcess()->GetTitleID(), |
| 203 | GetCurrentBuildID(system.GetCurrentProcessBuildID())}, | 203 | GetCurrentBuildID(system.GetCurrentProcessBuildID())}, |
| 204 | name, | 204 | name, GetProgressBackend(SyncType::Directory)); |
| 205 | progress.at(static_cast<std::size_t>(SyncType::Directory))); | ||
| 206 | 205 | ||
| 207 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 206 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 208 | rb.Push(RESULT_SUCCESS); | 207 | rb.Push(RESULT_SUCCESS); |
| @@ -265,9 +264,16 @@ private: | |||
| 265 | rb.Push(RESULT_SUCCESS); | 264 | rb.Push(RESULT_SUCCESS); |
| 266 | } | 265 | } |
| 267 | 266 | ||
| 268 | Backend& backend; | 267 | ProgressServiceBackend& GetProgressBackend(SyncType type) { |
| 268 | return progress.at(static_cast<size_t>(type)); | ||
| 269 | } | ||
| 269 | 270 | ||
| 270 | std::array<ProgressServiceBackend, static_cast<std::size_t>(SyncType::Count)> progress; | 271 | const ProgressServiceBackend& GetProgressBackend(SyncType type) const { |
| 272 | return progress.at(static_cast<size_t>(type)); | ||
| 273 | } | ||
| 274 | |||
| 275 | Backend& backend; | ||
| 276 | std::array<ProgressServiceBackend, static_cast<size_t>(SyncType::Count)> progress; | ||
| 271 | }; | 277 | }; |
| 272 | 278 | ||
| 273 | void Module::Interface::CreateBcatService(Kernel::HLERequestContext& ctx) { | 279 | void Module::Interface::CreateBcatService(Kernel::HLERequestContext& ctx) { |
diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp index a0215c4d7..7dc487e48 100644 --- a/src/core/hle/service/filesystem/fsp_srv.cpp +++ b/src/core/hle/service/filesystem/fsp_srv.cpp | |||
| @@ -337,13 +337,14 @@ public: | |||
| 337 | const auto file_buffer = ctx.ReadBuffer(); | 337 | const auto file_buffer = ctx.ReadBuffer(); |
| 338 | const std::string name = Common::StringFromBuffer(file_buffer); | 338 | const std::string name = Common::StringFromBuffer(file_buffer); |
| 339 | 339 | ||
| 340 | const u64 mode = rp.Pop<u64>(); | 340 | const u64 file_mode = rp.Pop<u64>(); |
| 341 | const u32 size = rp.Pop<u32>(); | 341 | const u32 file_size = rp.Pop<u32>(); |
| 342 | 342 | ||
| 343 | LOG_DEBUG(Service_FS, "called. file={}, mode=0x{:X}, size=0x{:08X}", name, mode, size); | 343 | LOG_DEBUG(Service_FS, "called. file={}, mode=0x{:X}, size=0x{:08X}", name, file_mode, |
| 344 | file_size); | ||
| 344 | 345 | ||
| 345 | IPC::ResponseBuilder rb{ctx, 2}; | 346 | IPC::ResponseBuilder rb{ctx, 2}; |
| 346 | rb.Push(backend.CreateFile(name, size)); | 347 | rb.Push(backend.CreateFile(name, file_size)); |
| 347 | } | 348 | } |
| 348 | 349 | ||
| 349 | void DeleteFile(Kernel::HLERequestContext& ctx) { | 350 | void DeleteFile(Kernel::HLERequestContext& ctx) { |
| @@ -935,8 +936,8 @@ void FSP_SRV::ReadSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute( | |||
| 935 | void FSP_SRV::OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx) { | 936 | void FSP_SRV::OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx) { |
| 936 | LOG_DEBUG(Service_FS, "called"); | 937 | LOG_DEBUG(Service_FS, "called"); |
| 937 | 938 | ||
| 938 | auto romfs = fsc.OpenRomFSCurrentProcess(); | 939 | auto current_romfs = fsc.OpenRomFSCurrentProcess(); |
| 939 | if (romfs.Failed()) { | 940 | if (current_romfs.Failed()) { |
| 940 | // TODO (bunnei): Find the right error code to use here | 941 | // TODO (bunnei): Find the right error code to use here |
| 941 | LOG_CRITICAL(Service_FS, "no file system interface available!"); | 942 | LOG_CRITICAL(Service_FS, "no file system interface available!"); |
| 942 | IPC::ResponseBuilder rb{ctx, 2}; | 943 | IPC::ResponseBuilder rb{ctx, 2}; |
| @@ -944,7 +945,7 @@ void FSP_SRV::OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx) { | |||
| 944 | return; | 945 | return; |
| 945 | } | 946 | } |
| 946 | 947 | ||
| 947 | auto storage = std::make_shared<IStorage>(system, std::move(romfs.Unwrap())); | 948 | auto storage = std::make_shared<IStorage>(system, std::move(current_romfs.Unwrap())); |
| 948 | 949 | ||
| 949 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 950 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 950 | rb.Push(RESULT_SUCCESS); | 951 | rb.Push(RESULT_SUCCESS); |
| @@ -1010,10 +1011,10 @@ void FSP_SRV::OpenDataStorageWithProgramIndex(Kernel::HLERequestContext& ctx) { | |||
| 1010 | 1011 | ||
| 1011 | LOG_DEBUG(Service_FS, "called, program_index={}", program_index); | 1012 | LOG_DEBUG(Service_FS, "called, program_index={}", program_index); |
| 1012 | 1013 | ||
| 1013 | auto romfs = fsc.OpenPatchedRomFSWithProgramIndex( | 1014 | auto patched_romfs = fsc.OpenPatchedRomFSWithProgramIndex( |
| 1014 | system.CurrentProcess()->GetTitleID(), program_index, FileSys::ContentRecordType::Program); | 1015 | system.CurrentProcess()->GetTitleID(), program_index, FileSys::ContentRecordType::Program); |
| 1015 | 1016 | ||
| 1016 | if (romfs.Failed()) { | 1017 | if (patched_romfs.Failed()) { |
| 1017 | // TODO: Find the right error code to use here | 1018 | // TODO: Find the right error code to use here |
| 1018 | LOG_ERROR(Service_FS, "could not open storage with program_index={}", program_index); | 1019 | LOG_ERROR(Service_FS, "could not open storage with program_index={}", program_index); |
| 1019 | 1020 | ||
| @@ -1022,7 +1023,7 @@ void FSP_SRV::OpenDataStorageWithProgramIndex(Kernel::HLERequestContext& ctx) { | |||
| 1022 | return; | 1023 | return; |
| 1023 | } | 1024 | } |
| 1024 | 1025 | ||
| 1025 | auto storage = std::make_shared<IStorage>(system, std::move(romfs.Unwrap())); | 1026 | auto storage = std::make_shared<IStorage>(system, std::move(patched_romfs.Unwrap())); |
| 1026 | 1027 | ||
| 1027 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 1028 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 1028 | rb.Push(RESULT_SUCCESS); | 1029 | rb.Push(RESULT_SUCCESS); |
diff --git a/src/core/hle/service/hid/controllers/console_sixaxis.cpp b/src/core/hle/service/hid/controllers/console_sixaxis.cpp new file mode 100644 index 000000000..913768fab --- /dev/null +++ b/src/core/hle/service/hid/controllers/console_sixaxis.cpp | |||
| @@ -0,0 +1,90 @@ | |||
| 1 | // Copyright 2021 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "common/settings.h" | ||
| 6 | #include "core/core_timing.h" | ||
| 7 | #include "core/hle/service/hid/controllers/console_sixaxis.h" | ||
| 8 | |||
| 9 | namespace Service::HID { | ||
| 10 | constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3C200; | ||
| 11 | |||
| 12 | Controller_ConsoleSixAxis::Controller_ConsoleSixAxis(Core::System& system) | ||
| 13 | : ControllerBase(system) {} | ||
| 14 | Controller_ConsoleSixAxis::~Controller_ConsoleSixAxis() = default; | ||
| 15 | |||
| 16 | void Controller_ConsoleSixAxis::OnInit() {} | ||
| 17 | |||
| 18 | void Controller_ConsoleSixAxis::OnRelease() {} | ||
| 19 | |||
| 20 | void Controller_ConsoleSixAxis::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* data, | ||
| 21 | std::size_t size) { | ||
| 22 | seven_six_axis.header.timestamp = core_timing.GetCPUTicks(); | ||
| 23 | seven_six_axis.header.total_entry_count = 17; | ||
| 24 | |||
| 25 | if (!IsControllerActivated() || !is_transfer_memory_set) { | ||
| 26 | seven_six_axis.header.entry_count = 0; | ||
| 27 | seven_six_axis.header.last_entry_index = 0; | ||
| 28 | return; | ||
| 29 | } | ||
| 30 | seven_six_axis.header.entry_count = 16; | ||
| 31 | |||
| 32 | const auto& last_entry = | ||
| 33 | seven_six_axis.sevensixaxis_states[seven_six_axis.header.last_entry_index]; | ||
| 34 | seven_six_axis.header.last_entry_index = (seven_six_axis.header.last_entry_index + 1) % 17; | ||
| 35 | auto& cur_entry = seven_six_axis.sevensixaxis_states[seven_six_axis.header.last_entry_index]; | ||
| 36 | |||
| 37 | cur_entry.sampling_number = last_entry.sampling_number + 1; | ||
| 38 | cur_entry.sampling_number2 = cur_entry.sampling_number; | ||
| 39 | |||
| 40 | // Try to read sixaxis sensor states | ||
| 41 | MotionDevice motion_device{}; | ||
| 42 | const auto& device = motions[0]; | ||
| 43 | if (device) { | ||
| 44 | std::tie(motion_device.accel, motion_device.gyro, motion_device.rotation, | ||
| 45 | motion_device.orientation, motion_device.quaternion) = device->GetStatus(); | ||
| 46 | console_six_axis.is_seven_six_axis_sensor_at_rest = motion_device.gyro.Length2() < 0.0001f; | ||
| 47 | } | ||
| 48 | |||
| 49 | cur_entry.accel = motion_device.accel; | ||
| 50 | // Zero gyro values as they just mess up with the camera | ||
| 51 | // Note: Probably a correct sensivity setting must be set | ||
| 52 | cur_entry.gyro = {}; | ||
| 53 | cur_entry.quaternion = { | ||
| 54 | { | ||
| 55 | motion_device.quaternion.xyz.y, | ||
| 56 | motion_device.quaternion.xyz.x, | ||
| 57 | -motion_device.quaternion.w, | ||
| 58 | }, | ||
| 59 | -motion_device.quaternion.xyz.z, | ||
| 60 | }; | ||
| 61 | |||
| 62 | console_six_axis.sampling_number++; | ||
| 63 | // TODO(German77): Find the purpose of those values | ||
| 64 | console_six_axis.verticalization_error = 0.0f; | ||
| 65 | console_six_axis.gyro_bias = {0.0f, 0.0f, 0.0f}; | ||
| 66 | |||
| 67 | // Update console six axis shared memory | ||
| 68 | std::memcpy(data + SHARED_MEMORY_OFFSET, &console_six_axis, sizeof(console_six_axis)); | ||
| 69 | // Update seven six axis transfer memory | ||
| 70 | std::memcpy(transfer_memory, &seven_six_axis, sizeof(seven_six_axis)); | ||
| 71 | } | ||
| 72 | |||
| 73 | void Controller_ConsoleSixAxis::OnLoadInputDevices() { | ||
| 74 | const auto player = Settings::values.players.GetValue()[0]; | ||
| 75 | std::transform(player.motions.begin() + Settings::NativeMotion::MOTION_HID_BEGIN, | ||
| 76 | player.motions.begin() + Settings::NativeMotion::MOTION_HID_END, motions.begin(), | ||
| 77 | Input::CreateDevice<Input::MotionDevice>); | ||
| 78 | } | ||
| 79 | |||
| 80 | void Controller_ConsoleSixAxis::SetTransferMemoryPointer(u8* t_mem) { | ||
| 81 | is_transfer_memory_set = true; | ||
| 82 | transfer_memory = t_mem; | ||
| 83 | } | ||
| 84 | |||
| 85 | void Controller_ConsoleSixAxis::ResetTimestamp() { | ||
| 86 | auto& cur_entry = seven_six_axis.sevensixaxis_states[seven_six_axis.header.last_entry_index]; | ||
| 87 | cur_entry.sampling_number = 0; | ||
| 88 | cur_entry.sampling_number2 = 0; | ||
| 89 | } | ||
| 90 | } // namespace Service::HID | ||
diff --git a/src/core/hle/service/hid/controllers/console_sixaxis.h b/src/core/hle/service/hid/controllers/console_sixaxis.h new file mode 100644 index 000000000..1fae98e94 --- /dev/null +++ b/src/core/hle/service/hid/controllers/console_sixaxis.h | |||
| @@ -0,0 +1,80 @@ | |||
| 1 | // Copyright 2021 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <array> | ||
| 8 | #include "common/bit_field.h" | ||
| 9 | #include "common/common_types.h" | ||
| 10 | #include "common/quaternion.h" | ||
| 11 | #include "core/frontend/input.h" | ||
| 12 | #include "core/hle/service/hid/controllers/controller_base.h" | ||
| 13 | |||
| 14 | namespace Service::HID { | ||
| 15 | class Controller_ConsoleSixAxis final : public ControllerBase { | ||
| 16 | public: | ||
| 17 | explicit Controller_ConsoleSixAxis(Core::System& system); | ||
| 18 | ~Controller_ConsoleSixAxis() override; | ||
| 19 | |||
| 20 | // Called when the controller is initialized | ||
| 21 | void OnInit() override; | ||
| 22 | |||
| 23 | // When the controller is released | ||
| 24 | void OnRelease() override; | ||
| 25 | |||
| 26 | // When the controller is requesting an update for the shared memory | ||
| 27 | void OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* data, size_t size) override; | ||
| 28 | |||
| 29 | // Called when input devices should be loaded | ||
| 30 | void OnLoadInputDevices() override; | ||
| 31 | |||
| 32 | // Called on InitializeSevenSixAxisSensor | ||
| 33 | void SetTransferMemoryPointer(u8* t_mem); | ||
| 34 | |||
| 35 | // Called on ResetSevenSixAxisSensorTimestamp | ||
| 36 | void ResetTimestamp(); | ||
| 37 | |||
| 38 | private: | ||
| 39 | struct SevenSixAxisState { | ||
| 40 | INSERT_PADDING_WORDS(4); // unused | ||
| 41 | s64_le sampling_number{}; | ||
| 42 | s64_le sampling_number2{}; | ||
| 43 | u64 unknown{}; | ||
| 44 | Common::Vec3f accel{}; | ||
| 45 | Common::Vec3f gyro{}; | ||
| 46 | Common::Quaternion<f32> quaternion{}; | ||
| 47 | }; | ||
| 48 | static_assert(sizeof(SevenSixAxisState) == 0x50, "SevenSixAxisState is an invalid size"); | ||
| 49 | |||
| 50 | struct SevenSixAxisMemory { | ||
| 51 | CommonHeader header{}; | ||
| 52 | std::array<SevenSixAxisState, 0x21> sevensixaxis_states{}; | ||
| 53 | }; | ||
| 54 | static_assert(sizeof(SevenSixAxisMemory) == 0xA70, "SevenSixAxisMemory is an invalid size"); | ||
| 55 | |||
| 56 | struct ConsoleSharedMemory { | ||
| 57 | u64_le sampling_number{}; | ||
| 58 | bool is_seven_six_axis_sensor_at_rest{}; | ||
| 59 | f32 verticalization_error{}; | ||
| 60 | Common::Vec3f gyro_bias{}; | ||
| 61 | }; | ||
| 62 | static_assert(sizeof(ConsoleSharedMemory) == 0x20, "ConsoleSharedMemory is an invalid size"); | ||
| 63 | |||
| 64 | struct MotionDevice { | ||
| 65 | Common::Vec3f accel; | ||
| 66 | Common::Vec3f gyro; | ||
| 67 | Common::Vec3f rotation; | ||
| 68 | std::array<Common::Vec3f, 3> orientation; | ||
| 69 | Common::Quaternion<f32> quaternion; | ||
| 70 | }; | ||
| 71 | |||
| 72 | using MotionArray = | ||
| 73 | std::array<std::unique_ptr<Input::MotionDevice>, Settings::NativeMotion::NUM_MOTIONS_HID>; | ||
| 74 | MotionArray motions; | ||
| 75 | u8* transfer_memory = nullptr; | ||
| 76 | bool is_transfer_memory_set = false; | ||
| 77 | ConsoleSharedMemory console_six_axis{}; | ||
| 78 | SevenSixAxisMemory seven_six_axis{}; | ||
| 79 | }; | ||
| 80 | } // namespace Service::HID | ||
diff --git a/src/core/hle/service/hid/controllers/gesture.cpp b/src/core/hle/service/hid/controllers/gesture.cpp index 155808f6a..71545bf1f 100644 --- a/src/core/hle/service/hid/controllers/gesture.cpp +++ b/src/core/hle/service/hid/controllers/gesture.cpp | |||
| @@ -33,7 +33,7 @@ void Controller_Gesture::OnUpdate(const Core::Timing::CoreTiming& core_timing, u | |||
| 33 | shared_memory.header.timestamp = core_timing.GetCPUTicks(); | 33 | shared_memory.header.timestamp = core_timing.GetCPUTicks(); |
| 34 | shared_memory.header.total_entry_count = 17; | 34 | shared_memory.header.total_entry_count = 17; |
| 35 | 35 | ||
| 36 | if (!IsControllerActivated()) { | 36 | if (!IsControllerActivated() || !Settings::values.touchscreen.enabled) { |
| 37 | shared_memory.header.entry_count = 0; | 37 | shared_memory.header.entry_count = 0; |
| 38 | shared_memory.header.last_entry_index = 0; | 38 | shared_memory.header.last_entry_index = 0; |
| 39 | return; | 39 | return; |
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index 113a41254..249c300f6 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp | |||
| @@ -654,8 +654,8 @@ void Controller_NPad::OnMotionUpdate(const Core::Timing::CoreTiming& core_timing | |||
| 654 | const auto& device = motions[i][e]; | 654 | const auto& device = motions[i][e]; |
| 655 | if (device) { | 655 | if (device) { |
| 656 | std::tie(motion_devices[e].accel, motion_devices[e].gyro, | 656 | std::tie(motion_devices[e].accel, motion_devices[e].gyro, |
| 657 | motion_devices[e].rotation, motion_devices[e].orientation) = | 657 | motion_devices[e].rotation, motion_devices[e].orientation, |
| 658 | device->GetStatus(); | 658 | motion_devices[e].quaternion) = device->GetStatus(); |
| 659 | sixaxis_at_rest = sixaxis_at_rest && motion_devices[e].gyro.Length2() < 0.0001f; | 659 | sixaxis_at_rest = sixaxis_at_rest && motion_devices[e].gyro.Length2() < 0.0001f; |
| 660 | } | 660 | } |
| 661 | } | 661 | } |
diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index c3b07bd41..085f42c48 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include <atomic> | 8 | #include <atomic> |
| 9 | #include "common/bit_field.h" | 9 | #include "common/bit_field.h" |
| 10 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 11 | #include "common/quaternion.h" | ||
| 11 | #include "common/settings.h" | 12 | #include "common/settings.h" |
| 12 | #include "core/frontend/input.h" | 13 | #include "core/frontend/input.h" |
| 13 | #include "core/hle/kernel/object.h" | 14 | #include "core/hle/kernel/object.h" |
| @@ -467,6 +468,7 @@ private: | |||
| 467 | Common::Vec3f gyro; | 468 | Common::Vec3f gyro; |
| 468 | Common::Vec3f rotation; | 469 | Common::Vec3f rotation; |
| 469 | std::array<Common::Vec3f, 3> orientation; | 470 | std::array<Common::Vec3f, 3> orientation; |
| 471 | Common::Quaternion<f32> quaternion; | ||
| 470 | }; | 472 | }; |
| 471 | 473 | ||
| 472 | struct NfcXcdHandle { | 474 | struct NfcXcdHandle { |
diff --git a/src/core/hle/service/hid/controllers/touchscreen.cpp b/src/core/hle/service/hid/controllers/touchscreen.cpp index b5f8077be..8f56a0255 100644 --- a/src/core/hle/service/hid/controllers/touchscreen.cpp +++ b/src/core/hle/service/hid/controllers/touchscreen.cpp | |||
| @@ -33,7 +33,7 @@ void Controller_Touchscreen::OnUpdate(const Core::Timing::CoreTiming& core_timin | |||
| 33 | shared_memory.header.timestamp = core_timing.GetCPUTicks(); | 33 | shared_memory.header.timestamp = core_timing.GetCPUTicks(); |
| 34 | shared_memory.header.total_entry_count = 17; | 34 | shared_memory.header.total_entry_count = 17; |
| 35 | 35 | ||
| 36 | if (!IsControllerActivated()) { | 36 | if (!IsControllerActivated() || !Settings::values.touchscreen.enabled) { |
| 37 | shared_memory.header.entry_count = 0; | 37 | shared_memory.header.entry_count = 0; |
| 38 | shared_memory.header.last_entry_index = 0; | 38 | shared_memory.header.last_entry_index = 0; |
| 39 | return; | 39 | return; |
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index 2aa1942cb..9c4bf6d16 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp | |||
| @@ -26,6 +26,7 @@ | |||
| 26 | #include "core/hle/service/hid/xcd.h" | 26 | #include "core/hle/service/hid/xcd.h" |
| 27 | #include "core/hle/service/service.h" | 27 | #include "core/hle/service/service.h" |
| 28 | 28 | ||
| 29 | #include "core/hle/service/hid/controllers/console_sixaxis.h" | ||
| 29 | #include "core/hle/service/hid/controllers/controller_base.h" | 30 | #include "core/hle/service/hid/controllers/controller_base.h" |
| 30 | #include "core/hle/service/hid/controllers/debug_pad.h" | 31 | #include "core/hle/service/hid/controllers/debug_pad.h" |
| 31 | #include "core/hle/service/hid/controllers/gesture.h" | 32 | #include "core/hle/service/hid/controllers/gesture.h" |
| @@ -67,7 +68,7 @@ IAppletResource::IAppletResource(Core::System& system_) | |||
| 67 | MakeController<Controller_Stubbed>(HidController::UniquePad); | 68 | MakeController<Controller_Stubbed>(HidController::UniquePad); |
| 68 | MakeController<Controller_NPad>(HidController::NPad); | 69 | MakeController<Controller_NPad>(HidController::NPad); |
| 69 | MakeController<Controller_Gesture>(HidController::Gesture); | 70 | MakeController<Controller_Gesture>(HidController::Gesture); |
| 70 | MakeController<Controller_Stubbed>(HidController::ConsoleSixAxisSensor); | 71 | MakeController<Controller_ConsoleSixAxis>(HidController::ConsoleSixAxisSensor); |
| 71 | 72 | ||
| 72 | // Homebrew doesn't try to activate some controllers, so we activate them by default | 73 | // Homebrew doesn't try to activate some controllers, so we activate them by default |
| 73 | GetController<Controller_NPad>(HidController::NPad).ActivateController(); | 74 | GetController<Controller_NPad>(HidController::NPad).ActivateController(); |
| @@ -78,8 +79,6 @@ IAppletResource::IAppletResource(Core::System& system_) | |||
| 78 | GetController<Controller_Stubbed>(HidController::CaptureButton).SetCommonHeaderOffset(0x5000); | 79 | GetController<Controller_Stubbed>(HidController::CaptureButton).SetCommonHeaderOffset(0x5000); |
| 79 | GetController<Controller_Stubbed>(HidController::InputDetector).SetCommonHeaderOffset(0x5200); | 80 | GetController<Controller_Stubbed>(HidController::InputDetector).SetCommonHeaderOffset(0x5200); |
| 80 | GetController<Controller_Stubbed>(HidController::UniquePad).SetCommonHeaderOffset(0x5A00); | 81 | GetController<Controller_Stubbed>(HidController::UniquePad).SetCommonHeaderOffset(0x5A00); |
| 81 | GetController<Controller_Stubbed>(HidController::ConsoleSixAxisSensor) | ||
| 82 | .SetCommonHeaderOffset(0x3C200); | ||
| 83 | 82 | ||
| 84 | // Register update callbacks | 83 | // Register update callbacks |
| 85 | pad_update_event = Core::Timing::CreateEvent( | 84 | pad_update_event = Core::Timing::CreateEvent( |
| @@ -1404,8 +1403,9 @@ void Hid::ActivateConsoleSixAxisSensor(Kernel::HLERequestContext& ctx) { | |||
| 1404 | IPC::RequestParser rp{ctx}; | 1403 | IPC::RequestParser rp{ctx}; |
| 1405 | const auto applet_resource_user_id{rp.Pop<u64>()}; | 1404 | const auto applet_resource_user_id{rp.Pop<u64>()}; |
| 1406 | 1405 | ||
| 1407 | LOG_WARNING(Service_HID, "(STUBBED) called, applet_resource_user_id={}", | 1406 | applet_resource->ActivateController(HidController::ConsoleSixAxisSensor); |
| 1408 | applet_resource_user_id); | 1407 | |
| 1408 | LOG_WARNING(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | ||
| 1409 | 1409 | ||
| 1410 | IPC::ResponseBuilder rb{ctx, 2}; | 1410 | IPC::ResponseBuilder rb{ctx, 2}; |
| 1411 | rb.Push(RESULT_SUCCESS); | 1411 | rb.Push(RESULT_SUCCESS); |
| @@ -1455,8 +1455,9 @@ void Hid::ActivateSevenSixAxisSensor(Kernel::HLERequestContext& ctx) { | |||
| 1455 | IPC::RequestParser rp{ctx}; | 1455 | IPC::RequestParser rp{ctx}; |
| 1456 | const auto applet_resource_user_id{rp.Pop<u64>()}; | 1456 | const auto applet_resource_user_id{rp.Pop<u64>()}; |
| 1457 | 1457 | ||
| 1458 | LOG_WARNING(Service_HID, "(STUBBED) called, applet_resource_user_id={}", | 1458 | applet_resource->ActivateController(HidController::ConsoleSixAxisSensor); |
| 1459 | applet_resource_user_id); | 1459 | |
| 1460 | LOG_WARNING(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | ||
| 1460 | 1461 | ||
| 1461 | IPC::ResponseBuilder rb{ctx, 2}; | 1462 | IPC::ResponseBuilder rb{ctx, 2}; |
| 1462 | rb.Push(RESULT_SUCCESS); | 1463 | rb.Push(RESULT_SUCCESS); |
| @@ -1518,8 +1519,15 @@ void Hid::InitializeSevenSixAxisSensor(Kernel::HLERequestContext& ctx) { | |||
| 1518 | ASSERT_MSG(t_mem_1->GetSize() == 0x1000, "t_mem_1 has incorrect size"); | 1519 | ASSERT_MSG(t_mem_1->GetSize() == 0x1000, "t_mem_1 has incorrect size"); |
| 1519 | ASSERT_MSG(t_mem_2->GetSize() == 0x7F000, "t_mem_2 has incorrect size"); | 1520 | ASSERT_MSG(t_mem_2->GetSize() == 0x7F000, "t_mem_2 has incorrect size"); |
| 1520 | 1521 | ||
| 1522 | // Activate console six axis controller | ||
| 1523 | applet_resource->GetController<Controller_ConsoleSixAxis>(HidController::ConsoleSixAxisSensor) | ||
| 1524 | .ActivateController(); | ||
| 1525 | |||
| 1526 | applet_resource->GetController<Controller_ConsoleSixAxis>(HidController::ConsoleSixAxisSensor) | ||
| 1527 | .SetTransferMemoryPointer(t_mem_1->GetPointer()); | ||
| 1528 | |||
| 1521 | LOG_WARNING(Service_HID, | 1529 | LOG_WARNING(Service_HID, |
| 1522 | "(STUBBED) called, t_mem_1_handle=0x{:08X}, t_mem_2_handle=0x{:08X}, " | 1530 | "called, t_mem_1_handle=0x{:08X}, t_mem_2_handle=0x{:08X}, " |
| 1523 | "applet_resource_user_id={}", | 1531 | "applet_resource_user_id={}", |
| 1524 | t_mem_1_handle, t_mem_2_handle, applet_resource_user_id); | 1532 | t_mem_1_handle, t_mem_2_handle, applet_resource_user_id); |
| 1525 | 1533 | ||
| @@ -1542,8 +1550,10 @@ void Hid::ResetSevenSixAxisSensorTimestamp(Kernel::HLERequestContext& ctx) { | |||
| 1542 | IPC::RequestParser rp{ctx}; | 1550 | IPC::RequestParser rp{ctx}; |
| 1543 | const auto applet_resource_user_id{rp.Pop<u64>()}; | 1551 | const auto applet_resource_user_id{rp.Pop<u64>()}; |
| 1544 | 1552 | ||
| 1545 | LOG_WARNING(Service_HID, "(STUBBED) called, applet_resource_user_id={}", | 1553 | applet_resource->GetController<Controller_ConsoleSixAxis>(HidController::ConsoleSixAxisSensor) |
| 1546 | applet_resource_user_id); | 1554 | .ResetTimestamp(); |
| 1555 | |||
| 1556 | LOG_WARNING(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | ||
| 1547 | 1557 | ||
| 1548 | IPC::ResponseBuilder rb{ctx, 2}; | 1558 | IPC::ResponseBuilder rb{ctx, 2}; |
| 1549 | rb.Push(RESULT_SUCCESS); | 1559 | rb.Push(RESULT_SUCCESS); |
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp index 4e58b9b80..e2f671d8e 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp | |||
| @@ -31,9 +31,8 @@ NvResult nvhost_nvdec::Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& | |||
| 31 | return SetSubmitTimeout(input, output); | 31 | return SetSubmitTimeout(input, output); |
| 32 | case 0x9: | 32 | case 0x9: |
| 33 | return MapBuffer(input, output); | 33 | return MapBuffer(input, output); |
| 34 | case 0xa: { | 34 | case 0xa: |
| 35 | return UnmapBuffer(input, output); | 35 | return UnmapBuffer(input, output); |
| 36 | } | ||
| 37 | default: | 36 | default: |
| 38 | break; | 37 | break; |
| 39 | } | 38 | } |
| @@ -67,7 +66,8 @@ NvResult nvhost_nvdec::Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& | |||
| 67 | void nvhost_nvdec::OnOpen(DeviceFD fd) {} | 66 | void nvhost_nvdec::OnOpen(DeviceFD fd) {} |
| 68 | 67 | ||
| 69 | void nvhost_nvdec::OnClose(DeviceFD fd) { | 68 | void nvhost_nvdec::OnClose(DeviceFD fd) { |
| 70 | system.GPU().ClearCommandBuffer(); | 69 | LOG_INFO(Service_NVDRV, "NVDEC video stream ended"); |
| 70 | system.GPU().ClearCdmaInstance(); | ||
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | } // namespace Service::Nvidia::Devices | 73 | } // namespace Service::Nvidia::Devices |
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp b/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp index 0421fb956..301efe8a1 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp | |||
| @@ -29,13 +29,8 @@ NvResult nvhost_vic::Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& i | |||
| 29 | return GetWaitbase(input, output); | 29 | return GetWaitbase(input, output); |
| 30 | case 0x9: | 30 | case 0x9: |
| 31 | return MapBuffer(input, output); | 31 | return MapBuffer(input, output); |
| 32 | case 0xa: { | 32 | case 0xa: |
| 33 | if (command.length == 0x1c) { | ||
| 34 | Tegra::ChCommandHeaderList cmdlist{{0xDEADB33F}}; | ||
| 35 | system.GPU().PushCommandBuffer(cmdlist); | ||
| 36 | } | ||
| 37 | return UnmapBuffer(input, output); | 33 | return UnmapBuffer(input, output); |
| 38 | } | ||
| 39 | default: | 34 | default: |
| 40 | break; | 35 | break; |
| 41 | } | 36 | } |
| @@ -69,6 +64,9 @@ NvResult nvhost_vic::Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& i | |||
| 69 | } | 64 | } |
| 70 | 65 | ||
| 71 | void nvhost_vic::OnOpen(DeviceFD fd) {} | 66 | void nvhost_vic::OnOpen(DeviceFD fd) {} |
| 72 | void nvhost_vic::OnClose(DeviceFD fd) {} | 67 | |
| 68 | void nvhost_vic::OnClose(DeviceFD fd) { | ||
| 69 | system.GPU().ClearCdmaInstance(); | ||
| 70 | } | ||
| 73 | 71 | ||
| 74 | } // namespace Service::Nvidia::Devices | 72 | } // namespace Service::Nvidia::Devices |
diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp index 539b02bc4..c43593e7f 100644 --- a/src/core/hle/service/nvflinger/nvflinger.cpp +++ b/src/core/hle/service/nvflinger/nvflinger.cpp | |||
| @@ -72,7 +72,7 @@ NVFlinger::NVFlinger(Core::System& system) : system(system) { | |||
| 72 | // Schedule the screen composition events | 72 | // Schedule the screen composition events |
| 73 | composition_event = Core::Timing::CreateEvent( | 73 | composition_event = Core::Timing::CreateEvent( |
| 74 | "ScreenComposition", [this](std::uintptr_t, std::chrono::nanoseconds ns_late) { | 74 | "ScreenComposition", [this](std::uintptr_t, std::chrono::nanoseconds ns_late) { |
| 75 | const auto guard = Lock(); | 75 | const auto lock_guard = Lock(); |
| 76 | Compose(); | 76 | Compose(); |
| 77 | 77 | ||
| 78 | const auto ticks = std::chrono::nanoseconds{GetNextTicks()}; | 78 | const auto ticks = std::chrono::nanoseconds{GetNextTicks()}; |
| @@ -112,7 +112,7 @@ void NVFlinger::SetNVDrvInstance(std::shared_ptr<Nvidia::Module> instance) { | |||
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | std::optional<u64> NVFlinger::OpenDisplay(std::string_view name) { | 114 | std::optional<u64> NVFlinger::OpenDisplay(std::string_view name) { |
| 115 | const auto guard = Lock(); | 115 | const auto lock_guard = Lock(); |
| 116 | 116 | ||
| 117 | LOG_DEBUG(Service, "Opening \"{}\" display", name); | 117 | LOG_DEBUG(Service, "Opening \"{}\" display", name); |
| 118 | 118 | ||
| @@ -131,7 +131,7 @@ std::optional<u64> NVFlinger::OpenDisplay(std::string_view name) { | |||
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | std::optional<u64> NVFlinger::CreateLayer(u64 display_id) { | 133 | std::optional<u64> NVFlinger::CreateLayer(u64 display_id) { |
| 134 | const auto guard = Lock(); | 134 | const auto lock_guard = Lock(); |
| 135 | auto* const display = FindDisplay(display_id); | 135 | auto* const display = FindDisplay(display_id); |
| 136 | 136 | ||
| 137 | if (display == nullptr) { | 137 | if (display == nullptr) { |
| @@ -147,7 +147,7 @@ std::optional<u64> NVFlinger::CreateLayer(u64 display_id) { | |||
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | void NVFlinger::CloseLayer(u64 layer_id) { | 149 | void NVFlinger::CloseLayer(u64 layer_id) { |
| 150 | const auto guard = Lock(); | 150 | const auto lock_guard = Lock(); |
| 151 | 151 | ||
| 152 | for (auto& display : displays) { | 152 | for (auto& display : displays) { |
| 153 | display.CloseLayer(layer_id); | 153 | display.CloseLayer(layer_id); |
| @@ -155,7 +155,7 @@ void NVFlinger::CloseLayer(u64 layer_id) { | |||
| 155 | } | 155 | } |
| 156 | 156 | ||
| 157 | std::optional<u32> NVFlinger::FindBufferQueueId(u64 display_id, u64 layer_id) const { | 157 | std::optional<u32> NVFlinger::FindBufferQueueId(u64 display_id, u64 layer_id) const { |
| 158 | const auto guard = Lock(); | 158 | const auto lock_guard = Lock(); |
| 159 | const auto* const layer = FindLayer(display_id, layer_id); | 159 | const auto* const layer = FindLayer(display_id, layer_id); |
| 160 | 160 | ||
| 161 | if (layer == nullptr) { | 161 | if (layer == nullptr) { |
| @@ -166,7 +166,7 @@ std::optional<u32> NVFlinger::FindBufferQueueId(u64 display_id, u64 layer_id) co | |||
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | std::shared_ptr<Kernel::KReadableEvent> NVFlinger::FindVsyncEvent(u64 display_id) const { | 168 | std::shared_ptr<Kernel::KReadableEvent> NVFlinger::FindVsyncEvent(u64 display_id) const { |
| 169 | const auto guard = Lock(); | 169 | const auto lock_guard = Lock(); |
| 170 | auto* const display = FindDisplay(display_id); | 170 | auto* const display = FindDisplay(display_id); |
| 171 | 171 | ||
| 172 | if (display == nullptr) { | 172 | if (display == nullptr) { |
| @@ -177,7 +177,7 @@ std::shared_ptr<Kernel::KReadableEvent> NVFlinger::FindVsyncEvent(u64 display_id | |||
| 177 | } | 177 | } |
| 178 | 178 | ||
| 179 | BufferQueue* NVFlinger::FindBufferQueue(u32 id) { | 179 | BufferQueue* NVFlinger::FindBufferQueue(u32 id) { |
| 180 | const auto guard = Lock(); | 180 | const auto lock_guard = Lock(); |
| 181 | const auto itr = std::find_if(buffer_queues.begin(), buffer_queues.end(), | 181 | const auto itr = std::find_if(buffer_queues.begin(), buffer_queues.end(), |
| 182 | [id](const auto& queue) { return queue->GetId() == id; }); | 182 | [id](const auto& queue) { return queue->GetId() == id; }); |
| 183 | 183 | ||
diff --git a/src/core/hle/service/time/standard_user_system_clock_core.cpp b/src/core/hle/service/time/standard_user_system_clock_core.cpp index b9faa474e..3172acc5a 100644 --- a/src/core/hle/service/time/standard_user_system_clock_core.cpp +++ b/src/core/hle/service/time/standard_user_system_clock_core.cpp | |||
| @@ -45,12 +45,12 @@ ResultCode StandardUserSystemClockCore::GetClockContext(Core::System& system, | |||
| 45 | return local_system_clock_core.GetClockContext(system, context); | 45 | return local_system_clock_core.GetClockContext(system, context); |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | ResultCode StandardUserSystemClockCore::Flush(const SystemClockContext& context) { | 48 | ResultCode StandardUserSystemClockCore::Flush(const SystemClockContext&) { |
| 49 | UNREACHABLE(); | 49 | UNREACHABLE(); |
| 50 | return ERROR_NOT_IMPLEMENTED; | 50 | return ERROR_NOT_IMPLEMENTED; |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | ResultCode StandardUserSystemClockCore::SetClockContext(const SystemClockContext& context) { | 53 | ResultCode StandardUserSystemClockCore::SetClockContext(const SystemClockContext&) { |
| 54 | UNREACHABLE(); | 54 | UNREACHABLE(); |
| 55 | return ERROR_NOT_IMPLEMENTED; | 55 | return ERROR_NOT_IMPLEMENTED; |
| 56 | } | 56 | } |
diff --git a/src/core/hle/service/time/standard_user_system_clock_core.h b/src/core/hle/service/time/standard_user_system_clock_core.h index aac44d72f..5bc8bf5c2 100644 --- a/src/core/hle/service/time/standard_user_system_clock_core.h +++ b/src/core/hle/service/time/standard_user_system_clock_core.h | |||
| @@ -39,7 +39,7 @@ public: | |||
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | protected: | 41 | protected: |
| 42 | ResultCode Flush(const SystemClockContext& context) override; | 42 | ResultCode Flush(const SystemClockContext&) override; |
| 43 | 43 | ||
| 44 | ResultCode SetClockContext(const SystemClockContext&) override; | 44 | ResultCode SetClockContext(const SystemClockContext&) override; |
| 45 | 45 | ||
diff --git a/src/core/hle/service/time/system_clock_core.cpp b/src/core/hle/service/time/system_clock_core.cpp index d31d4e2ca..46fc8c6c3 100644 --- a/src/core/hle/service/time/system_clock_core.cpp +++ b/src/core/hle/service/time/system_clock_core.cpp | |||
| @@ -45,18 +45,18 @@ ResultCode SystemClockCore::SetCurrentTime(Core::System& system, s64 posix_time) | |||
| 45 | return Flush(clock_context); | 45 | return Flush(clock_context); |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | ResultCode SystemClockCore::Flush(const SystemClockContext& context) { | 48 | ResultCode SystemClockCore::Flush(const SystemClockContext& clock_context) { |
| 49 | if (!system_clock_context_update_callback) { | 49 | if (!system_clock_context_update_callback) { |
| 50 | return RESULT_SUCCESS; | 50 | return RESULT_SUCCESS; |
| 51 | } | 51 | } |
| 52 | return system_clock_context_update_callback->Update(context); | 52 | return system_clock_context_update_callback->Update(clock_context); |
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | ResultCode SystemClockCore::SetSystemClockContext(const SystemClockContext& context) { | 55 | ResultCode SystemClockCore::SetSystemClockContext(const SystemClockContext& clock_context) { |
| 56 | if (const ResultCode result{SetClockContext(context)}; result != RESULT_SUCCESS) { | 56 | if (const ResultCode result{SetClockContext(clock_context)}; result != RESULT_SUCCESS) { |
| 57 | return result; | 57 | return result; |
| 58 | } | 58 | } |
| 59 | return Flush(context); | 59 | return Flush(clock_context); |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | bool SystemClockCore::IsClockSetup(Core::System& system) const { | 62 | bool SystemClockCore::IsClockSetup(Core::System& system) const { |
diff --git a/src/core/hle/service/time/system_clock_core.h b/src/core/hle/service/time/system_clock_core.h index 608dd3b2e..82a8b79ff 100644 --- a/src/core/hle/service/time/system_clock_core.h +++ b/src/core/hle/service/time/system_clock_core.h | |||
| @@ -43,7 +43,7 @@ public: | |||
| 43 | return RESULT_SUCCESS; | 43 | return RESULT_SUCCESS; |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | virtual ResultCode Flush(const SystemClockContext& context); | 46 | virtual ResultCode Flush(const SystemClockContext& clock_context); |
| 47 | 47 | ||
| 48 | void SetUpdateCallbackInstance(std::shared_ptr<SystemClockContextUpdateCallback> callback) { | 48 | void SetUpdateCallbackInstance(std::shared_ptr<SystemClockContextUpdateCallback> callback) { |
| 49 | system_clock_context_update_callback = std::move(callback); | 49 | system_clock_context_update_callback = std::move(callback); |
diff --git a/src/core/hle/service/time/time_manager.cpp b/src/core/hle/service/time/time_manager.cpp index f89c5aaad..fe01a3739 100644 --- a/src/core/hle/service/time/time_manager.cpp +++ b/src/core/hle/service/time/time_manager.cpp | |||
| @@ -129,7 +129,7 @@ struct TimeManager::Impl final { | |||
| 129 | return 0; | 129 | return 0; |
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | void SetupStandardSteadyClock(Core::System& system, Common::UUID clock_source_id, | 132 | void SetupStandardSteadyClock(Core::System& system_, Common::UUID clock_source_id, |
| 133 | Clock::TimeSpanType setup_value, | 133 | Clock::TimeSpanType setup_value, |
| 134 | Clock::TimeSpanType internal_offset, bool is_rtc_reset_detected) { | 134 | Clock::TimeSpanType internal_offset, bool is_rtc_reset_detected) { |
| 135 | standard_steady_clock_core.SetClockSourceId(clock_source_id); | 135 | standard_steady_clock_core.SetClockSourceId(clock_source_id); |
| @@ -137,21 +137,21 @@ struct TimeManager::Impl final { | |||
| 137 | standard_steady_clock_core.SetInternalOffset(internal_offset); | 137 | standard_steady_clock_core.SetInternalOffset(internal_offset); |
| 138 | standard_steady_clock_core.MarkAsInitialized(); | 138 | standard_steady_clock_core.MarkAsInitialized(); |
| 139 | 139 | ||
| 140 | const auto current_time_point{standard_steady_clock_core.GetCurrentRawTimePoint(system)}; | 140 | const auto current_time_point{standard_steady_clock_core.GetCurrentRawTimePoint(system_)}; |
| 141 | shared_memory.SetupStandardSteadyClock(system, clock_source_id, current_time_point); | 141 | shared_memory.SetupStandardSteadyClock(clock_source_id, current_time_point); |
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | void SetupStandardLocalSystemClock(Core::System& system, | 144 | void SetupStandardLocalSystemClock(Core::System& system_, |
| 145 | Clock::SystemClockContext clock_context, s64 posix_time) { | 145 | Clock::SystemClockContext clock_context, s64 posix_time) { |
| 146 | standard_local_system_clock_core.SetUpdateCallbackInstance( | 146 | standard_local_system_clock_core.SetUpdateCallbackInstance( |
| 147 | local_system_clock_context_writer); | 147 | local_system_clock_context_writer); |
| 148 | 148 | ||
| 149 | const auto current_time_point{ | 149 | const auto current_time_point{ |
| 150 | standard_local_system_clock_core.GetSteadyClockCore().GetCurrentTimePoint(system)}; | 150 | standard_local_system_clock_core.GetSteadyClockCore().GetCurrentTimePoint(system_)}; |
| 151 | if (current_time_point.clock_source_id == clock_context.steady_time_point.clock_source_id) { | 151 | if (current_time_point.clock_source_id == clock_context.steady_time_point.clock_source_id) { |
| 152 | standard_local_system_clock_core.SetSystemClockContext(clock_context); | 152 | standard_local_system_clock_core.SetSystemClockContext(clock_context); |
| 153 | } else { | 153 | } else { |
| 154 | if (standard_local_system_clock_core.SetCurrentTime(system, posix_time) != | 154 | if (standard_local_system_clock_core.SetCurrentTime(system_, posix_time) != |
| 155 | RESULT_SUCCESS) { | 155 | RESULT_SUCCESS) { |
| 156 | UNREACHABLE(); | 156 | UNREACHABLE(); |
| 157 | return; | 157 | return; |
| @@ -177,10 +177,10 @@ struct TimeManager::Impl final { | |||
| 177 | standard_network_system_clock_core.MarkAsInitialized(); | 177 | standard_network_system_clock_core.MarkAsInitialized(); |
| 178 | } | 178 | } |
| 179 | 179 | ||
| 180 | void SetupStandardUserSystemClock(Core::System& system, bool is_automatic_correction_enabled, | 180 | void SetupStandardUserSystemClock(Core::System& system_, bool is_automatic_correction_enabled, |
| 181 | Clock::SteadyClockTimePoint steady_clock_time_point) { | 181 | Clock::SteadyClockTimePoint steady_clock_time_point) { |
| 182 | if (standard_user_system_clock_core.SetAutomaticCorrectionEnabled( | 182 | if (standard_user_system_clock_core.SetAutomaticCorrectionEnabled( |
| 183 | system, is_automatic_correction_enabled) != RESULT_SUCCESS) { | 183 | system_, is_automatic_correction_enabled) != RESULT_SUCCESS) { |
| 184 | UNREACHABLE(); | 184 | UNREACHABLE(); |
| 185 | return; | 185 | return; |
| 186 | } | 186 | } |
| @@ -196,10 +196,10 @@ struct TimeManager::Impl final { | |||
| 196 | ephemeral_network_system_clock_core.MarkAsInitialized(); | 196 | ephemeral_network_system_clock_core.MarkAsInitialized(); |
| 197 | } | 197 | } |
| 198 | 198 | ||
| 199 | void UpdateLocalSystemClockTime(Core::System& system, s64 posix_time) { | 199 | void UpdateLocalSystemClockTime(Core::System& system_, s64 posix_time) { |
| 200 | const auto timespan{Service::Time::Clock::TimeSpanType::FromSeconds(posix_time)}; | 200 | const auto timespan{Clock::TimeSpanType::FromSeconds(posix_time)}; |
| 201 | if (GetStandardLocalSystemClockCore() | 201 | if (GetStandardLocalSystemClockCore() |
| 202 | .SetCurrentTime(system, timespan.ToSeconds()) | 202 | .SetCurrentTime(system_, timespan.ToSeconds()) |
| 203 | .IsError()) { | 203 | .IsError()) { |
| 204 | UNREACHABLE(); | 204 | UNREACHABLE(); |
| 205 | return; | 205 | return; |
diff --git a/src/core/hle/service/time/time_sharedmemory.cpp b/src/core/hle/service/time/time_sharedmemory.cpp index 4d8de81be..018ce94ed 100644 --- a/src/core/hle/service/time/time_sharedmemory.cpp +++ b/src/core/hle/service/time/time_sharedmemory.cpp | |||
| @@ -26,8 +26,7 @@ std::shared_ptr<Kernel::KSharedMemory> SharedMemory::GetSharedMemoryHolder() con | |||
| 26 | return shared_memory_holder; | 26 | return shared_memory_holder; |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | void SharedMemory::SetupStandardSteadyClock(Core::System& system, | 29 | void SharedMemory::SetupStandardSteadyClock(const Common::UUID& clock_source_id, |
| 30 | const Common::UUID& clock_source_id, | ||
| 31 | Clock::TimeSpanType current_time_point) { | 30 | Clock::TimeSpanType current_time_point) { |
| 32 | const Clock::TimeSpanType ticks_time_span{Clock::TimeSpanType::FromTicks( | 31 | const Clock::TimeSpanType ticks_time_span{Clock::TimeSpanType::FromTicks( |
| 33 | system.CoreTiming().GetClockTicks(), Core::Hardware::CNTFREQ)}; | 32 | system.CoreTiming().GetClockTicks(), Core::Hardware::CNTFREQ)}; |
diff --git a/src/core/hle/service/time/time_sharedmemory.h b/src/core/hle/service/time/time_sharedmemory.h index 299680517..3bc749114 100644 --- a/src/core/hle/service/time/time_sharedmemory.h +++ b/src/core/hle/service/time/time_sharedmemory.h | |||
| @@ -56,8 +56,8 @@ public: | |||
| 56 | }; | 56 | }; |
| 57 | static_assert(sizeof(Format) == 0xd8, "Format is an invalid size"); | 57 | static_assert(sizeof(Format) == 0xd8, "Format is an invalid size"); |
| 58 | 58 | ||
| 59 | void SetupStandardSteadyClock(Core::System& system, const Common::UUID& clock_source_id, | 59 | void SetupStandardSteadyClock(const Common::UUID& clock_source_id, |
| 60 | Clock::TimeSpanType currentTimePoint); | 60 | Clock::TimeSpanType current_time_point); |
| 61 | void UpdateLocalSystemClockContext(const Clock::SystemClockContext& context); | 61 | void UpdateLocalSystemClockContext(const Clock::SystemClockContext& context); |
| 62 | void UpdateNetworkSystemClockContext(const Clock::SystemClockContext& context); | 62 | void UpdateNetworkSystemClockContext(const Clock::SystemClockContext& context); |
| 63 | void SetAutomaticCorrectionEnabled(bool is_enabled); | 63 | void SetAutomaticCorrectionEnabled(bool is_enabled); |
diff --git a/src/core/hle/service/vi/display/vi_display.cpp b/src/core/hle/service/vi/display/vi_display.cpp index 7f42aa4a0..ac9e87338 100644 --- a/src/core/hle/service/vi/display/vi_display.cpp +++ b/src/core/hle/service/vi/display/vi_display.cpp | |||
| @@ -41,24 +41,22 @@ void Display::SignalVSyncEvent() { | |||
| 41 | vsync_event->GetWritableEvent()->Signal(); | 41 | vsync_event->GetWritableEvent()->Signal(); |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | void Display::CreateLayer(u64 id, NVFlinger::BufferQueue& buffer_queue) { | 44 | void Display::CreateLayer(u64 layer_id, NVFlinger::BufferQueue& buffer_queue) { |
| 45 | // TODO(Subv): Support more than 1 layer. | 45 | // TODO(Subv): Support more than 1 layer. |
| 46 | ASSERT_MSG(layers.empty(), "Only one layer is supported per display at the moment"); | 46 | ASSERT_MSG(layers.empty(), "Only one layer is supported per display at the moment"); |
| 47 | 47 | ||
| 48 | layers.emplace_back(std::make_shared<Layer>(id, buffer_queue)); | 48 | layers.emplace_back(std::make_shared<Layer>(layer_id, buffer_queue)); |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | void Display::CloseLayer(u64 id) { | 51 | void Display::CloseLayer(u64 layer_id) { |
| 52 | layers.erase( | 52 | std::erase_if(layers, [layer_id](const auto& layer) { return layer->GetID() == layer_id; }); |
| 53 | std::remove_if(layers.begin(), layers.end(), | ||
| 54 | [id](const std::shared_ptr<Layer>& layer) { return layer->GetID() == id; }), | ||
| 55 | layers.end()); | ||
| 56 | } | 53 | } |
| 57 | 54 | ||
| 58 | Layer* Display::FindLayer(u64 id) { | 55 | Layer* Display::FindLayer(u64 layer_id) { |
| 59 | const auto itr = | 56 | const auto itr = |
| 60 | std::find_if(layers.begin(), layers.end(), | 57 | std::find_if(layers.begin(), layers.end(), [layer_id](const std::shared_ptr<Layer>& layer) { |
| 61 | [id](const std::shared_ptr<Layer>& layer) { return layer->GetID() == id; }); | 58 | return layer->GetID() == layer_id; |
| 59 | }); | ||
| 62 | 60 | ||
| 63 | if (itr == layers.end()) { | 61 | if (itr == layers.end()) { |
| 64 | return nullptr; | 62 | return nullptr; |
| @@ -67,10 +65,11 @@ Layer* Display::FindLayer(u64 id) { | |||
| 67 | return itr->get(); | 65 | return itr->get(); |
| 68 | } | 66 | } |
| 69 | 67 | ||
| 70 | const Layer* Display::FindLayer(u64 id) const { | 68 | const Layer* Display::FindLayer(u64 layer_id) const { |
| 71 | const auto itr = | 69 | const auto itr = |
| 72 | std::find_if(layers.begin(), layers.end(), | 70 | std::find_if(layers.begin(), layers.end(), [layer_id](const std::shared_ptr<Layer>& layer) { |
| 73 | [id](const std::shared_ptr<Layer>& layer) { return layer->GetID() == id; }); | 71 | return layer->GetID() == layer_id; |
| 72 | }); | ||
| 74 | 73 | ||
| 75 | if (itr == layers.end()) { | 74 | if (itr == layers.end()) { |
| 76 | return nullptr; | 75 | return nullptr; |
diff --git a/src/core/hle/service/vi/display/vi_display.h b/src/core/hle/service/vi/display/vi_display.h index 931c898f6..8340059de 100644 --- a/src/core/hle/service/vi/display/vi_display.h +++ b/src/core/hle/service/vi/display/vi_display.h | |||
| @@ -68,34 +68,34 @@ public: | |||
| 68 | 68 | ||
| 69 | /// Creates and adds a layer to this display with the given ID. | 69 | /// Creates and adds a layer to this display with the given ID. |
| 70 | /// | 70 | /// |
| 71 | /// @param id The ID to assign to the created layer. | 71 | /// @param layer_id The ID to assign to the created layer. |
| 72 | /// @param buffer_queue The buffer queue for the layer instance to use. | 72 | /// @param buffer_queue The buffer queue for the layer instance to use. |
| 73 | /// | 73 | /// |
| 74 | void CreateLayer(u64 id, NVFlinger::BufferQueue& buffer_queue); | 74 | void CreateLayer(u64 layer_id, NVFlinger::BufferQueue& buffer_queue); |
| 75 | 75 | ||
| 76 | /// Closes and removes a layer from this display with the given ID. | 76 | /// Closes and removes a layer from this display with the given ID. |
| 77 | /// | 77 | /// |
| 78 | /// @param id The ID assigned to the layer to close. | 78 | /// @param layer_id The ID assigned to the layer to close. |
| 79 | /// | 79 | /// |
| 80 | void CloseLayer(u64 id); | 80 | void CloseLayer(u64 layer_id); |
| 81 | 81 | ||
| 82 | /// Attempts to find a layer with the given ID. | 82 | /// Attempts to find a layer with the given ID. |
| 83 | /// | 83 | /// |
| 84 | /// @param id The layer ID. | 84 | /// @param layer_id The layer ID. |
| 85 | /// | 85 | /// |
| 86 | /// @returns If found, the Layer instance with the given ID. | 86 | /// @returns If found, the Layer instance with the given ID. |
| 87 | /// If not found, then nullptr is returned. | 87 | /// If not found, then nullptr is returned. |
| 88 | /// | 88 | /// |
| 89 | Layer* FindLayer(u64 id); | 89 | Layer* FindLayer(u64 layer_id); |
| 90 | 90 | ||
| 91 | /// Attempts to find a layer with the given ID. | 91 | /// Attempts to find a layer with the given ID. |
| 92 | /// | 92 | /// |
| 93 | /// @param id The layer ID. | 93 | /// @param layer_id The layer ID. |
| 94 | /// | 94 | /// |
| 95 | /// @returns If found, the Layer instance with the given ID. | 95 | /// @returns If found, the Layer instance with the given ID. |
| 96 | /// If not found, then nullptr is returned. | 96 | /// If not found, then nullptr is returned. |
| 97 | /// | 97 | /// |
| 98 | const Layer* FindLayer(u64 id) const; | 98 | const Layer* FindLayer(u64 layer_id) const; |
| 99 | 99 | ||
| 100 | private: | 100 | private: |
| 101 | u64 id; | 101 | u64 id; |
diff --git a/src/core/loader/deconstructed_rom_directory.cpp b/src/core/loader/deconstructed_rom_directory.cpp index 4a10211f6..ed776fc49 100644 --- a/src/core/loader/deconstructed_rom_directory.cpp +++ b/src/core/loader/deconstructed_rom_directory.cpp | |||
| @@ -24,10 +24,10 @@ namespace Loader { | |||
| 24 | AppLoader_DeconstructedRomDirectory::AppLoader_DeconstructedRomDirectory(FileSys::VirtualFile file_, | 24 | AppLoader_DeconstructedRomDirectory::AppLoader_DeconstructedRomDirectory(FileSys::VirtualFile file_, |
| 25 | bool override_update) | 25 | bool override_update) |
| 26 | : AppLoader(std::move(file_)), override_update(override_update) { | 26 | : AppLoader(std::move(file_)), override_update(override_update) { |
| 27 | const auto dir = file->GetContainingDirectory(); | 27 | const auto file_dir = file->GetContainingDirectory(); |
| 28 | 28 | ||
| 29 | // Title ID | 29 | // Title ID |
| 30 | const auto npdm = dir->GetFile("main.npdm"); | 30 | const auto npdm = file_dir->GetFile("main.npdm"); |
| 31 | if (npdm != nullptr) { | 31 | if (npdm != nullptr) { |
| 32 | const auto res = metadata.Load(npdm); | 32 | const auto res = metadata.Load(npdm); |
| 33 | if (res == ResultStatus::Success) | 33 | if (res == ResultStatus::Success) |
| @@ -37,7 +37,7 @@ AppLoader_DeconstructedRomDirectory::AppLoader_DeconstructedRomDirectory(FileSys | |||
| 37 | // Icon | 37 | // Icon |
| 38 | FileSys::VirtualFile icon_file = nullptr; | 38 | FileSys::VirtualFile icon_file = nullptr; |
| 39 | for (const auto& language : FileSys::LANGUAGE_NAMES) { | 39 | for (const auto& language : FileSys::LANGUAGE_NAMES) { |
| 40 | icon_file = dir->GetFile("icon_" + std::string(language) + ".dat"); | 40 | icon_file = file_dir->GetFile("icon_" + std::string(language) + ".dat"); |
| 41 | if (icon_file != nullptr) { | 41 | if (icon_file != nullptr) { |
| 42 | icon_data = icon_file->ReadAllBytes(); | 42 | icon_data = icon_file->ReadAllBytes(); |
| 43 | break; | 43 | break; |
| @@ -46,7 +46,7 @@ AppLoader_DeconstructedRomDirectory::AppLoader_DeconstructedRomDirectory(FileSys | |||
| 46 | 46 | ||
| 47 | if (icon_data.empty()) { | 47 | if (icon_data.empty()) { |
| 48 | // Any png, jpeg, or bmp file | 48 | // Any png, jpeg, or bmp file |
| 49 | const auto& files = dir->GetFiles(); | 49 | const auto& files = file_dir->GetFiles(); |
| 50 | const auto icon_iter = | 50 | const auto icon_iter = |
| 51 | std::find_if(files.begin(), files.end(), [](const FileSys::VirtualFile& file) { | 51 | std::find_if(files.begin(), files.end(), [](const FileSys::VirtualFile& file) { |
| 52 | return file->GetExtension() == "png" || file->GetExtension() == "jpg" || | 52 | return file->GetExtension() == "png" || file->GetExtension() == "jpg" || |
| @@ -57,9 +57,9 @@ AppLoader_DeconstructedRomDirectory::AppLoader_DeconstructedRomDirectory(FileSys | |||
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | // Metadata | 59 | // Metadata |
| 60 | FileSys::VirtualFile nacp_file = dir->GetFile("control.nacp"); | 60 | FileSys::VirtualFile nacp_file = file_dir->GetFile("control.nacp"); |
| 61 | if (nacp_file == nullptr) { | 61 | if (nacp_file == nullptr) { |
| 62 | const auto& files = dir->GetFiles(); | 62 | const auto& files = file_dir->GetFiles(); |
| 63 | const auto nacp_iter = | 63 | const auto nacp_iter = |
| 64 | std::find_if(files.begin(), files.end(), [](const FileSys::VirtualFile& file) { | 64 | std::find_if(files.begin(), files.end(), [](const FileSys::VirtualFile& file) { |
| 65 | return file->GetExtension() == "nacp"; | 65 | return file->GetExtension() == "nacp"; |
| @@ -200,17 +200,21 @@ AppLoader_DeconstructedRomDirectory::LoadResult AppLoader_DeconstructedRomDirect | |||
| 200 | LoadParameters{metadata.GetMainThreadPriority(), metadata.GetMainThreadStackSize()}}; | 200 | LoadParameters{metadata.GetMainThreadPriority(), metadata.GetMainThreadStackSize()}}; |
| 201 | } | 201 | } |
| 202 | 202 | ||
| 203 | ResultStatus AppLoader_DeconstructedRomDirectory::ReadRomFS(FileSys::VirtualFile& dir) { | 203 | ResultStatus AppLoader_DeconstructedRomDirectory::ReadRomFS(FileSys::VirtualFile& out_dir) { |
| 204 | if (romfs == nullptr) | 204 | if (romfs == nullptr) { |
| 205 | return ResultStatus::ErrorNoRomFS; | 205 | return ResultStatus::ErrorNoRomFS; |
| 206 | dir = romfs; | 206 | } |
| 207 | |||
| 208 | out_dir = romfs; | ||
| 207 | return ResultStatus::Success; | 209 | return ResultStatus::Success; |
| 208 | } | 210 | } |
| 209 | 211 | ||
| 210 | ResultStatus AppLoader_DeconstructedRomDirectory::ReadIcon(std::vector<u8>& buffer) { | 212 | ResultStatus AppLoader_DeconstructedRomDirectory::ReadIcon(std::vector<u8>& out_buffer) { |
| 211 | if (icon_data.empty()) | 213 | if (icon_data.empty()) { |
| 212 | return ResultStatus::ErrorNoIcon; | 214 | return ResultStatus::ErrorNoIcon; |
| 213 | buffer = icon_data; | 215 | } |
| 216 | |||
| 217 | out_buffer = icon_data; | ||
| 214 | return ResultStatus::Success; | 218 | return ResultStatus::Success; |
| 215 | } | 219 | } |
| 216 | 220 | ||
| @@ -219,10 +223,12 @@ ResultStatus AppLoader_DeconstructedRomDirectory::ReadProgramId(u64& out_program | |||
| 219 | return ResultStatus::Success; | 223 | return ResultStatus::Success; |
| 220 | } | 224 | } |
| 221 | 225 | ||
| 222 | ResultStatus AppLoader_DeconstructedRomDirectory::ReadTitle(std::string& title) { | 226 | ResultStatus AppLoader_DeconstructedRomDirectory::ReadTitle(std::string& out_title) { |
| 223 | if (name.empty()) | 227 | if (name.empty()) { |
| 224 | return ResultStatus::ErrorNoControl; | 228 | return ResultStatus::ErrorNoControl; |
| 225 | title = name; | 229 | } |
| 230 | |||
| 231 | out_title = name; | ||
| 226 | return ResultStatus::Success; | 232 | return ResultStatus::Success; |
| 227 | } | 233 | } |
| 228 | 234 | ||
| @@ -230,12 +236,12 @@ bool AppLoader_DeconstructedRomDirectory::IsRomFSUpdatable() const { | |||
| 230 | return false; | 236 | return false; |
| 231 | } | 237 | } |
| 232 | 238 | ||
| 233 | ResultStatus AppLoader_DeconstructedRomDirectory::ReadNSOModules(Modules& modules) { | 239 | ResultStatus AppLoader_DeconstructedRomDirectory::ReadNSOModules(Modules& out_modules) { |
| 234 | if (!is_loaded) { | 240 | if (!is_loaded) { |
| 235 | return ResultStatus::ErrorNotInitialized; | 241 | return ResultStatus::ErrorNotInitialized; |
| 236 | } | 242 | } |
| 237 | 243 | ||
| 238 | modules = this->modules; | 244 | out_modules = this->modules; |
| 239 | return ResultStatus::Success; | 245 | return ResultStatus::Success; |
| 240 | } | 246 | } |
| 241 | 247 | ||
diff --git a/src/core/loader/deconstructed_rom_directory.h b/src/core/loader/deconstructed_rom_directory.h index 3c968580f..c2b46e1bf 100644 --- a/src/core/loader/deconstructed_rom_directory.h +++ b/src/core/loader/deconstructed_rom_directory.h | |||
| @@ -43,13 +43,13 @@ public: | |||
| 43 | 43 | ||
| 44 | LoadResult Load(Kernel::Process& process, Core::System& system) override; | 44 | LoadResult Load(Kernel::Process& process, Core::System& system) override; |
| 45 | 45 | ||
| 46 | ResultStatus ReadRomFS(FileSys::VirtualFile& dir) override; | 46 | ResultStatus ReadRomFS(FileSys::VirtualFile& out_dir) override; |
| 47 | ResultStatus ReadIcon(std::vector<u8>& buffer) override; | 47 | ResultStatus ReadIcon(std::vector<u8>& out_buffer) override; |
| 48 | ResultStatus ReadProgramId(u64& out_program_id) override; | 48 | ResultStatus ReadProgramId(u64& out_program_id) override; |
| 49 | ResultStatus ReadTitle(std::string& title) override; | 49 | ResultStatus ReadTitle(std::string& title) override; |
| 50 | bool IsRomFSUpdatable() const override; | 50 | bool IsRomFSUpdatable() const override; |
| 51 | 51 | ||
| 52 | ResultStatus ReadNSOModules(Modules& modules) override; | 52 | ResultStatus ReadNSOModules(Modules& out_modules) override; |
| 53 | 53 | ||
| 54 | private: | 54 | private: |
| 55 | FileSys::ProgramMetadata metadata; | 55 | FileSys::ProgramMetadata metadata; |
diff --git a/src/core/loader/elf.cpp b/src/core/loader/elf.cpp index f4a339390..627c18c7e 100644 --- a/src/core/loader/elf.cpp +++ b/src/core/loader/elf.cpp | |||
| @@ -364,21 +364,24 @@ SectionID ElfReader::GetSectionByName(const char* name, int firstSection) const | |||
| 364 | 364 | ||
| 365 | namespace Loader { | 365 | namespace Loader { |
| 366 | 366 | ||
| 367 | AppLoader_ELF::AppLoader_ELF(FileSys::VirtualFile file) : AppLoader(std::move(file)) {} | 367 | AppLoader_ELF::AppLoader_ELF(FileSys::VirtualFile file_) : AppLoader(std::move(file_)) {} |
| 368 | 368 | ||
| 369 | FileType AppLoader_ELF::IdentifyType(const FileSys::VirtualFile& file) { | 369 | FileType AppLoader_ELF::IdentifyType(const FileSys::VirtualFile& elf_file) { |
| 370 | static constexpr u16 ELF_MACHINE_ARM{0x28}; | 370 | static constexpr u16 ELF_MACHINE_ARM{0x28}; |
| 371 | 371 | ||
| 372 | u32 magic = 0; | 372 | u32 magic = 0; |
| 373 | if (4 != file->ReadObject(&magic)) | 373 | if (4 != elf_file->ReadObject(&magic)) { |
| 374 | return FileType::Error; | 374 | return FileType::Error; |
| 375 | } | ||
| 375 | 376 | ||
| 376 | u16 machine = 0; | 377 | u16 machine = 0; |
| 377 | if (2 != file->ReadObject(&machine, 18)) | 378 | if (2 != elf_file->ReadObject(&machine, 18)) { |
| 378 | return FileType::Error; | 379 | return FileType::Error; |
| 380 | } | ||
| 379 | 381 | ||
| 380 | if (Common::MakeMagic('\x7f', 'E', 'L', 'F') == magic && ELF_MACHINE_ARM == machine) | 382 | if (Common::MakeMagic('\x7f', 'E', 'L', 'F') == magic && ELF_MACHINE_ARM == machine) { |
| 381 | return FileType::ELF; | 383 | return FileType::ELF; |
| 384 | } | ||
| 382 | 385 | ||
| 383 | return FileType::Error; | 386 | return FileType::Error; |
| 384 | } | 387 | } |
diff --git a/src/core/loader/elf.h b/src/core/loader/elf.h index 2067932c7..2b86c0b49 100644 --- a/src/core/loader/elf.h +++ b/src/core/loader/elf.h | |||
| @@ -20,11 +20,13 @@ public: | |||
| 20 | explicit AppLoader_ELF(FileSys::VirtualFile file); | 20 | explicit AppLoader_ELF(FileSys::VirtualFile file); |
| 21 | 21 | ||
| 22 | /** | 22 | /** |
| 23 | * Returns the type of the file | 23 | * Identifies whether or not the given file is an ELF file. |
| 24 | * @param file open file | 24 | * |
| 25 | * @return FileType found, or FileType::Error if this loader doesn't know it | 25 | * @param elf_file The file to identify. |
| 26 | * | ||
| 27 | * @return FileType::ELF, or FileType::Error if the file is not an ELF file. | ||
| 26 | */ | 28 | */ |
| 27 | static FileType IdentifyType(const FileSys::VirtualFile& file); | 29 | static FileType IdentifyType(const FileSys::VirtualFile& elf_file); |
| 28 | 30 | ||
| 29 | FileType GetFileType() const override { | 31 | FileType GetFileType() const override { |
| 30 | return IdentifyType(file); | 32 | return IdentifyType(file); |
diff --git a/src/core/loader/kip.cpp b/src/core/loader/kip.cpp index 55e6de794..9b447da2a 100644 --- a/src/core/loader/kip.cpp +++ b/src/core/loader/kip.cpp | |||
| @@ -24,9 +24,9 @@ AppLoader_KIP::AppLoader_KIP(FileSys::VirtualFile file_) | |||
| 24 | 24 | ||
| 25 | AppLoader_KIP::~AppLoader_KIP() = default; | 25 | AppLoader_KIP::~AppLoader_KIP() = default; |
| 26 | 26 | ||
| 27 | FileType AppLoader_KIP::IdentifyType(const FileSys::VirtualFile& file) { | 27 | FileType AppLoader_KIP::IdentifyType(const FileSys::VirtualFile& in_file) { |
| 28 | u32_le magic{}; | 28 | u32_le magic{}; |
| 29 | if (file->GetSize() < sizeof(u32) || file->ReadObject(&magic) != sizeof(u32)) { | 29 | if (in_file->GetSize() < sizeof(u32) || in_file->ReadObject(&magic) != sizeof(u32)) { |
| 30 | return FileType::Error; | 30 | return FileType::Error; |
| 31 | } | 31 | } |
| 32 | 32 | ||
| @@ -56,10 +56,10 @@ AppLoader::LoadResult AppLoader_KIP::Load(Kernel::Process& process, | |||
| 56 | return {kip->GetStatus(), {}}; | 56 | return {kip->GetStatus(), {}}; |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | const auto get_kip_address_space_type = [](const auto& kip) { | 59 | const auto get_kip_address_space_type = [](const auto& kip_type) { |
| 60 | return kip.Is64Bit() | 60 | return kip_type.Is64Bit() |
| 61 | ? (kip.Is39BitAddressSpace() ? FileSys::ProgramAddressSpaceType::Is39Bit | 61 | ? (kip_type.Is39BitAddressSpace() ? FileSys::ProgramAddressSpaceType::Is39Bit |
| 62 | : FileSys::ProgramAddressSpaceType::Is36Bit) | 62 | : FileSys::ProgramAddressSpaceType::Is36Bit) |
| 63 | : FileSys::ProgramAddressSpaceType::Is32Bit; | 63 | : FileSys::ProgramAddressSpaceType::Is32Bit; |
| 64 | }; | 64 | }; |
| 65 | 65 | ||
diff --git a/src/core/loader/kip.h b/src/core/loader/kip.h index 14a85e295..2fe636f01 100644 --- a/src/core/loader/kip.h +++ b/src/core/loader/kip.h | |||
| @@ -22,11 +22,13 @@ public: | |||
| 22 | ~AppLoader_KIP() override; | 22 | ~AppLoader_KIP() override; |
| 23 | 23 | ||
| 24 | /** | 24 | /** |
| 25 | * Returns the type of the file | 25 | * Identifies whether or not the given file is a KIP. |
| 26 | * @param file open file | 26 | * |
| 27 | * @return FileType found, or FileType::Error if this loader doesn't know it | 27 | * @param in_file The file to identify. |
| 28 | * | ||
| 29 | * @return FileType::KIP if found, or FileType::Error if unknown. | ||
| 28 | */ | 30 | */ |
| 29 | static FileType IdentifyType(const FileSys::VirtualFile& file); | 31 | static FileType IdentifyType(const FileSys::VirtualFile& in_file); |
| 30 | 32 | ||
| 31 | FileType GetFileType() const override; | 33 | FileType GetFileType() const override; |
| 32 | 34 | ||
diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h index b2e5b13de..bf6db1ab1 100644 --- a/src/core/loader/loader.h +++ b/src/core/loader/loader.h | |||
| @@ -152,21 +152,26 @@ public: | |||
| 152 | 152 | ||
| 153 | /** | 153 | /** |
| 154 | * Returns the type of this file | 154 | * Returns the type of this file |
| 155 | * | ||
| 155 | * @return FileType corresponding to the loaded file | 156 | * @return FileType corresponding to the loaded file |
| 156 | */ | 157 | */ |
| 157 | virtual FileType GetFileType() const = 0; | 158 | virtual FileType GetFileType() const = 0; |
| 158 | 159 | ||
| 159 | /** | 160 | /** |
| 160 | * Load the application and return the created Process instance | 161 | * Load the application and return the created Process instance |
| 162 | * | ||
| 161 | * @param process The newly created process. | 163 | * @param process The newly created process. |
| 162 | * @param system The system that this process is being loaded under. | 164 | * @param system The system that this process is being loaded under. |
| 165 | * | ||
| 163 | * @return The status result of the operation. | 166 | * @return The status result of the operation. |
| 164 | */ | 167 | */ |
| 165 | virtual LoadResult Load(Kernel::Process& process, Core::System& system) = 0; | 168 | virtual LoadResult Load(Kernel::Process& process, Core::System& system) = 0; |
| 166 | 169 | ||
| 167 | /** | 170 | /** |
| 168 | * Get the code (typically .code section) of the application | 171 | * Get the code (typically .code section) of the application |
| 169 | * @param buffer Reference to buffer to store data | 172 | * |
| 173 | * @param[out] buffer Reference to buffer to store data | ||
| 174 | * | ||
| 170 | * @return ResultStatus result of function | 175 | * @return ResultStatus result of function |
| 171 | */ | 176 | */ |
| 172 | virtual ResultStatus ReadCode(std::vector<u8>& buffer) { | 177 | virtual ResultStatus ReadCode(std::vector<u8>& buffer) { |
| @@ -175,7 +180,9 @@ public: | |||
| 175 | 180 | ||
| 176 | /** | 181 | /** |
| 177 | * Get the icon (typically icon section) of the application | 182 | * Get the icon (typically icon section) of the application |
| 178 | * @param buffer Reference to buffer to store data | 183 | * |
| 184 | * @param[out] buffer Reference to buffer to store data | ||
| 185 | * | ||
| 179 | * @return ResultStatus result of function | 186 | * @return ResultStatus result of function |
| 180 | */ | 187 | */ |
| 181 | virtual ResultStatus ReadIcon(std::vector<u8>& buffer) { | 188 | virtual ResultStatus ReadIcon(std::vector<u8>& buffer) { |
| @@ -186,7 +193,9 @@ public: | |||
| 186 | * Get the banner (typically banner section) of the application | 193 | * Get the banner (typically banner section) of the application |
| 187 | * In the context of NX, this is the animation that displays in the bottom right of the screen | 194 | * In the context of NX, this is the animation that displays in the bottom right of the screen |
| 188 | * when a game boots. Stored in GIF format. | 195 | * when a game boots. Stored in GIF format. |
| 189 | * @param buffer Reference to buffer to store data | 196 | * |
| 197 | * @param[out] buffer Reference to buffer to store data | ||
| 198 | * | ||
| 190 | * @return ResultStatus result of function | 199 | * @return ResultStatus result of function |
| 191 | */ | 200 | */ |
| 192 | virtual ResultStatus ReadBanner(std::vector<u8>& buffer) { | 201 | virtual ResultStatus ReadBanner(std::vector<u8>& buffer) { |
| @@ -197,7 +206,9 @@ public: | |||
| 197 | * Get the logo (typically logo section) of the application | 206 | * Get the logo (typically logo section) of the application |
| 198 | * In the context of NX, this is the static image that displays in the top left of the screen | 207 | * In the context of NX, this is the static image that displays in the top left of the screen |
| 199 | * when a game boots. Stored in JPEG format. | 208 | * when a game boots. Stored in JPEG format. |
| 200 | * @param buffer Reference to buffer to store data | 209 | * |
| 210 | * @param[out] buffer Reference to buffer to store data | ||
| 211 | * | ||
| 201 | * @return ResultStatus result of function | 212 | * @return ResultStatus result of function |
| 202 | */ | 213 | */ |
| 203 | virtual ResultStatus ReadLogo(std::vector<u8>& buffer) { | 214 | virtual ResultStatus ReadLogo(std::vector<u8>& buffer) { |
| @@ -206,7 +217,9 @@ public: | |||
| 206 | 217 | ||
| 207 | /** | 218 | /** |
| 208 | * Get the program id of the application | 219 | * Get the program id of the application |
| 209 | * @param out_program_id Reference to store program id into | 220 | * |
| 221 | * @param[out] out_program_id Reference to store program id into | ||
| 222 | * | ||
| 210 | * @return ResultStatus result of function | 223 | * @return ResultStatus result of function |
| 211 | */ | 224 | */ |
| 212 | virtual ResultStatus ReadProgramId(u64& out_program_id) { | 225 | virtual ResultStatus ReadProgramId(u64& out_program_id) { |
| @@ -216,19 +229,23 @@ public: | |||
| 216 | /** | 229 | /** |
| 217 | * Get the RomFS of the application | 230 | * Get the RomFS of the application |
| 218 | * Since the RomFS can be huge, we return a file reference instead of copying to a buffer | 231 | * Since the RomFS can be huge, we return a file reference instead of copying to a buffer |
| 219 | * @param file The directory containing the RomFS | 232 | * |
| 233 | * @param[out] out_file The directory containing the RomFS | ||
| 234 | * | ||
| 220 | * @return ResultStatus result of function | 235 | * @return ResultStatus result of function |
| 221 | */ | 236 | */ |
| 222 | virtual ResultStatus ReadRomFS(FileSys::VirtualFile& file) { | 237 | virtual ResultStatus ReadRomFS(FileSys::VirtualFile& out_file) { |
| 223 | return ResultStatus::ErrorNotImplemented; | 238 | return ResultStatus::ErrorNotImplemented; |
| 224 | } | 239 | } |
| 225 | 240 | ||
| 226 | /** | 241 | /** |
| 227 | * Get the raw update of the application, should it come packed with one | 242 | * Get the raw update of the application, should it come packed with one |
| 228 | * @param file The raw update NCA file (Program-type | 243 | * |
| 244 | * @param[out] out_file The raw update NCA file (Program-type) | ||
| 245 | * | ||
| 229 | * @return ResultStatus result of function | 246 | * @return ResultStatus result of function |
| 230 | */ | 247 | */ |
| 231 | virtual ResultStatus ReadUpdateRaw(FileSys::VirtualFile& file) { | 248 | virtual ResultStatus ReadUpdateRaw(FileSys::VirtualFile& out_file) { |
| 232 | return ResultStatus::ErrorNotImplemented; | 249 | return ResultStatus::ErrorNotImplemented; |
| 233 | } | 250 | } |
| 234 | 251 | ||
| @@ -236,7 +253,8 @@ public: | |||
| 236 | * Get whether or not updates can be applied to the RomFS. | 253 | * Get whether or not updates can be applied to the RomFS. |
| 237 | * By default, this is true, however for formats where it cannot be guaranteed that the RomFS is | 254 | * By default, this is true, however for formats where it cannot be guaranteed that the RomFS is |
| 238 | * the base game it should be set to false. | 255 | * the base game it should be set to false. |
| 239 | * @return bool whether or not updatable. | 256 | * |
| 257 | * @return bool indicating whether or not the RomFS is updatable. | ||
| 240 | */ | 258 | */ |
| 241 | virtual bool IsRomFSUpdatable() const { | 259 | virtual bool IsRomFSUpdatable() const { |
| 242 | return true; | 260 | return true; |
| @@ -244,8 +262,9 @@ public: | |||
| 244 | 262 | ||
| 245 | /** | 263 | /** |
| 246 | * Gets the difference between the start of the IVFC header and the start of level 6 (RomFS) | 264 | * Gets the difference between the start of the IVFC header and the start of level 6 (RomFS) |
| 247 | * data. Needed for bktr patching. | 265 | * data. Needed for BKTR patching. |
| 248 | * @return IVFC offset for romfs. | 266 | * |
| 267 | * @return IVFC offset for RomFS. | ||
| 249 | */ | 268 | */ |
| 250 | virtual u64 ReadRomFSIVFCOffset() const { | 269 | virtual u64 ReadRomFSIVFCOffset() const { |
| 251 | return 0; | 270 | return 0; |
| @@ -253,7 +272,9 @@ public: | |||
| 253 | 272 | ||
| 254 | /** | 273 | /** |
| 255 | * Get the title of the application | 274 | * Get the title of the application |
| 256 | * @param title Reference to store the application title into | 275 | * |
| 276 | * @param[out] title Reference to store the application title into | ||
| 277 | * | ||
| 257 | * @return ResultStatus result of function | 278 | * @return ResultStatus result of function |
| 258 | */ | 279 | */ |
| 259 | virtual ResultStatus ReadTitle(std::string& title) { | 280 | virtual ResultStatus ReadTitle(std::string& title) { |
| @@ -262,7 +283,9 @@ public: | |||
| 262 | 283 | ||
| 263 | /** | 284 | /** |
| 264 | * Get the control data (CNMT) of the application | 285 | * Get the control data (CNMT) of the application |
| 265 | * @param control Reference to store the application control data into | 286 | * |
| 287 | * @param[out] control Reference to store the application control data into | ||
| 288 | * | ||
| 266 | * @return ResultStatus result of function | 289 | * @return ResultStatus result of function |
| 267 | */ | 290 | */ |
| 268 | virtual ResultStatus ReadControlData(FileSys::NACP& control) { | 291 | virtual ResultStatus ReadControlData(FileSys::NACP& control) { |
| @@ -271,10 +294,12 @@ public: | |||
| 271 | 294 | ||
| 272 | /** | 295 | /** |
| 273 | * Get the RomFS of the manual of the application | 296 | * Get the RomFS of the manual of the application |
| 274 | * @param file The raw manual RomFS of the game | 297 | * |
| 298 | * @param[out] out_file The raw manual RomFS of the game | ||
| 299 | * | ||
| 275 | * @return ResultStatus result of function | 300 | * @return ResultStatus result of function |
| 276 | */ | 301 | */ |
| 277 | virtual ResultStatus ReadManualRomFS(FileSys::VirtualFile& file) { | 302 | virtual ResultStatus ReadManualRomFS(FileSys::VirtualFile& out_file) { |
| 278 | return ResultStatus::ErrorNotImplemented; | 303 | return ResultStatus::ErrorNotImplemented; |
| 279 | } | 304 | } |
| 280 | 305 | ||
diff --git a/src/core/loader/nax.cpp b/src/core/loader/nax.cpp index 49028177b..f53c3a72c 100644 --- a/src/core/loader/nax.cpp +++ b/src/core/loader/nax.cpp | |||
| @@ -26,14 +26,14 @@ FileType IdentifyTypeImpl(const FileSys::NAX& nax) { | |||
| 26 | } | 26 | } |
| 27 | } // Anonymous namespace | 27 | } // Anonymous namespace |
| 28 | 28 | ||
| 29 | AppLoader_NAX::AppLoader_NAX(FileSys::VirtualFile file) | 29 | AppLoader_NAX::AppLoader_NAX(FileSys::VirtualFile file_) |
| 30 | : AppLoader(file), nax(std::make_unique<FileSys::NAX>(file)), | 30 | : AppLoader(file_), nax(std::make_unique<FileSys::NAX>(file_)), |
| 31 | nca_loader(std::make_unique<AppLoader_NCA>(nax->GetDecrypted())) {} | 31 | nca_loader(std::make_unique<AppLoader_NCA>(nax->GetDecrypted())) {} |
| 32 | 32 | ||
| 33 | AppLoader_NAX::~AppLoader_NAX() = default; | 33 | AppLoader_NAX::~AppLoader_NAX() = default; |
| 34 | 34 | ||
| 35 | FileType AppLoader_NAX::IdentifyType(const FileSys::VirtualFile& file) { | 35 | FileType AppLoader_NAX::IdentifyType(const FileSys::VirtualFile& nax_file) { |
| 36 | const FileSys::NAX nax(file); | 36 | const FileSys::NAX nax(nax_file); |
| 37 | return IdentifyTypeImpl(nax); | 37 | return IdentifyTypeImpl(nax); |
| 38 | } | 38 | } |
| 39 | 39 | ||
| @@ -41,8 +41,7 @@ FileType AppLoader_NAX::GetFileType() const { | |||
| 41 | return IdentifyTypeImpl(*nax); | 41 | return IdentifyTypeImpl(*nax); |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | AppLoader_NAX::LoadResult AppLoader_NAX::Load(Kernel::Process& process, | 44 | AppLoader_NAX::LoadResult AppLoader_NAX::Load(Kernel::Process& process, Core::System& system) { |
| 45 | [[maybe_unused]] Core::System& system) { | ||
| 46 | if (is_loaded) { | 45 | if (is_loaded) { |
| 47 | return {ResultStatus::ErrorAlreadyLoaded, {}}; | 46 | return {ResultStatus::ErrorAlreadyLoaded, {}}; |
| 48 | } | 47 | } |
diff --git a/src/core/loader/nax.h b/src/core/loader/nax.h index a5b5e2ae1..68427c1cf 100644 --- a/src/core/loader/nax.h +++ b/src/core/loader/nax.h | |||
| @@ -23,15 +23,17 @@ class AppLoader_NCA; | |||
| 23 | /// Loads a NAX file | 23 | /// Loads a NAX file |
| 24 | class AppLoader_NAX final : public AppLoader { | 24 | class AppLoader_NAX final : public AppLoader { |
| 25 | public: | 25 | public: |
| 26 | explicit AppLoader_NAX(FileSys::VirtualFile file); | 26 | explicit AppLoader_NAX(FileSys::VirtualFile file_); |
| 27 | ~AppLoader_NAX() override; | 27 | ~AppLoader_NAX() override; |
| 28 | 28 | ||
| 29 | /** | 29 | /** |
| 30 | * Returns the type of the file | 30 | * Identifies whether or not the given file is a NAX file. |
| 31 | * @param file open file | 31 | * |
| 32 | * @return FileType found, or FileType::Error if this loader doesn't know it | 32 | * @param nax_file The file to identify. |
| 33 | * | ||
| 34 | * @return FileType::NAX, or FileType::Error if the file is not a NAX file. | ||
| 33 | */ | 35 | */ |
| 34 | static FileType IdentifyType(const FileSys::VirtualFile& file); | 36 | static FileType IdentifyType(const FileSys::VirtualFile& nax_file); |
| 35 | 37 | ||
| 36 | FileType GetFileType() const override; | 38 | FileType GetFileType() const override; |
| 37 | 39 | ||
diff --git a/src/core/loader/nca.cpp b/src/core/loader/nca.cpp index fa694de37..47e7a77a9 100644 --- a/src/core/loader/nca.cpp +++ b/src/core/loader/nca.cpp | |||
| @@ -21,12 +21,13 @@ AppLoader_NCA::AppLoader_NCA(FileSys::VirtualFile file_) | |||
| 21 | 21 | ||
| 22 | AppLoader_NCA::~AppLoader_NCA() = default; | 22 | AppLoader_NCA::~AppLoader_NCA() = default; |
| 23 | 23 | ||
| 24 | FileType AppLoader_NCA::IdentifyType(const FileSys::VirtualFile& file) { | 24 | FileType AppLoader_NCA::IdentifyType(const FileSys::VirtualFile& nca_file) { |
| 25 | FileSys::NCA nca(file); | 25 | const FileSys::NCA nca(nca_file); |
| 26 | 26 | ||
| 27 | if (nca.GetStatus() == ResultStatus::Success && | 27 | if (nca.GetStatus() == ResultStatus::Success && |
| 28 | nca.GetType() == FileSys::NCAContentType::Program) | 28 | nca.GetType() == FileSys::NCAContentType::Program) { |
| 29 | return FileType::NCA; | 29 | return FileType::NCA; |
| 30 | } | ||
| 30 | 31 | ||
| 31 | return FileType::Error; | 32 | return FileType::Error; |
| 32 | } | 33 | } |
| @@ -67,43 +68,59 @@ AppLoader_NCA::LoadResult AppLoader_NCA::Load(Kernel::Process& process, Core::Sy | |||
| 67 | } | 68 | } |
| 68 | 69 | ||
| 69 | ResultStatus AppLoader_NCA::ReadRomFS(FileSys::VirtualFile& dir) { | 70 | ResultStatus AppLoader_NCA::ReadRomFS(FileSys::VirtualFile& dir) { |
| 70 | if (nca == nullptr) | 71 | if (nca == nullptr) { |
| 71 | return ResultStatus::ErrorNotInitialized; | 72 | return ResultStatus::ErrorNotInitialized; |
| 72 | if (nca->GetRomFS() == nullptr || nca->GetRomFS()->GetSize() == 0) | 73 | } |
| 74 | |||
| 75 | if (nca->GetRomFS() == nullptr || nca->GetRomFS()->GetSize() == 0) { | ||
| 73 | return ResultStatus::ErrorNoRomFS; | 76 | return ResultStatus::ErrorNoRomFS; |
| 77 | } | ||
| 78 | |||
| 74 | dir = nca->GetRomFS(); | 79 | dir = nca->GetRomFS(); |
| 75 | return ResultStatus::Success; | 80 | return ResultStatus::Success; |
| 76 | } | 81 | } |
| 77 | 82 | ||
| 78 | u64 AppLoader_NCA::ReadRomFSIVFCOffset() const { | 83 | u64 AppLoader_NCA::ReadRomFSIVFCOffset() const { |
| 79 | if (nca == nullptr) | 84 | if (nca == nullptr) { |
| 80 | return 0; | 85 | return 0; |
| 86 | } | ||
| 87 | |||
| 81 | return nca->GetBaseIVFCOffset(); | 88 | return nca->GetBaseIVFCOffset(); |
| 82 | } | 89 | } |
| 83 | 90 | ||
| 84 | ResultStatus AppLoader_NCA::ReadProgramId(u64& out_program_id) { | 91 | ResultStatus AppLoader_NCA::ReadProgramId(u64& out_program_id) { |
| 85 | if (nca == nullptr || nca->GetStatus() != ResultStatus::Success) | 92 | if (nca == nullptr || nca->GetStatus() != ResultStatus::Success) { |
| 86 | return ResultStatus::ErrorNotInitialized; | 93 | return ResultStatus::ErrorNotInitialized; |
| 94 | } | ||
| 95 | |||
| 87 | out_program_id = nca->GetTitleId(); | 96 | out_program_id = nca->GetTitleId(); |
| 88 | return ResultStatus::Success; | 97 | return ResultStatus::Success; |
| 89 | } | 98 | } |
| 90 | 99 | ||
| 91 | ResultStatus AppLoader_NCA::ReadBanner(std::vector<u8>& buffer) { | 100 | ResultStatus AppLoader_NCA::ReadBanner(std::vector<u8>& buffer) { |
| 92 | if (nca == nullptr || nca->GetStatus() != ResultStatus::Success) | 101 | if (nca == nullptr || nca->GetStatus() != ResultStatus::Success) { |
| 93 | return ResultStatus::ErrorNotInitialized; | 102 | return ResultStatus::ErrorNotInitialized; |
| 103 | } | ||
| 104 | |||
| 94 | const auto logo = nca->GetLogoPartition(); | 105 | const auto logo = nca->GetLogoPartition(); |
| 95 | if (logo == nullptr) | 106 | if (logo == nullptr) { |
| 96 | return ResultStatus::ErrorNoIcon; | 107 | return ResultStatus::ErrorNoIcon; |
| 108 | } | ||
| 109 | |||
| 97 | buffer = logo->GetFile("StartupMovie.gif")->ReadAllBytes(); | 110 | buffer = logo->GetFile("StartupMovie.gif")->ReadAllBytes(); |
| 98 | return ResultStatus::Success; | 111 | return ResultStatus::Success; |
| 99 | } | 112 | } |
| 100 | 113 | ||
| 101 | ResultStatus AppLoader_NCA::ReadLogo(std::vector<u8>& buffer) { | 114 | ResultStatus AppLoader_NCA::ReadLogo(std::vector<u8>& buffer) { |
| 102 | if (nca == nullptr || nca->GetStatus() != ResultStatus::Success) | 115 | if (nca == nullptr || nca->GetStatus() != ResultStatus::Success) { |
| 103 | return ResultStatus::ErrorNotInitialized; | 116 | return ResultStatus::ErrorNotInitialized; |
| 117 | } | ||
| 118 | |||
| 104 | const auto logo = nca->GetLogoPartition(); | 119 | const auto logo = nca->GetLogoPartition(); |
| 105 | if (logo == nullptr) | 120 | if (logo == nullptr) { |
| 106 | return ResultStatus::ErrorNoIcon; | 121 | return ResultStatus::ErrorNoIcon; |
| 122 | } | ||
| 123 | |||
| 107 | buffer = logo->GetFile("NintendoLogo.png")->ReadAllBytes(); | 124 | buffer = logo->GetFile("NintendoLogo.png")->ReadAllBytes(); |
| 108 | return ResultStatus::Success; | 125 | return ResultStatus::Success; |
| 109 | } | 126 | } |
diff --git a/src/core/loader/nca.h b/src/core/loader/nca.h index 918792800..c9792f390 100644 --- a/src/core/loader/nca.h +++ b/src/core/loader/nca.h | |||
| @@ -23,15 +23,17 @@ class AppLoader_DeconstructedRomDirectory; | |||
| 23 | /// Loads an NCA file | 23 | /// Loads an NCA file |
| 24 | class AppLoader_NCA final : public AppLoader { | 24 | class AppLoader_NCA final : public AppLoader { |
| 25 | public: | 25 | public: |
| 26 | explicit AppLoader_NCA(FileSys::VirtualFile file); | 26 | explicit AppLoader_NCA(FileSys::VirtualFile file_); |
| 27 | ~AppLoader_NCA() override; | 27 | ~AppLoader_NCA() override; |
| 28 | 28 | ||
| 29 | /** | 29 | /** |
| 30 | * Returns the type of the file | 30 | * Identifies whether or not the given file is an NCA file. |
| 31 | * @param file open file | 31 | * |
| 32 | * @return FileType found, or FileType::Error if this loader doesn't know it | 32 | * @param nca_file The file to identify. |
| 33 | * | ||
| 34 | * @return FileType::NCA, or FileType::Error if the file is not an NCA file. | ||
| 33 | */ | 35 | */ |
| 34 | static FileType IdentifyType(const FileSys::VirtualFile& file); | 36 | static FileType IdentifyType(const FileSys::VirtualFile& nca_file); |
| 35 | 37 | ||
| 36 | FileType GetFileType() const override { | 38 | FileType GetFileType() const override { |
| 37 | return IdentifyType(file); | 39 | return IdentifyType(file); |
diff --git a/src/core/loader/nro.cpp b/src/core/loader/nro.cpp index 0115ed0c4..0597cfa60 100644 --- a/src/core/loader/nro.cpp +++ b/src/core/loader/nro.cpp | |||
| @@ -72,7 +72,7 @@ struct AssetHeader { | |||
| 72 | }; | 72 | }; |
| 73 | static_assert(sizeof(AssetHeader) == 0x38, "AssetHeader has incorrect size."); | 73 | static_assert(sizeof(AssetHeader) == 0x38, "AssetHeader has incorrect size."); |
| 74 | 74 | ||
| 75 | AppLoader_NRO::AppLoader_NRO(FileSys::VirtualFile file) : AppLoader(file) { | 75 | AppLoader_NRO::AppLoader_NRO(FileSys::VirtualFile file_) : AppLoader(std::move(file_)) { |
| 76 | NroHeader nro_header{}; | 76 | NroHeader nro_header{}; |
| 77 | if (file->ReadObject(&nro_header) != sizeof(NroHeader)) { | 77 | if (file->ReadObject(&nro_header) != sizeof(NroHeader)) { |
| 78 | return; | 78 | return; |
| @@ -114,10 +114,10 @@ AppLoader_NRO::AppLoader_NRO(FileSys::VirtualFile file) : AppLoader(file) { | |||
| 114 | 114 | ||
| 115 | AppLoader_NRO::~AppLoader_NRO() = default; | 115 | AppLoader_NRO::~AppLoader_NRO() = default; |
| 116 | 116 | ||
| 117 | FileType AppLoader_NRO::IdentifyType(const FileSys::VirtualFile& file) { | 117 | FileType AppLoader_NRO::IdentifyType(const FileSys::VirtualFile& nro_file) { |
| 118 | // Read NSO header | 118 | // Read NSO header |
| 119 | NroHeader nro_header{}; | 119 | NroHeader nro_header{}; |
| 120 | if (sizeof(NroHeader) != file->ReadObject(&nro_header)) { | 120 | if (sizeof(NroHeader) != nro_file->ReadObject(&nro_header)) { |
| 121 | return FileType::Error; | 121 | return FileType::Error; |
| 122 | } | 122 | } |
| 123 | if (nro_header.magic == Common::MakeMagic('N', 'R', 'O', '0')) { | 123 | if (nro_header.magic == Common::MakeMagic('N', 'R', 'O', '0')) { |
| @@ -130,8 +130,7 @@ static constexpr u32 PageAlignSize(u32 size) { | |||
| 130 | return static_cast<u32>((size + Core::Memory::PAGE_MASK) & ~Core::Memory::PAGE_MASK); | 130 | return static_cast<u32>((size + Core::Memory::PAGE_MASK) & ~Core::Memory::PAGE_MASK); |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | static bool LoadNroImpl(Kernel::Process& process, const std::vector<u8>& data, | 133 | static bool LoadNroImpl(Kernel::Process& process, const std::vector<u8>& data) { |
| 134 | const std::string& name) { | ||
| 135 | if (data.size() < sizeof(NroHeader)) { | 134 | if (data.size() < sizeof(NroHeader)) { |
| 136 | return {}; | 135 | return {}; |
| 137 | } | 136 | } |
| @@ -200,8 +199,8 @@ static bool LoadNroImpl(Kernel::Process& process, const std::vector<u8>& data, | |||
| 200 | return true; | 199 | return true; |
| 201 | } | 200 | } |
| 202 | 201 | ||
| 203 | bool AppLoader_NRO::LoadNro(Kernel::Process& process, const FileSys::VfsFile& file) { | 202 | bool AppLoader_NRO::LoadNro(Kernel::Process& process, const FileSys::VfsFile& nro_file) { |
| 204 | return LoadNroImpl(process, file.ReadAllBytes(), file.GetName()); | 203 | return LoadNroImpl(process, nro_file.ReadAllBytes()); |
| 205 | } | 204 | } |
| 206 | 205 | ||
| 207 | AppLoader_NRO::LoadResult AppLoader_NRO::Load(Kernel::Process& process, Core::System& system) { | 206 | AppLoader_NRO::LoadResult AppLoader_NRO::Load(Kernel::Process& process, Core::System& system) { |
diff --git a/src/core/loader/nro.h b/src/core/loader/nro.h index a82b66221..20bbaeb0e 100644 --- a/src/core/loader/nro.h +++ b/src/core/loader/nro.h | |||
| @@ -27,15 +27,17 @@ namespace Loader { | |||
| 27 | /// Loads an NRO file | 27 | /// Loads an NRO file |
| 28 | class AppLoader_NRO final : public AppLoader { | 28 | class AppLoader_NRO final : public AppLoader { |
| 29 | public: | 29 | public: |
| 30 | explicit AppLoader_NRO(FileSys::VirtualFile file); | 30 | explicit AppLoader_NRO(FileSys::VirtualFile file_); |
| 31 | ~AppLoader_NRO() override; | 31 | ~AppLoader_NRO() override; |
| 32 | 32 | ||
| 33 | /** | 33 | /** |
| 34 | * Returns the type of the file | 34 | * Identifies whether or not the given file is an NRO file. |
| 35 | * @param file open file | 35 | * |
| 36 | * @return FileType found, or FileType::Error if this loader doesn't know it | 36 | * @param nro_file The file to identify. |
| 37 | * | ||
| 38 | * @return FileType::NRO, or FileType::Error if the file is not an NRO file. | ||
| 37 | */ | 39 | */ |
| 38 | static FileType IdentifyType(const FileSys::VirtualFile& file); | 40 | static FileType IdentifyType(const FileSys::VirtualFile& nro_file); |
| 39 | 41 | ||
| 40 | FileType GetFileType() const override { | 42 | FileType GetFileType() const override { |
| 41 | return IdentifyType(file); | 43 | return IdentifyType(file); |
| @@ -51,7 +53,7 @@ public: | |||
| 51 | bool IsRomFSUpdatable() const override; | 53 | bool IsRomFSUpdatable() const override; |
| 52 | 54 | ||
| 53 | private: | 55 | private: |
| 54 | bool LoadNro(Kernel::Process& process, const FileSys::VfsFile& file); | 56 | bool LoadNro(Kernel::Process& process, const FileSys::VfsFile& nro_file); |
| 55 | 57 | ||
| 56 | std::vector<u8> icon_data; | 58 | std::vector<u8> icon_data; |
| 57 | std::unique_ptr<FileSys::NACP> nacp; | 59 | std::unique_ptr<FileSys::NACP> nacp; |
diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp index 0c83dd666..f671afe02 100644 --- a/src/core/loader/nso.cpp +++ b/src/core/loader/nso.cpp | |||
| @@ -56,11 +56,11 @@ bool NSOHeader::IsSegmentCompressed(size_t segment_num) const { | |||
| 56 | return ((flags >> segment_num) & 1) != 0; | 56 | return ((flags >> segment_num) & 1) != 0; |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | AppLoader_NSO::AppLoader_NSO(FileSys::VirtualFile file) : AppLoader(std::move(file)) {} | 59 | AppLoader_NSO::AppLoader_NSO(FileSys::VirtualFile file_) : AppLoader(std::move(file_)) {} |
| 60 | 60 | ||
| 61 | FileType AppLoader_NSO::IdentifyType(const FileSys::VirtualFile& file) { | 61 | FileType AppLoader_NSO::IdentifyType(const FileSys::VirtualFile& in_file) { |
| 62 | u32 magic = 0; | 62 | u32 magic = 0; |
| 63 | if (file->ReadObject(&magic) != sizeof(magic)) { | 63 | if (in_file->ReadObject(&magic) != sizeof(magic)) { |
| 64 | return FileType::Error; | 64 | return FileType::Error; |
| 65 | } | 65 | } |
| 66 | 66 | ||
| @@ -72,15 +72,15 @@ FileType AppLoader_NSO::IdentifyType(const FileSys::VirtualFile& file) { | |||
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::Process& process, Core::System& system, | 74 | std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::Process& process, Core::System& system, |
| 75 | const FileSys::VfsFile& file, VAddr load_base, | 75 | const FileSys::VfsFile& nso_file, VAddr load_base, |
| 76 | bool should_pass_arguments, bool load_into_process, | 76 | bool should_pass_arguments, bool load_into_process, |
| 77 | std::optional<FileSys::PatchManager> pm) { | 77 | std::optional<FileSys::PatchManager> pm) { |
| 78 | if (file.GetSize() < sizeof(NSOHeader)) { | 78 | if (nso_file.GetSize() < sizeof(NSOHeader)) { |
| 79 | return std::nullopt; | 79 | return std::nullopt; |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | NSOHeader nso_header{}; | 82 | NSOHeader nso_header{}; |
| 83 | if (sizeof(NSOHeader) != file.ReadObject(&nso_header)) { | 83 | if (sizeof(NSOHeader) != nso_file.ReadObject(&nso_header)) { |
| 84 | return std::nullopt; | 84 | return std::nullopt; |
| 85 | } | 85 | } |
| 86 | 86 | ||
| @@ -92,8 +92,8 @@ std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::Process& process, Core::S | |||
| 92 | Kernel::CodeSet codeset; | 92 | Kernel::CodeSet codeset; |
| 93 | Kernel::PhysicalMemory program_image; | 93 | Kernel::PhysicalMemory program_image; |
| 94 | for (std::size_t i = 0; i < nso_header.segments.size(); ++i) { | 94 | for (std::size_t i = 0; i < nso_header.segments.size(); ++i) { |
| 95 | std::vector<u8> data = | 95 | std::vector<u8> data = nso_file.ReadBytes(nso_header.segments_compressed_size[i], |
| 96 | file.ReadBytes(nso_header.segments_compressed_size[i], nso_header.segments[i].offset); | 96 | nso_header.segments[i].offset); |
| 97 | if (nso_header.IsSegmentCompressed(i)) { | 97 | if (nso_header.IsSegmentCompressed(i)) { |
| 98 | data = DecompressSegment(data, nso_header.segments[i]); | 98 | data = DecompressSegment(data, nso_header.segments[i]); |
| 99 | } | 99 | } |
| @@ -136,7 +136,7 @@ std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::Process& process, Core::S | |||
| 136 | pi_header.insert(pi_header.begin() + sizeof(NSOHeader), program_image.data(), | 136 | pi_header.insert(pi_header.begin() + sizeof(NSOHeader), program_image.data(), |
| 137 | program_image.data() + program_image.size()); | 137 | program_image.data() + program_image.size()); |
| 138 | 138 | ||
| 139 | pi_header = pm->PatchNSO(pi_header, file.GetName()); | 139 | pi_header = pm->PatchNSO(pi_header, nso_file.GetName()); |
| 140 | 140 | ||
| 141 | std::copy(pi_header.begin() + sizeof(NSOHeader), pi_header.end(), program_image.data()); | 141 | std::copy(pi_header.begin() + sizeof(NSOHeader), pi_header.end(), program_image.data()); |
| 142 | } | 142 | } |
| @@ -183,8 +183,8 @@ AppLoader_NSO::LoadResult AppLoader_NSO::Load(Kernel::Process& process, Core::Sy | |||
| 183 | Core::Memory::DEFAULT_STACK_SIZE}}; | 183 | Core::Memory::DEFAULT_STACK_SIZE}}; |
| 184 | } | 184 | } |
| 185 | 185 | ||
| 186 | ResultStatus AppLoader_NSO::ReadNSOModules(Modules& modules) { | 186 | ResultStatus AppLoader_NSO::ReadNSOModules(Modules& out_modules) { |
| 187 | modules = this->modules; | 187 | out_modules = this->modules; |
| 188 | return ResultStatus::Success; | 188 | return ResultStatus::Success; |
| 189 | } | 189 | } |
| 190 | 190 | ||
diff --git a/src/core/loader/nso.h b/src/core/loader/nso.h index 3af461b5f..195149b55 100644 --- a/src/core/loader/nso.h +++ b/src/core/loader/nso.h | |||
| @@ -71,27 +71,29 @@ static_assert(sizeof(NSOArgumentHeader) == 0x20, "NSOArgumentHeader has incorrec | |||
| 71 | /// Loads an NSO file | 71 | /// Loads an NSO file |
| 72 | class AppLoader_NSO final : public AppLoader { | 72 | class AppLoader_NSO final : public AppLoader { |
| 73 | public: | 73 | public: |
| 74 | explicit AppLoader_NSO(FileSys::VirtualFile file); | 74 | explicit AppLoader_NSO(FileSys::VirtualFile file_); |
| 75 | 75 | ||
| 76 | /** | 76 | /** |
| 77 | * Returns the type of the file | 77 | * Identifies whether or not the given file is a form of NSO file. |
| 78 | * @param file open file | 78 | * |
| 79 | * @return FileType found, or FileType::Error if this loader doesn't know it | 79 | * @param in_file The file to be identified. |
| 80 | * | ||
| 81 | * @return FileType::NSO if found, or FileType::Error if some other type of file. | ||
| 80 | */ | 82 | */ |
| 81 | static FileType IdentifyType(const FileSys::VirtualFile& file); | 83 | static FileType IdentifyType(const FileSys::VirtualFile& in_file); |
| 82 | 84 | ||
| 83 | FileType GetFileType() const override { | 85 | FileType GetFileType() const override { |
| 84 | return IdentifyType(file); | 86 | return IdentifyType(file); |
| 85 | } | 87 | } |
| 86 | 88 | ||
| 87 | static std::optional<VAddr> LoadModule(Kernel::Process& process, Core::System& system, | 89 | static std::optional<VAddr> LoadModule(Kernel::Process& process, Core::System& system, |
| 88 | const FileSys::VfsFile& file, VAddr load_base, | 90 | const FileSys::VfsFile& nso_file, VAddr load_base, |
| 89 | bool should_pass_arguments, bool load_into_process, | 91 | bool should_pass_arguments, bool load_into_process, |
| 90 | std::optional<FileSys::PatchManager> pm = {}); | 92 | std::optional<FileSys::PatchManager> pm = {}); |
| 91 | 93 | ||
| 92 | LoadResult Load(Kernel::Process& process, Core::System& system) override; | 94 | LoadResult Load(Kernel::Process& process, Core::System& system) override; |
| 93 | 95 | ||
| 94 | ResultStatus ReadNSOModules(Modules& modules) override; | 96 | ResultStatus ReadNSOModules(Modules& out_modules) override; |
| 95 | 97 | ||
| 96 | private: | 98 | private: |
| 97 | Modules modules; | 99 | Modules modules; |
diff --git a/src/core/loader/nsp.cpp b/src/core/loader/nsp.cpp index 928f64c8c..d7e590f1c 100644 --- a/src/core/loader/nsp.cpp +++ b/src/core/loader/nsp.cpp | |||
| @@ -21,11 +21,11 @@ | |||
| 21 | 21 | ||
| 22 | namespace Loader { | 22 | namespace Loader { |
| 23 | 23 | ||
| 24 | AppLoader_NSP::AppLoader_NSP(FileSys::VirtualFile file, | 24 | AppLoader_NSP::AppLoader_NSP(FileSys::VirtualFile file_, |
| 25 | const Service::FileSystem::FileSystemController& fsc, | 25 | const Service::FileSystem::FileSystemController& fsc, |
| 26 | const FileSys::ContentProvider& content_provider, | 26 | const FileSys::ContentProvider& content_provider, |
| 27 | std::size_t program_index) | 27 | std::size_t program_index) |
| 28 | : AppLoader(file), nsp(std::make_unique<FileSys::NSP>(file, program_index)), | 28 | : AppLoader(file_), nsp(std::make_unique<FileSys::NSP>(file_, program_index)), |
| 29 | title_id(nsp->GetProgramTitleID()) { | 29 | title_id(nsp->GetProgramTitleID()) { |
| 30 | 30 | ||
| 31 | if (nsp->GetStatus() != ResultStatus::Success) { | 31 | if (nsp->GetStatus() != ResultStatus::Success) { |
| @@ -57,8 +57,8 @@ AppLoader_NSP::AppLoader_NSP(FileSys::VirtualFile file, | |||
| 57 | 57 | ||
| 58 | AppLoader_NSP::~AppLoader_NSP() = default; | 58 | AppLoader_NSP::~AppLoader_NSP() = default; |
| 59 | 59 | ||
| 60 | FileType AppLoader_NSP::IdentifyType(const FileSys::VirtualFile& file) { | 60 | FileType AppLoader_NSP::IdentifyType(const FileSys::VirtualFile& nsp_file) { |
| 61 | FileSys::NSP nsp(file); | 61 | const FileSys::NSP nsp(nsp_file); |
| 62 | 62 | ||
| 63 | if (nsp.GetStatus() == ResultStatus::Success) { | 63 | if (nsp.GetStatus() == ResultStatus::Success) { |
| 64 | // Extracted Type case | 64 | // Extracted Type case |
| @@ -121,67 +121,80 @@ AppLoader_NSP::LoadResult AppLoader_NSP::Load(Kernel::Process& process, Core::Sy | |||
| 121 | return result; | 121 | return result; |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | ResultStatus AppLoader_NSP::ReadRomFS(FileSys::VirtualFile& file) { | 124 | ResultStatus AppLoader_NSP::ReadRomFS(FileSys::VirtualFile& out_file) { |
| 125 | return secondary_loader->ReadRomFS(file); | 125 | return secondary_loader->ReadRomFS(out_file); |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | u64 AppLoader_NSP::ReadRomFSIVFCOffset() const { | 128 | u64 AppLoader_NSP::ReadRomFSIVFCOffset() const { |
| 129 | return secondary_loader->ReadRomFSIVFCOffset(); | 129 | return secondary_loader->ReadRomFSIVFCOffset(); |
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | ResultStatus AppLoader_NSP::ReadUpdateRaw(FileSys::VirtualFile& file) { | 132 | ResultStatus AppLoader_NSP::ReadUpdateRaw(FileSys::VirtualFile& out_file) { |
| 133 | if (nsp->IsExtractedType()) | 133 | if (nsp->IsExtractedType()) { |
| 134 | return ResultStatus::ErrorNoPackedUpdate; | 134 | return ResultStatus::ErrorNoPackedUpdate; |
| 135 | } | ||
| 135 | 136 | ||
| 136 | const auto read = | 137 | const auto read = |
| 137 | nsp->GetNCAFile(FileSys::GetUpdateTitleID(title_id), FileSys::ContentRecordType::Program); | 138 | nsp->GetNCAFile(FileSys::GetUpdateTitleID(title_id), FileSys::ContentRecordType::Program); |
| 138 | 139 | ||
| 139 | if (read == nullptr) | 140 | if (read == nullptr) { |
| 140 | return ResultStatus::ErrorNoPackedUpdate; | 141 | return ResultStatus::ErrorNoPackedUpdate; |
| 141 | const auto nca_test = std::make_shared<FileSys::NCA>(read); | 142 | } |
| 142 | 143 | ||
| 143 | if (nca_test->GetStatus() != ResultStatus::ErrorMissingBKTRBaseRomFS) | 144 | const auto nca_test = std::make_shared<FileSys::NCA>(read); |
| 145 | if (nca_test->GetStatus() != ResultStatus::ErrorMissingBKTRBaseRomFS) { | ||
| 144 | return nca_test->GetStatus(); | 146 | return nca_test->GetStatus(); |
| 147 | } | ||
| 145 | 148 | ||
| 146 | file = read; | 149 | out_file = read; |
| 147 | return ResultStatus::Success; | 150 | return ResultStatus::Success; |
| 148 | } | 151 | } |
| 149 | 152 | ||
| 150 | ResultStatus AppLoader_NSP::ReadProgramId(u64& out_program_id) { | 153 | ResultStatus AppLoader_NSP::ReadProgramId(u64& out_program_id) { |
| 151 | if (title_id == 0) | 154 | if (title_id == 0) { |
| 152 | return ResultStatus::ErrorNotInitialized; | 155 | return ResultStatus::ErrorNotInitialized; |
| 156 | } | ||
| 157 | |||
| 153 | out_program_id = title_id; | 158 | out_program_id = title_id; |
| 154 | return ResultStatus::Success; | 159 | return ResultStatus::Success; |
| 155 | } | 160 | } |
| 156 | 161 | ||
| 157 | ResultStatus AppLoader_NSP::ReadIcon(std::vector<u8>& buffer) { | 162 | ResultStatus AppLoader_NSP::ReadIcon(std::vector<u8>& buffer) { |
| 158 | if (icon_file == nullptr) | 163 | if (icon_file == nullptr) { |
| 159 | return ResultStatus::ErrorNoControl; | 164 | return ResultStatus::ErrorNoControl; |
| 165 | } | ||
| 166 | |||
| 160 | buffer = icon_file->ReadAllBytes(); | 167 | buffer = icon_file->ReadAllBytes(); |
| 161 | return ResultStatus::Success; | 168 | return ResultStatus::Success; |
| 162 | } | 169 | } |
| 163 | 170 | ||
| 164 | ResultStatus AppLoader_NSP::ReadTitle(std::string& title) { | 171 | ResultStatus AppLoader_NSP::ReadTitle(std::string& title) { |
| 165 | if (nacp_file == nullptr) | 172 | if (nacp_file == nullptr) { |
| 166 | return ResultStatus::ErrorNoControl; | 173 | return ResultStatus::ErrorNoControl; |
| 174 | } | ||
| 175 | |||
| 167 | title = nacp_file->GetApplicationName(); | 176 | title = nacp_file->GetApplicationName(); |
| 168 | return ResultStatus::Success; | 177 | return ResultStatus::Success; |
| 169 | } | 178 | } |
| 170 | 179 | ||
| 171 | ResultStatus AppLoader_NSP::ReadControlData(FileSys::NACP& nacp) { | 180 | ResultStatus AppLoader_NSP::ReadControlData(FileSys::NACP& nacp) { |
| 172 | if (nacp_file == nullptr) | 181 | if (nacp_file == nullptr) { |
| 173 | return ResultStatus::ErrorNoControl; | 182 | return ResultStatus::ErrorNoControl; |
| 183 | } | ||
| 184 | |||
| 174 | nacp = *nacp_file; | 185 | nacp = *nacp_file; |
| 175 | return ResultStatus::Success; | 186 | return ResultStatus::Success; |
| 176 | } | 187 | } |
| 177 | 188 | ||
| 178 | ResultStatus AppLoader_NSP::ReadManualRomFS(FileSys::VirtualFile& file) { | 189 | ResultStatus AppLoader_NSP::ReadManualRomFS(FileSys::VirtualFile& out_file) { |
| 179 | const auto nca = | 190 | const auto nca = |
| 180 | nsp->GetNCA(nsp->GetProgramTitleID(), FileSys::ContentRecordType::HtmlDocument); | 191 | nsp->GetNCA(nsp->GetProgramTitleID(), FileSys::ContentRecordType::HtmlDocument); |
| 181 | if (nsp->GetStatus() != ResultStatus::Success || nca == nullptr) | 192 | if (nsp->GetStatus() != ResultStatus::Success || nca == nullptr) { |
| 182 | return ResultStatus::ErrorNoRomFS; | 193 | return ResultStatus::ErrorNoRomFS; |
| 183 | file = nca->GetRomFS(); | 194 | } |
| 184 | return file == nullptr ? ResultStatus::ErrorNoRomFS : ResultStatus::Success; | 195 | |
| 196 | out_file = nca->GetRomFS(); | ||
| 197 | return out_file == nullptr ? ResultStatus::ErrorNoRomFS : ResultStatus::Success; | ||
| 185 | } | 198 | } |
| 186 | 199 | ||
| 187 | ResultStatus AppLoader_NSP::ReadBanner(std::vector<u8>& buffer) { | 200 | ResultStatus AppLoader_NSP::ReadBanner(std::vector<u8>& buffer) { |
diff --git a/src/core/loader/nsp.h b/src/core/loader/nsp.h index d48d87f2c..1660f1b94 100644 --- a/src/core/loader/nsp.h +++ b/src/core/loader/nsp.h | |||
| @@ -26,18 +26,20 @@ class AppLoader_NCA; | |||
| 26 | /// Loads an XCI file | 26 | /// Loads an XCI file |
| 27 | class AppLoader_NSP final : public AppLoader { | 27 | class AppLoader_NSP final : public AppLoader { |
| 28 | public: | 28 | public: |
| 29 | explicit AppLoader_NSP(FileSys::VirtualFile file, | 29 | explicit AppLoader_NSP(FileSys::VirtualFile file_, |
| 30 | const Service::FileSystem::FileSystemController& fsc, | 30 | const Service::FileSystem::FileSystemController& fsc, |
| 31 | const FileSys::ContentProvider& content_provider, | 31 | const FileSys::ContentProvider& content_provider, |
| 32 | std::size_t program_index); | 32 | std::size_t program_index); |
| 33 | ~AppLoader_NSP() override; | 33 | ~AppLoader_NSP() override; |
| 34 | 34 | ||
| 35 | /** | 35 | /** |
| 36 | * Returns the type of the file | 36 | * Identifies whether or not the given file is an NSP file. |
| 37 | * @param file open file | 37 | * |
| 38 | * @return FileType found, or FileType::Error if this loader doesn't know it | 38 | * @param nsp_file The file to identify. |
| 39 | * | ||
| 40 | * @return FileType::NSP, or FileType::Error if the file is not an NSP. | ||
| 39 | */ | 41 | */ |
| 40 | static FileType IdentifyType(const FileSys::VirtualFile& file); | 42 | static FileType IdentifyType(const FileSys::VirtualFile& nsp_file); |
| 41 | 43 | ||
| 42 | FileType GetFileType() const override { | 44 | FileType GetFileType() const override { |
| 43 | return IdentifyType(file); | 45 | return IdentifyType(file); |
| @@ -45,14 +47,14 @@ public: | |||
| 45 | 47 | ||
| 46 | LoadResult Load(Kernel::Process& process, Core::System& system) override; | 48 | LoadResult Load(Kernel::Process& process, Core::System& system) override; |
| 47 | 49 | ||
| 48 | ResultStatus ReadRomFS(FileSys::VirtualFile& file) override; | 50 | ResultStatus ReadRomFS(FileSys::VirtualFile& out_file) override; |
| 49 | u64 ReadRomFSIVFCOffset() const override; | 51 | u64 ReadRomFSIVFCOffset() const override; |
| 50 | ResultStatus ReadUpdateRaw(FileSys::VirtualFile& file) override; | 52 | ResultStatus ReadUpdateRaw(FileSys::VirtualFile& out_file) override; |
| 51 | ResultStatus ReadProgramId(u64& out_program_id) override; | 53 | ResultStatus ReadProgramId(u64& out_program_id) override; |
| 52 | ResultStatus ReadIcon(std::vector<u8>& buffer) override; | 54 | ResultStatus ReadIcon(std::vector<u8>& buffer) override; |
| 53 | ResultStatus ReadTitle(std::string& title) override; | 55 | ResultStatus ReadTitle(std::string& title) override; |
| 54 | ResultStatus ReadControlData(FileSys::NACP& nacp) override; | 56 | ResultStatus ReadControlData(FileSys::NACP& nacp) override; |
| 55 | ResultStatus ReadManualRomFS(FileSys::VirtualFile& file) override; | 57 | ResultStatus ReadManualRomFS(FileSys::VirtualFile& out_file) override; |
| 56 | 58 | ||
| 57 | ResultStatus ReadBanner(std::vector<u8>& buffer) override; | 59 | ResultStatus ReadBanner(std::vector<u8>& buffer) override; |
| 58 | ResultStatus ReadLogo(std::vector<u8>& buffer) override; | 60 | ResultStatus ReadLogo(std::vector<u8>& buffer) override; |
diff --git a/src/core/loader/xci.cpp b/src/core/loader/xci.cpp index aaa250cea..0125ddf33 100644 --- a/src/core/loader/xci.cpp +++ b/src/core/loader/xci.cpp | |||
| @@ -20,11 +20,11 @@ | |||
| 20 | 20 | ||
| 21 | namespace Loader { | 21 | namespace Loader { |
| 22 | 22 | ||
| 23 | AppLoader_XCI::AppLoader_XCI(FileSys::VirtualFile file, | 23 | AppLoader_XCI::AppLoader_XCI(FileSys::VirtualFile file_, |
| 24 | const Service::FileSystem::FileSystemController& fsc, | 24 | const Service::FileSystem::FileSystemController& fsc, |
| 25 | const FileSys::ContentProvider& content_provider, | 25 | const FileSys::ContentProvider& content_provider, |
| 26 | std::size_t program_index) | 26 | std::size_t program_index) |
| 27 | : AppLoader(file), xci(std::make_unique<FileSys::XCI>(file, program_index)), | 27 | : AppLoader(file_), xci(std::make_unique<FileSys::XCI>(file_, program_index)), |
| 28 | nca_loader(std::make_unique<AppLoader_NCA>(xci->GetProgramNCAFile())) { | 28 | nca_loader(std::make_unique<AppLoader_NCA>(xci->GetProgramNCAFile())) { |
| 29 | if (xci->GetStatus() != ResultStatus::Success) { | 29 | if (xci->GetStatus() != ResultStatus::Success) { |
| 30 | return; | 30 | return; |
| @@ -43,8 +43,8 @@ AppLoader_XCI::AppLoader_XCI(FileSys::VirtualFile file, | |||
| 43 | 43 | ||
| 44 | AppLoader_XCI::~AppLoader_XCI() = default; | 44 | AppLoader_XCI::~AppLoader_XCI() = default; |
| 45 | 45 | ||
| 46 | FileType AppLoader_XCI::IdentifyType(const FileSys::VirtualFile& file) { | 46 | FileType AppLoader_XCI::IdentifyType(const FileSys::VirtualFile& xci_file) { |
| 47 | FileSys::XCI xci(file); | 47 | const FileSys::XCI xci(xci_file); |
| 48 | 48 | ||
| 49 | if (xci.GetStatus() == ResultStatus::Success && | 49 | if (xci.GetStatus() == ResultStatus::Success && |
| 50 | xci.GetNCAByType(FileSys::NCAContentType::Program) != nullptr && | 50 | xci.GetNCAByType(FileSys::NCAContentType::Program) != nullptr && |
| @@ -87,31 +87,33 @@ AppLoader_XCI::LoadResult AppLoader_XCI::Load(Kernel::Process& process, Core::Sy | |||
| 87 | return result; | 87 | return result; |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | ResultStatus AppLoader_XCI::ReadRomFS(FileSys::VirtualFile& file) { | 90 | ResultStatus AppLoader_XCI::ReadRomFS(FileSys::VirtualFile& out_file) { |
| 91 | return nca_loader->ReadRomFS(file); | 91 | return nca_loader->ReadRomFS(out_file); |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | u64 AppLoader_XCI::ReadRomFSIVFCOffset() const { | 94 | u64 AppLoader_XCI::ReadRomFSIVFCOffset() const { |
| 95 | return nca_loader->ReadRomFSIVFCOffset(); | 95 | return nca_loader->ReadRomFSIVFCOffset(); |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | ResultStatus AppLoader_XCI::ReadUpdateRaw(FileSys::VirtualFile& file) { | 98 | ResultStatus AppLoader_XCI::ReadUpdateRaw(FileSys::VirtualFile& out_file) { |
| 99 | u64 program_id{}; | 99 | u64 program_id{}; |
| 100 | nca_loader->ReadProgramId(program_id); | 100 | nca_loader->ReadProgramId(program_id); |
| 101 | if (program_id == 0) | 101 | if (program_id == 0) { |
| 102 | return ResultStatus::ErrorXCIMissingProgramNCA; | 102 | return ResultStatus::ErrorXCIMissingProgramNCA; |
| 103 | } | ||
| 103 | 104 | ||
| 104 | const auto read = xci->GetSecurePartitionNSP()->GetNCAFile( | 105 | const auto read = xci->GetSecurePartitionNSP()->GetNCAFile( |
| 105 | FileSys::GetUpdateTitleID(program_id), FileSys::ContentRecordType::Program); | 106 | FileSys::GetUpdateTitleID(program_id), FileSys::ContentRecordType::Program); |
| 106 | 107 | if (read == nullptr) { | |
| 107 | if (read == nullptr) | ||
| 108 | return ResultStatus::ErrorNoPackedUpdate; | 108 | return ResultStatus::ErrorNoPackedUpdate; |
| 109 | const auto nca_test = std::make_shared<FileSys::NCA>(read); | 109 | } |
| 110 | 110 | ||
| 111 | if (nca_test->GetStatus() != ResultStatus::ErrorMissingBKTRBaseRomFS) | 111 | const auto nca_test = std::make_shared<FileSys::NCA>(read); |
| 112 | if (nca_test->GetStatus() != ResultStatus::ErrorMissingBKTRBaseRomFS) { | ||
| 112 | return nca_test->GetStatus(); | 113 | return nca_test->GetStatus(); |
| 114 | } | ||
| 113 | 115 | ||
| 114 | file = read; | 116 | out_file = read; |
| 115 | return ResultStatus::Success; | 117 | return ResultStatus::Success; |
| 116 | } | 118 | } |
| 117 | 119 | ||
| @@ -120,33 +122,41 @@ ResultStatus AppLoader_XCI::ReadProgramId(u64& out_program_id) { | |||
| 120 | } | 122 | } |
| 121 | 123 | ||
| 122 | ResultStatus AppLoader_XCI::ReadIcon(std::vector<u8>& buffer) { | 124 | ResultStatus AppLoader_XCI::ReadIcon(std::vector<u8>& buffer) { |
| 123 | if (icon_file == nullptr) | 125 | if (icon_file == nullptr) { |
| 124 | return ResultStatus::ErrorNoControl; | 126 | return ResultStatus::ErrorNoControl; |
| 127 | } | ||
| 128 | |||
| 125 | buffer = icon_file->ReadAllBytes(); | 129 | buffer = icon_file->ReadAllBytes(); |
| 126 | return ResultStatus::Success; | 130 | return ResultStatus::Success; |
| 127 | } | 131 | } |
| 128 | 132 | ||
| 129 | ResultStatus AppLoader_XCI::ReadTitle(std::string& title) { | 133 | ResultStatus AppLoader_XCI::ReadTitle(std::string& title) { |
| 130 | if (nacp_file == nullptr) | 134 | if (nacp_file == nullptr) { |
| 131 | return ResultStatus::ErrorNoControl; | 135 | return ResultStatus::ErrorNoControl; |
| 136 | } | ||
| 137 | |||
| 132 | title = nacp_file->GetApplicationName(); | 138 | title = nacp_file->GetApplicationName(); |
| 133 | return ResultStatus::Success; | 139 | return ResultStatus::Success; |
| 134 | } | 140 | } |
| 135 | 141 | ||
| 136 | ResultStatus AppLoader_XCI::ReadControlData(FileSys::NACP& control) { | 142 | ResultStatus AppLoader_XCI::ReadControlData(FileSys::NACP& control) { |
| 137 | if (nacp_file == nullptr) | 143 | if (nacp_file == nullptr) { |
| 138 | return ResultStatus::ErrorNoControl; | 144 | return ResultStatus::ErrorNoControl; |
| 145 | } | ||
| 146 | |||
| 139 | control = *nacp_file; | 147 | control = *nacp_file; |
| 140 | return ResultStatus::Success; | 148 | return ResultStatus::Success; |
| 141 | } | 149 | } |
| 142 | 150 | ||
| 143 | ResultStatus AppLoader_XCI::ReadManualRomFS(FileSys::VirtualFile& file) { | 151 | ResultStatus AppLoader_XCI::ReadManualRomFS(FileSys::VirtualFile& out_file) { |
| 144 | const auto nca = xci->GetSecurePartitionNSP()->GetNCA(xci->GetProgramTitleID(), | 152 | const auto nca = xci->GetSecurePartitionNSP()->GetNCA(xci->GetProgramTitleID(), |
| 145 | FileSys::ContentRecordType::HtmlDocument); | 153 | FileSys::ContentRecordType::HtmlDocument); |
| 146 | if (xci->GetStatus() != ResultStatus::Success || nca == nullptr) | 154 | if (xci->GetStatus() != ResultStatus::Success || nca == nullptr) { |
| 147 | return ResultStatus::ErrorXCIMissingPartition; | 155 | return ResultStatus::ErrorXCIMissingPartition; |
| 148 | file = nca->GetRomFS(); | 156 | } |
| 149 | return file == nullptr ? ResultStatus::ErrorNoRomFS : ResultStatus::Success; | 157 | |
| 158 | out_file = nca->GetRomFS(); | ||
| 159 | return out_file == nullptr ? ResultStatus::ErrorNoRomFS : ResultStatus::Success; | ||
| 150 | } | 160 | } |
| 151 | 161 | ||
| 152 | ResultStatus AppLoader_XCI::ReadBanner(std::vector<u8>& buffer) { | 162 | ResultStatus AppLoader_XCI::ReadBanner(std::vector<u8>& buffer) { |
diff --git a/src/core/loader/xci.h b/src/core/loader/xci.h index 9f0ceb5ef..7ea8179af 100644 --- a/src/core/loader/xci.h +++ b/src/core/loader/xci.h | |||
| @@ -26,18 +26,20 @@ class AppLoader_NCA; | |||
| 26 | /// Loads an XCI file | 26 | /// Loads an XCI file |
| 27 | class AppLoader_XCI final : public AppLoader { | 27 | class AppLoader_XCI final : public AppLoader { |
| 28 | public: | 28 | public: |
| 29 | explicit AppLoader_XCI(FileSys::VirtualFile file, | 29 | explicit AppLoader_XCI(FileSys::VirtualFile file_, |
| 30 | const Service::FileSystem::FileSystemController& fsc, | 30 | const Service::FileSystem::FileSystemController& fsc, |
| 31 | const FileSys::ContentProvider& content_provider, | 31 | const FileSys::ContentProvider& content_provider, |
| 32 | std::size_t program_index); | 32 | std::size_t program_index); |
| 33 | ~AppLoader_XCI() override; | 33 | ~AppLoader_XCI() override; |
| 34 | 34 | ||
| 35 | /** | 35 | /** |
| 36 | * Returns the type of the file | 36 | * Identifies whether or not the given file is an XCI file. |
| 37 | * @param file open file | 37 | * |
| 38 | * @return FileType found, or FileType::Error if this loader doesn't know it | 38 | * @param xci_file The file to identify. |
| 39 | * | ||
| 40 | * @return FileType::XCI, or FileType::Error if the file is not an XCI file. | ||
| 39 | */ | 41 | */ |
| 40 | static FileType IdentifyType(const FileSys::VirtualFile& file); | 42 | static FileType IdentifyType(const FileSys::VirtualFile& xci_file); |
| 41 | 43 | ||
| 42 | FileType GetFileType() const override { | 44 | FileType GetFileType() const override { |
| 43 | return IdentifyType(file); | 45 | return IdentifyType(file); |
| @@ -45,14 +47,14 @@ public: | |||
| 45 | 47 | ||
| 46 | LoadResult Load(Kernel::Process& process, Core::System& system) override; | 48 | LoadResult Load(Kernel::Process& process, Core::System& system) override; |
| 47 | 49 | ||
| 48 | ResultStatus ReadRomFS(FileSys::VirtualFile& file) override; | 50 | ResultStatus ReadRomFS(FileSys::VirtualFile& out_file) override; |
| 49 | u64 ReadRomFSIVFCOffset() const override; | 51 | u64 ReadRomFSIVFCOffset() const override; |
| 50 | ResultStatus ReadUpdateRaw(FileSys::VirtualFile& file) override; | 52 | ResultStatus ReadUpdateRaw(FileSys::VirtualFile& out_file) override; |
| 51 | ResultStatus ReadProgramId(u64& out_program_id) override; | 53 | ResultStatus ReadProgramId(u64& out_program_id) override; |
| 52 | ResultStatus ReadIcon(std::vector<u8>& buffer) override; | 54 | ResultStatus ReadIcon(std::vector<u8>& buffer) override; |
| 53 | ResultStatus ReadTitle(std::string& title) override; | 55 | ResultStatus ReadTitle(std::string& title) override; |
| 54 | ResultStatus ReadControlData(FileSys::NACP& control) override; | 56 | ResultStatus ReadControlData(FileSys::NACP& control) override; |
| 55 | ResultStatus ReadManualRomFS(FileSys::VirtualFile& file) override; | 57 | ResultStatus ReadManualRomFS(FileSys::VirtualFile& out_file) override; |
| 56 | 58 | ||
| 57 | ResultStatus ReadBanner(std::vector<u8>& buffer) override; | 59 | ResultStatus ReadBanner(std::vector<u8>& buffer) override; |
| 58 | ResultStatus ReadLogo(std::vector<u8>& buffer) override; | 60 | ResultStatus ReadLogo(std::vector<u8>& buffer) override; |
diff --git a/src/input_common/gcadapter/gc_adapter.cpp b/src/input_common/gcadapter/gc_adapter.cpp index ec3167bea..320f51ee6 100644 --- a/src/input_common/gcadapter/gc_adapter.cpp +++ b/src/input_common/gcadapter/gc_adapter.cpp | |||
| @@ -155,8 +155,12 @@ void Adapter::UpdateStateAxes(std::size_t port, const AdapterPayload& adapter_pa | |||
| 155 | for (const PadAxes axis : axes) { | 155 | for (const PadAxes axis : axes) { |
| 156 | const auto index = static_cast<std::size_t>(axis); | 156 | const auto index = static_cast<std::size_t>(axis); |
| 157 | const u8 axis_value = adapter_payload[offset + 3 + index]; | 157 | const u8 axis_value = adapter_payload[offset + 3 + index]; |
| 158 | if (pads[port].axis_origin[index] == 255) { | 158 | if (pads[port].reset_origin_counter <= 18) { |
| 159 | if (pads[port].axis_origin[index] != axis_value) { | ||
| 160 | pads[port].reset_origin_counter = 0; | ||
| 161 | } | ||
| 159 | pads[port].axis_origin[index] = axis_value; | 162 | pads[port].axis_origin[index] = axis_value; |
| 163 | pads[port].reset_origin_counter++; | ||
| 160 | } | 164 | } |
| 161 | pads[port].axis_values[index] = | 165 | pads[port].axis_values[index] = |
| 162 | static_cast<s16>(axis_value - pads[port].axis_origin[index]); | 166 | static_cast<s16>(axis_value - pads[port].axis_origin[index]); |
| @@ -375,7 +379,7 @@ void Adapter::ResetDevice(std::size_t port) { | |||
| 375 | pads[port].buttons = 0; | 379 | pads[port].buttons = 0; |
| 376 | pads[port].last_button = PadButton::Undefined; | 380 | pads[port].last_button = PadButton::Undefined; |
| 377 | pads[port].axis_values.fill(0); | 381 | pads[port].axis_values.fill(0); |
| 378 | pads[port].axis_origin.fill(255); | 382 | pads[port].reset_origin_counter = 0; |
| 379 | } | 383 | } |
| 380 | 384 | ||
| 381 | void Adapter::Reset() { | 385 | void Adapter::Reset() { |
diff --git a/src/input_common/gcadapter/gc_adapter.h b/src/input_common/gcadapter/gc_adapter.h index 7a6c545bd..e5de5e94f 100644 --- a/src/input_common/gcadapter/gc_adapter.h +++ b/src/input_common/gcadapter/gc_adapter.h | |||
| @@ -70,6 +70,7 @@ struct GCController { | |||
| 70 | PadButton last_button{}; | 70 | PadButton last_button{}; |
| 71 | std::array<s16, 6> axis_values{}; | 71 | std::array<s16, 6> axis_values{}; |
| 72 | std::array<u8, 6> axis_origin{}; | 72 | std::array<u8, 6> axis_origin{}; |
| 73 | u8 reset_origin_counter{}; | ||
| 73 | }; | 74 | }; |
| 74 | 75 | ||
| 75 | class Adapter { | 76 | class Adapter { |
diff --git a/src/input_common/motion_input.cpp b/src/input_common/motion_input.cpp index 6a65f175e..1c9d561c0 100644 --- a/src/input_common/motion_input.cpp +++ b/src/input_common/motion_input.cpp | |||
| @@ -195,7 +195,8 @@ Input::MotionStatus MotionInput::GetMotion() const { | |||
| 195 | const Common::Vec3f accelerometer = GetAcceleration(); | 195 | const Common::Vec3f accelerometer = GetAcceleration(); |
| 196 | const Common::Vec3f rotation = GetRotations(); | 196 | const Common::Vec3f rotation = GetRotations(); |
| 197 | const std::array<Common::Vec3f, 3> orientation = GetOrientation(); | 197 | const std::array<Common::Vec3f, 3> orientation = GetOrientation(); |
| 198 | return {accelerometer, gyroscope, rotation, orientation}; | 198 | const Common::Quaternion<f32> quaternion = GetQuaternion(); |
| 199 | return {accelerometer, gyroscope, rotation, orientation, quaternion}; | ||
| 199 | } | 200 | } |
| 200 | 201 | ||
| 201 | Input::MotionStatus MotionInput::GetRandomMotion(int accel_magnitude, int gyro_magnitude) const { | 202 | Input::MotionStatus MotionInput::GetRandomMotion(int accel_magnitude, int gyro_magnitude) const { |
| @@ -218,7 +219,12 @@ Input::MotionStatus MotionInput::GetRandomMotion(int accel_magnitude, int gyro_m | |||
| 218 | Common::Vec3f{0.0f, 1.0f, 0.0f}, | 219 | Common::Vec3f{0.0f, 1.0f, 0.0f}, |
| 219 | Common::Vec3f{0.0f, 0.0f, 1.0f}, | 220 | Common::Vec3f{0.0f, 0.0f, 1.0f}, |
| 220 | }; | 221 | }; |
| 221 | return {accelerometer * accel_magnitude, gyroscope * gyro_magnitude, rotation, orientation}; | 222 | constexpr Common::Quaternion<f32> quaternion{ |
| 223 | {0.0f, 0.0f, 0.0f}, | ||
| 224 | 1.0f, | ||
| 225 | }; | ||
| 226 | return {accelerometer * accel_magnitude, gyroscope * gyro_magnitude, rotation, orientation, | ||
| 227 | quaternion}; | ||
| 222 | } | 228 | } |
| 223 | 229 | ||
| 224 | void MotionInput::ResetOrientation() { | 230 | void MotionInput::ResetOrientation() { |
diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp index 7c42f1177..a38024242 100644 --- a/src/video_core/gpu.cpp +++ b/src/video_core/gpu.cpp | |||
| @@ -492,10 +492,8 @@ void GPU::PushCommandBuffer(Tegra::ChCommandHeaderList& entries) { | |||
| 492 | cdma_pusher->ProcessEntries(std::move(entries)); | 492 | cdma_pusher->ProcessEntries(std::move(entries)); |
| 493 | } | 493 | } |
| 494 | 494 | ||
| 495 | void GPU::ClearCommandBuffer() { | 495 | void GPU::ClearCdmaInstance() { |
| 496 | // This condition fires when a video stream ends, clear all intermediary data | ||
| 497 | cdma_pusher.reset(); | 496 | cdma_pusher.reset(); |
| 498 | LOG_INFO(Service_NVDRV, "NVDEC video stream ended"); | ||
| 499 | } | 497 | } |
| 500 | 498 | ||
| 501 | void GPU::SwapBuffers(const Tegra::FramebufferConfig* framebuffer) { | 499 | void GPU::SwapBuffers(const Tegra::FramebufferConfig* framebuffer) { |
diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h index b1960ea86..8669e9940 100644 --- a/src/video_core/gpu.h +++ b/src/video_core/gpu.h | |||
| @@ -324,8 +324,8 @@ public: | |||
| 324 | /// Push GPU command buffer entries to be processed | 324 | /// Push GPU command buffer entries to be processed |
| 325 | void PushCommandBuffer(Tegra::ChCommandHeaderList& entries); | 325 | void PushCommandBuffer(Tegra::ChCommandHeaderList& entries); |
| 326 | 326 | ||
| 327 | /// Frees the CDMAPusher to free up resources | 327 | /// Frees the CDMAPusher instance to free up resources |
| 328 | void ClearCommandBuffer(); | 328 | void ClearCdmaInstance(); |
| 329 | 329 | ||
| 330 | /// Swap buffers (render frame) | 330 | /// Swap buffers (render frame) |
| 331 | void SwapBuffers(const Tegra::FramebufferConfig* framebuffer); | 331 | void SwapBuffers(const Tegra::FramebufferConfig* framebuffer); |
diff --git a/src/yuzu/applets/software_keyboard.cpp b/src/yuzu/applets/software_keyboard.cpp index fd3368479..653486493 100644 --- a/src/yuzu/applets/software_keyboard.cpp +++ b/src/yuzu/applets/software_keyboard.cpp | |||
| @@ -1027,10 +1027,8 @@ void QtSoftwareKeyboardDialog::ChangeBottomOSKIndex() { | |||
| 1027 | ui->bottomOSK->setCurrentIndex(static_cast<int>(bottom_osk_index)); | 1027 | ui->bottomOSK->setCurrentIndex(static_cast<int>(bottom_osk_index)); |
| 1028 | 1028 | ||
| 1029 | ui->button_shift_shift->setStyleSheet( | 1029 | ui->button_shift_shift->setStyleSheet( |
| 1030 | QStringLiteral("background-image: url(:/overlay/osk_button_shift_lock_off.png);" | 1030 | QStringLiteral("image: url(:/overlay/osk_button_shift_lock_off.png);" |
| 1031 | "\nbackground-position: left top;" | 1031 | "\nimage-position: left;")); |
| 1032 | "\nbackground-repeat: no-repeat;" | ||
| 1033 | "\nbackground-origin: content;")); | ||
| 1034 | 1032 | ||
| 1035 | ui->button_shift_shift->setIconSize(ui->button_shift->iconSize()); | 1033 | ui->button_shift_shift->setIconSize(ui->button_shift->iconSize()); |
| 1036 | ui->button_backspace_shift->setIconSize(ui->button_backspace->iconSize()); | 1034 | ui->button_backspace_shift->setIconSize(ui->button_backspace->iconSize()); |
| @@ -1040,10 +1038,8 @@ void QtSoftwareKeyboardDialog::ChangeBottomOSKIndex() { | |||
| 1040 | caps_lock_enabled = false; | 1038 | caps_lock_enabled = false; |
| 1041 | 1039 | ||
| 1042 | ui->button_shift_shift->setStyleSheet( | 1040 | ui->button_shift_shift->setStyleSheet( |
| 1043 | QStringLiteral("background-image: url(:/overlay/osk_button_shift_lock_off.png);" | 1041 | QStringLiteral("image: url(:/overlay/osk_button_shift_lock_off.png);" |
| 1044 | "\nbackground-position: left top;" | 1042 | "\nimage-position: left;")); |
| 1045 | "\nbackground-repeat: no-repeat;" | ||
| 1046 | "\nbackground-origin: content;")); | ||
| 1047 | 1043 | ||
| 1048 | ui->button_shift_shift->setIconSize(ui->button_shift->iconSize()); | 1044 | ui->button_shift_shift->setIconSize(ui->button_shift->iconSize()); |
| 1049 | ui->button_backspace_shift->setIconSize(ui->button_backspace->iconSize()); | 1045 | ui->button_backspace_shift->setIconSize(ui->button_backspace->iconSize()); |
| @@ -1056,10 +1052,8 @@ void QtSoftwareKeyboardDialog::ChangeBottomOSKIndex() { | |||
| 1056 | caps_lock_enabled = true; | 1052 | caps_lock_enabled = true; |
| 1057 | 1053 | ||
| 1058 | ui->button_shift_shift->setStyleSheet( | 1054 | ui->button_shift_shift->setStyleSheet( |
| 1059 | QStringLiteral("background-image: url(:/overlay/osk_button_shift_lock_on.png);" | 1055 | QStringLiteral("image: url(:/overlay/osk_button_shift_lock_on.png);" |
| 1060 | "\nbackground-position: left top;" | 1056 | "\nimage-position: left;")); |
| 1061 | "\nbackground-repeat: no-repeat;" | ||
| 1062 | "\nbackground-origin: content;")); | ||
| 1063 | 1057 | ||
| 1064 | ui->button_shift_shift->setIconSize(ui->button_shift->iconSize()); | 1058 | ui->button_shift_shift->setIconSize(ui->button_shift->iconSize()); |
| 1065 | ui->button_backspace_shift->setIconSize(ui->button_backspace->iconSize()); | 1059 | ui->button_backspace_shift->setIconSize(ui->button_backspace->iconSize()); |
diff --git a/src/yuzu/applets/web_browser.cpp b/src/yuzu/applets/web_browser.cpp index e482ba029..93e3a4f6f 100644 --- a/src/yuzu/applets/web_browser.cpp +++ b/src/yuzu/applets/web_browser.cpp | |||
| @@ -102,8 +102,8 @@ QtNXWebEngineView::~QtNXWebEngineView() { | |||
| 102 | StopInputThread(); | 102 | StopInputThread(); |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | void QtNXWebEngineView::LoadLocalWebPage(std::string_view main_url, | 105 | void QtNXWebEngineView::LoadLocalWebPage(const std::string& main_url, |
| 106 | std::string_view additional_args) { | 106 | const std::string& additional_args) { |
| 107 | is_local = true; | 107 | is_local = true; |
| 108 | 108 | ||
| 109 | LoadExtractedFonts(); | 109 | LoadExtractedFonts(); |
| @@ -113,12 +113,12 @@ void QtNXWebEngineView::LoadLocalWebPage(std::string_view main_url, | |||
| 113 | SetLastURL("http://localhost/"); | 113 | SetLastURL("http://localhost/"); |
| 114 | StartInputThread(); | 114 | StartInputThread(); |
| 115 | 115 | ||
| 116 | load(QUrl(QUrl::fromLocalFile(QString::fromStdString(std::string(main_url))).toString() + | 116 | load(QUrl(QUrl::fromLocalFile(QString::fromStdString(main_url)).toString() + |
| 117 | QString::fromStdString(std::string(additional_args)))); | 117 | QString::fromStdString(additional_args))); |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | void QtNXWebEngineView::LoadExternalWebPage(std::string_view main_url, | 120 | void QtNXWebEngineView::LoadExternalWebPage(const std::string& main_url, |
| 121 | std::string_view additional_args) { | 121 | const std::string& additional_args) { |
| 122 | is_local = false; | 122 | is_local = false; |
| 123 | 123 | ||
| 124 | SetUserAgent(UserAgent::WebApplet); | 124 | SetUserAgent(UserAgent::WebApplet); |
| @@ -127,8 +127,7 @@ void QtNXWebEngineView::LoadExternalWebPage(std::string_view main_url, | |||
| 127 | SetLastURL("http://localhost/"); | 127 | SetLastURL("http://localhost/"); |
| 128 | StartInputThread(); | 128 | StartInputThread(); |
| 129 | 129 | ||
| 130 | load(QUrl(QString::fromStdString(std::string(main_url)) + | 130 | load(QUrl(QString::fromStdString(main_url) + QString::fromStdString(additional_args))); |
| 131 | QString::fromStdString(std::string(additional_args)))); | ||
| 132 | } | 131 | } |
| 133 | 132 | ||
| 134 | void QtNXWebEngineView::SetUserAgent(UserAgent user_agent) { | 133 | void QtNXWebEngineView::SetUserAgent(UserAgent user_agent) { |
| @@ -375,7 +374,7 @@ QtWebBrowser::QtWebBrowser(GMainWindow& main_window) { | |||
| 375 | QtWebBrowser::~QtWebBrowser() = default; | 374 | QtWebBrowser::~QtWebBrowser() = default; |
| 376 | 375 | ||
| 377 | void QtWebBrowser::OpenLocalWebPage( | 376 | void QtWebBrowser::OpenLocalWebPage( |
| 378 | std::string_view local_url, std::function<void()> extract_romfs_callback_, | 377 | const std::string& local_url, std::function<void()> extract_romfs_callback_, |
| 379 | std::function<void(Service::AM::Applets::WebExitReason, std::string)> callback_) const { | 378 | std::function<void(Service::AM::Applets::WebExitReason, std::string)> callback_) const { |
| 380 | extract_romfs_callback = std::move(extract_romfs_callback_); | 379 | extract_romfs_callback = std::move(extract_romfs_callback_); |
| 381 | callback = std::move(callback_); | 380 | callback = std::move(callback_); |
| @@ -390,7 +389,7 @@ void QtWebBrowser::OpenLocalWebPage( | |||
| 390 | } | 389 | } |
| 391 | 390 | ||
| 392 | void QtWebBrowser::OpenExternalWebPage( | 391 | void QtWebBrowser::OpenExternalWebPage( |
| 393 | std::string_view external_url, | 392 | const std::string& external_url, |
| 394 | std::function<void(Service::AM::Applets::WebExitReason, std::string)> callback_) const { | 393 | std::function<void(Service::AM::Applets::WebExitReason, std::string)> callback_) const { |
| 395 | callback = std::move(callback_); | 394 | callback = std::move(callback_); |
| 396 | 395 | ||
diff --git a/src/yuzu/applets/web_browser.h b/src/yuzu/applets/web_browser.h index 47f960d69..7ad07409f 100644 --- a/src/yuzu/applets/web_browser.h +++ b/src/yuzu/applets/web_browser.h | |||
| @@ -58,7 +58,7 @@ public: | |||
| 58 | * @param main_url The url to the file. | 58 | * @param main_url The url to the file. |
| 59 | * @param additional_args Additional arguments appended to the main url. | 59 | * @param additional_args Additional arguments appended to the main url. |
| 60 | */ | 60 | */ |
| 61 | void LoadLocalWebPage(std::string_view main_url, std::string_view additional_args); | 61 | void LoadLocalWebPage(const std::string& main_url, const std::string& additional_args); |
| 62 | 62 | ||
| 63 | /** | 63 | /** |
| 64 | * Loads an external website. Cannot be used to load local urls. | 64 | * Loads an external website. Cannot be used to load local urls. |
| @@ -66,7 +66,7 @@ public: | |||
| 66 | * @param main_url The url to the website. | 66 | * @param main_url The url to the website. |
| 67 | * @param additional_args Additional arguments appended to the main url. | 67 | * @param additional_args Additional arguments appended to the main url. |
| 68 | */ | 68 | */ |
| 69 | void LoadExternalWebPage(std::string_view main_url, std::string_view additional_args); | 69 | void LoadExternalWebPage(const std::string& main_url, const std::string& additional_args); |
| 70 | 70 | ||
| 71 | /** | 71 | /** |
| 72 | * Sets the background color of the web page. | 72 | * Sets the background color of the web page. |
| @@ -193,16 +193,17 @@ public: | |||
| 193 | explicit QtWebBrowser(GMainWindow& parent); | 193 | explicit QtWebBrowser(GMainWindow& parent); |
| 194 | ~QtWebBrowser() override; | 194 | ~QtWebBrowser() override; |
| 195 | 195 | ||
| 196 | void OpenLocalWebPage(std::string_view local_url, std::function<void()> extract_romfs_callback_, | 196 | void OpenLocalWebPage(const std::string& local_url, |
| 197 | std::function<void()> extract_romfs_callback_, | ||
| 197 | std::function<void(Service::AM::Applets::WebExitReason, std::string)> | 198 | std::function<void(Service::AM::Applets::WebExitReason, std::string)> |
| 198 | callback_) const override; | 199 | callback_) const override; |
| 199 | 200 | ||
| 200 | void OpenExternalWebPage(std::string_view external_url, | 201 | void OpenExternalWebPage(const std::string& external_url, |
| 201 | std::function<void(Service::AM::Applets::WebExitReason, std::string)> | 202 | std::function<void(Service::AM::Applets::WebExitReason, std::string)> |
| 202 | callback_) const override; | 203 | callback_) const override; |
| 203 | 204 | ||
| 204 | signals: | 205 | signals: |
| 205 | void MainWindowOpenWebPage(std::string_view main_url, std::string_view additional_args, | 206 | void MainWindowOpenWebPage(const std::string& main_url, const std::string& additional_args, |
| 206 | bool is_local) const; | 207 | bool is_local) const; |
| 207 | 208 | ||
| 208 | private: | 209 | private: |
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 851246233..e80a3df77 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp | |||
| @@ -29,9 +29,10 @@ Config::~Config() { | |||
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | const std::array<int, Settings::NativeButton::NumButtons> Config::default_buttons = { | 31 | const std::array<int, Settings::NativeButton::NumButtons> Config::default_buttons = { |
| 32 | Qt::Key_A, Qt::Key_S, Qt::Key_Z, Qt::Key_X, Qt::Key_3, Qt::Key_4, Qt::Key_Q, | 32 | Qt::Key_C, Qt::Key_X, Qt::Key_V, Qt::Key_Z, Qt::Key_F, |
| 33 | Qt::Key_W, Qt::Key_1, Qt::Key_2, Qt::Key_N, Qt::Key_M, Qt::Key_F, Qt::Key_T, | 33 | Qt::Key_G, Qt::Key_Q, Qt::Key_E, Qt::Key_R, Qt::Key_T, |
| 34 | Qt::Key_H, Qt::Key_G, Qt::Key_D, Qt::Key_C, Qt::Key_B, Qt::Key_V, | 34 | Qt::Key_M, Qt::Key_N, Qt::Key_Left, Qt::Key_Up, Qt::Key_Right, |
| 35 | Qt::Key_Down, Qt::Key_Q, Qt::Key_E, 0, 0, | ||
| 35 | }; | 36 | }; |
| 36 | 37 | ||
| 37 | const std::array<int, Settings::NativeMotion::NumMotions> Config::default_motions = { | 38 | const std::array<int, Settings::NativeMotion::NumMotions> Config::default_motions = { |
| @@ -41,10 +42,10 @@ const std::array<int, Settings::NativeMotion::NumMotions> Config::default_motion | |||
| 41 | 42 | ||
| 42 | const std::array<std::array<int, 4>, Settings::NativeAnalog::NumAnalogs> Config::default_analogs{{ | 43 | const std::array<std::array<int, 4>, Settings::NativeAnalog::NumAnalogs> Config::default_analogs{{ |
| 43 | { | 44 | { |
| 44 | Qt::Key_Up, | 45 | Qt::Key_W, |
| 45 | Qt::Key_Down, | 46 | Qt::Key_S, |
| 46 | Qt::Key_Left, | 47 | Qt::Key_A, |
| 47 | Qt::Key_Right, | 48 | Qt::Key_D, |
| 48 | }, | 49 | }, |
| 49 | { | 50 | { |
| 50 | Qt::Key_I, | 51 | Qt::Key_I, |
| @@ -55,8 +56,8 @@ const std::array<std::array<int, 4>, Settings::NativeAnalog::NumAnalogs> Config: | |||
| 55 | }}; | 56 | }}; |
| 56 | 57 | ||
| 57 | const std::array<int, 2> Config::default_stick_mod = { | 58 | const std::array<int, 2> Config::default_stick_mod = { |
| 58 | Qt::Key_E, | 59 | Qt::Key_Shift, |
| 59 | Qt::Key_R, | 60 | 0, |
| 60 | }; | 61 | }; |
| 61 | 62 | ||
| 62 | const std::array<int, Settings::NativeMouseButton::NumMouseButtons> Config::default_mouse_buttons = | 63 | const std::array<int, Settings::NativeMouseButton::NumMouseButtons> Config::default_mouse_buttons = |
| @@ -862,8 +863,7 @@ void Config::ReadSystemValues() { | |||
| 862 | Settings::values.rng_seed.SetGlobal(rng_seed_global); | 863 | Settings::values.rng_seed.SetGlobal(rng_seed_global); |
| 863 | if (global || !rng_seed_global) { | 864 | if (global || !rng_seed_global) { |
| 864 | if (rng_seed_enabled) { | 865 | if (rng_seed_enabled) { |
| 865 | Settings::values.rng_seed.SetValue( | 866 | Settings::values.rng_seed.SetValue(ReadSetting(QStringLiteral("rng_seed"), 0).toUInt()); |
| 866 | ReadSetting(QStringLiteral("rng_seed"), 0).toULongLong()); | ||
| 867 | } else { | 867 | } else { |
| 868 | Settings::values.rng_seed.SetValue(std::nullopt); | 868 | Settings::values.rng_seed.SetValue(std::nullopt); |
| 869 | } | 869 | } |
| @@ -936,6 +936,13 @@ void Config::ReadUIGamelistValues() { | |||
| 936 | UISettings::values.row_2_text_id = ReadSetting(QStringLiteral("row_2_text_id"), 2).toUInt(); | 936 | UISettings::values.row_2_text_id = ReadSetting(QStringLiteral("row_2_text_id"), 2).toUInt(); |
| 937 | UISettings::values.cache_game_list = | 937 | UISettings::values.cache_game_list = |
| 938 | ReadSetting(QStringLiteral("cache_game_list"), true).toBool(); | 938 | ReadSetting(QStringLiteral("cache_game_list"), true).toBool(); |
| 939 | const int favorites_size = qt_config->beginReadArray(QStringLiteral("favorites")); | ||
| 940 | for (int i = 0; i < favorites_size; i++) { | ||
| 941 | qt_config->setArrayIndex(i); | ||
| 942 | UISettings::values.favorited_ids.append( | ||
| 943 | ReadSetting(QStringLiteral("program_id")).toULongLong()); | ||
| 944 | } | ||
| 945 | qt_config->endArray(); | ||
| 939 | 946 | ||
| 940 | qt_config->endGroup(); | 947 | qt_config->endGroup(); |
| 941 | } | 948 | } |
| @@ -1479,6 +1486,13 @@ void Config::SaveUIGamelistValues() { | |||
| 1479 | WriteSetting(QStringLiteral("row_1_text_id"), UISettings::values.row_1_text_id, 3); | 1486 | WriteSetting(QStringLiteral("row_1_text_id"), UISettings::values.row_1_text_id, 3); |
| 1480 | WriteSetting(QStringLiteral("row_2_text_id"), UISettings::values.row_2_text_id, 2); | 1487 | WriteSetting(QStringLiteral("row_2_text_id"), UISettings::values.row_2_text_id, 2); |
| 1481 | WriteSetting(QStringLiteral("cache_game_list"), UISettings::values.cache_game_list, true); | 1488 | WriteSetting(QStringLiteral("cache_game_list"), UISettings::values.cache_game_list, true); |
| 1489 | qt_config->beginWriteArray(QStringLiteral("favorites")); | ||
| 1490 | for (int i = 0; i < UISettings::values.favorited_ids.size(); i++) { | ||
| 1491 | qt_config->setArrayIndex(i); | ||
| 1492 | WriteSetting(QStringLiteral("program_id"), | ||
| 1493 | QVariant::fromValue(UISettings::values.favorited_ids[i])); | ||
| 1494 | } | ||
| 1495 | qt_config->endArray(); | ||
| 1482 | 1496 | ||
| 1483 | qt_config->endGroup(); | 1497 | qt_config->endGroup(); |
| 1484 | } | 1498 | } |
diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp index 9afd5b45f..827bc10e7 100644 --- a/src/yuzu/game_list.cpp +++ b/src/yuzu/game_list.cpp | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #include <QJsonDocument> | 11 | #include <QJsonDocument> |
| 12 | #include <QJsonObject> | 12 | #include <QJsonObject> |
| 13 | #include <QKeyEvent> | 13 | #include <QKeyEvent> |
| 14 | #include <QList> | ||
| 14 | #include <QMenu> | 15 | #include <QMenu> |
| 15 | #include <QThreadPool> | 16 | #include <QThreadPool> |
| 16 | #include <fmt/format.h> | 17 | #include <fmt/format.h> |
| @@ -84,6 +85,10 @@ void GameListSearchField::setFilterResult(int visible, int total) { | |||
| 84 | label_filter_result->setText(tr("%1 of %n result(s)", "", total).arg(visible)); | 85 | label_filter_result->setText(tr("%1 of %n result(s)", "", total).arg(visible)); |
| 85 | } | 86 | } |
| 86 | 87 | ||
| 88 | QString GameListSearchField::filterText() const { | ||
| 89 | return edit_filter->text(); | ||
| 90 | } | ||
| 91 | |||
| 87 | QString GameList::GetLastFilterResultItem() const { | 92 | QString GameList::GetLastFilterResultItem() const { |
| 88 | QString file_path; | 93 | QString file_path; |
| 89 | const int folder_count = item_model->rowCount(); | 94 | const int folder_count = item_model->rowCount(); |
| @@ -187,7 +192,9 @@ void GameList::OnTextChanged(const QString& new_text) { | |||
| 187 | // If the searchfield is empty every item is visible | 192 | // If the searchfield is empty every item is visible |
| 188 | // Otherwise the filter gets applied | 193 | // Otherwise the filter gets applied |
| 189 | if (edit_filter_text.isEmpty()) { | 194 | if (edit_filter_text.isEmpty()) { |
| 190 | for (int i = 0; i < folder_count; ++i) { | 195 | tree_view->setRowHidden(0, item_model->invisibleRootItem()->index(), |
| 196 | UISettings::values.favorited_ids.size() == 0); | ||
| 197 | for (int i = 1; i < folder_count; ++i) { | ||
| 191 | folder = item_model->item(i, 0); | 198 | folder = item_model->item(i, 0); |
| 192 | const QModelIndex folder_index = folder->index(); | 199 | const QModelIndex folder_index = folder->index(); |
| 193 | const int children_count = folder->rowCount(); | 200 | const int children_count = folder->rowCount(); |
| @@ -198,8 +205,9 @@ void GameList::OnTextChanged(const QString& new_text) { | |||
| 198 | } | 205 | } |
| 199 | search_field->setFilterResult(children_total, children_total); | 206 | search_field->setFilterResult(children_total, children_total); |
| 200 | } else { | 207 | } else { |
| 208 | tree_view->setRowHidden(0, item_model->invisibleRootItem()->index(), true); | ||
| 201 | int result_count = 0; | 209 | int result_count = 0; |
| 202 | for (int i = 0; i < folder_count; ++i) { | 210 | for (int i = 1; i < folder_count; ++i) { |
| 203 | folder = item_model->item(i, 0); | 211 | folder = item_model->item(i, 0); |
| 204 | const QModelIndex folder_index = folder->index(); | 212 | const QModelIndex folder_index = folder->index(); |
| 205 | const int children_count = folder->rowCount(); | 213 | const int children_count = folder->rowCount(); |
| @@ -228,9 +236,9 @@ void GameList::OnTextChanged(const QString& new_text) { | |||
| 228 | } else { | 236 | } else { |
| 229 | tree_view->setRowHidden(j, folder_index, true); | 237 | tree_view->setRowHidden(j, folder_index, true); |
| 230 | } | 238 | } |
| 231 | search_field->setFilterResult(result_count, children_total); | ||
| 232 | } | 239 | } |
| 233 | } | 240 | } |
| 241 | search_field->setFilterResult(result_count, children_total); | ||
| 234 | } | 242 | } |
| 235 | } | 243 | } |
| 236 | 244 | ||
| @@ -280,6 +288,13 @@ void GameList::OnUpdateThemedIcons() { | |||
| 280 | .scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), | 288 | .scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), |
| 281 | Qt::DecorationRole); | 289 | Qt::DecorationRole); |
| 282 | break; | 290 | break; |
| 291 | case GameListItemType::Favorites: | ||
| 292 | child->setData( | ||
| 293 | QIcon::fromTheme(QStringLiteral("star")) | ||
| 294 | .pixmap(icon_size) | ||
| 295 | .scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), | ||
| 296 | Qt::DecorationRole); | ||
| 297 | break; | ||
| 283 | default: | 298 | default: |
| 284 | break; | 299 | break; |
| 285 | } | 300 | } |
| @@ -427,6 +442,13 @@ void GameList::DonePopulating(const QStringList& watch_list) { | |||
| 427 | emit ShowList(!IsEmpty()); | 442 | emit ShowList(!IsEmpty()); |
| 428 | 443 | ||
| 429 | item_model->invisibleRootItem()->appendRow(new GameListAddDir()); | 444 | item_model->invisibleRootItem()->appendRow(new GameListAddDir()); |
| 445 | item_model->invisibleRootItem()->insertRow(0, new GameListFavorites()); | ||
| 446 | tree_view->setRowHidden(0, item_model->invisibleRootItem()->index(), | ||
| 447 | UISettings::values.favorited_ids.size() == 0); | ||
| 448 | tree_view->expand(item_model->invisibleRootItem()->child(0)->index()); | ||
| 449 | for (const auto id : UISettings::values.favorited_ids) { | ||
| 450 | AddFavorite(id); | ||
| 451 | } | ||
| 430 | 452 | ||
| 431 | // Clear out the old directories to watch for changes and add the new ones | 453 | // Clear out the old directories to watch for changes and add the new ones |
| 432 | auto watch_dirs = watcher->directories(); | 454 | auto watch_dirs = watcher->directories(); |
| @@ -446,7 +468,7 @@ void GameList::DonePopulating(const QStringList& watch_list) { | |||
| 446 | tree_view->setEnabled(true); | 468 | tree_view->setEnabled(true); |
| 447 | const int folder_count = tree_view->model()->rowCount(); | 469 | const int folder_count = tree_view->model()->rowCount(); |
| 448 | int children_total = 0; | 470 | int children_total = 0; |
| 449 | for (int i = 0; i < folder_count; ++i) { | 471 | for (int i = 1; i < folder_count; ++i) { |
| 450 | children_total += item_model->item(i, 0)->rowCount(); | 472 | children_total += item_model->item(i, 0)->rowCount(); |
| 451 | } | 473 | } |
| 452 | search_field->setFilterResult(children_total, children_total); | 474 | search_field->setFilterResult(children_total, children_total); |
| @@ -478,6 +500,9 @@ void GameList::PopupContextMenu(const QPoint& menu_location) { | |||
| 478 | case GameListItemType::SysNandDir: | 500 | case GameListItemType::SysNandDir: |
| 479 | AddPermDirPopup(context_menu, selected); | 501 | AddPermDirPopup(context_menu, selected); |
| 480 | break; | 502 | break; |
| 503 | case GameListItemType::Favorites: | ||
| 504 | AddFavoritesPopup(context_menu); | ||
| 505 | break; | ||
| 481 | default: | 506 | default: |
| 482 | break; | 507 | break; |
| 483 | } | 508 | } |
| @@ -485,6 +510,8 @@ void GameList::PopupContextMenu(const QPoint& menu_location) { | |||
| 485 | } | 510 | } |
| 486 | 511 | ||
| 487 | void GameList::AddGamePopup(QMenu& context_menu, u64 program_id, const std::string& path) { | 512 | void GameList::AddGamePopup(QMenu& context_menu, u64 program_id, const std::string& path) { |
| 513 | QAction* favorite = context_menu.addAction(tr("Favorite")); | ||
| 514 | context_menu.addSeparator(); | ||
| 488 | QAction* open_save_location = context_menu.addAction(tr("Open Save Data Location")); | 515 | QAction* open_save_location = context_menu.addAction(tr("Open Save Data Location")); |
| 489 | QAction* open_mod_location = context_menu.addAction(tr("Open Mod Data Location")); | 516 | QAction* open_mod_location = context_menu.addAction(tr("Open Mod Data Location")); |
| 490 | QAction* open_transferable_shader_cache = | 517 | QAction* open_transferable_shader_cache = |
| @@ -503,6 +530,9 @@ void GameList::AddGamePopup(QMenu& context_menu, u64 program_id, const std::stri | |||
| 503 | context_menu.addSeparator(); | 530 | context_menu.addSeparator(); |
| 504 | QAction* properties = context_menu.addAction(tr("Properties")); | 531 | QAction* properties = context_menu.addAction(tr("Properties")); |
| 505 | 532 | ||
| 533 | favorite->setVisible(program_id != 0); | ||
| 534 | favorite->setCheckable(true); | ||
| 535 | favorite->setChecked(UISettings::values.favorited_ids.contains(program_id)); | ||
| 506 | open_save_location->setVisible(program_id != 0); | 536 | open_save_location->setVisible(program_id != 0); |
| 507 | open_mod_location->setVisible(program_id != 0); | 537 | open_mod_location->setVisible(program_id != 0); |
| 508 | open_transferable_shader_cache->setVisible(program_id != 0); | 538 | open_transferable_shader_cache->setVisible(program_id != 0); |
| @@ -513,6 +543,7 @@ void GameList::AddGamePopup(QMenu& context_menu, u64 program_id, const std::stri | |||
| 513 | auto it = FindMatchingCompatibilityEntry(compatibility_list, program_id); | 543 | auto it = FindMatchingCompatibilityEntry(compatibility_list, program_id); |
| 514 | navigate_to_gamedb_entry->setVisible(it != compatibility_list.end() && program_id != 0); | 544 | navigate_to_gamedb_entry->setVisible(it != compatibility_list.end() && program_id != 0); |
| 515 | 545 | ||
| 546 | connect(favorite, &QAction::triggered, [this, program_id]() { ToggleFavorite(program_id); }); | ||
| 516 | connect(open_save_location, &QAction::triggered, [this, program_id, path]() { | 547 | connect(open_save_location, &QAction::triggered, [this, program_id, path]() { |
| 517 | emit OpenFolderRequested(program_id, GameListOpenTarget::SaveData, path); | 548 | emit OpenFolderRequested(program_id, GameListOpenTarget::SaveData, path); |
| 518 | }); | 549 | }); |
| @@ -564,6 +595,7 @@ void GameList::AddCustomDirPopup(QMenu& context_menu, QModelIndex selected) { | |||
| 564 | connect(delete_dir, &QAction::triggered, [this, &game_dir, selected] { | 595 | connect(delete_dir, &QAction::triggered, [this, &game_dir, selected] { |
| 565 | UISettings::values.game_dirs.removeOne(game_dir); | 596 | UISettings::values.game_dirs.removeOne(game_dir); |
| 566 | item_model->invisibleRootItem()->removeRow(selected.row()); | 597 | item_model->invisibleRootItem()->removeRow(selected.row()); |
| 598 | OnTextChanged(search_field->filterText()); | ||
| 567 | }); | 599 | }); |
| 568 | } | 600 | } |
| 569 | 601 | ||
| @@ -576,7 +608,7 @@ void GameList::AddPermDirPopup(QMenu& context_menu, QModelIndex selected) { | |||
| 576 | 608 | ||
| 577 | const int row = selected.row(); | 609 | const int row = selected.row(); |
| 578 | 610 | ||
| 579 | move_up->setEnabled(row > 0); | 611 | move_up->setEnabled(row > 1); |
| 580 | move_down->setEnabled(row < item_model->rowCount() - 2); | 612 | move_down->setEnabled(row < item_model->rowCount() - 2); |
| 581 | 613 | ||
| 582 | connect(move_up, &QAction::triggered, [this, selected, row, game_dir_index] { | 614 | connect(move_up, &QAction::triggered, [this, selected, row, game_dir_index] { |
| @@ -614,6 +646,18 @@ void GameList::AddPermDirPopup(QMenu& context_menu, QModelIndex selected) { | |||
| 614 | }); | 646 | }); |
| 615 | } | 647 | } |
| 616 | 648 | ||
| 649 | void GameList::AddFavoritesPopup(QMenu& context_menu) { | ||
| 650 | QAction* clear_all = context_menu.addAction(tr("Clear")); | ||
| 651 | |||
| 652 | connect(clear_all, &QAction::triggered, [this] { | ||
| 653 | for (const auto id : UISettings::values.favorited_ids) { | ||
| 654 | RemoveFavorite(id); | ||
| 655 | } | ||
| 656 | UISettings::values.favorited_ids.clear(); | ||
| 657 | tree_view->setRowHidden(0, item_model->invisibleRootItem()->index(), true); | ||
| 658 | }); | ||
| 659 | } | ||
| 660 | |||
| 617 | void GameList::LoadCompatibilityList() { | 661 | void GameList::LoadCompatibilityList() { |
| 618 | QFile compat_list{QStringLiteral(":compatibility_list/compatibility_list.json")}; | 662 | QFile compat_list{QStringLiteral(":compatibility_list/compatibility_list.json")}; |
| 619 | 663 | ||
| @@ -728,6 +772,58 @@ void GameList::RefreshGameDirectory() { | |||
| 728 | } | 772 | } |
| 729 | } | 773 | } |
| 730 | 774 | ||
| 775 | void GameList::ToggleFavorite(u64 program_id) { | ||
| 776 | if (!UISettings::values.favorited_ids.contains(program_id)) { | ||
| 777 | tree_view->setRowHidden(0, item_model->invisibleRootItem()->index(), | ||
| 778 | !search_field->filterText().isEmpty()); | ||
| 779 | UISettings::values.favorited_ids.append(program_id); | ||
| 780 | AddFavorite(program_id); | ||
| 781 | item_model->sort(tree_view->header()->sortIndicatorSection(), | ||
| 782 | tree_view->header()->sortIndicatorOrder()); | ||
| 783 | } else { | ||
| 784 | UISettings::values.favorited_ids.removeOne(program_id); | ||
| 785 | RemoveFavorite(program_id); | ||
| 786 | if (UISettings::values.favorited_ids.size() == 0) { | ||
| 787 | tree_view->setRowHidden(0, item_model->invisibleRootItem()->index(), true); | ||
| 788 | } | ||
| 789 | } | ||
| 790 | } | ||
| 791 | |||
| 792 | void GameList::AddFavorite(u64 program_id) { | ||
| 793 | auto* favorites_row = item_model->item(0); | ||
| 794 | |||
| 795 | for (int i = 1; i < item_model->rowCount() - 1; i++) { | ||
| 796 | const auto* folder = item_model->item(i); | ||
| 797 | for (int j = 0; j < folder->rowCount(); j++) { | ||
| 798 | if (folder->child(j)->data(GameListItemPath::ProgramIdRole).toULongLong() == | ||
| 799 | program_id) { | ||
| 800 | QList<QStandardItem*> list; | ||
| 801 | for (int k = 0; k < item_model->columnCount(); k++) { | ||
| 802 | list.append(folder->child(j, k)->clone()); | ||
| 803 | } | ||
| 804 | list[0]->setData(folder->child(j)->data(GameListItem::SortRole), | ||
| 805 | GameListItem::SortRole); | ||
| 806 | list[0]->setText(folder->child(j)->data(Qt::DisplayRole).toString()); | ||
| 807 | |||
| 808 | favorites_row->appendRow(list); | ||
| 809 | return; | ||
| 810 | } | ||
| 811 | } | ||
| 812 | } | ||
| 813 | } | ||
| 814 | |||
| 815 | void GameList::RemoveFavorite(u64 program_id) { | ||
| 816 | auto* favorites_row = item_model->item(0); | ||
| 817 | |||
| 818 | for (int i = 0; i < favorites_row->rowCount(); i++) { | ||
| 819 | const auto* game = favorites_row->child(i); | ||
| 820 | if (game->data(GameListItemPath::ProgramIdRole).toULongLong() == program_id) { | ||
| 821 | favorites_row->removeRow(i); | ||
| 822 | return; | ||
| 823 | } | ||
| 824 | } | ||
| 825 | } | ||
| 826 | |||
| 731 | GameListPlaceholder::GameListPlaceholder(GMainWindow* parent) : QWidget{parent} { | 827 | GameListPlaceholder::GameListPlaceholder(GMainWindow* parent) : QWidget{parent} { |
| 732 | connect(parent, &GMainWindow::UpdateThemedIcons, this, | 828 | connect(parent, &GMainWindow::UpdateThemedIcons, this, |
| 733 | &GameListPlaceholder::onUpdateThemedIcons); | 829 | &GameListPlaceholder::onUpdateThemedIcons); |
diff --git a/src/yuzu/game_list.h b/src/yuzu/game_list.h index 58059a3c4..9c0a1a482 100644 --- a/src/yuzu/game_list.h +++ b/src/yuzu/game_list.h | |||
| @@ -112,10 +112,15 @@ private: | |||
| 112 | 112 | ||
| 113 | void RefreshGameDirectory(); | 113 | void RefreshGameDirectory(); |
| 114 | 114 | ||
| 115 | void ToggleFavorite(u64 program_id); | ||
| 116 | void AddFavorite(u64 program_id); | ||
| 117 | void RemoveFavorite(u64 program_id); | ||
| 118 | |||
| 115 | void PopupContextMenu(const QPoint& menu_location); | 119 | void PopupContextMenu(const QPoint& menu_location); |
| 116 | void AddGamePopup(QMenu& context_menu, u64 program_id, const std::string& path); | 120 | void AddGamePopup(QMenu& context_menu, u64 program_id, const std::string& path); |
| 117 | void AddCustomDirPopup(QMenu& context_menu, QModelIndex selected); | 121 | void AddCustomDirPopup(QMenu& context_menu, QModelIndex selected); |
| 118 | void AddPermDirPopup(QMenu& context_menu, QModelIndex selected); | 122 | void AddPermDirPopup(QMenu& context_menu, QModelIndex selected); |
| 123 | void AddFavoritesPopup(QMenu& context_menu); | ||
| 119 | 124 | ||
| 120 | std::shared_ptr<FileSys::VfsFilesystem> vfs; | 125 | std::shared_ptr<FileSys::VfsFilesystem> vfs; |
| 121 | FileSys::ManualContentProvider* provider; | 126 | FileSys::ManualContentProvider* provider; |
diff --git a/src/yuzu/game_list_p.h b/src/yuzu/game_list_p.h index f25445f18..978d27325 100644 --- a/src/yuzu/game_list_p.h +++ b/src/yuzu/game_list_p.h | |||
| @@ -29,7 +29,8 @@ enum class GameListItemType { | |||
| 29 | SdmcDir = QStandardItem::UserType + 3, | 29 | SdmcDir = QStandardItem::UserType + 3, |
| 30 | UserNandDir = QStandardItem::UserType + 4, | 30 | UserNandDir = QStandardItem::UserType + 4, |
| 31 | SysNandDir = QStandardItem::UserType + 5, | 31 | SysNandDir = QStandardItem::UserType + 5, |
| 32 | AddDir = QStandardItem::UserType + 6 | 32 | AddDir = QStandardItem::UserType + 6, |
| 33 | Favorites = QStandardItem::UserType + 7, | ||
| 33 | }; | 34 | }; |
| 34 | 35 | ||
| 35 | Q_DECLARE_METATYPE(GameListItemType); | 36 | Q_DECLARE_METATYPE(GameListItemType); |
| @@ -310,6 +311,28 @@ public: | |||
| 310 | } | 311 | } |
| 311 | }; | 312 | }; |
| 312 | 313 | ||
| 314 | class GameListFavorites : public GameListItem { | ||
| 315 | public: | ||
| 316 | explicit GameListFavorites() { | ||
| 317 | setData(type(), TypeRole); | ||
| 318 | |||
| 319 | const int icon_size = std::min(static_cast<int>(UISettings::values.icon_size), 64); | ||
| 320 | setData(QIcon::fromTheme(QStringLiteral("star")) | ||
| 321 | .pixmap(icon_size) | ||
| 322 | .scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), | ||
| 323 | Qt::DecorationRole); | ||
| 324 | setData(QObject::tr("Favorites"), Qt::DisplayRole); | ||
| 325 | } | ||
| 326 | |||
| 327 | int type() const override { | ||
| 328 | return static_cast<int>(GameListItemType::Favorites); | ||
| 329 | } | ||
| 330 | |||
| 331 | bool operator<(const QStandardItem& other) const override { | ||
| 332 | return false; | ||
| 333 | } | ||
| 334 | }; | ||
| 335 | |||
| 313 | class GameList; | 336 | class GameList; |
| 314 | class QHBoxLayout; | 337 | class QHBoxLayout; |
| 315 | class QTreeView; | 338 | class QTreeView; |
| @@ -323,6 +346,7 @@ class GameListSearchField : public QWidget { | |||
| 323 | public: | 346 | public: |
| 324 | explicit GameListSearchField(GameList* parent = nullptr); | 347 | explicit GameListSearchField(GameList* parent = nullptr); |
| 325 | 348 | ||
| 349 | QString filterText() const; | ||
| 326 | void setFilterResult(int visible, int total); | 350 | void setFilterResult(int visible, int total); |
| 327 | 351 | ||
| 328 | void clear(); | 352 | void clear(); |
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 5f6cdc0c6..00d4cfe67 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -349,7 +349,7 @@ GMainWindow::GMainWindow() | |||
| 349 | continue; | 349 | continue; |
| 350 | } | 350 | } |
| 351 | 351 | ||
| 352 | Settings::values.current_user = selected_user; | 352 | Settings::values.current_user = static_cast<s32>(selected_user); |
| 353 | continue; | 353 | continue; |
| 354 | } | 354 | } |
| 355 | 355 | ||
| @@ -574,8 +574,8 @@ void GMainWindow::SoftwareKeyboardExit() { | |||
| 574 | software_keyboard = nullptr; | 574 | software_keyboard = nullptr; |
| 575 | } | 575 | } |
| 576 | 576 | ||
| 577 | void GMainWindow::WebBrowserOpenWebPage(std::string_view main_url, std::string_view additional_args, | 577 | void GMainWindow::WebBrowserOpenWebPage(const std::string& main_url, |
| 578 | bool is_local) { | 578 | const std::string& additional_args, bool is_local) { |
| 579 | #ifdef YUZU_USE_QT_WEB_ENGINE | 579 | #ifdef YUZU_USE_QT_WEB_ENGINE |
| 580 | 580 | ||
| 581 | if (disable_web_applet) { | 581 | if (disable_web_applet) { |
| @@ -596,13 +596,15 @@ void GMainWindow::WebBrowserOpenWebPage(std::string_view main_url, std::string_v | |||
| 596 | loading_progress.setRange(0, 3); | 596 | loading_progress.setRange(0, 3); |
| 597 | loading_progress.setValue(0); | 597 | loading_progress.setValue(0); |
| 598 | 598 | ||
| 599 | if (is_local && !Common::FS::Exists(std::string(main_url))) { | 599 | if (is_local && !Common::FS::Exists(main_url)) { |
| 600 | loading_progress.show(); | 600 | loading_progress.show(); |
| 601 | 601 | ||
| 602 | auto future = QtConcurrent::run([this] { emit WebBrowserExtractOfflineRomFS(); }); | 602 | auto future = QtConcurrent::run([this] { emit WebBrowserExtractOfflineRomFS(); }); |
| 603 | 603 | ||
| 604 | while (!future.isFinished()) { | 604 | while (!future.isFinished()) { |
| 605 | QCoreApplication::processEvents(); | 605 | QCoreApplication::processEvents(); |
| 606 | |||
| 607 | std::this_thread::sleep_for(std::chrono::milliseconds(1)); | ||
| 606 | } | 608 | } |
| 607 | } | 609 | } |
| 608 | 610 | ||
diff --git a/src/yuzu/main.h b/src/yuzu/main.h index 7f1e50a5b..98a608fce 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h | |||
| @@ -159,7 +159,7 @@ public slots: | |||
| 159 | void SoftwareKeyboardExit(); | 159 | void SoftwareKeyboardExit(); |
| 160 | void ErrorDisplayDisplayError(QString error_code, QString error_text); | 160 | void ErrorDisplayDisplayError(QString error_code, QString error_text); |
| 161 | void ProfileSelectorSelectProfile(); | 161 | void ProfileSelectorSelectProfile(); |
| 162 | void WebBrowserOpenWebPage(std::string_view main_url, std::string_view additional_args, | 162 | void WebBrowserOpenWebPage(const std::string& main_url, const std::string& additional_args, |
| 163 | bool is_local); | 163 | bool is_local); |
| 164 | void OnAppFocusStateChanged(Qt::ApplicationState state); | 164 | void OnAppFocusStateChanged(Qt::ApplicationState state); |
| 165 | 165 | ||
diff --git a/src/yuzu/uisettings.h b/src/yuzu/uisettings.h index ce3945485..5ba00b8c8 100644 --- a/src/yuzu/uisettings.h +++ b/src/yuzu/uisettings.h | |||
| @@ -74,6 +74,7 @@ struct Values { | |||
| 74 | QString game_dir_deprecated; | 74 | QString game_dir_deprecated; |
| 75 | bool game_dir_deprecated_deepscan; | 75 | bool game_dir_deprecated_deepscan; |
| 76 | QVector<UISettings::GameDir> game_dirs; | 76 | QVector<UISettings::GameDir> game_dirs; |
| 77 | QVector<u64> favorited_ids; | ||
| 77 | QStringList recent_files; | 78 | QStringList recent_files; |
| 78 | QString language; | 79 | QString language; |
| 79 | 80 | ||