summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgerman77 <juangerman-13@hotmail.com>2021-07-17 20:30:43 +0200
committergerman77 <juangerman-13@hotmail.com>2021-07-17 20:30:43 +0200
commit2c339a51145bce113e48c1d7ed03619a1c885068 (patch)
tree7ef1b907cac7dd95d30c2eb4d8121dcbcfdbb165
parentinput_common: Make button threshold customizable (diff)
downloadyuzu-2c339a51145bce113e48c1d7ed03619a1c885068.tar
yuzu-2c339a51145bce113e48c1d7ed03619a1c885068.tar.gz
yuzu-2c339a51145bce113e48c1d7ed03619a1c885068.tar.bz2
yuzu-2c339a51145bce113e48c1d7ed03619a1c885068.tar.lz
yuzu-2c339a51145bce113e48c1d7ed03619a1c885068.tar.xz
yuzu-2c339a51145bce113e48c1d7ed03619a1c885068.tar.zst
yuzu-2c339a51145bce113e48c1d7ed03619a1c885068.zip
-rw-r--r--src/yuzu/configuration/configure_input_player.cpp34
-rw-r--r--src/yuzu/configuration/configure_input_player.ui44
2 files changed, 78 insertions, 0 deletions
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp
index 0d98e0986..d69324a69 100644
--- a/src/yuzu/configuration/configure_input_player.cpp
+++ b/src/yuzu/configuration/configure_input_player.cpp
@@ -321,8 +321,16 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
this, tr("Set threshold"), tr("Choose a value between 0% and 100%"),
button_threshold, 0, 100);
buttons_param[button_id].Set("threshold", new_threshold / 100.0f);
+
+ if (button_id == Settings::NativeButton::ZL) {
+ ui->sliderZLThreshold->setValue(new_threshold);
+ }
+ if (button_id == Settings::NativeButton::ZR) {
+ ui->sliderZRThreshold->setValue(new_threshold);
+ }
});
}
+
context_menu.exec(button_map[button_id]->mapToGlobal(menu_location));
ui->controllerFrame->SetPlayerInput(player_index, buttons_param, analogs_param);
});
@@ -351,6 +359,20 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
});
}
+ connect(ui->sliderZLThreshold, &QSlider::valueChanged, [=, this] {
+ if (buttons_param[Settings::NativeButton::ZL].Has("threshold")) {
+ const auto slider_value = ui->sliderZLThreshold->value();
+ buttons_param[Settings::NativeButton::ZL].Set("threshold", slider_value / 100.0f);
+ }
+ });
+
+ connect(ui->sliderZRThreshold, &QSlider::valueChanged, [=, this] {
+ if (buttons_param[Settings::NativeButton::ZR].Has("threshold")) {
+ const auto slider_value = ui->sliderZRThreshold->value();
+ buttons_param[Settings::NativeButton::ZR].Set("threshold", slider_value / 100.0f);
+ }
+ });
+
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) {
auto* const analog_button = analog_map_buttons[analog_id][sub_button_id];
@@ -859,6 +881,18 @@ void ConfigureInputPlayer::UpdateUI() {
button_map[button]->setText(ButtonToText(buttons_param[button]));
}
+ if (buttons_param[Settings::NativeButton::ZL].Has("threshold")) {
+ const int button_threshold = static_cast<int>(
+ buttons_param[Settings::NativeButton::ZL].Get("threshold", 0.5f) * 100.0f);
+ ui->sliderZLThreshold->setValue(button_threshold);
+ }
+
+ if (buttons_param[Settings::NativeButton::ZR].Has("threshold")) {
+ const int button_threshold = static_cast<int>(
+ buttons_param[Settings::NativeButton::ZR].Get("threshold", 0.5f) * 100.0f);
+ ui->sliderZRThreshold->setValue(button_threshold);
+ }
+
for (int motion_id = 0; motion_id < Settings::NativeMotion::NumMotions; ++motion_id) {
motion_map[motion_id]->setText(ButtonToText(motions_param[motion_id]));
}
diff --git a/src/yuzu/configuration/configure_input_player.ui b/src/yuzu/configuration/configure_input_player.ui
index e76aa484f..e7433912b 100644
--- a/src/yuzu/configuration/configure_input_player.ui
+++ b/src/yuzu/configuration/configure_input_player.ui
@@ -1334,6 +1334,12 @@
</item>
<item>
<widget class="QGroupBox" name="buttonShoulderButtonsButtonZLGroup">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="title">
<string>ZL</string>
</property>
@@ -1378,6 +1384,22 @@
</property>
</widget>
</item>
+ <item>
+ <widget class="QSlider" name="sliderZLThreshold">
+ <property name="maximumSize">
+ <size>
+ <width>70</width>
+ <height>15</height>
+ </size>
+ </property>
+ <property name="maximum">
+ <number>100</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
@@ -1759,6 +1781,12 @@
</item>
<item>
<widget class="QGroupBox" name="buttonShoulderButtonsZRGroup">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="title">
<string>ZR</string>
</property>
@@ -1803,6 +1831,22 @@
</property>
</widget>
</item>
+ <item>
+ <widget class="QSlider" name="sliderZRThreshold">
+ <property name="maximumSize">
+ <size>
+ <width>70</width>
+ <height>15</height>
+ </size>
+ </property>
+ <property name="maximum">
+ <number>100</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>