diff --git a/src/citra_qt/configuration/configure_system.cpp b/src/citra_qt/configuration/configure_system.cpp index aa2fac4d8..475699b86 100644 --- a/src/citra_qt/configuration/configure_system.cpp +++ b/src/citra_qt/configuration/configure_system.cpp @@ -246,12 +246,7 @@ void ConfigureSystem::setConfiguration() { ui->edit_init_time->setDateTime(date_time); if (!enabled) { - - auto cfg_interface = Core::System::GetInstance() - .ServiceManager() - .GetService("cfg:u"); - ASSERT_MSG(cfg_interface, "cfg:u not started!"); - cfg = cfg_interface->GetModule(); + cfg = Service::CFG::GetModule(Core::System::GetInstance()); ASSERT_MSG(cfg, "CFG Module missing!"); ReadSystemSettings(); ui->group_system_settings->setEnabled(false); diff --git a/src/core/frontend/applets/swkbd.cpp b/src/core/frontend/applets/swkbd.cpp index f61693ebb..8d10a0742 100644 --- a/src/core/frontend/applets/swkbd.cpp +++ b/src/core/frontend/applets/swkbd.cpp @@ -136,13 +136,9 @@ ValidationError SoftwareKeyboard::Finalize(const std::string& text, u8 button) { void DefaultKeyboard::Setup(const Frontend::KeyboardConfig* config) { SoftwareKeyboard::Setup(config); - auto cfg = - Core::System::GetInstance().ServiceManager().GetService( - "cfg:u"); - ASSERT_MSG(cfg, "cfg:u not started!"); - auto cfg_module = cfg->GetModule(); - ASSERT_MSG(cfg_module, "CFG Module missing!"); - std::string username = Common::UTF16ToUTF8(cfg_module->GetUsername()); + auto cfg = Service::CFG::GetModule(Core::System::GetInstance()); + ASSERT_MSG(cfg, "CFG Module missing!"); + std::string username = Common::UTF16ToUTF8(cfg->GetUsername()); switch (this->config.button_config) { case ButtonConfig::None: case ButtonConfig::Single: diff --git a/src/core/hle/service/apt/applet_manager.cpp b/src/core/hle/service/apt/applet_manager.cpp index 4bb93f9a7..e950542aa 100644 --- a/src/core/hle/service/apt/applet_manager.cpp +++ b/src/core/hle/service/apt/applet_manager.cpp @@ -465,11 +465,9 @@ ResultVal AppletManager::GetAppletInfo(AppletId app_i ErrorLevel::Status); } - auto cfg = system.ServiceManager().GetService("cfg:u"); - ASSERT_MSG(cfg, "cfg:u not started!"); - auto cfg_module = cfg->GetModule(); - ASSERT_MSG(cfg_module, "CFG Module missing!"); - u32 region_value = cfg_module->GetRegionValue(); + auto cfg = Service::CFG::GetModule(system); + ASSERT_MSG(cfg, "CFG Module missing!"); + u32 region_value = cfg->GetRegionValue(); return MakeResult({GetTitleIdForApplet(app_id, region_value), Service::FS::MediaType::NAND, slot->registered, slot->loaded, slot->attributes.raw}); @@ -554,11 +552,9 @@ void AppletManager::EnsureHomeMenuLoaded() { return; } - auto cfg = system.ServiceManager().GetService("cfg:u"); - ASSERT_MSG(cfg, "cfg:u not started!"); - auto cfg_module = cfg->GetModule(); - ASSERT_MSG(cfg_module, "CFG Module missing!"); - u32 region_value = cfg_module->GetRegionValue(); + auto cfg = Service::CFG::GetModule(system); + ASSERT_MSG(cfg, "CFG Module missing!"); + u32 region_value = cfg->GetRegionValue(); u64 menu_title_id = GetTitleIdForApplet(AppletId::HomeMenu, region_value); auto process = NS::LaunchTitle(FS::MediaType::NAND, menu_title_id); if (!process) { diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp index eb5b7d537..7c302bdee 100644 --- a/src/core/hle/service/apt/apt.cpp +++ b/src/core/hle/service/apt/apt.cpp @@ -103,13 +103,9 @@ static u32 DecompressLZ11(const u8* in, u8* out) { bool Module::LoadSharedFont() { u8 font_region_code; - auto cfg = - Core::System::GetInstance().ServiceManager().GetService( - "cfg:u"); - ASSERT_MSG(cfg, "cfg:u not started!"); - auto cfg_module = cfg->GetModule(); - ASSERT_MSG(cfg_module, "CFG Module missing!"); - switch (cfg_module->GetRegionValue()) { + auto cfg = Service::CFG::GetModule(Core::System::GetInstance()); + ASSERT_MSG(cfg, "CFG Module missing!"); + switch (cfg->GetRegionValue()) { case 4: // CHN font_region_code = 2; break; diff --git a/src/core/hle/service/cam/cam.cpp b/src/core/hle/service/cam/cam.cpp index d6399194a..99dad6980 100644 --- a/src/core/hle/service/cam/cam.cpp +++ b/src/core/hle/service/cam/cam.cpp @@ -1052,6 +1052,13 @@ void Module::LoadCameraImplementation(CameraConfig& camera, int camera_id) { camera.impl->SetResolution(camera.contexts[0].resolution); } +std::shared_ptr GetModule(Core::System& system) { + auto cam = system.ServiceManager().GetService("cam:u"); + if (!cam) + return nullptr; + return cam->GetModule(); +} + void InstallInterfaces(Core::System& system) { auto& service_manager = system.ServiceManager(); auto cam = std::make_shared(); diff --git a/src/core/hle/service/cam/cam.h b/src/core/hle/service/cam/cam.h index b8375999c..401a2a203 100644 --- a/src/core/hle/service/cam/cam.h +++ b/src/core/hle/service/cam/cam.h @@ -785,6 +785,8 @@ private: std::atomic is_camera_reload_pending{false}; }; +std::shared_ptr GetModule(Core::System& system); + void InstallInterfaces(Core::System& system); } // namespace Service::CAM diff --git a/src/core/hle/service/cfg/cfg.cpp b/src/core/hle/service/cfg/cfg.cpp index ab73bb048..d5c08a5a7 100644 --- a/src/core/hle/service/cfg/cfg.cpp +++ b/src/core/hle/service/cfg/cfg.cpp @@ -137,7 +137,7 @@ void Module::Interface::GetCountryCodeString(Kernel::HLERequestContext& ctx) { rb.Push(country_codes[country_code_id]); } -std::shared_ptr Module::Interface::GetModule() const { +std::shared_ptr Module::Interface::Interface::GetModule() const { return cfg; } @@ -718,6 +718,13 @@ u64 Module::GetConsoleUniqueId() { return console_id_le; } +std::shared_ptr GetModule(Core::System& system) { + auto cfg = system.ServiceManager().GetService("cfg:u"); + if (!cfg) + return nullptr; + return cfg->GetModule(); +} + void InstallInterfaces(Core::System& system) { auto& service_manager = system.ServiceManager(); auto cfg = std::make_shared(); diff --git a/src/core/hle/service/cfg/cfg.h b/src/core/hle/service/cfg/cfg.h index ed2f65fc8..b069ad728 100644 --- a/src/core/hle/service/cfg/cfg.h +++ b/src/core/hle/service/cfg/cfg.h @@ -411,6 +411,8 @@ private: u32 preferred_region_code = 0; }; +std::shared_ptr GetModule(Core::System& system); + void InstallInterfaces(Core::System& system); } // namespace Service::CFG diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index aa8ddb5f9..b9876012e 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp @@ -390,6 +390,13 @@ void Module::ReloadInputDevices() { is_device_reload_pending.store(true); } +std::shared_ptr GetModule(Core::System& system) { + auto hid = system.ServiceManager().GetService("hid:USER"); + if (!hid) + return nullptr; + return hid->GetModule(); +} + void InstallInterfaces(Core::System& system) { auto& service_manager = system.ServiceManager(); auto hid = std::make_shared(system); diff --git a/src/core/hle/service/hid/hid.h b/src/core/hle/service/hid/hid.h index 75b206dcd..45f94bb30 100644 --- a/src/core/hle/service/hid/hid.h +++ b/src/core/hle/service/hid/hid.h @@ -337,5 +337,7 @@ private: std::unique_ptr touch_device; }; +std::shared_ptr GetModule(Core::System& system); + void InstallInterfaces(Core::System& system); } // namespace Service::HID diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp index 96bf44fcb..2a087366a 100644 --- a/src/core/loader/ncch.cpp +++ b/src/core/loader/ncch.cpp @@ -144,13 +144,9 @@ void AppLoader_NCCH::ParseRegionLockoutInfo() { } region_lockout >>= 1; } - auto cfg = Core::System::GetInstance() - .ServiceManager() - .GetService("cfg:u"); - ASSERT_MSG(cfg, "cfg:u not started!"); - auto cfg_module = cfg->GetModule(); - ASSERT_MSG(cfg_module, "CFG Module missing!"); - cfg_module->SetPreferredRegionCodes(regions); + auto cfg = Service::CFG::GetModule(Core::System::GetInstance()); + ASSERT_MSG(cfg, "CFG Module missing!"); + cfg->SetPreferredRegionCodes(regions); } } diff --git a/src/core/settings.cpp b/src/core/settings.cpp index 22f70aac2..8bdf5689b 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -38,30 +38,22 @@ void Apply() { Core::DSP().SetSink(values.sink_id, values.audio_device_id); Core::DSP().EnableStretching(values.enable_audio_stretching); - auto& sm = system.ServiceManager(); - - auto hid = sm.GetService("hid:USER"); + auto hid = Service::HID::GetModule(system); if (hid) { - auto hid_module = hid->GetModule(); - if (hid_module) { - hid_module->ReloadInputDevices(); - } + hid->ReloadInputDevices(); } + auto sm = system.ServiceManager(); auto ir_user = sm.GetService("ir:USER"); if (ir_user) ir_user->ReloadInputDevices(); - auto ir_rst = sm.GetService("ir:rst"); if (ir_rst) ir_rst->ReloadInputDevices(); - auto cam = sm.GetService("cam:u"); + auto cam = Service::CAM::GetModule(system); if (cam) { - auto cam_module = cam->GetModule(); - if (cam_module) { - cam_module->ReloadCameraDevices(); - } + cam->ReloadCameraDevices(); } } }