diff --git a/README.md b/README.md index dd838173d..3ab8cdcf5 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 4091. +This is the source code for early-access 4092. ## Legal Notice diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt index 22da1d0e5..ef393c4be 100755 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt @@ -301,6 +301,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { R.id.menu_exit -> { emulationState.stop() + NativeConfig.reloadGlobalConfig() emulationViewModel.setIsEmulationStopping(true) binding.drawerLayout.close() binding.inGameMenu.requestFocus() diff --git a/src/core/hle/service/am/display_controller.cpp b/src/core/hle/service/am/display_controller.cpp index 3076f1752..4d6858348 100755 --- a/src/core/hle/service/am/display_controller.cpp +++ b/src/core/hle/service/am/display_controller.cpp @@ -60,13 +60,12 @@ void IDisplayController::GetCallerAppletCaptureImageEx(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); OutputParameters params{}; - const auto res = applet->system_buffer_manager.WriteApplicationCaptureBuffer( + const auto res = applet->system_buffer_manager.WriteAppletCaptureBuffer( ¶ms.was_written, ¶ms.fbshare_layer_index); IPC::ResponseBuilder rb{ctx, 4}; rb.Push(res); - rb.Push(params.was_written); - rb.Push(params.fbshare_layer_index); + rb.PushRaw(params); } void IDisplayController::TakeScreenShotOfOwnLayer(HLERequestContext& ctx) { @@ -80,13 +79,12 @@ void IDisplayController::AcquireLastApplicationCaptureSharedBuffer(HLERequestCon LOG_WARNING(Service_AM, "(STUBBED) called"); OutputParameters params{}; - const auto res = applet->system_buffer_manager.WriteApplicationCaptureBuffer( + const auto res = applet->system_buffer_manager.WriteAppletCaptureBuffer( ¶ms.was_written, ¶ms.fbshare_layer_index); IPC::ResponseBuilder rb{ctx, 4}; rb.Push(res); - rb.Push(params.was_written); - rb.Push(params.fbshare_layer_index); + rb.PushRaw(params); } void IDisplayController::ReleaseLastApplicationCaptureSharedBuffer(HLERequestContext& ctx) { @@ -100,13 +98,12 @@ void IDisplayController::AcquireLastForegroundCaptureSharedBuffer(HLERequestCont LOG_WARNING(Service_AM, "(STUBBED) called"); OutputParameters params{}; - const auto res = applet->system_buffer_manager.WriteApplicationCaptureBuffer( + const auto res = applet->system_buffer_manager.WriteAppletCaptureBuffer( ¶ms.was_written, ¶ms.fbshare_layer_index); IPC::ResponseBuilder rb{ctx, 4}; rb.Push(res); - rb.Push(params.was_written); - rb.Push(params.fbshare_layer_index); + rb.PushRaw(params); } void IDisplayController::ReleaseLastForegroundCaptureSharedBuffer(HLERequestContext& ctx) { @@ -120,13 +117,12 @@ void IDisplayController::AcquireCallerAppletCaptureSharedBuffer(HLERequestContex LOG_WARNING(Service_AM, "(STUBBED) called"); OutputParameters params{}; - const auto res = applet->system_buffer_manager.WriteApplicationCaptureBuffer( + const auto res = applet->system_buffer_manager.WriteAppletCaptureBuffer( ¶ms.was_written, ¶ms.fbshare_layer_index); IPC::ResponseBuilder rb{ctx, 4}; rb.Push(res); - rb.Push(params.was_written); - rb.Push(params.fbshare_layer_index); + rb.PushRaw(params); } void IDisplayController::ReleaseCallerAppletCaptureSharedBuffer(HLERequestContext& ctx) { diff --git a/src/core/hle/service/am/frontend/applet_mii_edit.cpp b/src/core/hle/service/am/frontend/applet_mii_edit.cpp index fa41bdb9c..e3d19fb3d 100755 --- a/src/core/hle/service/am/frontend/applet_mii_edit.cpp +++ b/src/core/hle/service/am/frontend/applet_mii_edit.cpp @@ -60,7 +60,7 @@ void MiiEdit::Initialize() { break; } - manager = system.ServiceManager().GetService("mii:e")->GetMiiManager(); + manager = system.ServiceManager().GetService("mii:e")->GetMiiManager(); if (manager == nullptr) { manager = std::make_shared(); } diff --git a/src/core/hle/service/am/library_applet_creator.cpp b/src/core/hle/service/am/library_applet_creator.cpp index 5c3569125..cc211e904 100755 --- a/src/core/hle/service/am/library_applet_creator.cpp +++ b/src/core/hle/service/am/library_applet_creator.cpp @@ -115,15 +115,10 @@ AppletProgramId AppletIdToProgramId(AppletId applet_id) { return std::make_shared(system, broker, applet); } -std::shared_ptr CreateFrontendApplet(Core::System& system, - std::shared_ptr caller_applet, - AppletId applet_id, - LibraryAppletMode mode) { +[[maybe_unused]] std::shared_ptr CreateFrontendApplet( + Core::System& system, std::shared_ptr caller_applet, AppletId applet_id, + LibraryAppletMode mode) { const auto program_id = static_cast(AppletIdToProgramId(applet_id)); - if (program_id == 0) { - // Unknown applet - return {}; - } auto process = std::make_unique(system); auto applet = std::make_shared(system, std::move(process)); diff --git a/src/core/hle/service/am/system_buffer_manager.cpp b/src/core/hle/service/am/system_buffer_manager.cpp index 3d998a334..60a9afc9d 100755 --- a/src/core/hle/service/am/system_buffer_manager.cpp +++ b/src/core/hle/service/am/system_buffer_manager.cpp @@ -60,8 +60,8 @@ void SystemBufferManager::SetWindowVisibility(bool visible) { } } -Result SystemBufferManager::WriteApplicationCaptureBuffer(bool* out_was_written, - s32* out_fbshare_layer_index) { +Result SystemBufferManager::WriteAppletCaptureBuffer(bool* out_was_written, + s32* out_fbshare_layer_index) { // TODO R_SUCCEED(); } diff --git a/src/core/hle/service/am/system_buffer_manager.h b/src/core/hle/service/am/system_buffer_manager.h index 87627ce1b..98c3cf055 100755 --- a/src/core/hle/service/am/system_buffer_manager.h +++ b/src/core/hle/service/am/system_buffer_manager.h @@ -37,7 +37,7 @@ public: void SetWindowVisibility(bool visible); - Result WriteApplicationCaptureBuffer(bool* out_was_written, s32* out_fbshare_layer_index); + Result WriteAppletCaptureBuffer(bool* out_was_written, s32* out_fbshare_layer_index); private: Kernel::KProcess* m_process{}; diff --git a/src/core/hle/service/mii/mii.cpp b/src/core/hle/service/mii/mii.cpp index 7ccbddd9e..5521cc5c4 100755 --- a/src/core/hle/service/mii/mii.cpp +++ b/src/core/hle/service/mii/mii.cpp @@ -4,15 +4,18 @@ #include #include "common/logging/log.h" +#include "core/hle/service/cmif_serialization.h" #include "core/hle/service/ipc_helpers.h" #include "core/hle/service/mii/mii.h" #include "core/hle/service/mii/mii_manager.h" #include "core/hle/service/mii/mii_result.h" #include "core/hle/service/mii/types/char_info.h" +#include "core/hle/service/mii/types/raw_data.h" #include "core/hle/service/mii/types/store_data.h" #include "core/hle/service/mii/types/ver3_store_data.h" #include "core/hle/service/server_manager.h" -#include "core/hle/service/service.h" +#include "core/hle/service/set/system_settings_server.h" +#include "core/hle/service/sm/sm.h" namespace Service::Mii { @@ -24,549 +27,302 @@ public: is_system_} { // clang-format off static const FunctionInfo functions[] = { - {0, &IDatabaseService::IsUpdated, "IsUpdated"}, - {1, &IDatabaseService::IsFullDatabase, "IsFullDatabase"}, - {2, &IDatabaseService::GetCount, "GetCount"}, - {3, &IDatabaseService::Get, "Get"}, - {4, &IDatabaseService::Get1, "Get1"}, - {5, &IDatabaseService::UpdateLatest, "UpdateLatest"}, - {6, &IDatabaseService::BuildRandom, "BuildRandom"}, - {7, &IDatabaseService::BuildDefault, "BuildDefault"}, - {8, &IDatabaseService::Get2, "Get2"}, - {9, &IDatabaseService::Get3, "Get3"}, - {10, &IDatabaseService::UpdateLatest1, "UpdateLatest1"}, - {11, &IDatabaseService::FindIndex, "FindIndex"}, - {12, &IDatabaseService::Move, "Move"}, - {13, &IDatabaseService::AddOrReplace, "AddOrReplace"}, - {14, &IDatabaseService::Delete, "Delete"}, - {15, &IDatabaseService::DestroyFile, "DestroyFile"}, - {16, &IDatabaseService::DeleteFile, "DeleteFile"}, - {17, &IDatabaseService::Format, "Format"}, + {0, D<&IDatabaseService::IsUpdated>, "IsUpdated"}, + {1, D<&IDatabaseService::IsFullDatabase>, "IsFullDatabase"}, + {2, D<&IDatabaseService::GetCount>, "GetCount"}, + {3, D<&IDatabaseService::Get>, "Get"}, + {4, D<&IDatabaseService::Get1>, "Get1"}, + {5, D<&IDatabaseService::UpdateLatest>, "UpdateLatest"}, + {6, D<&IDatabaseService::BuildRandom>, "BuildRandom"}, + {7, D<&IDatabaseService::BuildDefault>, "BuildDefault"}, + {8, D<&IDatabaseService::Get2>, "Get2"}, + {9, D<&IDatabaseService::Get3>, "Get3"}, + {10, D<&IDatabaseService::UpdateLatest1>, "UpdateLatest1"}, + {11, D<&IDatabaseService::FindIndex>, "FindIndex"}, + {12, D<&IDatabaseService::Move>, "Move"}, + {13, D<&IDatabaseService::AddOrReplace>, "AddOrReplace"}, + {14, D<&IDatabaseService::Delete>, "Delete"}, + {15, D<&IDatabaseService::DestroyFile>, "DestroyFile"}, + {16, D<&IDatabaseService::DeleteFile>, "DeleteFile"}, + {17, D<&IDatabaseService::Format>, "Format"}, {18, nullptr, "Import"}, {19, nullptr, "Export"}, - {20, &IDatabaseService::IsBrokenDatabaseWithClearFlag, "IsBrokenDatabaseWithClearFlag"}, - {21, &IDatabaseService::GetIndex, "GetIndex"}, - {22, &IDatabaseService::SetInterfaceVersion, "SetInterfaceVersion"}, - {23, &IDatabaseService::Convert, "Convert"}, - {24, &IDatabaseService::ConvertCoreDataToCharInfo, "ConvertCoreDataToCharInfo"}, - {25, &IDatabaseService::ConvertCharInfoToCoreData, "ConvertCharInfoToCoreData"}, - {26, &IDatabaseService::Append, "Append"}, + {20, D<&IDatabaseService::IsBrokenDatabaseWithClearFlag>, "IsBrokenDatabaseWithClearFlag"}, + {21, D<&IDatabaseService::GetIndex>, "GetIndex"}, + {22, D<&IDatabaseService::SetInterfaceVersion>, "SetInterfaceVersion"}, + {23, D<&IDatabaseService::Convert>, "Convert"}, + {24, D<&IDatabaseService::ConvertCoreDataToCharInfo>, "ConvertCoreDataToCharInfo"}, + {25, D<&IDatabaseService::ConvertCharInfoToCoreData>, "ConvertCharInfoToCoreData"}, + {26, D<&IDatabaseService::Append>, "Append"}, }; // clang-format on RegisterHandlers(functions); + m_set_sys = system.ServiceManager().GetService( + "set:sys", true); manager->Initialize(metadata); } private: - void IsUpdated(HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; - const auto source_flag{rp.PopRaw()}; - + Result IsUpdated(Out out_is_updated, SourceFlag source_flag) { LOG_DEBUG(Service_Mii, "called with source_flag={}", source_flag); - const bool is_updated = manager->IsUpdated(metadata, source_flag); + *out_is_updated = manager->IsUpdated(metadata, source_flag); - IPC::ResponseBuilder rb{ctx, 3}; - rb.Push(ResultSuccess); - rb.Push(is_updated); + R_SUCCEED(); } - void IsFullDatabase(HLERequestContext& ctx) { + Result IsFullDatabase(Out out_is_full_database) { LOG_DEBUG(Service_Mii, "called"); - const bool is_full_database = manager->IsFullDatabase(); + *out_is_full_database = manager->IsFullDatabase(); - IPC::ResponseBuilder rb{ctx, 3}; - rb.Push(ResultSuccess); - rb.Push(is_full_database); + R_SUCCEED(); } - void GetCount(HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; - const auto source_flag{rp.PopRaw()}; + Result GetCount(Out out_mii_count, SourceFlag source_flag) { + *out_mii_count = manager->GetCount(metadata, source_flag); - const u32 mii_count = manager->GetCount(metadata, source_flag); + LOG_DEBUG(Service_Mii, "called with source_flag={}, mii_count={}", source_flag, + *out_mii_count); - LOG_DEBUG(Service_Mii, "called with source_flag={}, mii_count={}", source_flag, mii_count); - - IPC::ResponseBuilder rb{ctx, 3}; - rb.Push(ResultSuccess); - rb.Push(mii_count); + R_SUCCEED(); } - void Get(HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; - const auto source_flag{rp.PopRaw()}; - const auto output_size{ctx.GetWriteBufferNumElements()}; + Result Get(Out out_mii_count, SourceFlag source_flag, + OutArray char_info_element_buffer) { + const auto result = + manager->Get(metadata, char_info_element_buffer, *out_mii_count, source_flag); - u32 mii_count{}; - std::vector char_info_elements(output_size); - const auto result = manager->Get(metadata, char_info_elements, mii_count, source_flag); + LOG_INFO(Service_Mii, "called with source_flag={}, mii_count={}", source_flag, + *out_mii_count); - if (mii_count != 0) { - ctx.WriteBuffer(char_info_elements); - } - - LOG_INFO(Service_Mii, "called with source_flag={}, out_size={}, mii_count={}", source_flag, - output_size, mii_count); - - IPC::ResponseBuilder rb{ctx, 3}; - rb.Push(result); - rb.Push(mii_count); + R_RETURN(result); } - void Get1(HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; - const auto source_flag{rp.PopRaw()}; - const auto output_size{ctx.GetWriteBufferNumElements()}; + Result Get1(Out out_mii_count, SourceFlag source_flag, + OutArray char_info_buffer) { + const auto result = manager->Get(metadata, char_info_buffer, *out_mii_count, source_flag); - u32 mii_count{}; - std::vector char_info(output_size); - const auto result = manager->Get(metadata, char_info, mii_count, source_flag); + LOG_INFO(Service_Mii, "called with source_flag={}, mii_count={}", source_flag, + *out_mii_count); - if (mii_count != 0) { - ctx.WriteBuffer(char_info); - } - - LOG_INFO(Service_Mii, "called with source_flag={}, out_size={}, mii_count={}", source_flag, - output_size, mii_count); - - IPC::ResponseBuilder rb{ctx, 3}; - rb.Push(result); - rb.Push(mii_count); + R_RETURN(result); } - void UpdateLatest(HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; - const auto char_info{rp.PopRaw()}; - const auto source_flag{rp.PopRaw()}; - + Result UpdateLatest(Out out_char_info, CharInfo& char_info, SourceFlag source_flag) { LOG_INFO(Service_Mii, "called with source_flag={}", source_flag); - CharInfo new_char_info{}; - const auto result = manager->UpdateLatest(metadata, new_char_info, char_info, source_flag); - if (result.IsFailure()) { - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(result); - return; - } - - IPC::ResponseBuilder rb{ctx, 2 + sizeof(CharInfo) / sizeof(u32)}; - rb.Push(ResultSuccess); - rb.PushRaw(new_char_info); + R_RETURN(manager->UpdateLatest(metadata, *out_char_info, char_info, source_flag)); } - void BuildRandom(HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; - const auto age{rp.PopRaw()}; - const auto gender{rp.PopRaw()}; - const auto race{rp.PopRaw()}; - + Result BuildRandom(Out out_char_info, Age age, Gender gender, Race race) { LOG_DEBUG(Service_Mii, "called with age={}, gender={}, race={}", age, gender, race); - if (age > Age::All) { - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultInvalidArgument); - return; - } + R_UNLESS(age <= Age::All, ResultInvalidArgument); + R_UNLESS(gender <= Gender::All, ResultInvalidArgument); + R_UNLESS(race <= Race::All, ResultInvalidArgument); - if (gender > Gender::All) { - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultInvalidArgument); - return; - } + manager->BuildRandom(*out_char_info, age, gender, race); - if (race > Race::All) { - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultInvalidArgument); - return; - } - - CharInfo char_info{}; - manager->BuildRandom(char_info, age, gender, race); - - IPC::ResponseBuilder rb{ctx, 2 + sizeof(CharInfo) / sizeof(u32)}; - rb.Push(ResultSuccess); - rb.PushRaw(char_info); + R_SUCCEED(); } - void BuildDefault(HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; - const auto index{rp.Pop()}; - + Result BuildDefault(Out out_char_info, s32 index) { LOG_DEBUG(Service_Mii, "called with index={}", index); + R_UNLESS(index < static_cast(RawData::DefaultMii.size()), ResultInvalidArgument); - if (index > 5) { - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultInvalidArgument); - return; - } + manager->BuildDefault(*out_char_info, index); - CharInfo char_info{}; - manager->BuildDefault(char_info, index); - - IPC::ResponseBuilder rb{ctx, 2 + sizeof(CharInfo) / sizeof(u32)}; - rb.Push(ResultSuccess); - rb.PushRaw(char_info); + R_SUCCEED(); } - void Get2(HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; - const auto source_flag{rp.PopRaw()}; - const auto output_size{ctx.GetWriteBufferNumElements()}; + Result Get2(Out out_mii_count, SourceFlag source_flag, + OutArray store_data_element_buffer) { + const auto result = + manager->Get(metadata, store_data_element_buffer, *out_mii_count, source_flag); - u32 mii_count{}; - std::vector store_data_elements(output_size); - const auto result = manager->Get(metadata, store_data_elements, mii_count, source_flag); + LOG_INFO(Service_Mii, "called with source_flag={}, mii_count={}", source_flag, + *out_mii_count); - if (mii_count != 0) { - ctx.WriteBuffer(store_data_elements); - } - - LOG_INFO(Service_Mii, "called with source_flag={}, out_size={}, mii_count={}", source_flag, - output_size, mii_count); - - IPC::ResponseBuilder rb{ctx, 3}; - rb.Push(result); - rb.Push(mii_count); + R_RETURN(result); } - void Get3(HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; - const auto source_flag{rp.PopRaw()}; - const auto output_size{ctx.GetWriteBufferNumElements()}; + Result Get3(Out out_mii_count, SourceFlag source_flag, + OutArray store_data_buffer) { + const auto result = manager->Get(metadata, store_data_buffer, *out_mii_count, source_flag); - u32 mii_count{}; - std::vector store_data(output_size); - const auto result = manager->Get(metadata, store_data, mii_count, source_flag); + LOG_INFO(Service_Mii, "called with source_flag={}, mii_count={}", source_flag, + *out_mii_count); - if (mii_count != 0) { - ctx.WriteBuffer(store_data); - } - - LOG_INFO(Service_Mii, "called with source_flag={}, out_size={}, mii_count={}", source_flag, - output_size, mii_count); - - IPC::ResponseBuilder rb{ctx, 3}; - rb.Push(result); - rb.Push(mii_count); + R_RETURN(result); } - void UpdateLatest1(HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; - const auto store_data{rp.PopRaw()}; - const auto source_flag{rp.PopRaw()}; - + Result UpdateLatest1(Out out_store_data, StoreData& store_data, + SourceFlag source_flag) { LOG_INFO(Service_Mii, "called with source_flag={}", source_flag); + R_UNLESS(is_system, ResultPermissionDenied); - Result result = ResultSuccess; - if (!is_system) { - result = ResultPermissionDenied; - } - - StoreData new_store_data{}; - if (result.IsSuccess()) { - result = manager->UpdateLatest(metadata, new_store_data, store_data, source_flag); - } - - if (result.IsFailure()) { - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(result); - return; - } - - IPC::ResponseBuilder rb{ctx, 2 + sizeof(StoreData) / sizeof(u32)}; - rb.Push(ResultSuccess); - rb.PushRaw(new_store_data); + R_RETURN(manager->UpdateLatest(metadata, *out_store_data, store_data, source_flag)); } - void FindIndex(HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; - const auto create_id{rp.PopRaw()}; - const auto is_special{rp.PopRaw()}; - + Result FindIndex(Out out_index, Common::UUID create_id, bool is_special) { LOG_INFO(Service_Mii, "called with create_id={}, is_special={}", create_id.FormattedString(), is_special); - const s32 index = manager->FindIndex(create_id, is_special); + *out_index = manager->FindIndex(create_id, is_special); - IPC::ResponseBuilder rb{ctx, 3}; - rb.Push(ResultSuccess); - rb.Push(index); + R_SUCCEED(); } - void Move(HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; - const auto create_id{rp.PopRaw()}; - const auto new_index{rp.PopRaw()}; - + Result Move(Common::UUID create_id, s32 new_index) { LOG_INFO(Service_Mii, "called with create_id={}, new_index={}", create_id.FormattedString(), new_index); + R_UNLESS(is_system, ResultPermissionDenied); - Result result = ResultSuccess; - if (!is_system) { - result = ResultPermissionDenied; - } + const u32 count = manager->GetCount(metadata, SourceFlag::Database); - if (result.IsSuccess()) { - const u32 count = manager->GetCount(metadata, SourceFlag::Database); - if (new_index < 0 || new_index >= static_cast(count)) { - result = ResultInvalidArgument; - } - } + R_UNLESS(new_index >= 0 && new_index < static_cast(count), ResultInvalidArgument); - if (result.IsSuccess()) { - result = manager->Move(metadata, new_index, create_id); - } - - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(result); + R_RETURN(manager->Move(metadata, new_index, create_id)); } - void AddOrReplace(HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; - const auto store_data{rp.PopRaw()}; - + Result AddOrReplace(StoreData& store_data) { LOG_INFO(Service_Mii, "called"); + R_UNLESS(is_system, ResultPermissionDenied); - Result result = ResultSuccess; + const auto result = manager->AddOrReplace(metadata, store_data); - if (!is_system) { - result = ResultPermissionDenied; - } - - if (result.IsSuccess()) { - result = manager->AddOrReplace(metadata, store_data); - } - - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(result); + R_RETURN(result); } - void Delete(HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; - const auto create_id{rp.PopRaw()}; - + Result Delete(Common::UUID create_id) { LOG_INFO(Service_Mii, "called, create_id={}", create_id.FormattedString()); + R_UNLESS(is_system, ResultPermissionDenied); - Result result = ResultSuccess; - - if (!is_system) { - result = ResultPermissionDenied; - } - - if (result.IsSuccess()) { - result = manager->Delete(metadata, create_id); - } - - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(result); + R_RETURN(manager->Delete(metadata, create_id)); } - void DestroyFile(HLERequestContext& ctx) { - // This calls nn::settings::fwdbg::GetSettingsItemValue("is_db_test_mode_enabled"); - const bool is_db_test_mode_enabled = false; + Result DestroyFile() { + bool is_db_test_mode_enabled{}; + m_set_sys->GetSettingsItemValue(is_db_test_mode_enabled, "mii", "is_db_test_mode_enabled"); LOG_INFO(Service_Mii, "called is_db_test_mode_enabled={}", is_db_test_mode_enabled); + R_UNLESS(is_db_test_mode_enabled, ResultTestModeOnly); - Result result = ResultSuccess; - - if (!is_db_test_mode_enabled) { - result = ResultTestModeOnly; - } - - if (result.IsSuccess()) { - result = manager->DestroyFile(metadata); - } - - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(result); + R_RETURN(manager->DestroyFile(metadata)); } - void DeleteFile(HLERequestContext& ctx) { - // This calls nn::settings::fwdbg::GetSettingsItemValue("is_db_test_mode_enabled"); - const bool is_db_test_mode_enabled = false; + Result DeleteFile() { + bool is_db_test_mode_enabled{}; + m_set_sys->GetSettingsItemValue(is_db_test_mode_enabled, "mii", "is_db_test_mode_enabled"); LOG_INFO(Service_Mii, "called is_db_test_mode_enabled={}", is_db_test_mode_enabled); + R_UNLESS(is_db_test_mode_enabled, ResultTestModeOnly); - Result result = ResultSuccess; - - if (!is_db_test_mode_enabled) { - result = ResultTestModeOnly; - } - - if (result.IsSuccess()) { - result = manager->DeleteFile(); - } - - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(result); + R_RETURN(manager->DeleteFile()); } - void Format(HLERequestContext& ctx) { - // This calls nn::settings::fwdbg::GetSettingsItemValue("is_db_test_mode_enabled"); - const bool is_db_test_mode_enabled = false; + Result Format() { + bool is_db_test_mode_enabled{}; + m_set_sys->GetSettingsItemValue(is_db_test_mode_enabled, "mii", "is_db_test_mode_enabled"); LOG_INFO(Service_Mii, "called is_db_test_mode_enabled={}", is_db_test_mode_enabled); + R_UNLESS(is_db_test_mode_enabled, ResultTestModeOnly); - Result result = ResultSuccess; - - if (!is_db_test_mode_enabled) { - result = ResultTestModeOnly; - } - - if (result.IsSuccess()) { - result = manager->Format(metadata); - } - - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(result); + R_RETURN(manager->Format(metadata)); } - void IsBrokenDatabaseWithClearFlag(HLERequestContext& ctx) { + Result IsBrokenDatabaseWithClearFlag(Out out_is_broken_with_clear_flag) { + LOG_DEBUG(Service_Mii, "called"); + R_UNLESS(is_system, ResultPermissionDenied); + + *out_is_broken_with_clear_flag = manager->IsBrokenWithClearFlag(metadata); + + R_SUCCEED(); + } + + Result GetIndex(Out out_index, CharInfo& char_info) { LOG_DEBUG(Service_Mii, "called"); - bool is_broken_with_clear_flag = false; - Result result = ResultSuccess; - - if (!is_system) { - result = ResultPermissionDenied; - } - - if (result.IsSuccess()) { - is_broken_with_clear_flag = manager->IsBrokenWithClearFlag(metadata); - } - - IPC::ResponseBuilder rb{ctx, 3}; - rb.Push(result); - rb.Push(is_broken_with_clear_flag); + R_RETURN(manager->GetIndex(metadata, char_info, *out_index)); } - void GetIndex(HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; - const auto info{rp.PopRaw()}; - - LOG_DEBUG(Service_Mii, "called"); - - s32 index{}; - const auto result = manager->GetIndex(metadata, info, index); - - IPC::ResponseBuilder rb{ctx, 3}; - rb.Push(result); - rb.Push(index); - } - - void SetInterfaceVersion(HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; - const auto interface_version{rp.PopRaw()}; - + Result SetInterfaceVersion(u32 interface_version) { LOG_INFO(Service_Mii, "called, interface_version={:08X}", interface_version); manager->SetInterfaceVersion(metadata, interface_version); - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); + R_SUCCEED(); } - void Convert(HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; - const auto mii_v3{rp.PopRaw()}; - + Result Convert(Out out_char_info, Ver3StoreData& mii_v3) { LOG_INFO(Service_Mii, "called"); - CharInfo char_info{}; - const auto result = manager->ConvertV3ToCharInfo(char_info, mii_v3); - - IPC::ResponseBuilder rb{ctx, 2 + sizeof(CharInfo) / sizeof(u32)}; - rb.Push(result); - rb.PushRaw(char_info); + R_RETURN(manager->ConvertV3ToCharInfo(*out_char_info, mii_v3)); } - void ConvertCoreDataToCharInfo(HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; - const auto core_data{rp.PopRaw()}; - + Result ConvertCoreDataToCharInfo(Out out_char_info, CoreData& core_data) { LOG_INFO(Service_Mii, "called"); - CharInfo char_info{}; - const auto result = manager->ConvertCoreDataToCharInfo(char_info, core_data); - - IPC::ResponseBuilder rb{ctx, 2 + sizeof(CharInfo) / sizeof(u32)}; - rb.Push(result); - rb.PushRaw(char_info); + R_RETURN(manager->ConvertCoreDataToCharInfo(*out_char_info, core_data)); } - void ConvertCharInfoToCoreData(HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; - const auto char_info{rp.PopRaw()}; - + Result ConvertCharInfoToCoreData(Out out_core_data, CharInfo& char_info) { LOG_INFO(Service_Mii, "called"); - CoreData core_data{}; - const auto result = manager->ConvertCharInfoToCoreData(core_data, char_info); - - IPC::ResponseBuilder rb{ctx, 2 + sizeof(CoreData) / sizeof(u32)}; - rb.Push(result); - rb.PushRaw(core_data); + R_RETURN(manager->ConvertCharInfoToCoreData(*out_core_data, char_info)); } - void Append(HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; - const auto char_info{rp.PopRaw()}; - + Result Append(CharInfo& char_info) { LOG_INFO(Service_Mii, "called"); - const auto result = manager->Append(metadata, char_info); - - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(result); + R_RETURN(manager->Append(metadata, char_info)); } std::shared_ptr manager = nullptr; DatabaseSessionMetadata metadata{}; bool is_system{}; + + std::shared_ptr m_set_sys; }; -MiiDBModule::MiiDBModule(Core::System& system_, const char* name_, - std::shared_ptr mii_manager, bool is_system_) +IStaticService::IStaticService(Core::System& system_, const char* name_, + std::shared_ptr mii_manager, bool is_system_) : ServiceFramework{system_, name_}, manager{mii_manager}, is_system{is_system_} { // clang-format off static const FunctionInfo functions[] = { - {0, &MiiDBModule::GetDatabaseService, "GetDatabaseService"}, + {0, D<&IStaticService::GetDatabaseService>, "GetDatabaseService"}, }; // clang-format on RegisterHandlers(functions); - - if (manager == nullptr) { - manager = std::make_shared(); - } } -MiiDBModule::~MiiDBModule() = default; - -void MiiDBModule::GetDatabaseService(HLERequestContext& ctx) { - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(ResultSuccess); - rb.PushIpcInterface(system, manager, is_system); +IStaticService::~IStaticService() = default; +Result IStaticService::GetDatabaseService( + Out> out_database_service) { LOG_DEBUG(Service_Mii, "called"); + + *out_database_service = std::make_shared(system, manager, is_system); + + R_SUCCEED(); } -std::shared_ptr MiiDBModule::GetMiiManager() { +std::shared_ptr IStaticService::GetMiiManager() { return manager; } -class MiiImg final : public ServiceFramework { +class IImageDatabaseService final : public ServiceFramework { public: - explicit MiiImg(Core::System& system_) : ServiceFramework{system_, "miiimg"} { + explicit IImageDatabaseService(Core::System& system_) : ServiceFramework{system_, "miiimg"} { // clang-format off static const FunctionInfo functions[] = { - {0, &MiiImg::Initialize, "Initialize"}, + {0, D<&IImageDatabaseService::Initialize>, "Initialize"}, {10, nullptr, "Reload"}, - {11, &MiiImg::GetCount, "GetCount"}, + {11, D<&IImageDatabaseService::GetCount>, "GetCount"}, {12, nullptr, "IsEmpty"}, {13, nullptr, "IsFull"}, {14, nullptr, "GetAttribute"}, @@ -585,31 +341,30 @@ public: } private: - void Initialize(HLERequestContext& ctx) { + Result Initialize() { LOG_INFO(Service_Mii, "called"); - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); + R_SUCCEED(); } - void GetCount(HLERequestContext& ctx) { + Result GetCount(Out out_count) { LOG_DEBUG(Service_Mii, "called"); - IPC::ResponseBuilder rb{ctx, 3}; - rb.Push(ResultSuccess); - rb.Push(0); + *out_count = 0; + + R_SUCCEED(); } }; void LoopProcess(Core::System& system) { auto server_manager = std::make_unique(system); - std::shared_ptr manager = nullptr; + std::shared_ptr manager = std::make_shared(); server_manager->RegisterNamedService( - "mii:e", std::make_shared(system, "mii:e", manager, true)); + "mii:e", std::make_shared(system, "mii:e", manager, true)); server_manager->RegisterNamedService( - "mii:u", std::make_shared(system, "mii:u", manager, false)); - server_manager->RegisterNamedService("miiimg", std::make_shared(system)); + "mii:u", std::make_shared(system, "mii:u", manager, false)); + server_manager->RegisterNamedService("miiimg", std::make_shared(system)); ServerManager::RunServer(std::move(server_manager)); } diff --git a/src/core/hle/service/mii/mii.h b/src/core/hle/service/mii/mii.h index c73402b62..5d9abcee0 100755 --- a/src/core/hle/service/mii/mii.h +++ b/src/core/hle/service/mii/mii.h @@ -3,7 +3,7 @@ #pragma once -#include "core/hle/service/service.h" +#include "core/hle/service/cmif_types.h" namespace Core { class System; @@ -11,19 +11,20 @@ class System; namespace Service::Mii { class MiiManager; +class IDatabaseService; -class MiiDBModule final : public ServiceFramework { +class IStaticService final : public ServiceFramework { public: - explicit MiiDBModule(Core::System& system_, const char* name_, - std::shared_ptr mii_manager, bool is_system_); - ~MiiDBModule() override; + explicit IStaticService(Core::System& system_, const char* name_, + std::shared_ptr mii_manager, bool is_system_); + ~IStaticService() override; std::shared_ptr GetMiiManager(); private: - void GetDatabaseService(HLERequestContext& ctx); + Result GetDatabaseService(Out> out_database_service); - std::shared_ptr manager = nullptr; + std::shared_ptr manager{nullptr}; bool is_system{}; }; diff --git a/src/core/hle/service/set/system_settings_server.cpp b/src/core/hle/service/set/system_settings_server.cpp index e907b57b6..b80655d2f 100755 --- a/src/core/hle/service/set/system_settings_server.cpp +++ b/src/core/hle/service/set/system_settings_server.cpp @@ -722,6 +722,9 @@ static Settings GetSettings() { ret["hid_debug"]["disabled_features_per_id"] = std::vector(0xa8); ret["hid_debug"]["touch_firmware_auto_update_disabled"] = ToBytes(bool{false}); + // Mii + ret["mii"]["is_db_test_mode_enabled"] = ToBytes(bool{false}); + // Settings ret["settings_debug"]["is_debug_mode_enabled"] = ToBytes(bool{false});