diff options
Diffstat (limited to 'src/yuzu/configuration')
-rw-r--r-- | src/yuzu/configuration/config.cpp | 27 | ||||
-rw-r--r-- | src/yuzu/configuration/config.h | 2 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_filesystem.cpp | 10 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_filesystem.h | 1 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_filesystem.ui | 35 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_graphics.cpp | 22 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_input_advanced.cpp | 5 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_input_advanced.ui | 82 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_input_player.cpp | 106 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_input_player.h | 6 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_input_player_widget.cpp | 282 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_input_player_widget.h | 8 |
12 files changed, 370 insertions, 216 deletions
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 8d85a1986..3d6f64300 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -220,7 +220,7 @@ const std::array<int, Settings::NativeKeyboard::NumKeyboardMods> Config::default // This must be in alphabetical order according to action name as it must have the same order as // UISetting::values.shortcuts, which is alphabetically ordered. // clang-format off -const std::array<UISettings::Shortcut, 16> Config::default_hotkeys{{ +const std::array<UISettings::Shortcut, 17> Config::default_hotkeys{{ {QStringLiteral("Capture Screenshot"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+P"), Qt::WidgetWithChildrenShortcut}}, {QStringLiteral("Change Docked Mode"), QStringLiteral("Main Window"), {QStringLiteral("F10"), Qt::ApplicationShortcut}}, {QStringLiteral("Continue/Pause Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F4"), Qt::WindowShortcut}}, @@ -235,6 +235,7 @@ const std::array<UISettings::Shortcut, 16> Config::default_hotkeys{{ {QStringLiteral("Restart Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F6"), Qt::WindowShortcut}}, {QStringLiteral("Stop Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F5"), Qt::WindowShortcut}}, {QStringLiteral("Toggle Filter Bar"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F"), Qt::WindowShortcut}}, + {QStringLiteral("Toggle Mouse Panning"), QStringLiteral("Main Window"), {QStringLiteral("F9"), Qt::ApplicationShortcut}}, {QStringLiteral("Toggle Speed Limit"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+Z"), Qt::ApplicationShortcut}}, {QStringLiteral("Toggle Status Bar"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+S"), Qt::WindowShortcut}}, }}; @@ -507,6 +508,9 @@ void Config::ReadControlValues() { Settings::values.emulate_analog_keyboard = ReadSetting(QStringLiteral("emulate_analog_keyboard"), false).toBool(); + Settings::values.mouse_panning = ReadSetting(QStringLiteral("mouse_panning"), false).toBool(); + Settings::values.mouse_panning_sensitivity = + ReadSetting(QStringLiteral("mouse_panning_sensitivity"), 1).toFloat(); ReadSettingGlobal(Settings::values.use_docked_mode, QStringLiteral("use_docked_mode"), true); ReadSettingGlobal(Settings::values.vibration_enabled, QStringLiteral("vibration_enabled"), @@ -610,12 +614,6 @@ void Config::ReadDataStorageValues() { QString::fromStdString(FS::GetUserPath(FS::UserPath::DumpDir))) .toString() .toStdString()); - FS::GetUserPath(FS::UserPath::CacheDir, - qt_config - ->value(QStringLiteral("cache_directory"), - QString::fromStdString(FS::GetUserPath(FS::UserPath::CacheDir))) - .toString() - .toStdString()); Settings::values.gamecard_inserted = ReadSetting(QStringLiteral("gamecard_inserted"), false).toBool(); Settings::values.gamecard_current_game = @@ -778,14 +776,14 @@ void Config::ReadRendererValues() { ReadSettingGlobal(Settings::values.frame_limit, QStringLiteral("frame_limit"), 100); ReadSettingGlobal(Settings::values.use_disk_shader_cache, QStringLiteral("use_disk_shader_cache"), true); - ReadSettingGlobal(Settings::values.gpu_accuracy, QStringLiteral("gpu_accuracy"), 0); + ReadSettingGlobal(Settings::values.gpu_accuracy, QStringLiteral("gpu_accuracy"), 1); ReadSettingGlobal(Settings::values.use_asynchronous_gpu_emulation, QStringLiteral("use_asynchronous_gpu_emulation"), true); ReadSettingGlobal(Settings::values.use_nvdec_emulation, QStringLiteral("use_nvdec_emulation"), true); ReadSettingGlobal(Settings::values.use_vsync, QStringLiteral("use_vsync"), true); ReadSettingGlobal(Settings::values.use_assembly_shaders, QStringLiteral("use_assembly_shaders"), - true); + false); ReadSettingGlobal(Settings::values.use_asynchronous_shaders, QStringLiteral("use_asynchronous_shaders"), false); ReadSettingGlobal(Settings::values.use_fast_gpu_time, QStringLiteral("use_fast_gpu_time"), @@ -1184,7 +1182,9 @@ void Config::SaveControlValues() { WriteSetting(QStringLiteral("keyboard_enabled"), Settings::values.keyboard_enabled, false); WriteSetting(QStringLiteral("emulate_analog_keyboard"), Settings::values.emulate_analog_keyboard, false); - + WriteSetting(QStringLiteral("mouse_panning"), Settings::values.mouse_panning, false); + WriteSetting(QStringLiteral("mouse_panning_sensitivity"), + Settings::values.mouse_panning_sensitivity, 1.0f); qt_config->endGroup(); } @@ -1212,9 +1212,6 @@ void Config::SaveDataStorageValues() { WriteSetting(QStringLiteral("dump_directory"), QString::fromStdString(FS::GetUserPath(FS::UserPath::DumpDir)), QString::fromStdString(FS::GetUserPath(FS::UserPath::DumpDir))); - WriteSetting(QStringLiteral("cache_directory"), - QString::fromStdString(FS::GetUserPath(FS::UserPath::CacheDir)), - QString::fromStdString(FS::GetUserPath(FS::UserPath::CacheDir))); WriteSetting(QStringLiteral("gamecard_inserted"), Settings::values.gamecard_inserted, false); WriteSetting(QStringLiteral("gamecard_current_game"), Settings::values.gamecard_current_game, false); @@ -1345,14 +1342,14 @@ void Config::SaveRendererValues() { Settings::values.use_disk_shader_cache, true); WriteSettingGlobal(QStringLiteral("gpu_accuracy"), static_cast<int>(Settings::values.gpu_accuracy.GetValue(global)), - Settings::values.gpu_accuracy.UsingGlobal(), 0); + Settings::values.gpu_accuracy.UsingGlobal(), 1); WriteSettingGlobal(QStringLiteral("use_asynchronous_gpu_emulation"), Settings::values.use_asynchronous_gpu_emulation, true); WriteSettingGlobal(QStringLiteral("use_nvdec_emulation"), Settings::values.use_nvdec_emulation, true); WriteSettingGlobal(QStringLiteral("use_vsync"), Settings::values.use_vsync, true); WriteSettingGlobal(QStringLiteral("use_assembly_shaders"), - Settings::values.use_assembly_shaders, true); + Settings::values.use_assembly_shaders, false); WriteSettingGlobal(QStringLiteral("use_asynchronous_shaders"), Settings::values.use_asynchronous_shaders, false); WriteSettingGlobal(QStringLiteral("use_fast_gpu_time"), Settings::values.use_fast_gpu_time, diff --git a/src/yuzu/configuration/config.h b/src/yuzu/configuration/config.h index 8a600e19d..949c4eb13 100644 --- a/src/yuzu/configuration/config.h +++ b/src/yuzu/configuration/config.h @@ -42,7 +42,7 @@ public: default_mouse_buttons; static const std::array<int, Settings::NativeKeyboard::NumKeyboardKeys> default_keyboard_keys; static const std::array<int, Settings::NativeKeyboard::NumKeyboardMods> default_keyboard_mods; - static const std::array<UISettings::Shortcut, 16> default_hotkeys; + static const std::array<UISettings::Shortcut, 17> default_hotkeys; private: void Initialize(const std::string& config_name); diff --git a/src/yuzu/configuration/configure_filesystem.cpp b/src/yuzu/configuration/configure_filesystem.cpp index 7ab4a80f7..bde2d4620 100644 --- a/src/yuzu/configuration/configure_filesystem.cpp +++ b/src/yuzu/configuration/configure_filesystem.cpp @@ -26,8 +26,6 @@ ConfigureFilesystem::ConfigureFilesystem(QWidget* parent) [this] { SetDirectory(DirectoryTarget::Dump, ui->dump_path_edit); }); connect(ui->load_path_button, &QToolButton::pressed, this, [this] { SetDirectory(DirectoryTarget::Load, ui->load_path_edit); }); - connect(ui->cache_directory_button, &QToolButton::pressed, this, - [this] { SetDirectory(DirectoryTarget::Cache, ui->cache_directory_edit); }); connect(ui->reset_game_list_cache, &QPushButton::pressed, this, &ConfigureFilesystem::ResetMetadata); @@ -50,8 +48,6 @@ void ConfigureFilesystem::setConfiguration() { QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::DumpDir))); ui->load_path_edit->setText( QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::LoadDir))); - ui->cache_directory_edit->setText( - QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::CacheDir))); ui->gamecard_inserted->setChecked(Settings::values.gamecard_inserted); ui->gamecard_current_game->setChecked(Settings::values.gamecard_current_game); @@ -72,9 +68,6 @@ void ConfigureFilesystem::applyConfiguration() { ui->dump_path_edit->text().toStdString()); Common::FS::GetUserPath(Common::FS::UserPath::LoadDir, ui->load_path_edit->text().toStdString()); - Common::FS::GetUserPath(Common::FS::UserPath::CacheDir, - ui->cache_directory_edit->text().toStdString()); - Settings::values.gamecard_path = ui->gamecard_path_edit->text().toStdString(); Settings::values.gamecard_inserted = ui->gamecard_inserted->isChecked(); Settings::values.gamecard_current_game = ui->gamecard_current_game->isChecked(); @@ -103,9 +96,6 @@ void ConfigureFilesystem::SetDirectory(DirectoryTarget target, QLineEdit* edit) case DirectoryTarget::Load: caption = tr("Select Mod Load Directory..."); break; - case DirectoryTarget::Cache: - caption = tr("Select Cache Directory..."); - break; } QString str; diff --git a/src/yuzu/configuration/configure_filesystem.h b/src/yuzu/configuration/configure_filesystem.h index a79303760..2147cd405 100644 --- a/src/yuzu/configuration/configure_filesystem.h +++ b/src/yuzu/configuration/configure_filesystem.h @@ -32,7 +32,6 @@ private: Gamecard, Dump, Load, - Cache, }; void SetDirectory(DirectoryTarget target, QLineEdit* edit); diff --git a/src/yuzu/configuration/configure_filesystem.ui b/src/yuzu/configuration/configure_filesystem.ui index 84bea0600..62b9abc7a 100644 --- a/src/yuzu/configuration/configure_filesystem.ui +++ b/src/yuzu/configuration/configure_filesystem.ui @@ -198,40 +198,7 @@ <string>Caching</string> </property> <layout class="QGridLayout" name="gridLayout_5"> - <item row="0" column="0"> - <widget class="QLabel" name="label_10"> - <property name="text"> - <string>Cache Directory</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <spacer name="horizontalSpacer_3"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Fixed</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="0" column="2"> - <widget class="QLineEdit" name="cache_directory_edit"/> - </item> - <item row="0" column="3"> - <widget class="QToolButton" name="cache_directory_button"> - <property name="text"> - <string>...</string> - </property> - </widget> - </item> - <item row="1" column="0" colspan="4"> + <item row="0" column="0" colspan="2"> <layout class="QHBoxLayout" name="horizontalLayout_2"> <item> <widget class="QCheckBox" name="cache_game_list"> diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp index b78a5dff0..9ff32aec4 100644 --- a/src/yuzu/configuration/configure_graphics.cpp +++ b/src/yuzu/configuration/configure_graphics.cpp @@ -2,6 +2,9 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +// Include this early to include Vulkan headers how we want to +#include "video_core/vulkan_common/vulkan_wrapper.h" + #include <QColorDialog> #include <QComboBox> #include <QVulkanInstance> @@ -11,7 +14,8 @@ #include "core/core.h" #include "core/settings.h" #include "ui_configure_graphics.h" -#include "video_core/renderer_vulkan/renderer_vulkan.h" +#include "video_core/vulkan_common/vulkan_instance.h" +#include "video_core/vulkan_common/vulkan_library.h" #include "yuzu/configuration/configuration_shared.h" #include "yuzu/configuration/configure_graphics.h" @@ -212,11 +216,23 @@ void ConfigureGraphics::UpdateDeviceComboBox() { ui->device->setEnabled(enabled && !Core::System::GetInstance().IsPoweredOn()); } -void ConfigureGraphics::RetrieveVulkanDevices() { +void ConfigureGraphics::RetrieveVulkanDevices() try { + using namespace Vulkan; + + vk::InstanceDispatch dld; + const Common::DynamicLibrary library = OpenLibrary(); + const vk::Instance instance = CreateInstance(library, dld, VK_API_VERSION_1_0); + const std::vector<VkPhysicalDevice> physical_devices = instance.EnumeratePhysicalDevices(); + vulkan_devices.clear(); - for (const auto& name : Vulkan::RendererVulkan::EnumerateDevices()) { + vulkan_devices.reserve(physical_devices.size()); + for (const VkPhysicalDevice device : physical_devices) { + const char* const name = vk::PhysicalDevice(device, dld).GetProperties().deviceName; vulkan_devices.push_back(QString::fromStdString(name)); } + +} catch (const Vulkan::vk::Exception& exception) { + LOG_ERROR(Frontend, "Failed to enumerate devices with error: {}", exception.what()); } Settings::RendererBackend ConfigureGraphics::GetCurrentGraphicsBackend() const { diff --git a/src/yuzu/configuration/configure_input_advanced.cpp b/src/yuzu/configuration/configure_input_advanced.cpp index 4e557bc6f..a1a0eb676 100644 --- a/src/yuzu/configuration/configure_input_advanced.cpp +++ b/src/yuzu/configuration/configure_input_advanced.cpp @@ -122,6 +122,9 @@ void ConfigureInputAdvanced::ApplyConfiguration() { Settings::values.mouse_enabled = ui->mouse_enabled->isChecked(); Settings::values.keyboard_enabled = ui->keyboard_enabled->isChecked(); Settings::values.emulate_analog_keyboard = ui->emulate_analog_keyboard->isChecked(); + Settings::values.mouse_panning = ui->mouse_panning->isChecked(); + Settings::values.mouse_panning_sensitivity = + static_cast<float>(ui->mouse_panning_sensitivity->value()); Settings::values.touchscreen.enabled = ui->touchscreen_enabled->isChecked(); } @@ -149,6 +152,8 @@ void ConfigureInputAdvanced::LoadConfiguration() { ui->mouse_enabled->setChecked(Settings::values.mouse_enabled); ui->keyboard_enabled->setChecked(Settings::values.keyboard_enabled); ui->emulate_analog_keyboard->setChecked(Settings::values.emulate_analog_keyboard); + ui->mouse_panning->setChecked(Settings::values.mouse_panning); + ui->mouse_panning_sensitivity->setValue(Settings::values.mouse_panning_sensitivity); ui->touchscreen_enabled->setChecked(Settings::values.touchscreen.enabled); UpdateUIEnabled(); diff --git a/src/yuzu/configuration/configure_input_advanced.ui b/src/yuzu/configuration/configure_input_advanced.ui index f207e5d3b..173130d8d 100644 --- a/src/yuzu/configuration/configure_input_advanced.ui +++ b/src/yuzu/configuration/configure_input_advanced.ui @@ -2546,27 +2546,65 @@ </property> </widget> </item> - <item row="1" column="0"> - <widget class="QCheckBox" name="emulate_analog_keyboard"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>23</height> - </size> - </property> - <property name="text"> - <string>Emulate Analog with Keyboard Input</string> - </property> - </widget> - </item> - <item row="5" column="2"> + <item row="1" column="0"> + <widget class="QCheckBox" name="emulate_analog_keyboard"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>23</height> + </size> + </property> + <property name="text"> + <string>Emulate Analog with Keyboard Input</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QCheckBox" name="mouse_panning"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>23</height> + </size> + </property> + <property name="text"> + <string>Enable mouse panning</string> + </property> + </widget> + </item> + <item row="2" column="2"> + <widget class="QDoubleSpinBox" name="mouse_panning_sensitivity"> + <property name="toolTip"> + <string>Mouse sensitivity</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="decimals"> + <number>2</number> + </property> + <property name="minimum"> + <double>0.100000000000000</double> + </property> + <property name="maximum"> + <double>16.000000000000000</double> + </property> + <property name="singleStep"> + <double>0.010000000000000</double> + </property> + <property name="value"> + <double>1.000000000000000</double> + </property> + </widget> + </item> + <item row="6" column="2"> <widget class="QPushButton" name="touchscreen_advanced"> <property name="text"> <string>Advanced</string> </property> </widget> </item> - <item row="2" column="1"> + <item row="3" column="1"> <spacer name="horizontalSpacer_8"> <property name="orientation"> <enum>Qt::Horizontal</enum> @@ -2582,21 +2620,21 @@ </property> </spacer> </item> - <item row="2" column="2"> + <item row="3" column="2"> <widget class="QPushButton" name="mouse_advanced"> <property name="text"> <string>Advanced</string> </property> </widget> </item> - <item row="5" column="0"> + <item row="6" column="0"> <widget class="QCheckBox" name="touchscreen_enabled"> <property name="text"> <string>Touchscreen</string> </property> </widget> </item> - <item row="2" column="0"> + <item row="3" column="0"> <widget class="QCheckBox" name="mouse_enabled"> <property name="minimumSize"> <size> @@ -2609,28 +2647,28 @@ </property> </widget> </item> - <item row="7" column="0"> + <item row="8" column="0"> <widget class="QLabel" name="motion_touch"> <property name="text"> <string>Motion / Touch</string> </property> </widget> </item> - <item row="7" column="2"> + <item row="8" column="2"> <widget class="QPushButton" name="buttonMotionTouch"> <property name="text"> <string>Configure</string> </property> </widget> </item> - <item row="6" column="0"> + <item row="7" column="0"> <widget class="QCheckBox" name="debug_enabled"> <property name="text"> <string>Debug Controller</string> </property> </widget> </item> - <item row="6" column="2"> + <item row="7" column="2"> <widget class="QPushButton" name="debug_configure"> <property name="text"> <string>Configure</string> diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index c9d19c948..21d0d3449 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp @@ -467,10 +467,14 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i UpdateControllerIcon(); UpdateControllerAvailableButtons(); + UpdateControllerEnabledButtons(); + UpdateControllerButtonNames(); UpdateMotionButtons(); connect(ui->comboControllerType, qOverload<int>(&QComboBox::currentIndexChanged), [this](int) { UpdateControllerIcon(); UpdateControllerAvailableButtons(); + UpdateControllerEnabledButtons(); + UpdateControllerButtonNames(); UpdateMotionButtons(); }); @@ -558,9 +562,6 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i &ConfigureInputPlayer::SaveProfile); LoadConfiguration(); - - // TODO(wwylele): enable this when we actually emulate it - ui->buttonHome->setEnabled(false); ui->controllerFrame->SetPlayerInput(player_index, buttons_param, analogs_param); ui->controllerFrame->SetConnectedStatus(ui->groupConnectedController->isChecked()); } @@ -924,6 +925,12 @@ void ConfigureInputPlayer::SetConnectableControllers() { Settings::ControllerType::Handheld); ui->comboControllerType->addItem(tr("Handheld")); } + + if (enable_all || npad_style_set.gamecube == 1) { + index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), + Settings::ControllerType::GameCube); + ui->comboControllerType->addItem(tr("GameCube Controller")); + } }; Core::System& system{Core::System::GetInstance()}; @@ -1014,7 +1021,7 @@ void ConfigureInputPlayer::UpdateControllerAvailableButtons() { // List of all the widgets that will be hidden by any of the following layouts that need // "unhidden" after the controller type changes - const std::array<QWidget*, 9> layout_show = { + const std::array<QWidget*, 11> layout_show = { ui->buttonShoulderButtonsSLSR, ui->horizontalSpacerShoulderButtonsWidget, ui->horizontalSpacerShoulderButtonsWidget2, @@ -1024,6 +1031,8 @@ void ConfigureInputPlayer::UpdateControllerAvailableButtons() { ui->buttonShoulderButtonsRight, ui->buttonMiscButtonsPlusHome, ui->bottomRight, + ui->buttonMiscButtonsMinusGroup, + ui->buttonMiscButtonsScreenshotGroup, }; for (auto* widget : layout_show) { @@ -1056,6 +1065,14 @@ void ConfigureInputPlayer::UpdateControllerAvailableButtons() { ui->bottomLeft, }; break; + case Settings::ControllerType::GameCube: + layout_hidden = { + ui->buttonShoulderButtonsSLSR, + ui->horizontalSpacerShoulderButtonsWidget2, + ui->buttonMiscButtonsMinusGroup, + ui->buttonMiscButtonsScreenshotGroup, + }; + break; } for (auto* widget : layout_hidden) { @@ -1063,6 +1080,52 @@ void ConfigureInputPlayer::UpdateControllerAvailableButtons() { } } +void ConfigureInputPlayer::UpdateControllerEnabledButtons() { + auto layout = GetControllerTypeFromIndex(ui->comboControllerType->currentIndex()); + if (debug) { + layout = Settings::ControllerType::ProController; + } + + // List of all the widgets that will be disabled by any of the following layouts that need + // "enabled" after the controller type changes + const std::array<QWidget*, 4> layout_enable = { + ui->buttonHome, + ui->buttonLStickPressedGroup, + ui->groupRStickPressed, + ui->buttonShoulderButtonsButtonLGroup, + }; + + for (auto* widget : layout_enable) { + widget->setEnabled(true); + } + + std::vector<QWidget*> layout_disable; + switch (layout) { + case Settings::ControllerType::ProController: + case Settings::ControllerType::DualJoyconDetached: + case Settings::ControllerType::Handheld: + case Settings::ControllerType::LeftJoycon: + case Settings::ControllerType::RightJoycon: + // TODO(wwylele): enable this when we actually emulate it + layout_disable = { + ui->buttonHome, + }; + break; + case Settings::ControllerType::GameCube: + layout_disable = { + ui->buttonHome, + ui->buttonLStickPressedGroup, + ui->groupRStickPressed, + ui->buttonShoulderButtonsButtonLGroup, + }; + break; + } + + for (auto* widget : layout_disable) { + widget->setEnabled(false); + } +} + void ConfigureInputPlayer::UpdateMotionButtons() { if (debug) { // Motion isn't used with the debug controller, hide both groupboxes. @@ -1085,6 +1148,11 @@ void ConfigureInputPlayer::UpdateMotionButtons() { ui->buttonMotionLeftGroup->hide(); ui->buttonMotionRightGroup->show(); break; + case Settings::ControllerType::GameCube: + // Hide both "Motion 1/2". + ui->buttonMotionLeftGroup->hide(); + ui->buttonMotionRightGroup->hide(); + break; case Settings::ControllerType::DualJoyconDetached: default: // Show both "Motion 1/2". @@ -1094,6 +1162,36 @@ void ConfigureInputPlayer::UpdateMotionButtons() { } } +void ConfigureInputPlayer::UpdateControllerButtonNames() { + auto layout = GetControllerTypeFromIndex(ui->comboControllerType->currentIndex()); + if (debug) { + layout = Settings::ControllerType::ProController; + } + + switch (layout) { + case Settings::ControllerType::ProController: + case Settings::ControllerType::DualJoyconDetached: + case Settings::ControllerType::Handheld: + case Settings::ControllerType::LeftJoycon: + case Settings::ControllerType::RightJoycon: + ui->buttonMiscButtonsPlusGroup->setTitle(tr("Plus")); + ui->buttonShoulderButtonsButtonZLGroup->setTitle(tr("ZL")); + ui->buttonShoulderButtonsZRGroup->setTitle(tr("ZR")); + ui->buttonShoulderButtonsRGroup->setTitle(tr("R")); + ui->LStick->setTitle(tr("Left Stick")); + ui->RStick->setTitle(tr("Right Stick")); + break; + case Settings::ControllerType::GameCube: + ui->buttonMiscButtonsPlusGroup->setTitle(tr("Start / Pause")); + ui->buttonShoulderButtonsButtonZLGroup->setTitle(tr("L")); + ui->buttonShoulderButtonsZRGroup->setTitle(tr("R")); + ui->buttonShoulderButtonsRGroup->setTitle(tr("Z")); + ui->LStick->setTitle(tr("Control Stick")); + ui->RStick->setTitle(tr("C-Stick")); + break; + } +} + void ConfigureInputPlayer::UpdateMappingWithDefaults() { if (ui->comboDevices->currentIndex() == 0) { return; diff --git a/src/yuzu/configuration/configure_input_player.h b/src/yuzu/configuration/configure_input_player.h index da2b89136..efe953fbc 100644 --- a/src/yuzu/configuration/configure_input_player.h +++ b/src/yuzu/configuration/configure_input_player.h @@ -143,9 +143,15 @@ private: /// Hides and disables controller settings based on the current controller type. void UpdateControllerAvailableButtons(); + /// Disables controller settings based on the current controller type. + void UpdateControllerEnabledButtons(); + /// Shows or hides motion groupboxes based on the current controller type. void UpdateMotionButtons(); + /// Alters the button names based on the current controller type. + void UpdateControllerButtonNames(); + /// Gets the default controller mapping for this device and auto configures the input to match. void UpdateMappingWithDefaults(); diff --git a/src/yuzu/configuration/configure_input_player_widget.cpp b/src/yuzu/configuration/configure_input_player_widget.cpp index e3e8bde48..61ba91cef 100644 --- a/src/yuzu/configuration/configure_input_player_widget.cpp +++ b/src/yuzu/configuration/configure_input_player_widget.cpp @@ -37,7 +37,8 @@ void PlayerControlPreview::SetPlayerInput(std::size_t index, const ButtonParam& Input::CreateDevice<Input::AnalogDevice>); UpdateColors(); } -void PlayerControlPreview::SetPlayerInputRaw(std::size_t index, const Settings::ButtonsRaw buttons_, +void PlayerControlPreview::SetPlayerInputRaw(std::size_t index, + const Settings::ButtonsRaw& buttons_, Settings::AnalogsRaw analogs_) { player_index = index; std::transform(buttons_.begin() + Settings::NativeButton::BUTTON_HID_BEGIN, @@ -226,6 +227,9 @@ void PlayerControlPreview::paintEvent(QPaintEvent* event) { case Settings::ControllerType::RightJoycon: DrawRightController(p, center); break; + case Settings::ControllerType::GameCube: + DrawGCController(p, center); + break; case Settings::ControllerType::ProController: default: DrawProController(p, center); @@ -517,14 +521,15 @@ void PlayerControlPreview::DrawDualController(QPainter& p, const QPointF center) { // Draw joysticks using namespace Settings::NativeAnalog; - DrawJoystick(p, center + QPointF(-65, -65) + (axis_values[LStick].value * 7), 1.62f, - button_values[Settings::NativeButton::LStick]); - DrawJoystick(p, center + QPointF(65, 12) + (axis_values[RStick].value * 7), 1.62f, - button_values[Settings::NativeButton::RStick]); - DrawRawJoystick(p, center + QPointF(-180, 90), axis_values[LStick].raw_value, - axis_values[LStick].properties); - DrawRawJoystick(p, center + QPointF(180, 90), axis_values[RStick].raw_value, - axis_values[RStick].properties); + const auto& l_stick = axis_values[LStick]; + const auto l_button = button_values[Settings::NativeButton::LStick]; + const auto& r_stick = axis_values[RStick]; + const auto r_button = button_values[Settings::NativeButton::RStick]; + + DrawJoystick(p, center + QPointF(-65, -65) + (l_stick.value * 7), 1.62f, l_button); + DrawJoystick(p, center + QPointF(65, 12) + (r_stick.value * 7), 1.62f, r_button); + DrawRawJoystick(p, center + QPointF(-180, 90), l_stick.raw_value, l_stick.properties); + DrawRawJoystick(p, center + QPointF(180, 90), r_stick.raw_value, r_stick.properties); } using namespace Settings::NativeButton; @@ -603,14 +608,15 @@ void PlayerControlPreview::DrawHandheldController(QPainter& p, const QPointF cen { // Draw joysticks using namespace Settings::NativeAnalog; - DrawJoystick(p, center + QPointF(-171, -41) + (axis_values[LStick].value * 4), 1.0f, - button_values[Settings::NativeButton::LStick]); - DrawJoystick(p, center + QPointF(171, 8) + (axis_values[RStick].value * 4), 1.0f, - button_values[Settings::NativeButton::RStick]); - DrawRawJoystick(p, center + QPointF(-50, 0), axis_values[LStick].raw_value, - axis_values[LStick].properties); - DrawRawJoystick(p, center + QPointF(50, 0), axis_values[RStick].raw_value, - axis_values[RStick].properties); + const auto& l_stick = axis_values[LStick]; + const auto l_button = button_values[Settings::NativeButton::LStick]; + const auto& r_stick = axis_values[RStick]; + const auto r_button = button_values[Settings::NativeButton::RStick]; + + DrawJoystick(p, center + QPointF(-171, -41) + (l_stick.value * 4), 1.0f, l_button); + DrawJoystick(p, center + QPointF(171, 8) + (r_stick.value * 4), 1.0f, r_button); + DrawRawJoystick(p, center + QPointF(-50, 0), l_stick.raw_value, l_stick.properties); + DrawRawJoystick(p, center + QPointF(50, 0), r_stick.raw_value, r_stick.properties); } using namespace Settings::NativeButton; @@ -699,9 +705,9 @@ void PlayerControlPreview::DrawProController(QPainter& p, const QPointF center) { // Draw joysticks using namespace Settings::NativeAnalog; - DrawProJoystick(p, center + QPointF(-111, -55) + (axis_values[LStick].value * 11), + DrawProJoystick(p, center + QPointF(-111, -55), axis_values[LStick].value, 11, button_values[Settings::NativeButton::LStick]); - DrawProJoystick(p, center + QPointF(51, 0) + (axis_values[RStick].value * 11), + DrawProJoystick(p, center + QPointF(51, 0), axis_values[RStick].value, 11, button_values[Settings::NativeButton::RStick]); DrawRawJoystick(p, center + QPointF(-50, 105), axis_values[LStick].raw_value, axis_values[LStick].properties); @@ -1002,12 +1008,6 @@ constexpr std::array<float, 3 * 2> up_arrow_symbol = { 0.0f, -3.0f, -3.0f, 2.0f, 3.0f, 2.0f, }; -constexpr std::array<float, 13 * 2> up_arrow = { - 9.4f, -9.8f, 9.4f, -10.2f, 8.9f, -29.8f, 8.5f, -30.0f, 8.1f, - -30.1f, 7.7f, -30.1f, -8.6f, -30.0f, -9.0f, -29.8f, -9.3f, -29.5f, - -9.5f, -29.1f, -9.5f, -28.7f, -9.1f, -9.1f, -8.8f, -8.8f, -}; - constexpr std::array<float, 64 * 2> trigger_button = { 5.5f, -12.6f, 5.8f, -12.6f, 6.7f, -12.5f, 8.1f, -12.3f, 8.6f, -12.2f, 9.2f, -12.0f, 9.5f, -11.9f, 9.9f, -11.8f, 10.6f, -11.5f, 11.0f, -11.3f, 11.2f, -11.2f, 11.4f, -11.1f, @@ -1457,15 +1457,18 @@ void PlayerControlPreview::DrawProBody(QPainter& p, const QPointF center) { constexpr int radius1 = 32; for (std::size_t point = 0; point < pro_left_handle.size() / 2; ++point) { - qleft_handle[point] = - center + QPointF(pro_left_handle[point * 2], pro_left_handle[point * 2 + 1]); - qright_handle[point] = - center + QPointF(-pro_left_handle[point * 2], pro_left_handle[point * 2 + 1]); + const float left_x = pro_left_handle[point * 2 + 0]; + const float left_y = pro_left_handle[point * 2 + 1]; + + qleft_handle[point] = center + QPointF(left_x, left_y); + qright_handle[point] = center + QPointF(-left_x, left_y); } for (std::size_t point = 0; point < pro_body.size() / 2; ++point) { - qbody[point] = center + QPointF(pro_body[point * 2], pro_body[point * 2 + 1]); - qbody[pro_body.size() - 1 - point] = - center + QPointF(-pro_body[point * 2], pro_body[point * 2 + 1]); + const float body_x = pro_body[point * 2 + 0]; + const float body_y = pro_body[point * 2 + 1]; + + qbody[point] = center + QPointF(body_x, body_y); + qbody[pro_body.size() - 1 - point] = center + QPointF(-body_x, body_y); } // Draw left handle body @@ -1496,21 +1499,25 @@ void PlayerControlPreview::DrawGCBody(QPainter& p, const QPointF center) { constexpr float angle = 2 * 3.1415f / 8; for (std::size_t point = 0; point < gc_left_body.size() / 2; ++point) { - qleft_handle[point] = - center + QPointF(gc_left_body[point * 2], gc_left_body[point * 2 + 1]); - qright_handle[point] = - center + QPointF(-gc_left_body[point * 2], gc_left_body[point * 2 + 1]); + const float body_x = gc_left_body[point * 2 + 0]; + const float body_y = gc_left_body[point * 2 + 1]; + + qleft_handle[point] = center + QPointF(body_x, body_y); + qright_handle[point] = center + QPointF(-body_x, body_y); } for (std::size_t point = 0; point < gc_body.size() / 2; ++point) { - qbody[point] = center + QPointF(gc_body[point * 2], gc_body[point * 2 + 1]); - qbody[gc_body.size() - 1 - point] = - center + QPointF(-gc_body[point * 2], gc_body[point * 2 + 1]); + const float body_x = gc_body[point * 2 + 0]; + const float body_y = gc_body[point * 2 + 1]; + + qbody[point] = center + QPointF(body_x, body_y); + qbody[gc_body.size() - 1 - point] = center + QPointF(-body_x, body_y); } for (std::size_t point = 0; point < 8; ++point) { - left_hex[point] = - center + QPointF(34 * std::cos(point * angle) - 111, 34 * std::sin(point * angle) - 44); - right_hex[point] = - center + QPointF(26 * std::cos(point * angle) + 61, 26 * std::sin(point * angle) + 37); + const float point_cos = std::cos(point * angle); + const float point_sin = std::sin(point * angle); + + left_hex[point] = center + QPointF(34 * point_cos - 111, 34 * point_sin - 44); + right_hex[point] = center + QPointF(26 * point_cos + 61, 26 * point_sin + 37); } // Draw body @@ -1631,32 +1638,36 @@ void PlayerControlPreview::DrawDualBody(QPainter& p, const QPointF center) { constexpr float offset = 209.3f; for (std::size_t point = 0; point < left_joycon_body.size() / 2; ++point) { - left_joycon[point] = center + QPointF(left_joycon_body[point * 2] * size + offset, - left_joycon_body[point * 2 + 1] * size - 1); - right_joycon[point] = center + QPointF(-left_joycon_body[point * 2] * size - offset, - left_joycon_body[point * 2 + 1] * size - 1); + const float body_x = left_joycon_body[point * 2 + 0]; + const float body_y = left_joycon_body[point * 2 + 1]; + + left_joycon[point] = center + QPointF(body_x * size + offset, body_y * size - 1); + right_joycon[point] = center + QPointF(-body_x * size - offset, body_y * size - 1); } for (std::size_t point = 0; point < left_joycon_slider.size() / 2; ++point) { - qleft_joycon_slider[point] = - center + QPointF(left_joycon_slider[point * 2], left_joycon_slider[point * 2 + 1]); - qright_joycon_slider[point] = - center + QPointF(-left_joycon_slider[point * 2], left_joycon_slider[point * 2 + 1]); + const float slider_x = left_joycon_slider[point * 2 + 0]; + const float slider_y = left_joycon_slider[point * 2 + 1]; + + qleft_joycon_slider[point] = center + QPointF(slider_x, slider_y); + qright_joycon_slider[point] = center + QPointF(-slider_x, slider_y); } for (std::size_t point = 0; point < left_joycon_topview.size() / 2; ++point) { + const float top_view_x = left_joycon_topview[point * 2 + 0]; + const float top_view_y = left_joycon_topview[point * 2 + 1]; + qleft_joycon_topview[point] = - center + QPointF(left_joycon_topview[point * 2] * size2 - 52, - left_joycon_topview[point * 2 + 1] * size2 - 52); + center + QPointF(top_view_x * size2 - 52, top_view_y * size2 - 52); qright_joycon_topview[point] = - center + QPointF(-left_joycon_topview[point * 2] * size2 + 52, - left_joycon_topview[point * 2 + 1] * size2 - 52); + center + QPointF(-top_view_x * size2 + 52, top_view_y * size2 - 52); } for (std::size_t point = 0; point < left_joycon_slider_topview.size() / 2; ++point) { + const float top_view_x = left_joycon_slider_topview[point * 2 + 0]; + const float top_view_y = left_joycon_slider_topview[point * 2 + 1]; + qleft_joycon_slider_topview[point] = - center + QPointF(left_joycon_slider_topview[point * 2] * size2 - 52, - left_joycon_slider_topview[point * 2 + 1] * size2 - 52); + center + QPointF(top_view_x * size2 - 52, top_view_y * size2 - 52); qright_joycon_slider_topview[point] = - center + QPointF(-left_joycon_slider_topview[point * 2] * size2 + 52, - left_joycon_slider_topview[point * 2 + 1] * size2 - 52); + center + QPointF(-top_view_x * size2 + 52, top_view_y * size2 - 52); } // right joycon body @@ -1905,18 +1916,19 @@ void PlayerControlPreview::DrawProTriggers(QPainter& p, const QPointF center, bo std::array<QPointF, pro_body_top.size()> qbody_top; for (std::size_t point = 0; point < pro_left_trigger.size() / 2; ++point) { - qleft_trigger[point] = - center + QPointF(pro_left_trigger[point * 2], - pro_left_trigger[point * 2 + 1] + (left_pressed ? 2 : 0)); - qright_trigger[point] = - center + QPointF(-pro_left_trigger[point * 2], - pro_left_trigger[point * 2 + 1] + (right_pressed ? 2 : 0)); + const float trigger_x = pro_left_trigger[point * 2 + 0]; + const float trigger_y = pro_left_trigger[point * 2 + 1]; + + qleft_trigger[point] = center + QPointF(trigger_x, trigger_y + (left_pressed ? 2 : 0)); + qright_trigger[point] = center + QPointF(-trigger_x, trigger_y + (right_pressed ? 2 : 0)); } for (std::size_t point = 0; point < pro_body_top.size() / 2; ++point) { - qbody_top[pro_body_top.size() - 1 - point] = - center + QPointF(-pro_body_top[point * 2], pro_body_top[point * 2 + 1]); - qbody_top[point] = center + QPointF(pro_body_top[point * 2], pro_body_top[point * 2 + 1]); + const float top_x = pro_body_top[point * 2 + 0]; + const float top_y = pro_body_top[point * 2 + 1]; + + qbody_top[pro_body_top.size() - 1 - point] = center + QPointF(-top_x, top_y); + qbody_top[point] = center + QPointF(top_x, top_y); } // Pro body detail @@ -1939,12 +1951,11 @@ void PlayerControlPreview::DrawGCTriggers(QPainter& p, const QPointF center, boo std::array<QPointF, left_gc_trigger.size() / 2> qright_trigger; for (std::size_t point = 0; point < left_gc_trigger.size() / 2; ++point) { - qleft_trigger[point] = - center + QPointF(left_gc_trigger[point * 2], - left_gc_trigger[point * 2 + 1] + (left_pressed ? 10 : 0)); - qright_trigger[point] = - center + QPointF(-left_gc_trigger[point * 2], - left_gc_trigger[point * 2 + 1] + (right_pressed ? 10 : 0)); + const float trigger_x = left_gc_trigger[point * 2 + 0]; + const float trigger_y = left_gc_trigger[point * 2 + 1]; + + qleft_trigger[point] = center + QPointF(trigger_x, trigger_y + (left_pressed ? 10 : 0)); + qright_trigger[point] = center + QPointF(-trigger_x, trigger_y + (right_pressed ? 10 : 0)); } // Left trigger @@ -1973,12 +1984,13 @@ void PlayerControlPreview::DrawHandheldTriggers(QPainter& p, const QPointF cente std::array<QPointF, left_joycon_trigger.size() / 2> qright_trigger; for (std::size_t point = 0; point < left_joycon_trigger.size() / 2; ++point) { + const float left_trigger_x = left_joycon_trigger[point * 2 + 0]; + const float left_trigger_y = left_joycon_trigger[point * 2 + 1]; + qleft_trigger[point] = - center + QPointF(left_joycon_trigger[point * 2], - left_joycon_trigger[point * 2 + 1] + (left_pressed ? 0.5f : 0)); + center + QPointF(left_trigger_x, left_trigger_y + (left_pressed ? 0.5f : 0)); qright_trigger[point] = - center + QPointF(-left_joycon_trigger[point * 2], - left_joycon_trigger[point * 2 + 1] + (right_pressed ? 0.5f : 0)); + center + QPointF(-left_trigger_x, left_trigger_y + (right_pressed ? 0.5f : 0)); } // Left trigger @@ -1998,12 +2010,14 @@ void PlayerControlPreview::DrawDualTriggers(QPainter& p, const QPointF center, b constexpr float size = 1.62f; constexpr float offset = 210.6f; for (std::size_t point = 0; point < left_joycon_trigger.size() / 2; ++point) { - qleft_trigger[point] = - center + QPointF(left_joycon_trigger[point * 2] * size + offset, - left_joycon_trigger[point * 2 + 1] * size + (left_pressed ? 0.5f : 0)); - qright_trigger[point] = center + QPointF(-left_joycon_trigger[point * 2] * size - offset, - left_joycon_trigger[point * 2 + 1] * size + - (right_pressed ? 0.5f : 0)); + const float left_trigger_x = left_joycon_trigger[point * 2 + 0]; + const float left_trigger_y = left_joycon_trigger[point * 2 + 1]; + + qleft_trigger[point] = center + QPointF(left_trigger_x * size + offset, + left_trigger_y * size + (left_pressed ? 0.5f : 0)); + qright_trigger[point] = + center + QPointF(-left_trigger_x * size - offset, + left_trigger_y * size + (right_pressed ? 0.5f : 0)); } // Left trigger @@ -2023,13 +2037,16 @@ void PlayerControlPreview::DrawDualTriggersTopView(QPainter& p, const QPointF ce constexpr float size = 0.9f; for (std::size_t point = 0; point < left_joystick_L_topview.size() / 2; ++point) { - qleft_trigger[point] = center + QPointF(left_joystick_L_topview[point * 2] * size - 50, - left_joystick_L_topview[point * 2 + 1] * size - 52); + const float top_view_x = left_joystick_L_topview[point * 2 + 0]; + const float top_view_y = left_joystick_L_topview[point * 2 + 1]; + + qleft_trigger[point] = center + QPointF(top_view_x * size - 50, top_view_y * size - 52); } for (std::size_t point = 0; point < left_joystick_L_topview.size() / 2; ++point) { - qright_trigger[point] = - center + QPointF(-left_joystick_L_topview[point * 2] * size + 50, - left_joystick_L_topview[point * 2 + 1] * size - 52); + const float top_view_x = left_joystick_L_topview[point * 2 + 0]; + const float top_view_y = left_joystick_L_topview[point * 2 + 1]; + + qright_trigger[point] = center + QPointF(-top_view_x * size + 50, top_view_y * size - 52); } p.setPen(colors.outline); @@ -2273,15 +2290,39 @@ void PlayerControlPreview::DrawJoystickSideview(QPainter& p, const QPointF cente p.drawLine(p2.at(32), p2.at(71)); } -void PlayerControlPreview::DrawProJoystick(QPainter& p, const QPointF center, bool pressed) { +void PlayerControlPreview::DrawProJoystick(QPainter& p, const QPointF center, const QPointF offset, + float offset_scalar, bool pressed) { + const float radius1 = 24.0f; + const float radius2 = 17.0f; + + const QPointF offset_center = center + offset * offset_scalar; + + const auto amplitude = static_cast<float>( + 1.0 - std::sqrt((offset.x() * offset.x()) + (offset.y() * offset.y())) * 0.1f); + + const float rotation = + ((offset.x() == 0) ? atan(1) * 2 : atan(offset.y() / offset.x())) * (180 / (atan(1) * 4)); + + p.save(); + p.translate(offset_center); + p.rotate(rotation); + // Outer circle p.setPen(colors.outline); p.setBrush(pressed ? colors.highlight : colors.button); - DrawCircle(p, center, 24.0f); + p.drawEllipse(QPointF(0, 0), radius1 * amplitude, radius1); // Inner circle p.setBrush(pressed ? colors.highlight2 : colors.button2); - DrawCircle(p, center, 17.0f); + + const float inner_offset = + (radius1 - radius2) * 0.4f * ((offset.x() == 0 && offset.y() < 0) ? -1.0f : 1.0f); + const float offset_factor = (1.0f - amplitude) / 0.1f; + + p.drawEllipse(QPointF((offset.x() < 0) ? -inner_offset : inner_offset, 0) * offset_factor, + radius2 * amplitude, radius2); + + p.restore(); } void PlayerControlPreview::DrawGCJoystick(QPainter& p, const QPointF center, bool pressed) { @@ -2299,7 +2340,7 @@ void PlayerControlPreview::DrawGCJoystick(QPainter& p, const QPointF center, boo } void PlayerControlPreview::DrawRawJoystick(QPainter& p, const QPointF center, const QPointF value, - const Input::AnalogProperties properties) { + const Input::AnalogProperties& properties) { constexpr float size = 45.0f; const float range = size * properties.range; const float deadzone = size * properties.deadzone; @@ -2422,17 +2463,16 @@ void PlayerControlPreview::DrawArrowButtonOutline(QPainter& p, const QPointF cen std::array<QPointF, (arrow_points - 1) * 4> arrow_button_outline; for (std::size_t point = 0; point < arrow_points - 1; ++point) { - arrow_button_outline[point] = center + QPointF(up_arrow_button[point * 2] * size, - up_arrow_button[point * 2 + 1] * size); + const float up_arrow_x = up_arrow_button[point * 2 + 0]; + const float up_arrow_y = up_arrow_button[point * 2 + 1]; + + arrow_button_outline[point] = center + QPointF(up_arrow_x * size, up_arrow_y * size); arrow_button_outline[(arrow_points - 1) * 2 - point - 1] = - center + - QPointF(up_arrow_button[point * 2 + 1] * size, up_arrow_button[point * 2] * size); + center + QPointF(up_arrow_y * size, up_arrow_x * size); arrow_button_outline[(arrow_points - 1) * 2 + point] = - center + - QPointF(-up_arrow_button[point * 2] * size, -up_arrow_button[point * 2 + 1] * size); + center + QPointF(-up_arrow_x * size, -up_arrow_y * size); arrow_button_outline[(arrow_points - 1) * 4 - point - 1] = - center + - QPointF(-up_arrow_button[point * 2 + 1] * size, -up_arrow_button[point * 2] * size); + center + QPointF(-up_arrow_y * size, -up_arrow_x * size); } // Draw arrow button outline p.setPen(colors.outline); @@ -2446,22 +2486,21 @@ void PlayerControlPreview::DrawArrowButton(QPainter& p, const QPointF center, QPoint offset; for (std::size_t point = 0; point < up_arrow_button.size() / 2; ++point) { + const float up_arrow_x = up_arrow_button[point * 2 + 0]; + const float up_arrow_y = up_arrow_button[point * 2 + 1]; + switch (direction) { case Direction::Up: - arrow_button[point] = center + QPointF(up_arrow_button[point * 2] * size, - up_arrow_button[point * 2 + 1] * size); + arrow_button[point] = center + QPointF(up_arrow_x * size, up_arrow_y * size); break; case Direction::Left: - arrow_button[point] = center + QPointF(up_arrow_button[point * 2 + 1] * size, - up_arrow_button[point * 2] * size); + arrow_button[point] = center + QPointF(up_arrow_y * size, up_arrow_x * size); break; case Direction::Right: - arrow_button[point] = center + QPointF(-up_arrow_button[point * 2 + 1] * size, - up_arrow_button[point * 2] * size); + arrow_button[point] = center + QPointF(-up_arrow_y * size, up_arrow_x * size); break; case Direction::Down: - arrow_button[point] = center + QPointF(up_arrow_button[point * 2] * size, - -up_arrow_button[point * 2 + 1] * size); + arrow_button[point] = center + QPointF(up_arrow_x * size, -up_arrow_y * size); break; case Direction::None: break; @@ -2500,17 +2539,17 @@ void PlayerControlPreview::DrawArrowButton(QPainter& p, const QPointF center, void PlayerControlPreview::DrawTriggerButton(QPainter& p, const QPointF center, const Direction direction, bool pressed) { std::array<QPointF, trigger_button.size() / 2> qtrigger_button; - QPoint offset; for (std::size_t point = 0; point < trigger_button.size() / 2; ++point) { + const float trigger_button_x = trigger_button[point * 2 + 0]; + const float trigger_button_y = trigger_button[point * 2 + 1]; + switch (direction) { case Direction::Left: - qtrigger_button[point] = - center + QPointF(-trigger_button[point * 2], trigger_button[point * 2 + 1]); + qtrigger_button[point] = center + QPointF(-trigger_button_x, trigger_button_y); break; case Direction::Right: - qtrigger_button[point] = - center + QPointF(trigger_button[point * 2], trigger_button[point * 2 + 1]); + qtrigger_button[point] = center + QPointF(trigger_button_x, trigger_button_y); break; case Direction::Up: case Direction::Down: @@ -2633,22 +2672,21 @@ void PlayerControlPreview::DrawArrow(QPainter& p, const QPointF center, const Di std::array<QPointF, up_arrow_symbol.size() / 2> arrow_symbol; for (std::size_t point = 0; point < up_arrow_symbol.size() / 2; ++point) { + const float up_arrow_x = up_arrow_symbol[point * 2 + 0]; + const float up_arrow_y = up_arrow_symbol[point * 2 + 1]; + switch (direction) { case Direction::Up: - arrow_symbol[point] = center + QPointF(up_arrow_symbol[point * 2] * size, - up_arrow_symbol[point * 2 + 1] * size); + arrow_symbol[point] = center + QPointF(up_arrow_x * size, up_arrow_y * size); break; case Direction::Left: - arrow_symbol[point] = center + QPointF(up_arrow_symbol[point * 2 + 1] * size, - up_arrow_symbol[point * 2] * size); + arrow_symbol[point] = center + QPointF(up_arrow_y * size, up_arrow_x * size); break; case Direction::Right: - arrow_symbol[point] = center + QPointF(-up_arrow_symbol[point * 2 + 1] * size, - up_arrow_symbol[point * 2] * size); + arrow_symbol[point] = center + QPointF(-up_arrow_y * size, up_arrow_x * size); break; case Direction::Down: - arrow_symbol[point] = center + QPointF(up_arrow_symbol[point * 2] * size, - -up_arrow_symbol[point * 2 + 1] * size); + arrow_symbol[point] = center + QPointF(up_arrow_x * size, -up_arrow_y * size); break; case Direction::None: break; diff --git a/src/yuzu/configuration/configure_input_player_widget.h b/src/yuzu/configuration/configure_input_player_widget.h index 39565f795..91c3343f1 100644 --- a/src/yuzu/configuration/configure_input_player_widget.h +++ b/src/yuzu/configuration/configure_input_player_widget.h @@ -25,7 +25,7 @@ public: void SetPlayerInput(std::size_t index, const ButtonParam& buttons_param, const AnalogParam& analogs_param); - void SetPlayerInputRaw(std::size_t index, const Settings::ButtonsRaw buttons_, + void SetPlayerInputRaw(std::size_t index, const Settings::ButtonsRaw& buttons_, Settings::AnalogsRaw analogs_); void SetConnectedStatus(bool checked); void SetControllerType(Settings::ControllerType type); @@ -138,9 +138,9 @@ private: // Draw joystick functions void DrawJoystick(QPainter& p, QPointF center, float size, bool pressed); void DrawJoystickSideview(QPainter& p, QPointF center, float angle, float size, bool pressed); - void DrawRawJoystick(QPainter& p, QPointF center, const QPointF value, - const Input::AnalogProperties properties); - void DrawProJoystick(QPainter& p, QPointF center, bool pressed); + void DrawRawJoystick(QPainter& p, QPointF center, QPointF value, + const Input::AnalogProperties& properties); + void DrawProJoystick(QPainter& p, QPointF center, QPointF offset, float scalar, bool pressed); void DrawGCJoystick(QPainter& p, QPointF center, bool pressed); // Draw button functions |