diff options
| author | 2022-02-01 14:48:33 -0500 | |
|---|---|---|
| committer | 2022-02-01 14:48:33 -0500 | |
| commit | cd9345e10cdb432033bbc06f37b71072f5bd94ab (patch) | |
| tree | 00bdc068b60a748ab23a84936d47e746bcee0c71 /src | |
| parent | Merge pull request #7828 from lioncash/dep (diff) | |
| parent | configure_input_player: Eliminate variable shadowing (diff) | |
| download | yuzu-cd9345e10cdb432033bbc06f37b71072f5bd94ab.tar.gz yuzu-cd9345e10cdb432033bbc06f37b71072f5bd94ab.tar.xz yuzu-cd9345e10cdb432033bbc06f37b71072f5bd94ab.zip | |
Merge pull request #7830 from lioncash/player-copy
configure_input_player: Avoid unnecessary ParamPackage copies
Diffstat (limited to '')
| -rw-r--r-- | src/yuzu/configuration/configure_input_player.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index 752504236..ba563b382 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp | |||
| @@ -326,7 +326,7 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i | |||
| 326 | connect(button, &QPushButton::clicked, [=, this] { | 326 | connect(button, &QPushButton::clicked, [=, this] { |
| 327 | HandleClick( | 327 | HandleClick( |
| 328 | button, button_id, | 328 | button, button_id, |
| 329 | [=, this](Common::ParamPackage params) { | 329 | [=, this](const Common::ParamPackage& params) { |
| 330 | emulated_controller->SetButtonParam(button_id, params); | 330 | emulated_controller->SetButtonParam(button_id, params); |
| 331 | }, | 331 | }, |
| 332 | InputCommon::Polling::InputType::Button); | 332 | InputCommon::Polling::InputType::Button); |
| @@ -392,7 +392,7 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i | |||
| 392 | connect(button, &QPushButton::clicked, [=, this] { | 392 | connect(button, &QPushButton::clicked, [=, this] { |
| 393 | HandleClick( | 393 | HandleClick( |
| 394 | button, motion_id, | 394 | button, motion_id, |
| 395 | [=, this](Common::ParamPackage params) { | 395 | [=, this](const Common::ParamPackage& params) { |
| 396 | emulated_controller->SetMotionParam(motion_id, params); | 396 | emulated_controller->SetMotionParam(motion_id, params); |
| 397 | }, | 397 | }, |
| 398 | InputCommon::Polling::InputType::Motion); | 398 | InputCommon::Polling::InputType::Motion); |
| @@ -497,10 +497,11 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i | |||
| 497 | param.Set("invert_y", invert_str); | 497 | param.Set("invert_y", invert_str); |
| 498 | emulated_controller->SetStickParam(analog_id, param); | 498 | emulated_controller->SetStickParam(analog_id, param); |
| 499 | } | 499 | } |
| 500 | for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; | 500 | for (int analog_sub_button_id = 0; |
| 501 | ++sub_button_id) { | 501 | analog_sub_button_id < ANALOG_SUB_BUTTONS_NUM; |
| 502 | analog_map_buttons[analog_id][sub_button_id]->setText( | 502 | ++analog_sub_button_id) { |
| 503 | AnalogToText(param, analog_sub_buttons[sub_button_id])); | 503 | analog_map_buttons[analog_id][analog_sub_button_id]->setText( |
| 504 | AnalogToText(param, analog_sub_buttons[analog_sub_button_id])); | ||
| 504 | } | 505 | } |
| 505 | }); | 506 | }); |
| 506 | context_menu.exec(analog_map_buttons[analog_id][sub_button_id]->mapToGlobal( | 507 | context_menu.exec(analog_map_buttons[analog_id][sub_button_id]->mapToGlobal( |
| @@ -783,7 +784,7 @@ void ConfigureInputPlayer::UpdateInputDeviceCombobox() { | |||
| 783 | if (devices.size() == 1) { | 784 | if (devices.size() == 1) { |
| 784 | const auto devices_it = std::find_if( | 785 | const auto devices_it = std::find_if( |
| 785 | input_devices.begin(), input_devices.end(), | 786 | input_devices.begin(), input_devices.end(), |
| 786 | [first_engine, first_guid, first_port, first_pad](const Common::ParamPackage param) { | 787 | [first_engine, first_guid, first_port, first_pad](const Common::ParamPackage& param) { |
| 787 | return param.Get("engine", "") == first_engine && | 788 | return param.Get("engine", "") == first_engine && |
| 788 | param.Get("guid", "") == first_guid && param.Get("port", 0) == first_port && | 789 | param.Get("guid", "") == first_guid && param.Get("port", 0) == first_port && |
| 789 | param.Get("pad", 0) == first_pad; | 790 | param.Get("pad", 0) == first_pad; |
| @@ -814,7 +815,7 @@ void ConfigureInputPlayer::UpdateInputDeviceCombobox() { | |||
| 814 | if (is_engine_equal && is_port_equal) { | 815 | if (is_engine_equal && is_port_equal) { |
| 815 | const auto devices_it = std::find_if( | 816 | const auto devices_it = std::find_if( |
| 816 | input_devices.begin(), input_devices.end(), | 817 | input_devices.begin(), input_devices.end(), |
| 817 | [first_engine, first_guid, second_guid, first_port](const Common::ParamPackage param) { | 818 | [first_engine, first_guid, second_guid, first_port](const Common::ParamPackage& param) { |
| 818 | const bool is_guid_valid = | 819 | const bool is_guid_valid = |
| 819 | (param.Get("guid", "") == first_guid && | 820 | (param.Get("guid", "") == first_guid && |
| 820 | param.Get("guid2", "") == second_guid) || | 821 | param.Get("guid2", "") == second_guid) || |
| @@ -1026,7 +1027,7 @@ int ConfigureInputPlayer::GetIndexFromControllerType(Core::HID::NpadStyleIndex t | |||
| 1026 | void ConfigureInputPlayer::UpdateInputDevices() { | 1027 | void ConfigureInputPlayer::UpdateInputDevices() { |
| 1027 | input_devices = input_subsystem->GetInputDevices(); | 1028 | input_devices = input_subsystem->GetInputDevices(); |
| 1028 | ui->comboDevices->clear(); | 1029 | ui->comboDevices->clear(); |
| 1029 | for (auto device : input_devices) { | 1030 | for (const auto& device : input_devices) { |
| 1030 | ui->comboDevices->addItem(QString::fromStdString(device.Get("display", "Unknown")), {}); | 1031 | ui->comboDevices->addItem(QString::fromStdString(device.Get("display", "Unknown")), {}); |
| 1031 | } | 1032 | } |
| 1032 | } | 1033 | } |
| @@ -1308,7 +1309,7 @@ void ConfigureInputPlayer::HandleClick( | |||
| 1308 | } | 1309 | } |
| 1309 | button->setFocus(); | 1310 | button->setFocus(); |
| 1310 | 1311 | ||
| 1311 | input_setter = new_input_setter; | 1312 | input_setter = std::move(new_input_setter); |
| 1312 | 1313 | ||
| 1313 | input_subsystem->BeginMapping(type); | 1314 | input_subsystem->BeginMapping(type); |
| 1314 | 1315 | ||
| @@ -1358,7 +1359,7 @@ bool ConfigureInputPlayer::IsInputAcceptable(const Common::ParamPackage& params) | |||
| 1358 | return params.Get("engine", "") == "keyboard" || params.Get("engine", "") == "mouse"; | 1359 | return params.Get("engine", "") == "keyboard" || params.Get("engine", "") == "mouse"; |
| 1359 | } | 1360 | } |
| 1360 | 1361 | ||
| 1361 | const auto current_input_device = input_devices[ui->comboDevices->currentIndex()]; | 1362 | const auto& current_input_device = input_devices[ui->comboDevices->currentIndex()]; |
| 1362 | return params.Get("engine", "") == current_input_device.Get("engine", "") && | 1363 | return params.Get("engine", "") == current_input_device.Get("engine", "") && |
| 1363 | (params.Get("guid", "") == current_input_device.Get("guid", "") || | 1364 | (params.Get("guid", "") == current_input_device.Get("guid", "") || |
| 1364 | params.Get("guid", "") == current_input_device.Get("guid2", "")) && | 1365 | params.Get("guid", "") == current_input_device.Get("guid2", "")) && |