mirror of
https://github.com/stenzek/duckstation.git
synced 2024-11-23 05:49:43 +00:00
Qt: Make multitap mode non-inheritable as well
This commit is contained in:
parent
98cce645a9
commit
ac19768247
@ -20,14 +20,16 @@ ControllerGlobalSettingsWidget::ControllerGlobalSettingsWidget(QWidget* parent,
|
||||
|
||||
ControllerSettingWidgetBinder::BindWidgetToInputProfileBool(sif, m_ui.enableSDLSource, "InputSources", "SDL", true);
|
||||
ControllerSettingWidgetBinder::BindWidgetToInputProfileBool(sif, m_ui.enableSDLEnhancedMode, "InputSources",
|
||||
"SDLControllerEnhancedMode", false);
|
||||
"SDLControllerEnhancedMode", false);
|
||||
connect(m_ui.enableSDLSource, &QCheckBox::checkStateChanged, this,
|
||||
&ControllerGlobalSettingsWidget::updateSDLOptionsEnabled);
|
||||
connect(m_ui.ledSettings, &QToolButton::clicked, this, &ControllerGlobalSettingsWidget::ledSettingsClicked);
|
||||
|
||||
#ifdef __APPLE__
|
||||
ControllerSettingWidgetBinder::BindWidgetToInputProfileBool(sif, m_ui.enableSDLIOKitDriver, "InputSources", "SDLIOKitDriver", true);
|
||||
ControllerSettingWidgetBinder::BindWidgetToInputProfileBool(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 +40,12 @@ ControllerGlobalSettingsWidget::ControllerGlobalSettingsWidget(QWidget* parent,
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
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);
|
||||
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;
|
||||
@ -52,9 +57,10 @@ ControllerGlobalSettingsWidget::ControllerGlobalSettingsWidget(QWidget* parent,
|
||||
|
||||
ControllerSettingWidgetBinder::BindWidgetToInputProfileBool(sif, m_ui.enableMouseMapping, "UI", "EnableMouseMapping",
|
||||
false);
|
||||
SettingWidgetBinder::BindWidgetToEnumSetting(sif, m_ui.multitapMode, "ControllerPorts", "MultitapMode",
|
||||
&Settings::ParseMultitapModeName, &Settings::GetMultitapModeName,
|
||||
Settings::DEFAULT_MULTITAP_MODE);
|
||||
ControllerSettingWidgetBinder::BindWidgetToInputProfileEnumSetting(
|
||||
sif, m_ui.multitapMode, "ControllerPorts", "MultitapMode", &Settings::ParseMultitapModeName,
|
||||
&Settings::GetMultitapModeName, &Settings::GetMultitapModeDisplayName, Settings::DEFAULT_MULTITAP_MODE,
|
||||
MultitapMode::Count);
|
||||
ControllerSettingWidgetBinder::BindWidgetToInputProfileFloat(sif, m_ui.pointerXScale, "ControllerPorts",
|
||||
"PointerXScale", 8.0f);
|
||||
ControllerSettingWidgetBinder::BindWidgetToInputProfileFloat(sif, m_ui.pointerYScale, "ControllerPorts",
|
||||
|
@ -98,28 +98,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="multitapMode">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Disabled</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Enable on Port 1 Only</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Enable on Port 2 Only</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Enable on Ports 1 and 2</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="multitapMode" />
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
@ -164,4 +164,60 @@ static void BindWidgetToInputProfileString(SettingsInterface* sif, WidgetType* w
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// Interface specific method of BindWidgetToEnumSetting().
|
||||
template<typename WidgetType, typename DataType, typename ValueCountType>
|
||||
static void BindWidgetToInputProfileEnumSetting(SettingsInterface* sif, WidgetType* widget, std::string section,
|
||||
std::string key,
|
||||
std::optional<DataType> (*from_string_function)(const char* str),
|
||||
const char* (*to_string_function)(DataType value),
|
||||
const char* (*to_display_name_function)(DataType value),
|
||||
DataType default_value, ValueCountType value_count)
|
||||
{
|
||||
using Accessor = SettingWidgetBinder::SettingAccessor<WidgetType>;
|
||||
using UnderlyingType = std::underlying_type_t<DataType>;
|
||||
|
||||
for (UnderlyingType i = 0; i < static_cast<UnderlyingType>(value_count); i++)
|
||||
Accessor::addOption(widget, to_display_name_function(static_cast<DataType>(i)));
|
||||
|
||||
const std::string value =
|
||||
sif ? sif->GetStringValue(section.c_str(), key.c_str(), to_string_function(default_value)) :
|
||||
Host::GetBaseStringSettingValue(section.c_str(), key.c_str(), to_string_function(default_value));
|
||||
const std::optional<DataType> typed_value = from_string_function(value.c_str());
|
||||
if (typed_value.has_value())
|
||||
Accessor::setIntValue(widget, static_cast<int>(static_cast<UnderlyingType>(typed_value.value())));
|
||||
else
|
||||
Accessor::setIntValue(widget, static_cast<int>(static_cast<UnderlyingType>(default_value)));
|
||||
|
||||
if (sif)
|
||||
{
|
||||
Accessor::connectValueChanged(
|
||||
widget, [sif, widget, section = std::move(section), key = std::move(key), to_string_function]() {
|
||||
if (std::optional<int> new_value = Accessor::getIntValue(widget); new_value.has_value())
|
||||
{
|
||||
const char* string_value =
|
||||
to_string_function(static_cast<DataType>(static_cast<UnderlyingType>(new_value.value())));
|
||||
sif->SetStringValue(section.c_str(), key.c_str(), string_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
sif->DeleteValue(section.c_str(), key.c_str());
|
||||
}
|
||||
|
||||
QtHost::SaveGameSettings(sif, true);
|
||||
g_emu_thread->reloadGameSettings();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Accessor::connectValueChanged(
|
||||
widget, [widget, section = std::move(section), key = std::move(key), to_string_function]() {
|
||||
const DataType value = static_cast<DataType>(static_cast<UnderlyingType>(Accessor::getIntValue(widget)));
|
||||
const char* string_value = to_string_function(value);
|
||||
Host::SetBaseStringSettingValue(section.c_str(), key.c_str(), string_value);
|
||||
Host::CommitBaseSettingChanges();
|
||||
g_emu_thread->applySettings();
|
||||
});
|
||||
}
|
||||
}
|
||||
} // namespace ControllerSettingWidgetBinder
|
||||
|
Loading…
Reference in New Issue
Block a user