Qt: Make input source selection non-inheritable

Makes sense to set this in the profile specifically,
given it is tied to devices.
This commit is contained in:
Stenzek 2024-11-03 20:17:42 +10:00
parent a8b588371a
commit 8c4d595a89
No known key found for this signature in database
6 changed files with 36 additions and 19 deletions

View File

@ -3607,7 +3607,7 @@ void FullscreenUI::DoLoadInputProfile()
auto lock = Host::GetSettingsLock();
SettingsInterface* dsi = GetEditingSettingsInterface();
InputManager::CopyConfiguration(dsi, ssi, true, true, IsEditingGameSettings(dsi));
InputManager::CopyConfiguration(dsi, ssi, true, true, true, IsEditingGameSettings(dsi));
SetSettingsChanged(dsi);
ShowToast(std::string(), fmt::format(FSUI_FSTR("Input profile '{}' loaded."), title));
CloseChoiceDialog();
@ -3620,7 +3620,7 @@ void FullscreenUI::DoSaveInputProfile(const std::string& name)
auto lock = Host::GetSettingsLock();
SettingsInterface* ssi = GetEditingSettingsInterface();
InputManager::CopyConfiguration(&dsi, *ssi, true, true, IsEditingGameSettings(ssi));
InputManager::CopyConfiguration(&dsi, *ssi, true, true, true, IsEditingGameSettings(ssi));
if (dsi.Save())
ShowToast(std::string(), fmt::format(FSUI_FSTR("Input profile '{}' saved."), name));
else

View File

@ -18,16 +18,16 @@ ControllerGlobalSettingsWidget::ControllerGlobalSettingsWidget(QWidget* parent,
SettingsInterface* sif = dialog->getEditingSettingsInterface();
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableSDLSource, "InputSources", "SDL", true);
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableSDLEnhancedMode, "InputSources",
ControllerSettingWidgetBinder::BindWidgetToInputProfileBool(sif, m_ui.enableSDLSource, "InputSources", "SDL", true);
ControllerSettingWidgetBinder::BindWidgetToInputProfileBool(sif, m_ui.enableSDLEnhancedMode, "InputSources",
"SDLControllerEnhancedMode", false);
connect(m_ui.enableSDLSource, &QCheckBox::checkStateChanged, this,
&ControllerGlobalSettingsWidget::updateSDLOptionsEnabled);
connect(m_ui.ledSettings, &QToolButton::clicked, this, &ControllerGlobalSettingsWidget::ledSettingsClicked);
#ifdef __APPLE__
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableSDLIOKitDriver, "InputSources", "SDLIOKitDriver", true);
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableSDLMFIDriver, "InputSources", "SDLMFIDriver", true);
ControllerSettingWidgetBinder::BindWidgetToInputProfileBool(sif, m_ui.enableSDLIOKitDriver, "InputSources", "SDLIOKitDriver", true);
ControllerSettingWidgetBinder::BindWidgetToInputProfileBool(sif, m_ui.enableSDLMFIDriver, "InputSources", "SDLMFIDriver", true);
#else
m_ui.sdlGridLayout->removeWidget(m_ui.enableSDLIOKitDriver);
delete m_ui.enableSDLIOKitDriver;
@ -38,9 +38,9 @@ ControllerGlobalSettingsWidget::ControllerGlobalSettingsWidget(QWidget* parent,
#endif
#ifdef _WIN32
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableDInputSource, "InputSources", "DInput", false);
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableXInputSource, "InputSources", "XInput", false);
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableRawInput, "InputSources", "RawInput", false);
ControllerSettingWidgetBinder::BindWidgetToInputProfileBool(sif, m_ui.enableDInputSource, "InputSources", "DInput", false);
ControllerSettingWidgetBinder::BindWidgetToInputProfileBool(sif, m_ui.enableXInputSource, "InputSources", "XInput", false);
ControllerSettingWidgetBinder::BindWidgetToInputProfileBool(sif, m_ui.enableRawInput, "InputSources", "RawInput", false);
#else
m_ui.mainLayout->removeWidget(m_ui.xinputGroup);
delete m_ui.xinputGroup;

View File

@ -196,7 +196,7 @@ void ControllerSettingsWindow::onNewProfileClicked()
// from global
auto lock = Host::GetSettingsLock();
InputManager::CopyConfiguration(&temp_si, *Host::Internal::GetBaseSettingsLayer(), true, true,
InputManager::CopyConfiguration(&temp_si, *Host::Internal::GetBaseSettingsLayer(), true, true, true,
copy_hotkey_bindings);
}
else
@ -205,9 +205,17 @@ void ControllerSettingsWindow::onNewProfileClicked()
const bool copy_hotkey_bindings =
m_editing_settings_interface->GetBoolValue("ControllerPorts", "UseProfileHotkeyBindings", false);
temp_si.SetBoolValue("ControllerPorts", "UseProfileHotkeyBindings", copy_hotkey_bindings);
InputManager::CopyConfiguration(&temp_si, *m_editing_settings_interface, true, true, copy_hotkey_bindings);
InputManager::CopyConfiguration(&temp_si, *m_editing_settings_interface, true, true, true, copy_hotkey_bindings);
}
}
else
{
// still need to copy the source config
if (!m_editing_settings_interface)
InputManager::CopyConfiguration(&temp_si, *Host::Internal::GetBaseSettingsLayer(), false, true, false, false);
else
InputManager::CopyConfiguration(&temp_si, *m_editing_settings_interface, false, true, false, false);
}
if (!temp_si.Save())
{
@ -237,7 +245,7 @@ void ControllerSettingsWindow::onApplyProfileClicked()
m_editing_settings_interface->GetBoolValue("ControllerPorts", "UseProfileHotkeyBindings", false);
auto lock = Host::GetSettingsLock();
InputManager::CopyConfiguration(Host::Internal::GetBaseSettingsLayer(), *m_editing_settings_interface, true, true,
copy_hotkey_bindings);
true, copy_hotkey_bindings);
QtHost::QueueSettingsSave();
}
g_emu_thread->applySettings();
@ -293,7 +301,7 @@ void ControllerSettingsWindow::onCopyGlobalSettingsClicked()
{
const auto lock = Host::GetSettingsLock();
InputManager::CopyConfiguration(m_editing_settings_interface, *Host::Internal::GetBaseSettingsLayer(), true, true,
false);
true, false);
}
m_editing_settings_interface->Save();

View File

@ -350,7 +350,7 @@ void GameSummaryWidget::onInputProfileChanged(int index)
{
const auto lock = Host::GetSettingsLock();
SettingsInterface* base_sif = Host::Internal::GetBaseSettingsLayer();
InputManager::CopyConfiguration(sif, *base_sif, true, true, false);
InputManager::CopyConfiguration(sif, *base_sif, true, true, true, false);
QWidget* dlg_parent = QtUtils::GetRootWidget(this);
QMessageBox::information(dlg_parent, dlg_parent->windowTitle(),

View File

@ -1388,12 +1388,21 @@ void InputManager::ClearPortBindings(SettingsInterface& si, u32 port)
}
void InputManager::CopyConfiguration(SettingsInterface* dest_si, const SettingsInterface& src_si,
bool copy_pad_config /*= true*/, bool copy_pad_bindings /*= true*/,
bool copy_hotkey_bindings /*= true*/)
bool copy_pad_config /*= true*/, bool copy_source_config /*= true*/,
bool copy_pad_bindings /*= true*/, bool copy_hotkey_bindings /*= true*/)
{
if (copy_pad_config)
dest_si->CopyStringValue(src_si, "ControllerPorts", "MultitapMode");
if (copy_source_config)
{
for (u32 type = 0; type < static_cast<u32>(InputSourceType::Count); type++)
{
dest_si->CopyBoolValue(src_si, "InputSources",
InputManager::InputSourceToString(static_cast<InputSourceType>(type)));
}
}
for (u32 port = 0; port < NUM_CONTROLLER_AND_CARD_PORTS; port++)
{
if (Controller::PadIsMultitapSlot(port))
@ -2021,7 +2030,7 @@ bool InputManager::IsInputSourceEnabled(const SettingsInterface& si, InputSource
return true;
#endif
return si.GetBoolValue("InputSources", InputManager::InputSourceToString(type), GetInputSourceDefaultEnabled(type));
return si.GetBoolValue("InputSources", InputSourceToString(type), GetInputSourceDefaultEnabled(type));
}
void InputManager::UpdateInputSourceState(const SettingsInterface& si, std::unique_lock<std::mutex>& settings_lock,
@ -2039,7 +2048,7 @@ void InputManager::UpdateInputSourceState(const SettingsInterface& si, std::uniq
std::unique_ptr<InputSource> source(factory_function());
if (!source->Initialize(si, settings_lock))
{
ERROR_LOG("Source '{}' failed to initialize.", InputManager::InputSourceToString(type));
ERROR_LOG("Source '{}' failed to initialize.", InputSourceToString(type));
return;
}

View File

@ -346,7 +346,7 @@ void ClearPortBindings(SettingsInterface& si, u32 port);
/// Copies pad configuration from one interface (ini) to another.
void CopyConfiguration(SettingsInterface* dest_si, const SettingsInterface& src_si, bool copy_pad_config = true,
bool copy_pad_bindings = true, bool copy_hotkey_bindings = true);
bool copy_source_config = true, bool copy_pad_bindings = true, bool copy_hotkey_bindings = true);
/// Performs automatic controller mapping with the provided list of generic mappings.
bool MapController(SettingsInterface& si, u32 controller,