mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-30 05:10:03 +00:00 
			
		
		
		
	Add GetModule() helper functions, for HID, CAM, and CFG
This commit is contained in:
		
							parent
							
								
									1b1de23a98
								
							
						
					
					
						commit
						eb3af0f16a
					
				
					 12 changed files with 49 additions and 51 deletions
				
			
		|  | @ -246,12 +246,7 @@ void ConfigureSystem::setConfiguration() { | ||||||
|     ui->edit_init_time->setDateTime(date_time); |     ui->edit_init_time->setDateTime(date_time); | ||||||
| 
 | 
 | ||||||
|     if (!enabled) { |     if (!enabled) { | ||||||
| 
 |         cfg = Service::CFG::GetModule(Core::System::GetInstance()); | ||||||
|         auto cfg_interface = Core::System::GetInstance() |  | ||||||
|                                  .ServiceManager() |  | ||||||
|                                  .GetService<Service::CFG::Module::Interface>("cfg:u"); |  | ||||||
|         ASSERT_MSG(cfg_interface, "cfg:u not started!"); |  | ||||||
|         cfg = cfg_interface->GetModule(); |  | ||||||
|         ASSERT_MSG(cfg, "CFG Module missing!"); |         ASSERT_MSG(cfg, "CFG Module missing!"); | ||||||
|         ReadSystemSettings(); |         ReadSystemSettings(); | ||||||
|         ui->group_system_settings->setEnabled(false); |         ui->group_system_settings->setEnabled(false); | ||||||
|  |  | ||||||
|  | @ -136,13 +136,9 @@ ValidationError SoftwareKeyboard::Finalize(const std::string& text, u8 button) { | ||||||
| void DefaultKeyboard::Setup(const Frontend::KeyboardConfig* config) { | void DefaultKeyboard::Setup(const Frontend::KeyboardConfig* config) { | ||||||
|     SoftwareKeyboard::Setup(config); |     SoftwareKeyboard::Setup(config); | ||||||
| 
 | 
 | ||||||
|     auto cfg = |     auto cfg = Service::CFG::GetModule(Core::System::GetInstance()); | ||||||
|         Core::System::GetInstance().ServiceManager().GetService<Service::CFG::Module::Interface>( |     ASSERT_MSG(cfg, "CFG Module missing!"); | ||||||
|             "cfg:u"); |     std::string username = Common::UTF16ToUTF8(cfg->GetUsername()); | ||||||
|     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()); |  | ||||||
|     switch (this->config.button_config) { |     switch (this->config.button_config) { | ||||||
|     case ButtonConfig::None: |     case ButtonConfig::None: | ||||||
|     case ButtonConfig::Single: |     case ButtonConfig::Single: | ||||||
|  |  | ||||||
|  | @ -465,11 +465,9 @@ ResultVal<AppletManager::AppletInfo> AppletManager::GetAppletInfo(AppletId app_i | ||||||
|                           ErrorLevel::Status); |                           ErrorLevel::Status); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     auto cfg = system.ServiceManager().GetService<Service::CFG::Module::Interface>("cfg:u"); |     auto cfg = Service::CFG::GetModule(system); | ||||||
|     ASSERT_MSG(cfg, "cfg:u not started!"); |     ASSERT_MSG(cfg, "CFG Module missing!"); | ||||||
|     auto cfg_module = cfg->GetModule(); |     u32 region_value = cfg->GetRegionValue(); | ||||||
|     ASSERT_MSG(cfg_module, "CFG Module missing!"); |  | ||||||
|     u32 region_value = cfg_module->GetRegionValue(); |  | ||||||
|     return MakeResult<AppletInfo>({GetTitleIdForApplet(app_id, region_value), |     return MakeResult<AppletInfo>({GetTitleIdForApplet(app_id, region_value), | ||||||
|                                    Service::FS::MediaType::NAND, slot->registered, slot->loaded, |                                    Service::FS::MediaType::NAND, slot->registered, slot->loaded, | ||||||
|                                    slot->attributes.raw}); |                                    slot->attributes.raw}); | ||||||
|  | @ -554,11 +552,9 @@ void AppletManager::EnsureHomeMenuLoaded() { | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     auto cfg = system.ServiceManager().GetService<Service::CFG::Module::Interface>("cfg:u"); |     auto cfg = Service::CFG::GetModule(system); | ||||||
|     ASSERT_MSG(cfg, "cfg:u not started!"); |     ASSERT_MSG(cfg, "CFG Module missing!"); | ||||||
|     auto cfg_module = cfg->GetModule(); |     u32 region_value = cfg->GetRegionValue(); | ||||||
|     ASSERT_MSG(cfg_module, "CFG Module missing!"); |  | ||||||
|     u32 region_value = cfg_module->GetRegionValue(); |  | ||||||
|     u64 menu_title_id = GetTitleIdForApplet(AppletId::HomeMenu, region_value); |     u64 menu_title_id = GetTitleIdForApplet(AppletId::HomeMenu, region_value); | ||||||
|     auto process = NS::LaunchTitle(FS::MediaType::NAND, menu_title_id); |     auto process = NS::LaunchTitle(FS::MediaType::NAND, menu_title_id); | ||||||
|     if (!process) { |     if (!process) { | ||||||
|  |  | ||||||
|  | @ -103,13 +103,9 @@ static u32 DecompressLZ11(const u8* in, u8* out) { | ||||||
| 
 | 
 | ||||||
| bool Module::LoadSharedFont() { | bool Module::LoadSharedFont() { | ||||||
|     u8 font_region_code; |     u8 font_region_code; | ||||||
|     auto cfg = |     auto cfg = Service::CFG::GetModule(Core::System::GetInstance()); | ||||||
|         Core::System::GetInstance().ServiceManager().GetService<Service::CFG::Module::Interface>( |     ASSERT_MSG(cfg, "CFG Module missing!"); | ||||||
|             "cfg:u"); |     switch (cfg->GetRegionValue()) { | ||||||
|     ASSERT_MSG(cfg, "cfg:u not started!"); |  | ||||||
|     auto cfg_module = cfg->GetModule(); |  | ||||||
|     ASSERT_MSG(cfg_module, "CFG Module missing!"); |  | ||||||
|     switch (cfg_module->GetRegionValue()) { |  | ||||||
|     case 4: // CHN
 |     case 4: // CHN
 | ||||||
|         font_region_code = 2; |         font_region_code = 2; | ||||||
|         break; |         break; | ||||||
|  |  | ||||||
|  | @ -1052,6 +1052,13 @@ void Module::LoadCameraImplementation(CameraConfig& camera, int camera_id) { | ||||||
|     camera.impl->SetResolution(camera.contexts[0].resolution); |     camera.impl->SetResolution(camera.contexts[0].resolution); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | std::shared_ptr<Module> GetModule(Core::System& system) { | ||||||
|  |     auto cam = system.ServiceManager().GetService<Service::CAM::Module::Interface>("cam:u"); | ||||||
|  |     if (!cam) | ||||||
|  |         return nullptr; | ||||||
|  |     return cam->GetModule(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| void InstallInterfaces(Core::System& system) { | void InstallInterfaces(Core::System& system) { | ||||||
|     auto& service_manager = system.ServiceManager(); |     auto& service_manager = system.ServiceManager(); | ||||||
|     auto cam = std::make_shared<Module>(); |     auto cam = std::make_shared<Module>(); | ||||||
|  |  | ||||||
|  | @ -785,6 +785,8 @@ private: | ||||||
|     std::atomic<bool> is_camera_reload_pending{false}; |     std::atomic<bool> is_camera_reload_pending{false}; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | std::shared_ptr<Module> GetModule(Core::System& system); | ||||||
|  | 
 | ||||||
| void InstallInterfaces(Core::System& system); | void InstallInterfaces(Core::System& system); | ||||||
| 
 | 
 | ||||||
| } // namespace Service::CAM
 | } // namespace Service::CAM
 | ||||||
|  |  | ||||||
|  | @ -137,7 +137,7 @@ void Module::Interface::GetCountryCodeString(Kernel::HLERequestContext& ctx) { | ||||||
|     rb.Push<u32>(country_codes[country_code_id]); |     rb.Push<u32>(country_codes[country_code_id]); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| std::shared_ptr<Module> Module::Interface::GetModule() const { | std::shared_ptr<Module> Module::Interface::Interface::GetModule() const { | ||||||
|     return cfg; |     return cfg; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -718,6 +718,13 @@ u64 Module::GetConsoleUniqueId() { | ||||||
|     return console_id_le; |     return console_id_le; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | std::shared_ptr<Module> GetModule(Core::System& system) { | ||||||
|  |     auto cfg = system.ServiceManager().GetService<Service::CFG::Module::Interface>("cfg:u"); | ||||||
|  |     if (!cfg) | ||||||
|  |         return nullptr; | ||||||
|  |     return cfg->GetModule(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| void InstallInterfaces(Core::System& system) { | void InstallInterfaces(Core::System& system) { | ||||||
|     auto& service_manager = system.ServiceManager(); |     auto& service_manager = system.ServiceManager(); | ||||||
|     auto cfg = std::make_shared<Module>(); |     auto cfg = std::make_shared<Module>(); | ||||||
|  |  | ||||||
|  | @ -411,6 +411,8 @@ private: | ||||||
|     u32 preferred_region_code = 0; |     u32 preferred_region_code = 0; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | std::shared_ptr<Module> GetModule(Core::System& system); | ||||||
|  | 
 | ||||||
| void InstallInterfaces(Core::System& system); | void InstallInterfaces(Core::System& system); | ||||||
| 
 | 
 | ||||||
| } // namespace Service::CFG
 | } // namespace Service::CFG
 | ||||||
|  |  | ||||||
|  | @ -390,6 +390,13 @@ void Module::ReloadInputDevices() { | ||||||
|     is_device_reload_pending.store(true); |     is_device_reload_pending.store(true); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | std::shared_ptr<Module> GetModule(Core::System& system) { | ||||||
|  |     auto hid = system.ServiceManager().GetService<Service::HID::Module::Interface>("hid:USER"); | ||||||
|  |     if (!hid) | ||||||
|  |         return nullptr; | ||||||
|  |     return hid->GetModule(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| void InstallInterfaces(Core::System& system) { | void InstallInterfaces(Core::System& system) { | ||||||
|     auto& service_manager = system.ServiceManager(); |     auto& service_manager = system.ServiceManager(); | ||||||
|     auto hid = std::make_shared<Module>(system); |     auto hid = std::make_shared<Module>(system); | ||||||
|  |  | ||||||
|  | @ -337,5 +337,7 @@ private: | ||||||
|     std::unique_ptr<Input::TouchDevice> touch_device; |     std::unique_ptr<Input::TouchDevice> touch_device; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | std::shared_ptr<Module> GetModule(Core::System& system); | ||||||
|  | 
 | ||||||
| void InstallInterfaces(Core::System& system); | void InstallInterfaces(Core::System& system); | ||||||
| } // namespace Service::HID
 | } // namespace Service::HID
 | ||||||
|  |  | ||||||
|  | @ -144,13 +144,9 @@ void AppLoader_NCCH::ParseRegionLockoutInfo() { | ||||||
|             } |             } | ||||||
|             region_lockout >>= 1; |             region_lockout >>= 1; | ||||||
|         } |         } | ||||||
|         auto cfg = Core::System::GetInstance() |         auto cfg = Service::CFG::GetModule(Core::System::GetInstance()); | ||||||
|                        .ServiceManager() |         ASSERT_MSG(cfg, "CFG Module missing!"); | ||||||
|                        .GetService<Service::CFG::Module::Interface>("cfg:u"); |         cfg->SetPreferredRegionCodes(regions); | ||||||
|         ASSERT_MSG(cfg, "cfg:u not started!"); |  | ||||||
|         auto cfg_module = cfg->GetModule(); |  | ||||||
|         ASSERT_MSG(cfg_module, "CFG Module missing!"); |  | ||||||
|         cfg_module->SetPreferredRegionCodes(regions); |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -38,30 +38,22 @@ void Apply() { | ||||||
|         Core::DSP().SetSink(values.sink_id, values.audio_device_id); |         Core::DSP().SetSink(values.sink_id, values.audio_device_id); | ||||||
|         Core::DSP().EnableStretching(values.enable_audio_stretching); |         Core::DSP().EnableStretching(values.enable_audio_stretching); | ||||||
| 
 | 
 | ||||||
|         auto& sm = system.ServiceManager(); |         auto hid = Service::HID::GetModule(system); | ||||||
| 
 |  | ||||||
|         auto hid = sm.GetService<Service::HID::Module::Interface>("hid:USER"); |  | ||||||
|         if (hid) { |         if (hid) { | ||||||
|             auto hid_module = hid->GetModule(); |             hid->ReloadInputDevices(); | ||||||
|             if (hid_module) { |  | ||||||
|                 hid_module->ReloadInputDevices(); |  | ||||||
|             } |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |         auto sm = system.ServiceManager(); | ||||||
|         auto ir_user = sm.GetService<Service::IR::IR_USER>("ir:USER"); |         auto ir_user = sm.GetService<Service::IR::IR_USER>("ir:USER"); | ||||||
|         if (ir_user) |         if (ir_user) | ||||||
|             ir_user->ReloadInputDevices(); |             ir_user->ReloadInputDevices(); | ||||||
| 
 |  | ||||||
|         auto ir_rst = sm.GetService<Service::IR::IR_RST>("ir:rst"); |         auto ir_rst = sm.GetService<Service::IR::IR_RST>("ir:rst"); | ||||||
|         if (ir_rst) |         if (ir_rst) | ||||||
|             ir_rst->ReloadInputDevices(); |             ir_rst->ReloadInputDevices(); | ||||||
| 
 | 
 | ||||||
|         auto cam = sm.GetService<Service::CAM::Module::Interface>("cam:u"); |         auto cam = Service::CAM::GetModule(system); | ||||||
|         if (cam) { |         if (cam) { | ||||||
|             auto cam_module = cam->GetModule(); |             cam->ReloadCameraDevices(); | ||||||
|             if (cam_module) { |  | ||||||
|                 cam_module->ReloadCameraDevices(); |  | ||||||
|             } |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue