diff options
| author | 2021-07-17 13:30:43 -0500 | |
|---|---|---|
| committer | 2021-07-17 13:30:43 -0500 | |
| commit | 2c339a51145bce113e48c1d7ed03619a1c885068 (patch) | |
| tree | 7ef1b907cac7dd95d30c2eb4d8121dcbcfdbb165 /src | |
| parent | input_common: Make button threshold customizable (diff) | |
| download | yuzu-2c339a51145bce113e48c1d7ed03619a1c885068.tar.gz yuzu-2c339a51145bce113e48c1d7ed03619a1c885068.tar.xz yuzu-2c339a51145bce113e48c1d7ed03619a1c885068.zip | |
configure/ui: Add sliders for trigger buttons
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuzu/configuration/configure_input_player.cpp | 34 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_player.ui | 44 |
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 | |||
| 321 | this, tr("Set threshold"), tr("Choose a value between 0% and 100%"), | 321 | this, tr("Set threshold"), tr("Choose a value between 0% and 100%"), |
| 322 | button_threshold, 0, 100); | 322 | button_threshold, 0, 100); |
| 323 | buttons_param[button_id].Set("threshold", new_threshold / 100.0f); | 323 | buttons_param[button_id].Set("threshold", new_threshold / 100.0f); |
| 324 | |||
| 325 | if (button_id == Settings::NativeButton::ZL) { | ||
| 326 | ui->sliderZLThreshold->setValue(new_threshold); | ||
| 327 | } | ||
| 328 | if (button_id == Settings::NativeButton::ZR) { | ||
| 329 | ui->sliderZRThreshold->setValue(new_threshold); | ||
| 330 | } | ||
| 324 | }); | 331 | }); |
| 325 | } | 332 | } |
| 333 | |||
| 326 | context_menu.exec(button_map[button_id]->mapToGlobal(menu_location)); | 334 | context_menu.exec(button_map[button_id]->mapToGlobal(menu_location)); |
| 327 | ui->controllerFrame->SetPlayerInput(player_index, buttons_param, analogs_param); | 335 | ui->controllerFrame->SetPlayerInput(player_index, buttons_param, analogs_param); |
| 328 | }); | 336 | }); |
| @@ -351,6 +359,20 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i | |||
| 351 | }); | 359 | }); |
| 352 | } | 360 | } |
| 353 | 361 | ||
| 362 | connect(ui->sliderZLThreshold, &QSlider::valueChanged, [=, this] { | ||
| 363 | if (buttons_param[Settings::NativeButton::ZL].Has("threshold")) { | ||
| 364 | const auto slider_value = ui->sliderZLThreshold->value(); | ||
| 365 | buttons_param[Settings::NativeButton::ZL].Set("threshold", slider_value / 100.0f); | ||
| 366 | } | ||
| 367 | }); | ||
| 368 | |||
| 369 | connect(ui->sliderZRThreshold, &QSlider::valueChanged, [=, this] { | ||
| 370 | if (buttons_param[Settings::NativeButton::ZR].Has("threshold")) { | ||
| 371 | const auto slider_value = ui->sliderZRThreshold->value(); | ||
| 372 | buttons_param[Settings::NativeButton::ZR].Set("threshold", slider_value / 100.0f); | ||
| 373 | } | ||
| 374 | }); | ||
| 375 | |||
| 354 | for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; ++analog_id) { | 376 | for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; ++analog_id) { |
| 355 | for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; ++sub_button_id) { | 377 | for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; ++sub_button_id) { |
| 356 | auto* const analog_button = analog_map_buttons[analog_id][sub_button_id]; | 378 | auto* const analog_button = analog_map_buttons[analog_id][sub_button_id]; |
| @@ -859,6 +881,18 @@ void ConfigureInputPlayer::UpdateUI() { | |||
| 859 | button_map[button]->setText(ButtonToText(buttons_param[button])); | 881 | button_map[button]->setText(ButtonToText(buttons_param[button])); |
| 860 | } | 882 | } |
| 861 | 883 | ||
| 884 | if (buttons_param[Settings::NativeButton::ZL].Has("threshold")) { | ||
| 885 | const int button_threshold = static_cast<int>( | ||
| 886 | buttons_param[Settings::NativeButton::ZL].Get("threshold", 0.5f) * 100.0f); | ||
| 887 | ui->sliderZLThreshold->setValue(button_threshold); | ||
| 888 | } | ||
| 889 | |||
| 890 | if (buttons_param[Settings::NativeButton::ZR].Has("threshold")) { | ||
| 891 | const int button_threshold = static_cast<int>( | ||
| 892 | buttons_param[Settings::NativeButton::ZR].Get("threshold", 0.5f) * 100.0f); | ||
| 893 | ui->sliderZRThreshold->setValue(button_threshold); | ||
| 894 | } | ||
| 895 | |||
| 862 | for (int motion_id = 0; motion_id < Settings::NativeMotion::NumMotions; ++motion_id) { | 896 | for (int motion_id = 0; motion_id < Settings::NativeMotion::NumMotions; ++motion_id) { |
| 863 | motion_map[motion_id]->setText(ButtonToText(motions_param[motion_id])); | 897 | motion_map[motion_id]->setText(ButtonToText(motions_param[motion_id])); |
| 864 | } | 898 | } |
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 @@ | |||
| 1334 | </item> | 1334 | </item> |
| 1335 | <item> | 1335 | <item> |
| 1336 | <widget class="QGroupBox" name="buttonShoulderButtonsButtonZLGroup"> | 1336 | <widget class="QGroupBox" name="buttonShoulderButtonsButtonZLGroup"> |
| 1337 | <property name="sizePolicy"> | ||
| 1338 | <sizepolicy hsizetype="Maximum" vsizetype="Preferred"> | ||
| 1339 | <horstretch>0</horstretch> | ||
| 1340 | <verstretch>0</verstretch> | ||
| 1341 | </sizepolicy> | ||
| 1342 | </property> | ||
| 1337 | <property name="title"> | 1343 | <property name="title"> |
| 1338 | <string>ZL</string> | 1344 | <string>ZL</string> |
| 1339 | </property> | 1345 | </property> |
| @@ -1378,6 +1384,22 @@ | |||
| 1378 | </property> | 1384 | </property> |
| 1379 | </widget> | 1385 | </widget> |
| 1380 | </item> | 1386 | </item> |
| 1387 | <item> | ||
| 1388 | <widget class="QSlider" name="sliderZLThreshold"> | ||
| 1389 | <property name="maximumSize"> | ||
| 1390 | <size> | ||
| 1391 | <width>70</width> | ||
| 1392 | <height>15</height> | ||
| 1393 | </size> | ||
| 1394 | </property> | ||
| 1395 | <property name="maximum"> | ||
| 1396 | <number>100</number> | ||
| 1397 | </property> | ||
| 1398 | <property name="orientation"> | ||
| 1399 | <enum>Qt::Horizontal</enum> | ||
| 1400 | </property> | ||
| 1401 | </widget> | ||
| 1402 | </item> | ||
| 1381 | </layout> | 1403 | </layout> |
| 1382 | </widget> | 1404 | </widget> |
| 1383 | </item> | 1405 | </item> |
| @@ -1759,6 +1781,12 @@ | |||
| 1759 | </item> | 1781 | </item> |
| 1760 | <item> | 1782 | <item> |
| 1761 | <widget class="QGroupBox" name="buttonShoulderButtonsZRGroup"> | 1783 | <widget class="QGroupBox" name="buttonShoulderButtonsZRGroup"> |
| 1784 | <property name="sizePolicy"> | ||
| 1785 | <sizepolicy hsizetype="Maximum" vsizetype="Preferred"> | ||
| 1786 | <horstretch>0</horstretch> | ||
| 1787 | <verstretch>0</verstretch> | ||
| 1788 | </sizepolicy> | ||
| 1789 | </property> | ||
| 1762 | <property name="title"> | 1790 | <property name="title"> |
| 1763 | <string>ZR</string> | 1791 | <string>ZR</string> |
| 1764 | </property> | 1792 | </property> |
| @@ -1803,6 +1831,22 @@ | |||
| 1803 | </property> | 1831 | </property> |
| 1804 | </widget> | 1832 | </widget> |
| 1805 | </item> | 1833 | </item> |
| 1834 | <item> | ||
| 1835 | <widget class="QSlider" name="sliderZRThreshold"> | ||
| 1836 | <property name="maximumSize"> | ||
| 1837 | <size> | ||
| 1838 | <width>70</width> | ||
| 1839 | <height>15</height> | ||
| 1840 | </size> | ||
| 1841 | </property> | ||
| 1842 | <property name="maximum"> | ||
| 1843 | <number>100</number> | ||
| 1844 | </property> | ||
| 1845 | <property name="orientation"> | ||
| 1846 | <enum>Qt::Horizontal</enum> | ||
| 1847 | </property> | ||
| 1848 | </widget> | ||
| 1849 | </item> | ||
| 1806 | </layout> | 1850 | </layout> |
| 1807 | </widget> | 1851 | </widget> |
| 1808 | </item> | 1852 | </item> |