mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 22:00:39 -06:00
Merge pull request #6167 from ligfx/encapsulatedefaultdevice
EmulatedController: encapsulate default device behind getters/setters
This commit is contained in:
@ -78,7 +78,7 @@ void ControlGroup::LoadConfig(IniFile::Section* sec, const std::string& defdev,
|
||||
|
||||
for (auto& ai : ext->attachments)
|
||||
{
|
||||
ai->default_device.FromString(defdev);
|
||||
ai->SetDefaultDevice(defdev);
|
||||
ai->LoadConfig(sec, base + ai->GetName() + "/");
|
||||
|
||||
if (ai->GetName() == extname)
|
||||
|
@ -37,7 +37,7 @@ void EmulatedController::UpdateReferences(const ControllerInterface& devi)
|
||||
for (auto& ctrlGroup : groups)
|
||||
{
|
||||
for (auto& control : ctrlGroup->controls)
|
||||
control->control_ref.get()->UpdateReference(devi, default_device);
|
||||
control->control_ref.get()->UpdateReference(devi, GetDefaultDevice());
|
||||
|
||||
// extension
|
||||
if (ctrlGroup->type == GroupType::Extension)
|
||||
@ -48,8 +48,22 @@ void EmulatedController::UpdateReferences(const ControllerInterface& devi)
|
||||
}
|
||||
}
|
||||
|
||||
void EmulatedController::UpdateDefaultDevice()
|
||||
const ciface::Core::DeviceQualifier& EmulatedController::GetDefaultDevice() const
|
||||
{
|
||||
return m_default_device;
|
||||
}
|
||||
|
||||
void EmulatedController::SetDefaultDevice(const std::string& device)
|
||||
{
|
||||
ciface::Core::DeviceQualifier devq;
|
||||
devq.FromString(device);
|
||||
SetDefaultDevice(std::move(devq));
|
||||
}
|
||||
|
||||
void EmulatedController::SetDefaultDevice(ciface::Core::DeviceQualifier devq)
|
||||
{
|
||||
m_default_device = std::move(devq);
|
||||
|
||||
for (auto& ctrlGroup : groups)
|
||||
{
|
||||
// extension
|
||||
@ -57,8 +71,7 @@ void EmulatedController::UpdateDefaultDevice()
|
||||
{
|
||||
for (auto& ai : ((Extension*)ctrlGroup.get())->attachments)
|
||||
{
|
||||
ai->default_device = default_device;
|
||||
ai->UpdateDefaultDevice();
|
||||
ai->SetDefaultDevice(m_default_device);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -66,11 +79,11 @@ void EmulatedController::UpdateDefaultDevice()
|
||||
|
||||
void EmulatedController::LoadConfig(IniFile::Section* sec, const std::string& base)
|
||||
{
|
||||
std::string defdev = default_device.ToString();
|
||||
std::string defdev = GetDefaultDevice().ToString();
|
||||
if (base.empty())
|
||||
{
|
||||
sec->Get(base + "Device", &defdev, "");
|
||||
default_device.FromString(defdev);
|
||||
SetDefaultDevice(defdev);
|
||||
}
|
||||
|
||||
for (auto& cg : groups)
|
||||
@ -79,7 +92,7 @@ void EmulatedController::LoadConfig(IniFile::Section* sec, const std::string& ba
|
||||
|
||||
void EmulatedController::SaveConfig(IniFile::Section* sec, const std::string& base)
|
||||
{
|
||||
const std::string defdev = default_device.ToString();
|
||||
const std::string defdev = GetDefaultDevice().ToString();
|
||||
if (base.empty())
|
||||
sec->Set(/*std::string(" ") +*/ base + "Device", defdev, "");
|
||||
|
||||
@ -96,8 +109,7 @@ void EmulatedController::LoadDefaults(const ControllerInterface& ciface)
|
||||
const std::string& default_device_string = ciface.GetDefaultDeviceString();
|
||||
if (!default_device_string.empty())
|
||||
{
|
||||
default_device.FromString(default_device_string);
|
||||
UpdateDefaultDevice();
|
||||
SetDefaultDevice(default_device_string);
|
||||
}
|
||||
}
|
||||
} // namespace ControllerEmu
|
||||
|
@ -32,7 +32,10 @@ public:
|
||||
|
||||
virtual void LoadConfig(IniFile::Section* sec, const std::string& base = "");
|
||||
virtual void SaveConfig(IniFile::Section* sec, const std::string& base = "");
|
||||
void UpdateDefaultDevice();
|
||||
|
||||
const ciface::Core::DeviceQualifier& GetDefaultDevice() const;
|
||||
void SetDefaultDevice(const std::string& device);
|
||||
void SetDefaultDevice(ciface::Core::DeviceQualifier devq);
|
||||
|
||||
void UpdateReferences(const ControllerInterface& devi);
|
||||
|
||||
@ -44,6 +47,7 @@ public:
|
||||
|
||||
std::vector<std::unique_ptr<ControlGroup>> groups;
|
||||
|
||||
ciface::Core::DeviceQualifier default_device;
|
||||
private:
|
||||
ciface::Core::DeviceQualifier m_default_device;
|
||||
};
|
||||
} // namespace ControllerEmu
|
||||
|
@ -133,7 +133,7 @@ bool InputConfig::IsControllerControlledByGamepadDevice(int index) const
|
||||
if (static_cast<size_t>(index) >= m_controllers.size())
|
||||
return false;
|
||||
|
||||
const auto& controller = m_controllers.at(index).get()->default_device;
|
||||
const auto& controller = m_controllers.at(index).get()->GetDefaultDevice();
|
||||
|
||||
// Filter out anything which obviously not a gamepad
|
||||
return !((controller.source == "Quartz") // OSX Quartz Keyboard/Mouse
|
||||
|
Reference in New Issue
Block a user