From 403e36fab2f79312af1c57ccc02c5188b0d3e23d Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Fri, 28 Aug 2020 23:51:19 -0400 Subject: yuzu/configuration: Fix index out of bounds for default_analogs --- src/yuzu/configuration/config.cpp | 14 ++++++++------ src/yuzu/configuration/config.h | 3 +-- src/yuzu/configuration/configure_input_player.cpp | 8 ++++---- 3 files changed, 13 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 489877be9..588bbd677 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -51,8 +51,10 @@ const std::array, Settings::NativeAnalog::NumAnalogs> Config: }, }}; -const int Config::default_lstick_mod = Qt::Key_E; -const int Config::default_rstick_mod = Qt::Key_R; +const std::array Config::default_stick_mod = { + Qt::Key_E, + Qt::Key_R, +}; const std::array Config::default_mouse_buttons = { @@ -285,7 +287,7 @@ void Config::ReadPlayerValues() { for (int i = 0; i < Settings::NativeAnalog::NumAnalogs; ++i) { const std::string default_param = InputCommon::GenerateAnalogParamFromKeys( default_analogs[i][0], default_analogs[i][1], default_analogs[i][2], - default_analogs[i][3], default_analogs[i][4], 0.5f); + default_analogs[i][3], default_stick_mod[i], 0.5f); auto& player_analogs = player.analogs[i]; player_analogs = qt_config @@ -323,7 +325,7 @@ void Config::ReadDebugValues() { for (int i = 0; i < Settings::NativeAnalog::NumAnalogs; ++i) { const std::string default_param = InputCommon::GenerateAnalogParamFromKeys( default_analogs[i][0], default_analogs[i][1], default_analogs[i][2], - default_analogs[i][3], default_analogs[i][4], 0.5f); + default_analogs[i][3], default_stick_mod[i], 0.5f); auto& debug_pad_analogs = Settings::values.debug_pad_analogs[i]; debug_pad_analogs = qt_config @@ -877,7 +879,7 @@ void Config::SavePlayerValues() { for (int i = 0; i < Settings::NativeAnalog::NumAnalogs; ++i) { const std::string default_param = InputCommon::GenerateAnalogParamFromKeys( default_analogs[i][0], default_analogs[i][1], default_analogs[i][2], - default_analogs[i][3], default_analogs[i][4], 0.5f); + default_analogs[i][3], default_stick_mod[i], 0.5f); WriteSetting(QStringLiteral("player_%1_").arg(p) + QString::fromStdString(Settings::NativeAnalog::mapping[i]), QString::fromStdString(player.analogs[i]), @@ -898,7 +900,7 @@ void Config::SaveDebugValues() { for (int i = 0; i < Settings::NativeAnalog::NumAnalogs; ++i) { const std::string default_param = InputCommon::GenerateAnalogParamFromKeys( default_analogs[i][0], default_analogs[i][1], default_analogs[i][2], - default_analogs[i][3], default_analogs[i][4], 0.5f); + default_analogs[i][3], default_stick_mod[i], 0.5f); WriteSetting(QStringLiteral("debug_pad_") + QString::fromStdString(Settings::NativeAnalog::mapping[i]), QString::fromStdString(Settings::values.debug_pad_analogs[i]), diff --git a/src/yuzu/configuration/config.h b/src/yuzu/configuration/config.h index 9eeaf9d1e..aa929d134 100644 --- a/src/yuzu/configuration/config.h +++ b/src/yuzu/configuration/config.h @@ -24,8 +24,7 @@ public: static const std::array default_buttons; static const std::array, Settings::NativeAnalog::NumAnalogs> default_analogs; - static const int default_lstick_mod; - static const int default_rstick_mod; + static const std::array default_stick_mod; static const std::array default_mouse_buttons; static const std::array default_keyboard_keys; diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index 80bf40acb..13ecb3dc5 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp @@ -305,8 +305,8 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i } // Handle clicks for the modifier buttons as well. - ConfigureButtonClick(ui->buttonLStickMod, &lstick_mod, Config::default_lstick_mod); - ConfigureButtonClick(ui->buttonRStickMod, &rstick_mod, Config::default_rstick_mod); + ConfigureButtonClick(ui->buttonLStickMod, &lstick_mod, Config::default_stick_mod[0]); + ConfigureButtonClick(ui->buttonRStickMod, &rstick_mod, Config::default_stick_mod[1]); for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; ++analog_id) { for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; ++sub_button_id) { @@ -532,9 +532,9 @@ void ConfigureInputPlayer::RestoreDefaults() { // Reset Modifier Buttons lstick_mod = - Common::ParamPackage(InputCommon::GenerateKeyboardParam(Config::default_lstick_mod)); + Common::ParamPackage(InputCommon::GenerateKeyboardParam(Config::default_stick_mod[0])); rstick_mod = - Common::ParamPackage(InputCommon::GenerateKeyboardParam(Config::default_rstick_mod)); + Common::ParamPackage(InputCommon::GenerateKeyboardParam(Config::default_stick_mod[1])); // Reset Analogs for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; ++analog_id) { -- cgit v1.2.3