From 97b2220a822548eed83993fceebe0e611dbec84b Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Tue, 27 Oct 2020 13:33:25 -0400 Subject: [PATCH] general: Fix compiler warnings on linux and miscellaneous changes --- src/core/hle/service/hid/controllers/npad.cpp | 17 ++++++++++------- src/core/hle/service/hid/controllers/npad.h | 2 +- src/yuzu/applets/controller.cpp | 5 +++-- .../configure_debug_controller.cpp | 1 + .../configuration/configure_debug_controller.h | 3 ++- src/yuzu/configuration/configure_input.h | 9 ++++----- .../configuration/configure_input_advanced.cpp | 6 +++--- .../configuration/configure_input_advanced.h | 2 +- .../configuration/configure_input_player.cpp | 3 ++- .../configure_input_profile_dialog.cpp | 1 + .../configure_input_profile_dialog.h | 3 ++- src/yuzu/main.cpp | 1 + 12 files changed, 31 insertions(+), 22 deletions(-) diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index cfafabbd82..30715267ce 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp @@ -287,7 +287,7 @@ void Controller_NPad::OnLoadInputDevices() { void Controller_NPad::OnRelease() { for (std::size_t npad_idx = 0; npad_idx < vibrations.size(); ++npad_idx) { for (std::size_t device_idx = 0; device_idx < vibrations[npad_idx].size(); ++device_idx) { - VibrateControllerAtIndex(npad_idx, device_idx); + VibrateControllerAtIndex(npad_idx, device_idx, {}); } } } @@ -720,11 +720,14 @@ bool Controller_NPad::VibrateControllerAtIndex(std::size_t npad_index, std::size last_vibration_timepoints[npad_index][device_index] = now; } - return vibrations[npad_index][device_index]->SetRumblePlay( - std::min(vibration_value.amp_low * player.vibration_strength / 100.0f, 1.0f), - vibration_value.freq_low, - std::min(vibration_value.amp_high * player.vibration_strength / 100.0f, 1.0f), - vibration_value.freq_high); + auto& vibration = vibrations[npad_index][device_index]; + const auto player_vibration_strength = static_cast(player.vibration_strength); + const auto amp_low = + std::min(vibration_value.amp_low * player_vibration_strength / 100.0f, 1.0f); + const auto amp_high = + std::min(vibration_value.amp_high * player_vibration_strength / 100.0f, 1.0f); + return vibration->SetRumblePlay(amp_low, vibration_value.freq_low, amp_high, + vibration_value.freq_high); } void Controller_NPad::VibrateController(const DeviceHandle& vibration_device_handle, @@ -855,7 +858,7 @@ void Controller_NPad::DisconnectNpad(u32 npad_id) { void Controller_NPad::DisconnectNpadAtIndex(std::size_t npad_index) { for (std::size_t device_idx = 0; device_idx < vibrations[npad_index].size(); ++device_idx) { // Send an empty vibration to stop any vibrations. - VibrateControllerAtIndex(npad_index, device_idx); + VibrateControllerAtIndex(npad_index, device_idx, {}); vibration_devices_mounted[npad_index][device_idx] = false; } diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index f5122124c5..99384524b0 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h @@ -149,7 +149,7 @@ public: void SetNpadMode(u32 npad_id, NpadAssignments assignment_mode); bool VibrateControllerAtIndex(std::size_t npad_index, std::size_t device_index, - const VibrationValue& vibration_value = {}); + const VibrationValue& vibration_value); void VibrateController(const DeviceHandle& vibration_device_handle, const VibrationValue& vibration_value); diff --git a/src/yuzu/applets/controller.cpp b/src/yuzu/applets/controller.cpp index 5112d48d24..8ecfec7702 100644 --- a/src/yuzu/applets/controller.cpp +++ b/src/yuzu/applets/controller.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include +#include #include "common/assert.h" #include "common/string_util.h" @@ -356,7 +357,7 @@ bool QtControllerSelectorDialog::CheckIfParametersMet() { } void QtControllerSelectorDialog::SetSupportedControllers() { - const QString theme = [this] { + const QString theme = [] { if (QIcon::themeName().contains(QStringLiteral("dark"))) { return QStringLiteral("_dark"); } else if (QIcon::themeName().contains(QStringLiteral("midnight"))) { @@ -445,7 +446,7 @@ void QtControllerSelectorDialog::UpdateControllerIcon(std::size_t player_index) } }(); - const QString theme = [this] { + const QString theme = [] { if (QIcon::themeName().contains(QStringLiteral("dark"))) { return QStringLiteral("_dark"); } else if (QIcon::themeName().contains(QStringLiteral("midnight"))) { diff --git a/src/yuzu/configuration/configure_debug_controller.cpp b/src/yuzu/configuration/configure_debug_controller.cpp index 6dc9c5e577..a878ef9c61 100644 --- a/src/yuzu/configuration/configure_debug_controller.cpp +++ b/src/yuzu/configuration/configure_debug_controller.cpp @@ -4,6 +4,7 @@ #include "ui_configure_debug_controller.h" #include "yuzu/configuration/configure_debug_controller.h" +#include "yuzu/configuration/configure_input_player.h" ConfigureDebugController::ConfigureDebugController(QWidget* parent, InputCommon::InputSubsystem* input_subsystem, diff --git a/src/yuzu/configuration/configure_debug_controller.h b/src/yuzu/configuration/configure_debug_controller.h index 2694b34194..b4f53fad52 100644 --- a/src/yuzu/configuration/configure_debug_controller.h +++ b/src/yuzu/configuration/configure_debug_controller.h @@ -6,10 +6,11 @@ #include #include -#include "yuzu/configuration/configure_input_player.h" class QPushButton; +class ConfigureInputPlayer; + class InputProfiles; namespace InputCommon { diff --git a/src/yuzu/configuration/configure_input.h b/src/yuzu/configuration/configure_input.h index f135a4299a..9eba9b5230 100644 --- a/src/yuzu/configuration/configure_input.h +++ b/src/yuzu/configuration/configure_input.h @@ -8,17 +8,16 @@ #include #include +#include #include -#include "yuzu/configuration/configure_input_advanced.h" -#include "yuzu/configuration/configure_input_player.h" - -#include "ui_configure_input.h" - class QCheckBox; class QString; class QTimer; +class ConfigureInputAdvanced; +class ConfigureInputPlayer; + class InputProfiles; namespace InputCommon { diff --git a/src/yuzu/configuration/configure_input_advanced.cpp b/src/yuzu/configuration/configure_input_advanced.cpp index 3074be833e..abaf03630e 100644 --- a/src/yuzu/configuration/configure_input_advanced.cpp +++ b/src/yuzu/configuration/configure_input_advanced.cpp @@ -68,8 +68,7 @@ ConfigureInputAdvanced::ConfigureInputAdvanced(QWidget* parent) for (std::size_t button_idx = 0; button_idx < color_buttons.size(); ++button_idx) { connect(color_buttons[button_idx], &QPushButton::clicked, this, [this, player_idx, button_idx] { - OnControllerButtonClick(static_cast(player_idx), - static_cast(button_idx)); + OnControllerButtonClick(player_idx, button_idx); }); } } @@ -94,7 +93,8 @@ ConfigureInputAdvanced::ConfigureInputAdvanced(QWidget* parent) ConfigureInputAdvanced::~ConfigureInputAdvanced() = default; -void ConfigureInputAdvanced::OnControllerButtonClick(int player_idx, int button_idx) { +void ConfigureInputAdvanced::OnControllerButtonClick(std::size_t player_idx, + std::size_t button_idx) { const QColor new_bg_color = QColorDialog::getColor(controllers_colors[player_idx][button_idx]); if (!new_bg_color.isValid()) { return; diff --git a/src/yuzu/configuration/configure_input_advanced.h b/src/yuzu/configuration/configure_input_advanced.h index 50bb877680..3083d55c14 100644 --- a/src/yuzu/configuration/configure_input_advanced.h +++ b/src/yuzu/configuration/configure_input_advanced.h @@ -35,7 +35,7 @@ private: void RetranslateUI(); void UpdateUIEnabled(); - void OnControllerButtonClick(int player_idx, int button_idx); + void OnControllerButtonClick(std::size_t player_idx, std::size_t button_idx); void LoadConfiguration(); diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index 5abf9f0bf4..0d10c1360d 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -857,7 +858,7 @@ void ConfigureInputPlayer::UpdateControllerIcon() { } }(); - const QString theme = [this] { + const QString theme = [] { if (QIcon::themeName().contains(QStringLiteral("dark"))) { return QStringLiteral("_dark"); } else if (QIcon::themeName().contains(QStringLiteral("midnight"))) { diff --git a/src/yuzu/configuration/configure_input_profile_dialog.cpp b/src/yuzu/configuration/configure_input_profile_dialog.cpp index 818399b472..1f5cfa75bf 100644 --- a/src/yuzu/configuration/configure_input_profile_dialog.cpp +++ b/src/yuzu/configuration/configure_input_profile_dialog.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include "ui_configure_input_profile_dialog.h" +#include "yuzu/configuration/configure_input_player.h" #include "yuzu/configuration/configure_input_profile_dialog.h" ConfigureInputProfileDialog::ConfigureInputProfileDialog( diff --git a/src/yuzu/configuration/configure_input_profile_dialog.h b/src/yuzu/configuration/configure_input_profile_dialog.h index d4a3973d90..e6386bdbba 100644 --- a/src/yuzu/configuration/configure_input_profile_dialog.h +++ b/src/yuzu/configuration/configure_input_profile_dialog.h @@ -6,10 +6,11 @@ #include #include -#include "yuzu/configuration/configure_input_player.h" class QPushButton; +class ConfigureInputPlayer; + class InputProfiles; namespace InputCommon { diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 76a5c32f4e..9dabd8889d 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -58,6 +58,7 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual #include #include #include +#include #include #include #include