diff options
| author | 2020-04-22 18:39:49 +0200 | |
|---|---|---|
| committer | 2020-04-23 06:32:39 +0200 | |
| commit | 8d917e14f8d066d9cf7f8a1a7d1689731389870f (patch) | |
| tree | dd172b999415f39fdcd372eda8525112c9a82a5b /src | |
| parent | Merge pull request #3699 from FearlessTobi/port-5185 (diff) | |
| download | yuzu-8d917e14f8d066d9cf7f8a1a7d1689731389870f.tar.gz yuzu-8d917e14f8d066d9cf7f8a1a7d1689731389870f.tar.xz yuzu-8d917e14f8d066d9cf7f8a1a7d1689731389870f.zip | |
Edit modifier_scale with the deadzone slider
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuzu/configuration/configure_input_player.cpp | 60 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_player.h | 6 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_player.ui | 16 |
3 files changed, 52 insertions, 30 deletions
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index 15ac30f12..e4eb5594b 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp | |||
| @@ -56,7 +56,6 @@ static void SetAnalogButton(const Common::ParamPackage& input_param, | |||
| 56 | if (analog_param.Get("engine", "") != "analog_from_button") { | 56 | if (analog_param.Get("engine", "") != "analog_from_button") { |
| 57 | analog_param = { | 57 | analog_param = { |
| 58 | {"engine", "analog_from_button"}, | 58 | {"engine", "analog_from_button"}, |
| 59 | {"modifier_scale", "0.5"}, | ||
| 60 | }; | 59 | }; |
| 61 | } | 60 | } |
| 62 | analog_param.Set(button_name, input_param.Serialize()); | 61 | analog_param.Set(button_name, input_param.Serialize()); |
| @@ -236,8 +235,10 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i | |||
| 236 | widget->setVisible(false); | 235 | widget->setVisible(false); |
| 237 | 236 | ||
| 238 | analog_map_stick = {ui->buttonLStickAnalog, ui->buttonRStickAnalog}; | 237 | analog_map_stick = {ui->buttonLStickAnalog, ui->buttonRStickAnalog}; |
| 239 | analog_map_deadzone = {ui->sliderLStickDeadzone, ui->sliderRStickDeadzone}; | 238 | analog_map_deadzone_and_modifier_slider = {ui->sliderLStickDeadzoneAndModifier, |
| 240 | analog_map_deadzone_label = {ui->labelLStickDeadzone, ui->labelRStickDeadzone}; | 239 | ui->sliderRStickDeadzoneAndModifier}; |
| 240 | analog_map_deadzone_and_modifier_slider_label = {ui->labelLStickDeadzoneAndModifier, | ||
| 241 | ui->labelRStickDeadzoneAndModifier}; | ||
| 241 | 242 | ||
| 242 | for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; button_id++) { | 243 | for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; button_id++) { |
| 243 | auto* const button = button_map[button_id]; | 244 | auto* const button = button_map[button_id]; |
| @@ -328,10 +329,18 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i | |||
| 328 | InputCommon::Polling::DeviceType::Analog); | 329 | InputCommon::Polling::DeviceType::Analog); |
| 329 | } | 330 | } |
| 330 | }); | 331 | }); |
| 331 | connect(analog_map_deadzone[analog_id], &QSlider::valueChanged, [=] { | 332 | |
| 332 | const float deadzone = analog_map_deadzone[analog_id]->value() / 100.0f; | 333 | connect(analog_map_deadzone_and_modifier_slider[analog_id], &QSlider::valueChanged, [=] { |
| 333 | analog_map_deadzone_label[analog_id]->setText(tr("Deadzone: %1").arg(deadzone)); | 334 | const float slider_value = analog_map_deadzone_and_modifier_slider[analog_id]->value(); |
| 334 | analogs_param[analog_id].Set("deadzone", deadzone); | 335 | if (analogs_param[analog_id].Get("engine", "") == "sdl") { |
| 336 | analog_map_deadzone_and_modifier_slider_label[analog_id]->setText( | ||
| 337 | tr("Deadzone: %1%").arg(slider_value)); | ||
| 338 | analogs_param[analog_id].Set("deadzone", slider_value / 100.0f); | ||
| 339 | } else { | ||
| 340 | analog_map_deadzone_and_modifier_slider_label[analog_id]->setText( | ||
| 341 | tr("Modifier Scale: %1%").arg(slider_value)); | ||
| 342 | analogs_param[analog_id].Set("modifier_scale", slider_value / 100.0f); | ||
| 343 | } | ||
| 335 | }); | 344 | }); |
| 336 | } | 345 | } |
| 337 | 346 | ||
| @@ -517,20 +526,31 @@ void ConfigureInputPlayer::UpdateButtonLabels() { | |||
| 517 | analog_map_stick[analog_id]->setText(tr("Set Analog Stick")); | 526 | analog_map_stick[analog_id]->setText(tr("Set Analog Stick")); |
| 518 | 527 | ||
| 519 | auto& param = analogs_param[analog_id]; | 528 | auto& param = analogs_param[analog_id]; |
| 520 | auto* const analog_deadzone_slider = analog_map_deadzone[analog_id]; | 529 | auto* const analog_stick_slider = analog_map_deadzone_and_modifier_slider[analog_id]; |
| 521 | auto* const analog_deadzone_label = analog_map_deadzone_label[analog_id]; | 530 | auto* const analog_stick_slider_label = |
| 522 | 531 | analog_map_deadzone_and_modifier_slider_label[analog_id]; | |
| 523 | if (param.Has("engine") && param.Get("engine", "") == "sdl") { | 532 | |
| 524 | if (!param.Has("deadzone")) { | 533 | if (param.Has("engine")) { |
| 525 | param.Set("deadzone", 0.1f); | 534 | if (param.Get("engine", "") == "sdl") { |
| 535 | if (!param.Has("deadzone")) { | ||
| 536 | param.Set("deadzone", 0.1f); | ||
| 537 | } | ||
| 538 | |||
| 539 | analog_stick_slider->setValue(static_cast<int>(param.Get("deadzone", 0.1f) * 100)); | ||
| 540 | if (analog_stick_slider->value() == 0) { | ||
| 541 | analog_stick_slider_label->setText(tr("Deadzone: 0%")); | ||
| 542 | } | ||
| 543 | } else { | ||
| 544 | if (!param.Has("modifier_scale")) { | ||
| 545 | param.Set("modifier_scale", 0.5f); | ||
| 546 | } | ||
| 547 | |||
| 548 | analog_stick_slider->setValue( | ||
| 549 | static_cast<int>(param.Get("modifier_scale", 0.5f) * 100)); | ||
| 550 | if (analog_stick_slider->value() == 0) { | ||
| 551 | analog_stick_slider_label->setText(tr("Modifier Scale: 0%")); | ||
| 552 | } | ||
| 526 | } | 553 | } |
| 527 | |||
| 528 | analog_deadzone_slider->setValue(static_cast<int>(param.Get("deadzone", 0.1f) * 100)); | ||
| 529 | analog_deadzone_slider->setVisible(true); | ||
| 530 | analog_deadzone_label->setVisible(true); | ||
| 531 | } else { | ||
| 532 | analog_deadzone_slider->setVisible(false); | ||
| 533 | analog_deadzone_label->setVisible(false); | ||
| 534 | } | 554 | } |
| 535 | } | 555 | } |
| 536 | } | 556 | } |
diff --git a/src/yuzu/configuration/configure_input_player.h b/src/yuzu/configuration/configure_input_player.h index 045704e47..95afa5375 100644 --- a/src/yuzu/configuration/configure_input_player.h +++ b/src/yuzu/configuration/configure_input_player.h | |||
| @@ -97,8 +97,10 @@ private: | |||
| 97 | /// Analog inputs are also represented each with a single button, used to configure with an | 97 | /// Analog inputs are also represented each with a single button, used to configure with an |
| 98 | /// actual analog stick | 98 | /// actual analog stick |
| 99 | std::array<QPushButton*, Settings::NativeAnalog::NumAnalogs> analog_map_stick; | 99 | std::array<QPushButton*, Settings::NativeAnalog::NumAnalogs> analog_map_stick; |
| 100 | std::array<QSlider*, Settings::NativeAnalog::NumAnalogs> analog_map_deadzone; | 100 | std::array<QSlider*, Settings::NativeAnalog::NumAnalogs> |
| 101 | std::array<QLabel*, Settings::NativeAnalog::NumAnalogs> analog_map_deadzone_label; | 101 | analog_map_deadzone_and_modifier_slider; |
| 102 | std::array<QLabel*, Settings::NativeAnalog::NumAnalogs> | ||
| 103 | analog_map_deadzone_and_modifier_slider_label; | ||
| 102 | 104 | ||
| 103 | static const std::array<std::string, ANALOG_SUB_BUTTONS_NUM> analog_sub_buttons; | 105 | static const std::array<std::string, ANALOG_SUB_BUTTONS_NUM> analog_sub_buttons; |
| 104 | 106 | ||
diff --git a/src/yuzu/configuration/configure_input_player.ui b/src/yuzu/configuration/configure_input_player.ui index 4b37746a1..f27a77180 100644 --- a/src/yuzu/configuration/configure_input_player.ui +++ b/src/yuzu/configuration/configure_input_player.ui | |||
| @@ -171,11 +171,11 @@ | |||
| 171 | </layout> | 171 | </layout> |
| 172 | </item> | 172 | </item> |
| 173 | <item row="4" column="0" colspan="2"> | 173 | <item row="4" column="0" colspan="2"> |
| 174 | <layout class="QVBoxLayout" name="sliderRStickDeadzoneVerticalLayout"> | 174 | <layout class="QVBoxLayout" name="sliderRStickDeadzoneAndModifierVerticalLayout"> |
| 175 | <item> | 175 | <item> |
| 176 | <layout class="QHBoxLayout" name="sliderRStickDeadzoneHorizontalLayout"> | 176 | <layout class="QHBoxLayout" name="sliderRStickDeadzoneAndModifierHorizontalLayout"> |
| 177 | <item> | 177 | <item> |
| 178 | <widget class="QLabel" name="labelRStickDeadzone"> | 178 | <widget class="QLabel" name="labelRStickDeadzoneAndModifier"> |
| 179 | <property name="text"> | 179 | <property name="text"> |
| 180 | <string>Deadzone: 0</string> | 180 | <string>Deadzone: 0</string> |
| 181 | </property> | 181 | </property> |
| @@ -187,7 +187,7 @@ | |||
| 187 | </layout> | 187 | </layout> |
| 188 | </item> | 188 | </item> |
| 189 | <item> | 189 | <item> |
| 190 | <widget class="QSlider" name="sliderRStickDeadzone"> | 190 | <widget class="QSlider" name="sliderRStickDeadzoneAndModifier"> |
| 191 | <property name="orientation"> | 191 | <property name="orientation"> |
| 192 | <enum>Qt::Horizontal</enum> | 192 | <enum>Qt::Horizontal</enum> |
| 193 | </property> | 193 | </property> |
| @@ -784,14 +784,14 @@ | |||
| 784 | </layout> | 784 | </layout> |
| 785 | </item> | 785 | </item> |
| 786 | <item row="5" column="1" colspan="2"> | 786 | <item row="5" column="1" colspan="2"> |
| 787 | <layout class="QVBoxLayout" name="sliderLStickDeadzoneVerticalLayout"> | 787 | <layout class="QVBoxLayout" name="sliderLStickDeadzoneAndModifierVerticalLayout"> |
| 788 | <property name="sizeConstraint"> | 788 | <property name="sizeConstraint"> |
| 789 | <enum>QLayout::SetDefaultConstraint</enum> | 789 | <enum>QLayout::SetDefaultConstraint</enum> |
| 790 | </property> | 790 | </property> |
| 791 | <item> | 791 | <item> |
| 792 | <layout class="QHBoxLayout" name="sliderLStickDeadzoneHorizontalLayout"> | 792 | <layout class="QHBoxLayout" name="sliderLStickDeadzoneAndModifierHorizontalLayout"> |
| 793 | <item> | 793 | <item> |
| 794 | <widget class="QLabel" name="labelLStickDeadzone"> | 794 | <widget class="QLabel" name="labelLStickDeadzoneAndModifier"> |
| 795 | <property name="text"> | 795 | <property name="text"> |
| 796 | <string>Deadzone: 0</string> | 796 | <string>Deadzone: 0</string> |
| 797 | </property> | 797 | </property> |
| @@ -803,7 +803,7 @@ | |||
| 803 | </layout> | 803 | </layout> |
| 804 | </item> | 804 | </item> |
| 805 | <item> | 805 | <item> |
| 806 | <widget class="QSlider" name="sliderLStickDeadzone"> | 806 | <widget class="QSlider" name="sliderLStickDeadzoneAndModifier"> |
| 807 | <property name="orientation"> | 807 | <property name="orientation"> |
| 808 | <enum>Qt::Horizontal</enum> | 808 | <enum>Qt::Horizontal</enum> |
| 809 | </property> | 809 | </property> |