forked from ShuriZma/suyu
1
0
Fork 0

Edit modifier_scale with the deadzone slider

This commit is contained in:
Kewlan 2020-04-22 18:39:49 +02:00
parent e84f82a028
commit 8d917e14f8
3 changed files with 51 additions and 29 deletions

View File

@ -56,7 +56,6 @@ static void SetAnalogButton(const Common::ParamPackage& input_param,
if (analog_param.Get("engine", "") != "analog_from_button") { if (analog_param.Get("engine", "") != "analog_from_button") {
analog_param = { analog_param = {
{"engine", "analog_from_button"}, {"engine", "analog_from_button"},
{"modifier_scale", "0.5"},
}; };
} }
analog_param.Set(button_name, input_param.Serialize()); analog_param.Set(button_name, input_param.Serialize());
@ -236,8 +235,10 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
widget->setVisible(false); widget->setVisible(false);
analog_map_stick = {ui->buttonLStickAnalog, ui->buttonRStickAnalog}; analog_map_stick = {ui->buttonLStickAnalog, ui->buttonRStickAnalog};
analog_map_deadzone = {ui->sliderLStickDeadzone, ui->sliderRStickDeadzone}; analog_map_deadzone_and_modifier_slider = {ui->sliderLStickDeadzoneAndModifier,
analog_map_deadzone_label = {ui->labelLStickDeadzone, ui->labelRStickDeadzone}; ui->sliderRStickDeadzoneAndModifier};
analog_map_deadzone_and_modifier_slider_label = {ui->labelLStickDeadzoneAndModifier,
ui->labelRStickDeadzoneAndModifier};
for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; button_id++) { for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; button_id++) {
auto* const button = button_map[button_id]; auto* const button = button_map[button_id];
@ -328,10 +329,18 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
InputCommon::Polling::DeviceType::Analog); InputCommon::Polling::DeviceType::Analog);
} }
}); });
connect(analog_map_deadzone[analog_id], &QSlider::valueChanged, [=] {
const float deadzone = analog_map_deadzone[analog_id]->value() / 100.0f; connect(analog_map_deadzone_and_modifier_slider[analog_id], &QSlider::valueChanged, [=] {
analog_map_deadzone_label[analog_id]->setText(tr("Deadzone: %1").arg(deadzone)); const float slider_value = analog_map_deadzone_and_modifier_slider[analog_id]->value();
analogs_param[analog_id].Set("deadzone", deadzone); if (analogs_param[analog_id].Get("engine", "") == "sdl") {
analog_map_deadzone_and_modifier_slider_label[analog_id]->setText(
tr("Deadzone: %1%").arg(slider_value));
analogs_param[analog_id].Set("deadzone", slider_value / 100.0f);
} else {
analog_map_deadzone_and_modifier_slider_label[analog_id]->setText(
tr("Modifier Scale: %1%").arg(slider_value));
analogs_param[analog_id].Set("modifier_scale", slider_value / 100.0f);
}
}); });
} }
@ -517,20 +526,31 @@ void ConfigureInputPlayer::UpdateButtonLabels() {
analog_map_stick[analog_id]->setText(tr("Set Analog Stick")); analog_map_stick[analog_id]->setText(tr("Set Analog Stick"));
auto& param = analogs_param[analog_id]; auto& param = analogs_param[analog_id];
auto* const analog_deadzone_slider = analog_map_deadzone[analog_id]; auto* const analog_stick_slider = analog_map_deadzone_and_modifier_slider[analog_id];
auto* const analog_deadzone_label = analog_map_deadzone_label[analog_id]; auto* const analog_stick_slider_label =
analog_map_deadzone_and_modifier_slider_label[analog_id];
if (param.Has("engine") && param.Get("engine", "") == "sdl") { if (param.Has("engine")) {
if (!param.Has("deadzone")) { if (param.Get("engine", "") == "sdl") {
param.Set("deadzone", 0.1f); if (!param.Has("deadzone")) {
param.Set("deadzone", 0.1f);
}
analog_stick_slider->setValue(static_cast<int>(param.Get("deadzone", 0.1f) * 100));
if (analog_stick_slider->value() == 0) {
analog_stick_slider_label->setText(tr("Deadzone: 0%"));
}
} else {
if (!param.Has("modifier_scale")) {
param.Set("modifier_scale", 0.5f);
}
analog_stick_slider->setValue(
static_cast<int>(param.Get("modifier_scale", 0.5f) * 100));
if (analog_stick_slider->value() == 0) {
analog_stick_slider_label->setText(tr("Modifier Scale: 0%"));
}
} }
analog_deadzone_slider->setValue(static_cast<int>(param.Get("deadzone", 0.1f) * 100));
analog_deadzone_slider->setVisible(true);
analog_deadzone_label->setVisible(true);
} else {
analog_deadzone_slider->setVisible(false);
analog_deadzone_label->setVisible(false);
} }
} }
} }

View File

@ -97,8 +97,10 @@ private:
/// Analog inputs are also represented each with a single button, used to configure with an /// Analog inputs are also represented each with a single button, used to configure with an
/// actual analog stick /// actual analog stick
std::array<QPushButton*, Settings::NativeAnalog::NumAnalogs> analog_map_stick; std::array<QPushButton*, Settings::NativeAnalog::NumAnalogs> analog_map_stick;
std::array<QSlider*, Settings::NativeAnalog::NumAnalogs> analog_map_deadzone; std::array<QSlider*, Settings::NativeAnalog::NumAnalogs>
std::array<QLabel*, Settings::NativeAnalog::NumAnalogs> analog_map_deadzone_label; analog_map_deadzone_and_modifier_slider;
std::array<QLabel*, Settings::NativeAnalog::NumAnalogs>
analog_map_deadzone_and_modifier_slider_label;
static const std::array<std::string, ANALOG_SUB_BUTTONS_NUM> analog_sub_buttons; static const std::array<std::string, ANALOG_SUB_BUTTONS_NUM> analog_sub_buttons;

View File

@ -171,11 +171,11 @@
</layout> </layout>
</item> </item>
<item row="4" column="0" colspan="2"> <item row="4" column="0" colspan="2">
<layout class="QVBoxLayout" name="sliderRStickDeadzoneVerticalLayout"> <layout class="QVBoxLayout" name="sliderRStickDeadzoneAndModifierVerticalLayout">
<item> <item>
<layout class="QHBoxLayout" name="sliderRStickDeadzoneHorizontalLayout"> <layout class="QHBoxLayout" name="sliderRStickDeadzoneAndModifierHorizontalLayout">
<item> <item>
<widget class="QLabel" name="labelRStickDeadzone"> <widget class="QLabel" name="labelRStickDeadzoneAndModifier">
<property name="text"> <property name="text">
<string>Deadzone: 0</string> <string>Deadzone: 0</string>
</property> </property>
@ -187,7 +187,7 @@
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QSlider" name="sliderRStickDeadzone"> <widget class="QSlider" name="sliderRStickDeadzoneAndModifier">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
@ -784,14 +784,14 @@
</layout> </layout>
</item> </item>
<item row="5" column="1" colspan="2"> <item row="5" column="1" colspan="2">
<layout class="QVBoxLayout" name="sliderLStickDeadzoneVerticalLayout"> <layout class="QVBoxLayout" name="sliderLStickDeadzoneAndModifierVerticalLayout">
<property name="sizeConstraint"> <property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum> <enum>QLayout::SetDefaultConstraint</enum>
</property> </property>
<item> <item>
<layout class="QHBoxLayout" name="sliderLStickDeadzoneHorizontalLayout"> <layout class="QHBoxLayout" name="sliderLStickDeadzoneAndModifierHorizontalLayout">
<item> <item>
<widget class="QLabel" name="labelLStickDeadzone"> <widget class="QLabel" name="labelLStickDeadzoneAndModifier">
<property name="text"> <property name="text">
<string>Deadzone: 0</string> <string>Deadzone: 0</string>
</property> </property>
@ -803,7 +803,7 @@
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QSlider" name="sliderLStickDeadzone"> <widget class="QSlider" name="sliderLStickDeadzoneAndModifier">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>