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);
|
||||
|
||||
if (!enabled) {
|
||||
|
||||
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();
|
||||
cfg = Service::CFG::GetModule(Core::System::GetInstance());
|
||||
ASSERT_MSG(cfg, "CFG Module missing!");
|
||||
ReadSystemSettings();
|
||||
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) {
|
||||
SoftwareKeyboard::Setup(config);
|
||||
|
||||
auto cfg =
|
||||
Core::System::GetInstance().ServiceManager().GetService<Service::CFG::Module::Interface>(
|
||||
"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:
|
||||
|
|
|
@ -465,11 +465,9 @@ ResultVal<AppletManager::AppletInfo> AppletManager::GetAppletInfo(AppletId app_i
|
|||
ErrorLevel::Status);
|
||||
}
|
||||
|
||||
auto cfg = system.ServiceManager().GetService<Service::CFG::Module::Interface>("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<AppletInfo>({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<Service::CFG::Module::Interface>("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) {
|
||||
|
|
|
@ -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<Service::CFG::Module::Interface>(
|
||||
"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;
|
||||
|
|
|
@ -1052,6 +1052,13 @@ void Module::LoadCameraImplementation(CameraConfig& camera, int camera_id) {
|
|||
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) {
|
||||
auto& service_manager = system.ServiceManager();
|
||||
auto cam = std::make_shared<Module>();
|
||||
|
|
|
@ -785,6 +785,8 @@ private:
|
|||
std::atomic<bool> is_camera_reload_pending{false};
|
||||
};
|
||||
|
||||
std::shared_ptr<Module> GetModule(Core::System& system);
|
||||
|
||||
void InstallInterfaces(Core::System& system);
|
||||
|
||||
} // namespace Service::CAM
|
||||
|
|
|
@ -137,7 +137,7 @@ void Module::Interface::GetCountryCodeString(Kernel::HLERequestContext& ctx) {
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -718,6 +718,13 @@ u64 Module::GetConsoleUniqueId() {
|
|||
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) {
|
||||
auto& service_manager = system.ServiceManager();
|
||||
auto cfg = std::make_shared<Module>();
|
||||
|
|
|
@ -411,6 +411,8 @@ private:
|
|||
u32 preferred_region_code = 0;
|
||||
};
|
||||
|
||||
std::shared_ptr<Module> GetModule(Core::System& system);
|
||||
|
||||
void InstallInterfaces(Core::System& system);
|
||||
|
||||
} // namespace Service::CFG
|
||||
|
|
|
@ -390,6 +390,13 @@ void Module::ReloadInputDevices() {
|
|||
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) {
|
||||
auto& service_manager = system.ServiceManager();
|
||||
auto hid = std::make_shared<Module>(system);
|
||||
|
|
|
@ -337,5 +337,7 @@ private:
|
|||
std::unique_ptr<Input::TouchDevice> touch_device;
|
||||
};
|
||||
|
||||
std::shared_ptr<Module> GetModule(Core::System& system);
|
||||
|
||||
void InstallInterfaces(Core::System& system);
|
||||
} // namespace Service::HID
|
||||
|
|
|
@ -144,13 +144,9 @@ void AppLoader_NCCH::ParseRegionLockoutInfo() {
|
|||
}
|
||||
region_lockout >>= 1;
|
||||
}
|
||||
auto cfg = Core::System::GetInstance()
|
||||
.ServiceManager()
|
||||
.GetService<Service::CFG::Module::Interface>("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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Service::HID::Module::Interface>("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<Service::IR::IR_USER>("ir:USER");
|
||||
if (ir_user)
|
||||
ir_user->ReloadInputDevices();
|
||||
|
||||
auto ir_rst = sm.GetService<Service::IR::IR_RST>("ir:rst");
|
||||
if (ir_rst)
|
||||
ir_rst->ReloadInputDevices();
|
||||
|
||||
auto cam = sm.GetService<Service::CAM::Module::Interface>("cam:u");
|
||||
auto cam = Service::CAM::GetModule(system);
|
||||
if (cam) {
|
||||
auto cam_module = cam->GetModule();
|
||||
if (cam_module) {
|
||||
cam_module->ReloadCameraDevices();
|
||||
}
|
||||
cam->ReloadCameraDevices();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue