summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar liamwhite2022-12-06 11:26:46 -0500
committerGravatar GitHub2022-12-06 11:26:46 -0500
commitbbdb6d391e76845a9f2db57d05b2d0a85eeeba4e (patch)
tree14708267c324948a8164a19df7d992c764aaac27 /src
parentMerge pull request #9386 from lioncash/init (diff)
parentemulated_controller: Remove unused parameter in GetMappedDevices() (diff)
downloadyuzu-bbdb6d391e76845a9f2db57d05b2d0a85eeeba4e.tar.gz
yuzu-bbdb6d391e76845a9f2db57d05b2d0a85eeeba4e.tar.xz
yuzu-bbdb6d391e76845a9f2db57d05b2d0a85eeeba4e.zip
Merge pull request #9389 from lioncash/emumove
emulated_console/emulated_controller: std::move ParamPackage instances where applicable
Diffstat (limited to 'src')
-rw-r--r--src/core/hid/emulated_console.cpp10
-rw-r--r--src/core/hid/emulated_controller.cpp15
-rw-r--r--src/core/hid/emulated_controller.h2
-rw-r--r--src/yuzu/configuration/configure_input_player.cpp3
4 files changed, 14 insertions, 16 deletions
diff --git a/src/core/hid/emulated_console.cpp b/src/core/hid/emulated_console.cpp
index b6c8cc58d..30c2e9d17 100644
--- a/src/core/hid/emulated_console.cpp
+++ b/src/core/hid/emulated_console.cpp
@@ -37,7 +37,7 @@ void EmulatedConsole::SetTouchParams() {
37 touchscreen_param.Set("axis_x", i * 2); 37 touchscreen_param.Set("axis_x", i * 2);
38 touchscreen_param.Set("axis_y", (i * 2) + 1); 38 touchscreen_param.Set("axis_y", (i * 2) + 1);
39 touchscreen_param.Set("button", i); 39 touchscreen_param.Set("button", i);
40 touch_params[index++] = touchscreen_param; 40 touch_params[index++] = std::move(touchscreen_param);
41 } 41 }
42 42
43 const auto button_index = 43 const auto button_index =
@@ -59,7 +59,7 @@ void EmulatedConsole::SetTouchParams() {
59 touch_button_params.Set("button", params.Serialize()); 59 touch_button_params.Set("button", params.Serialize());
60 touch_button_params.Set("x", x); 60 touch_button_params.Set("x", x);
61 touch_button_params.Set("y", y); 61 touch_button_params.Set("y", y);
62 touch_params[index] = touch_button_params; 62 touch_params[index] = std::move(touch_button_params);
63 index++; 63 index++;
64 } 64 }
65} 65}
@@ -131,7 +131,7 @@ Common::ParamPackage EmulatedConsole::GetMotionParam() const {
131} 131}
132 132
133void EmulatedConsole::SetMotionParam(Common::ParamPackage param) { 133void EmulatedConsole::SetMotionParam(Common::ParamPackage param) {
134 motion_params = param; 134 motion_params = std::move(param);
135 ReloadInput(); 135 ReloadInput();
136} 136}
137 137
@@ -199,7 +199,7 @@ void EmulatedConsole::SetTouch(const Common::Input::CallbackStatus& callback, st
199 199
200 if (is_new_input) { 200 if (is_new_input) {
201 touch_value.pressed.value = true; 201 touch_value.pressed.value = true;
202 touch_value.id = static_cast<u32>(index); 202 touch_value.id = static_cast<int>(index);
203 } 203 }
204 204
205 touch_value.x = touch_input.x; 205 touch_value.x = touch_input.x;
@@ -284,7 +284,7 @@ void EmulatedConsole::TriggerOnChange(ConsoleTriggerType type) {
284 284
285int EmulatedConsole::SetCallback(ConsoleUpdateCallback update_callback) { 285int EmulatedConsole::SetCallback(ConsoleUpdateCallback update_callback) {
286 std::scoped_lock lock{callback_mutex}; 286 std::scoped_lock lock{callback_mutex};
287 callback_list.insert_or_assign(last_callback_key, update_callback); 287 callback_list.insert_or_assign(last_callback_key, std::move(update_callback));
288 return last_callback_key++; 288 return last_callback_key++;
289} 289}
290 290
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp
index 74c877728..67969e938 100644
--- a/src/core/hid/emulated_controller.cpp
+++ b/src/core/hid/emulated_controller.cpp
@@ -424,15 +424,14 @@ void EmulatedController::RestoreConfig() {
424 ReloadFromSettings(); 424 ReloadFromSettings();
425} 425}
426 426
427std::vector<Common::ParamPackage> EmulatedController::GetMappedDevices( 427std::vector<Common::ParamPackage> EmulatedController::GetMappedDevices() const {
428 EmulatedDeviceIndex device_index) const {
429 std::vector<Common::ParamPackage> devices; 428 std::vector<Common::ParamPackage> devices;
430 for (const auto& param : button_params) { 429 for (const auto& param : button_params) {
431 if (!param.Has("engine")) { 430 if (!param.Has("engine")) {
432 continue; 431 continue;
433 } 432 }
434 const auto devices_it = std::find_if( 433 const auto devices_it = std::find_if(
435 devices.begin(), devices.end(), [param](const Common::ParamPackage param_) { 434 devices.begin(), devices.end(), [&param](const Common::ParamPackage& param_) {
436 return param.Get("engine", "") == param_.Get("engine", "") && 435 return param.Get("engine", "") == param_.Get("engine", "") &&
437 param.Get("guid", "") == param_.Get("guid", "") && 436 param.Get("guid", "") == param_.Get("guid", "") &&
438 param.Get("port", 0) == param_.Get("port", 0) && 437 param.Get("port", 0) == param_.Get("port", 0) &&
@@ -441,12 +440,12 @@ std::vector<Common::ParamPackage> EmulatedController::GetMappedDevices(
441 if (devices_it != devices.end()) { 440 if (devices_it != devices.end()) {
442 continue; 441 continue;
443 } 442 }
444 Common::ParamPackage device{}; 443
444 auto& device = devices.emplace_back();
445 device.Set("engine", param.Get("engine", "")); 445 device.Set("engine", param.Get("engine", ""));
446 device.Set("guid", param.Get("guid", "")); 446 device.Set("guid", param.Get("guid", ""));
447 device.Set("port", param.Get("port", 0)); 447 device.Set("port", param.Get("port", 0));
448 device.Set("pad", param.Get("pad", 0)); 448 device.Set("pad", param.Get("pad", 0));
449 devices.push_back(device);
450 } 449 }
451 450
452 for (const auto& param : stick_params) { 451 for (const auto& param : stick_params) {
@@ -457,7 +456,7 @@ std::vector<Common::ParamPackage> EmulatedController::GetMappedDevices(
457 continue; 456 continue;
458 } 457 }
459 const auto devices_it = std::find_if( 458 const auto devices_it = std::find_if(
460 devices.begin(), devices.end(), [param](const Common::ParamPackage param_) { 459 devices.begin(), devices.end(), [&param](const Common::ParamPackage& param_) {
461 return param.Get("engine", "") == param_.Get("engine", "") && 460 return param.Get("engine", "") == param_.Get("engine", "") &&
462 param.Get("guid", "") == param_.Get("guid", "") && 461 param.Get("guid", "") == param_.Get("guid", "") &&
463 param.Get("port", 0) == param_.Get("port", 0) && 462 param.Get("port", 0) == param_.Get("port", 0) &&
@@ -466,12 +465,12 @@ std::vector<Common::ParamPackage> EmulatedController::GetMappedDevices(
466 if (devices_it != devices.end()) { 465 if (devices_it != devices.end()) {
467 continue; 466 continue;
468 } 467 }
469 Common::ParamPackage device{}; 468
469 auto& device = devices.emplace_back();
470 device.Set("engine", param.Get("engine", "")); 470 device.Set("engine", param.Get("engine", ""));
471 device.Set("guid", param.Get("guid", "")); 471 device.Set("guid", param.Get("guid", ""));
472 device.Set("port", param.Get("port", 0)); 472 device.Set("port", param.Get("port", 0));
473 device.Set("pad", param.Get("pad", 0)); 473 device.Set("pad", param.Get("pad", 0));
474 devices.push_back(device);
475 } 474 }
476 return devices; 475 return devices;
477} 476}
diff --git a/src/core/hid/emulated_controller.h b/src/core/hid/emulated_controller.h
index 3f83108d3..fa7a34278 100644
--- a/src/core/hid/emulated_controller.h
+++ b/src/core/hid/emulated_controller.h
@@ -244,7 +244,7 @@ public:
244 void RestoreConfig(); 244 void RestoreConfig();
245 245
246 /// Returns a vector of mapped devices from the mapped button and stick parameters 246 /// Returns a vector of mapped devices from the mapped button and stick parameters
247 std::vector<Common::ParamPackage> GetMappedDevices(EmulatedDeviceIndex device_index) const; 247 std::vector<Common::ParamPackage> GetMappedDevices() const;
248 248
249 // Returns the current mapped button device 249 // Returns the current mapped button device
250 Common::ParamPackage GetButtonParam(std::size_t index) const; 250 Common::ParamPackage GetButtonParam(std::size_t index) const;
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp
index ed21f4b92..b1575b0d3 100644
--- a/src/yuzu/configuration/configure_input_player.cpp
+++ b/src/yuzu/configuration/configure_input_player.cpp
@@ -855,8 +855,7 @@ void ConfigureInputPlayer::UpdateInputDeviceCombobox() {
855 return; 855 return;
856 } 856 }
857 857
858 const auto devices = 858 const auto devices = emulated_controller->GetMappedDevices();
859 emulated_controller->GetMappedDevices(Core::HID::EmulatedDeviceIndex::AllDevices);
860 UpdateInputDevices(); 859 UpdateInputDevices();
861 860
862 if (devices.empty()) { 861 if (devices.empty()) {