diff --git a/src/citra_qt/configuration/configure_input.cpp b/src/citra_qt/configuration/configure_input.cpp index 2f7e70c774..657f404f1a 100644 --- a/src/citra_qt/configuration/configure_input.cpp +++ b/src/citra_qt/configuration/configure_input.cpp @@ -43,7 +43,6 @@ static void SetAnalogButton(const Common::ParamPackage& input_param, if (analog_param.Get("engine", "") != "analog_from_button") { analog_param = { {"engine", "analog_from_button"}, - {"modifier_scale", "0.5"}, }; } analog_param.Set(button_name, input_param.Serialize()); @@ -155,6 +154,10 @@ ConfigureInput::ConfigureInput(QWidget* parent) }}; analog_map_stick = {ui->buttonCircleAnalog, ui->buttonCStickAnalog}; + analog_map_deadzone_and_modifier_slider = {ui->sliderCirclePadDeadzoneAndModifier, + ui->sliderCStickDeadzoneAndModifier}; + analog_map_deadzone_and_modifier_slider_label = {ui->labelCirclePadDeadzoneAndModifier, + ui->labelCStickDeadzoneAndModifier}; for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; button_id++) { if (!button_map[button_id]) @@ -245,6 +248,18 @@ ConfigureInput::ConfigureInput(QWidget* parent) InputCommon::Polling::DeviceType::Analog); } }); + connect(analog_map_deadzone_and_modifier_slider[analog_id], &QSlider::valueChanged, [=] { + const float slider_value = analog_map_deadzone_and_modifier_slider[analog_id]->value(); + 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); + } + }); } connect(ui->buttonMotionTouch, &QPushButton::clicked, [this] { @@ -360,11 +375,7 @@ void ConfigureInput::ClearAll() { buttons_param[button_id].Clear(); } for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; analog_id++) { - for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; sub_button_id++) { - if (analog_map_buttons[analog_id][sub_button_id] && - analog_map_buttons[analog_id][sub_button_id]->isEnabled()) - analogs_param[analog_id].Erase(analog_sub_buttons[sub_button_id]); - } + analogs_param[analog_id].Clear(); } UpdateButtonLabels(); } @@ -383,6 +394,34 @@ void ConfigureInput::UpdateButtonLabels() { } } analog_map_stick[analog_id]->setText(tr("Set Analog Stick")); + + auto& param = analogs_param[analog_id]; + auto* const analog_stick_slider = analog_map_deadzone_and_modifier_slider[analog_id]; + auto* const analog_stick_slider_label = + analog_map_deadzone_and_modifier_slider_label[analog_id]; + + if (param.Has("engine")) { + if (param.Get("engine", "") == "sdl") { + if (!param.Has("deadzone")) { + param.Set("deadzone", 0.1f); + } + + analog_stick_slider->setValue(static_cast(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(param.Get("modifier_scale", 0.5f) * 100)); + if (analog_stick_slider->value() == 0) { + analog_stick_slider_label->setText(tr("Modifier Scale: 0%")); + } + } + } } EmitInputKeysChanged(); diff --git a/src/citra_qt/configuration/configure_input.h b/src/citra_qt/configuration/configure_input.h index 2421b32912..1fd87245ce 100644 --- a/src/citra_qt/configuration/configure_input.h +++ b/src/citra_qt/configuration/configure_input.h @@ -12,6 +12,7 @@ #include #include #include +#include #include #include "common/param_package.h" #include "core/settings.h" @@ -74,6 +75,10 @@ private: /// Analog inputs are also represented each with a single button, used to configure with an /// actual analog stick std::array analog_map_stick; + std::array + analog_map_deadzone_and_modifier_slider; + std::array + analog_map_deadzone_and_modifier_slider_label; static const std::array analog_sub_buttons; diff --git a/src/citra_qt/configuration/configure_input.ui b/src/citra_qt/configuration/configure_input.ui index 6d0cb8ac74..3a76730adf 100644 --- a/src/citra_qt/configuration/configure_input.ui +++ b/src/citra_qt/configuration/configure_input.ui @@ -7,7 +7,7 @@ 0 0 374 - 595 + 670 @@ -238,281 +238,6 @@ - - - - Shoulder Buttons - - - false - - - false - - - - - - - - L: - - - - - - - - - - - - - - - - - - R: - - - - - - - - - - - - - - - - - - ZL: - - - - - - - - - - - - - - - - - - ZR: - - - - - - - - - - - - - - - - - - - Circle Pad - - - false - - - false - - - - - - - - Up: - - - - - - - - - - - - - - - - - - Down: - - - - - - - - - - - - - - - - - - Right: - - - - - - - - - - - - - - - - Set Analog Stick - - - - - - - - - Left: - - - - - - - - - - - - - - - - - - - C-Stick - - - false - - - false - - - - - - - - Left: - - - - - - - - - - - - - - - - - - Right: - - - - - - - - - - - - - - - - - - Up: - - - - - - - - - - - - - - - - - - Down: - - - - - - - - - - - - - - - - Set Analog Stick - - - - - - @@ -636,6 +361,337 @@ + + + + Circle Pad + + + false + + + false + + + + + + + + Up: + + + + + + + + + + + + + + + + + + Right: + + + + + + + + + + + + + + + + + + Left: + + + + + + + + + + + + + + + + Set Analog Stick + + + + + + + + + Down: + + + + + + + + + + + + + + + + + + QLayout::SetDefaultConstraint + + + + + Deadzone: 0 + + + Qt::AlignHCenter + + + + + + + + + Qt::Horizontal + + + + + + + + + + + + C-Stick + + + false + + + false + + + + + + + + Right: + + + + + + + + + + + + + + + + + + Left: + + + + + + + + + + + + + + + + + + Up: + + + + + + + + + + + + + + + + Set Analog Stick + + + + + + + + + Down: + + + + + + + + + + + + + + + + QLayout::SetDefaultConstraint + + + + + + + Deadzone: 0 + + + Qt::AlignHCenter + + + + + + + + + Qt::Horizontal + + + + + + + + + + + + Shoulder Buttons + + + false + + + false + + + + + + + + ZR: + + + + + + + + + + + + + + + + + + ZL: + + + + + + + + + + + + + + + + + + L: + + + + + + + + + + + + + + + + + + R: + + + + + + + + + + + + + + +