diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/input_common/sdl/sdl_impl.cpp | 6 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_player.cpp | 44 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_player.ui | 44 |
3 files changed, 91 insertions, 3 deletions
diff --git a/src/input_common/sdl/sdl_impl.cpp b/src/input_common/sdl/sdl_impl.cpp index 7778b3562..70a0ba09c 100644 --- a/src/input_common/sdl/sdl_impl.cpp +++ b/src/input_common/sdl/sdl_impl.cpp | |||
| @@ -707,7 +707,8 @@ public: | |||
| 707 | 707 | ||
| 708 | if (params.Has("axis")) { | 708 | if (params.Has("axis")) { |
| 709 | const int axis = params.Get("axis", 0); | 709 | const int axis = params.Get("axis", 0); |
| 710 | const float threshold = params.Get("threshold", 0.5f); | 710 | // Convert range from (0.0, 1.0) to (-1.0, 1.0) |
| 711 | const float threshold = (params.Get("threshold", 0.5f) - 0.5f) * 2.0f; | ||
| 711 | const std::string direction_name = params.Get("direction", ""); | 712 | const std::string direction_name = params.Get("direction", ""); |
| 712 | bool trigger_if_greater; | 713 | bool trigger_if_greater; |
| 713 | if (direction_name == "+") { | 714 | if (direction_name == "+") { |
| @@ -980,12 +981,11 @@ Common::ParamPackage BuildAnalogParamPackageForButton(int port, std::string guid | |||
| 980 | params.Set("port", port); | 981 | params.Set("port", port); |
| 981 | params.Set("guid", std::move(guid)); | 982 | params.Set("guid", std::move(guid)); |
| 982 | params.Set("axis", axis); | 983 | params.Set("axis", axis); |
| 984 | params.Set("threshold", "0.5"); | ||
| 983 | if (value > 0) { | 985 | if (value > 0) { |
| 984 | params.Set("direction", "+"); | 986 | params.Set("direction", "+"); |
| 985 | params.Set("threshold", "0.5"); | ||
| 986 | } else { | 987 | } else { |
| 987 | params.Set("direction", "-"); | 988 | params.Set("direction", "-"); |
| 988 | params.Set("threshold", "-0.5"); | ||
| 989 | } | 989 | } |
| 990 | return params; | 990 | return params; |
| 991 | } | 991 | } |
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index 14579c220..6b9bd05f1 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp | |||
| @@ -314,6 +314,24 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i | |||
| 314 | buttons_param[button_id].Set("toggle", toggle_value); | 314 | buttons_param[button_id].Set("toggle", toggle_value); |
| 315 | button_map[button_id]->setText(ButtonToText(buttons_param[button_id])); | 315 | button_map[button_id]->setText(ButtonToText(buttons_param[button_id])); |
| 316 | }); | 316 | }); |
| 317 | if (buttons_param[button_id].Has("threshold")) { | ||
| 318 | context_menu.addAction(tr("Set threshold"), [&] { | ||
| 319 | const int button_threshold = static_cast<int>( | ||
| 320 | buttons_param[button_id].Get("threshold", 0.5f) * 100.0f); | ||
| 321 | const int new_threshold = QInputDialog::getInt( | ||
| 322 | this, tr("Set threshold"), tr("Choose a value between 0% and 100%"), | ||
| 323 | button_threshold, 0, 100); | ||
| 324 | buttons_param[button_id].Set("threshold", new_threshold / 100.0f); | ||
| 325 | |||
| 326 | if (button_id == Settings::NativeButton::ZL) { | ||
| 327 | ui->sliderZLThreshold->setValue(new_threshold); | ||
| 328 | } | ||
| 329 | if (button_id == Settings::NativeButton::ZR) { | ||
| 330 | ui->sliderZRThreshold->setValue(new_threshold); | ||
| 331 | } | ||
| 332 | }); | ||
| 333 | } | ||
| 334 | |||
| 317 | context_menu.exec(button_map[button_id]->mapToGlobal(menu_location)); | 335 | context_menu.exec(button_map[button_id]->mapToGlobal(menu_location)); |
| 318 | ui->controllerFrame->SetPlayerInput(player_index, buttons_param, analogs_param); | 336 | ui->controllerFrame->SetPlayerInput(player_index, buttons_param, analogs_param); |
| 319 | }); | 337 | }); |
| @@ -342,6 +360,20 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i | |||
| 342 | }); | 360 | }); |
| 343 | } | 361 | } |
| 344 | 362 | ||
| 363 | connect(ui->sliderZLThreshold, &QSlider::valueChanged, [=, this] { | ||
| 364 | if (buttons_param[Settings::NativeButton::ZL].Has("threshold")) { | ||
| 365 | const auto slider_value = ui->sliderZLThreshold->value(); | ||
| 366 | buttons_param[Settings::NativeButton::ZL].Set("threshold", slider_value / 100.0f); | ||
| 367 | } | ||
| 368 | }); | ||
| 369 | |||
| 370 | connect(ui->sliderZRThreshold, &QSlider::valueChanged, [=, this] { | ||
| 371 | if (buttons_param[Settings::NativeButton::ZR].Has("threshold")) { | ||
| 372 | const auto slider_value = ui->sliderZRThreshold->value(); | ||
| 373 | buttons_param[Settings::NativeButton::ZR].Set("threshold", slider_value / 100.0f); | ||
| 374 | } | ||
| 375 | }); | ||
| 376 | |||
| 345 | for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; ++analog_id) { | 377 | for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; ++analog_id) { |
| 346 | for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; ++sub_button_id) { | 378 | for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; ++sub_button_id) { |
| 347 | auto* const analog_button = analog_map_buttons[analog_id][sub_button_id]; | 379 | auto* const analog_button = analog_map_buttons[analog_id][sub_button_id]; |
| @@ -850,6 +882,18 @@ void ConfigureInputPlayer::UpdateUI() { | |||
| 850 | button_map[button]->setText(ButtonToText(buttons_param[button])); | 882 | button_map[button]->setText(ButtonToText(buttons_param[button])); |
| 851 | } | 883 | } |
| 852 | 884 | ||
| 885 | if (buttons_param[Settings::NativeButton::ZL].Has("threshold")) { | ||
| 886 | const int button_threshold = static_cast<int>( | ||
| 887 | buttons_param[Settings::NativeButton::ZL].Get("threshold", 0.5f) * 100.0f); | ||
| 888 | ui->sliderZLThreshold->setValue(button_threshold); | ||
| 889 | } | ||
| 890 | |||
| 891 | if (buttons_param[Settings::NativeButton::ZR].Has("threshold")) { | ||
| 892 | const int button_threshold = static_cast<int>( | ||
| 893 | buttons_param[Settings::NativeButton::ZR].Get("threshold", 0.5f) * 100.0f); | ||
| 894 | ui->sliderZRThreshold->setValue(button_threshold); | ||
| 895 | } | ||
| 896 | |||
| 853 | for (int motion_id = 0; motion_id < Settings::NativeMotion::NumMotions; ++motion_id) { | 897 | for (int motion_id = 0; motion_id < Settings::NativeMotion::NumMotions; ++motion_id) { |
| 854 | motion_map[motion_id]->setText(ButtonToText(motions_param[motion_id])); | 898 | motion_map[motion_id]->setText(ButtonToText(motions_param[motion_id])); |
| 855 | } | 899 | } |
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> |