diff options
| -rw-r--r-- | src/yuzu/configuration/configure_input_player.cpp | 72 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_player.h | 2 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_player.ui | 79 |
3 files changed, 129 insertions, 24 deletions
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index 67c9a7c6d..9fc443809 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp | |||
| @@ -236,6 +236,8 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i | |||
| 236 | widget->setVisible(false); | 236 | widget->setVisible(false); |
| 237 | 237 | ||
| 238 | analog_map_stick = {ui->buttonLStickAnalog, ui->buttonRStickAnalog}; | 238 | analog_map_stick = {ui->buttonLStickAnalog, ui->buttonRStickAnalog}; |
| 239 | analog_map_deadzone = {ui->sliderLStickDeadzone, ui->sliderRStickDeadzone}; | ||
| 240 | analog_map_deadzone_label = {ui->labelLStickDeadzone, ui->labelRStickDeadzone}; | ||
| 239 | 241 | ||
| 240 | for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; button_id++) { | 242 | for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; button_id++) { |
| 241 | auto* const button = button_map[button_id]; | 243 | auto* const button = button_map[button_id]; |
| @@ -246,23 +248,23 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i | |||
| 246 | button->setContextMenuPolicy(Qt::CustomContextMenu); | 248 | button->setContextMenuPolicy(Qt::CustomContextMenu); |
| 247 | connect(button, &QPushButton::clicked, [=] { | 249 | connect(button, &QPushButton::clicked, [=] { |
| 248 | HandleClick(button_map[button_id], | 250 | HandleClick(button_map[button_id], |
| 249 | [=](Common::ParamPackage params) { | 251 | [=](Common::ParamPackage params) { |
| 250 | // Workaround for ZL & ZR for analog triggers like on XBOX controllors. | 252 | // Workaround for ZL & ZR for analog triggers like on XBOX controllors. |
| 251 | // Analog triggers (from controllers like the XBOX controller) would not | 253 | // Analog triggers (from controllers like the XBOX controller) would not |
| 252 | // work due to a different range of their signals (from 0 to 255 on | 254 | // work due to a different range of their signals (from 0 to 255 on |
| 253 | // analog triggers instead of -32768 to 32768 on analog joysticks). The | 255 | // analog triggers instead of -32768 to 32768 on analog joysticks). The |
| 254 | // SDL driver misinterprets analog triggers as analog joysticks. | 256 | // SDL driver misinterprets analog triggers as analog joysticks. |
| 255 | // TODO: reinterpret the signal range for analog triggers to map the | 257 | // TODO: reinterpret the signal range for analog triggers to map the |
| 256 | // values correctly. This is required for the correct emulation of the | 258 | // values correctly. This is required for the correct emulation of the |
| 257 | // analog triggers of the GameCube controller. | 259 | // analog triggers of the GameCube controller. |
| 258 | if (button_id == Settings::NativeButton::ZL || | 260 | if (button_id == Settings::NativeButton::ZL || |
| 259 | button_id == Settings::NativeButton::ZR) { | 261 | button_id == Settings::NativeButton::ZR) { |
| 260 | params.Set("direction", "+"); | 262 | params.Set("direction", "+"); |
| 261 | params.Set("threshold", "0.5"); | 263 | params.Set("threshold", "0.5"); |
| 262 | } | 264 | } |
| 263 | buttons_param[button_id] = std::move(params); | 265 | buttons_param[button_id] = std::move(params); |
| 264 | }, | 266 | }, |
| 265 | InputCommon::Polling::DeviceType::Button); | 267 | InputCommon::Polling::DeviceType::Button); |
| 266 | }); | 268 | }); |
| 267 | connect(button, &QPushButton::customContextMenuRequested, [=](const QPoint& menu_location) { | 269 | connect(button, &QPushButton::customContextMenuRequested, [=](const QPoint& menu_location) { |
| 268 | QMenu context_menu; | 270 | QMenu context_menu; |
| @@ -289,11 +291,11 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i | |||
| 289 | analog_button->setContextMenuPolicy(Qt::CustomContextMenu); | 291 | analog_button->setContextMenuPolicy(Qt::CustomContextMenu); |
| 290 | connect(analog_button, &QPushButton::clicked, [=]() { | 292 | connect(analog_button, &QPushButton::clicked, [=]() { |
| 291 | HandleClick(analog_map_buttons[analog_id][sub_button_id], | 293 | HandleClick(analog_map_buttons[analog_id][sub_button_id], |
| 292 | [=](const Common::ParamPackage& params) { | 294 | [=](const Common::ParamPackage& params) { |
| 293 | SetAnalogButton(params, analogs_param[analog_id], | 295 | SetAnalogButton(params, analogs_param[analog_id], |
| 294 | analog_sub_buttons[sub_button_id]); | 296 | analog_sub_buttons[sub_button_id]); |
| 295 | }, | 297 | }, |
| 296 | InputCommon::Polling::DeviceType::Button); | 298 | InputCommon::Polling::DeviceType::Button); |
| 297 | }); | 299 | }); |
| 298 | connect(analog_button, &QPushButton::customContextMenuRequested, | 300 | connect(analog_button, &QPushButton::customContextMenuRequested, |
| 299 | [=](const QPoint& menu_location) { | 301 | [=](const QPoint& menu_location) { |
| @@ -326,6 +328,11 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i | |||
| 326 | InputCommon::Polling::DeviceType::Analog); | 328 | InputCommon::Polling::DeviceType::Analog); |
| 327 | } | 329 | } |
| 328 | }); | 330 | }); |
| 331 | connect(analog_map_deadzone[analog_id], &QSlider::valueChanged, [=] { | ||
| 332 | const float deadzone = analog_map_deadzone[analog_id]->value() / 100.0f; | ||
| 333 | analog_map_deadzone_label[analog_id]->setText(tr("Deadzone: %1").arg(deadzone)); | ||
| 334 | analogs_param[analog_id].Set("deadzone", deadzone); | ||
| 335 | }); | ||
| 329 | } | 336 | } |
| 330 | 337 | ||
| 331 | connect(ui->buttonClearAll, &QPushButton::clicked, [this] { ClearAll(); }); | 338 | connect(ui->buttonClearAll, &QPushButton::clicked, [this] { ClearAll(); }); |
| @@ -484,7 +491,7 @@ void ConfigureInputPlayer::ClearAll() { | |||
| 484 | continue; | 491 | continue; |
| 485 | } | 492 | } |
| 486 | 493 | ||
| 487 | analogs_param[analog_id].Erase(analog_sub_buttons[sub_button_id]); | 494 | analogs_param[analog_id].Clear(); |
| 488 | } | 495 | } |
| 489 | } | 496 | } |
| 490 | 497 | ||
| @@ -508,6 +515,23 @@ void ConfigureInputPlayer::UpdateButtonLabels() { | |||
| 508 | AnalogToText(analogs_param[analog_id], analog_sub_buttons[sub_button_id])); | 515 | AnalogToText(analogs_param[analog_id], analog_sub_buttons[sub_button_id])); |
| 509 | } | 516 | } |
| 510 | analog_map_stick[analog_id]->setText(tr("Set Analog Stick")); | 517 | analog_map_stick[analog_id]->setText(tr("Set Analog Stick")); |
| 518 | |||
| 519 | auto& const param = analogs_param[analog_id]; | ||
| 520 | auto* const analog_deadzone_slider = analog_map_deadzone[analog_id]; | ||
| 521 | auto* const analog_deadzone_label = analog_map_deadzone_label[analog_id]; | ||
| 522 | |||
| 523 | if (param.Has("engine") && param.Get("engine", "") == "sdl") { | ||
| 524 | if (!param.Has("deadzone")) { | ||
| 525 | param.Set("deadzone", 0.1f); | ||
| 526 | } | ||
| 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 | } | ||
| 511 | } | 535 | } |
| 512 | } | 536 | } |
| 513 | 537 | ||
| @@ -571,4 +595,4 @@ void ConfigureInputPlayer::keyPressEvent(QKeyEvent* event) { | |||
| 571 | } | 595 | } |
| 572 | } | 596 | } |
| 573 | SetPollingResult({}, true); | 597 | SetPollingResult({}, true); |
| 574 | } | 598 | } \ No newline at end of file |
diff --git a/src/yuzu/configuration/configure_input_player.h b/src/yuzu/configuration/configure_input_player.h index c66027651..045704e47 100644 --- a/src/yuzu/configuration/configure_input_player.h +++ b/src/yuzu/configuration/configure_input_player.h | |||
| @@ -97,6 +97,8 @@ 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; | ||
| 101 | std::array<QLabel*, Settings::NativeAnalog::NumAnalogs> analog_map_deadzone_label; | ||
| 100 | 102 | ||
| 101 | static const std::array<std::string, ANALOG_SUB_BUTTONS_NUM> analog_sub_buttons; | 103 | static const std::array<std::string, ANALOG_SUB_BUTTONS_NUM> analog_sub_buttons; |
| 102 | 104 | ||
diff --git a/src/yuzu/configuration/configure_input_player.ui b/src/yuzu/configuration/configure_input_player.ui index 42db020be..1556481d0 100644 --- a/src/yuzu/configuration/configure_input_player.ui +++ b/src/yuzu/configuration/configure_input_player.ui | |||
| @@ -170,6 +170,44 @@ | |||
| 170 | </item> | 170 | </item> |
| 171 | </layout> | 171 | </layout> |
| 172 | </item> | 172 | </item> |
| 173 | <item row="4" column="0" colspan="2"> | ||
| 174 | <layout class="QVBoxLayout" name="sliderRStickDeadzoneVerticalLayout"> | ||
| 175 | <item> | ||
| 176 | <layout class="QHBoxLayout" name="sliderRStickDeadzoneHorizontalLayout"> | ||
| 177 | <item> | ||
| 178 | <widget class="QLabel" name="labelRStickDeadzone"> | ||
| 179 | <property name="text"> | ||
| 180 | <string>Deadzone: 0</string> | ||
| 181 | </property> | ||
| 182 | <property name="alignment"> | ||
| 183 | <enum>Qt::AlignHCenter</enum> | ||
| 184 | </property> | ||
| 185 | </widget> | ||
| 186 | </item> | ||
| 187 | </layout> | ||
| 188 | </item> | ||
| 189 | <item> | ||
| 190 | <widget class="QSlider" name="sliderRStickDeadzone"> | ||
| 191 | <property name="orientation"> | ||
| 192 | <enum>Qt::Horizontal</enum> | ||
| 193 | </property> | ||
| 194 | </widget> | ||
| 195 | </item> | ||
| 196 | </layout> | ||
| 197 | </item> | ||
| 198 | <item row="5" column="0"> | ||
| 199 | <spacer name="RStick_verticalSpacer"> | ||
| 200 | <property name="orientation"> | ||
| 201 | <enum>Qt::Vertical</enum> | ||
| 202 | </property> | ||
| 203 | <property name="sizeHint" stdset="0"> | ||
| 204 | <size> | ||
| 205 | <width>0</width> | ||
| 206 | <height>0</height> | ||
| 207 | </size> | ||
| 208 | </property> | ||
| 209 | </spacer> | ||
| 210 | </item> | ||
| 173 | </layout> | 211 | </layout> |
| 174 | </widget> | 212 | </widget> |
| 175 | </item> | 213 | </item> |
| @@ -745,6 +783,47 @@ | |||
| 745 | </item> | 783 | </item> |
| 746 | </layout> | 784 | </layout> |
| 747 | </item> | 785 | </item> |
| 786 | <item row="5" column="1" colspan="2"> | ||
| 787 | <layout class="QVBoxLayout" name="sliderLStickDeadzoneVerticalLayout"> | ||
| 788 | <property name="sizeConstraint"> | ||
| 789 | <enum>QLayout::SetDefaultConstraint</enum> | ||
| 790 | </property> | ||
| 791 | <item> | ||
| 792 | <layout class="QHBoxLayout" name="sliderLStickDeadzoneHorizontalLayout"> | ||
| 793 | <item> | ||
| 794 | <widget class="QLabel" name="labelLStickDeadzone"> | ||
| 795 | <property name="text"> | ||
| 796 | <string>Deadzone: 0</string> | ||
| 797 | </property> | ||
| 798 | <property name="alignment"> | ||
| 799 | <enum>Qt::AlignHCenter</enum> | ||
| 800 | </property> | ||
| 801 | </widget> | ||
| 802 | </item> | ||
| 803 | </layout> | ||
| 804 | </item> | ||
| 805 | <item> | ||
| 806 | <widget class="QSlider" name="sliderLStickDeadzone"> | ||
| 807 | <property name="orientation"> | ||
| 808 | <enum>Qt::Horizontal</enum> | ||
| 809 | </property> | ||
| 810 | </widget> | ||
| 811 | </item> | ||
| 812 | </layout> | ||
| 813 | </item> | ||
| 814 | <item row="6" column="1"> | ||
| 815 | <spacer name="LStick_verticalSpacer"> | ||
| 816 | <property name="orientation"> | ||
| 817 | <enum>Qt::Vertical</enum> | ||
| 818 | </property> | ||
| 819 | <property name="sizeHint" stdset="0"> | ||
| 820 | <size> | ||
| 821 | <width>0</width> | ||
| 822 | <height>0</height> | ||
| 823 | </size> | ||
| 824 | </property> | ||
| 825 | </spacer> | ||
| 826 | </item> | ||
| 748 | </layout> | 827 | </layout> |
| 749 | </widget> | 828 | </widget> |
| 750 | </item> | 829 | </item> |