summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon
diff options
context:
space:
mode:
authorMartino Fontana <tinozzo123@gmail.com>2026-04-06 11:37:26 +0200
committerMartino Fontana <tinozzo123@gmail.com>2026-04-17 12:39:46 +0200
commit95dec132030e72b74da6bc46966e4fe5e4e239c0 (patch)
treef4340655ebc036425e69048651ee49dec16ddc12 /Source/Core/InputCommon
parent33f62b0f9f36a3dfccc3ecfc13358899d0cc8036 (diff)
Improve usage of std::move and const references parameters
Accomplished using `run-clang-tidy` with `performance-move-const-arg,performance-unnecessary-value-param,modernize-pass-by-value`. Changed arguments to const references, removed them where inappropriate (e.g. sink parameters). Same with std::move. Manually reviewed each change to make sure that it makes sense, and do something more appropriate if possible.
Diffstat (limited to 'Source/Core/InputCommon')
-rw-r--r--Source/Core/InputCommon/ControlReference/ExpressionParser.cpp2
-rw-r--r--Source/Core/InputCommon/ControllerEmu/ControlGroup/Buttons.cpp5
-rw-r--r--Source/Core/InputCommon/ControllerEmu/ControlGroup/Buttons.h2
-rw-r--r--Source/Core/InputCommon/ControllerEmu/ControlGroup/ModifySettingsButton.cpp3
-rw-r--r--Source/Core/InputCommon/ControllerEmu/ControlGroup/ModifySettingsButton.h2
-rw-r--r--Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp2
-rw-r--r--Source/Core/InputCommon/ControllerInterface/ControllerInterface.h2
-rw-r--r--Source/Core/InputCommon/ControllerInterface/CoreDevice.cpp4
-rw-r--r--Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPClient.cpp2
-rw-r--r--Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.cpp3
-rw-r--r--Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.h2
-rw-r--r--Source/Core/InputCommon/ControllerInterface/Wiimote/WiimoteController.cpp2
-rw-r--r--Source/Core/InputCommon/GCAdapter.cpp4
-rw-r--r--Source/Core/InputCommon/InputConfig.cpp10
-rw-r--r--Source/Core/InputCommon/InputConfig.h4
15 files changed, 28 insertions, 21 deletions
diff --git a/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp b/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp
index daa654e48c..ee2e78db49 100644
--- a/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp
+++ b/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp
@@ -956,7 +956,7 @@ private:
static bool IsRTLBinaryOp(TokenType type) { return type == TOK_ASSIGN; }
- static bool IsBinaryOpWithPrecedence(Token tok, int precedence)
+ static bool IsBinaryOpWithPrecedence(const Token& tok, int precedence)
{
if (!tok.IsBinaryOperator())
return false;
diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Buttons.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Buttons.cpp
index 612310a470..65926a2524 100644
--- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Buttons.cpp
+++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Buttons.cpp
@@ -4,6 +4,7 @@
#include "InputCommon/ControllerEmu/ControlGroup/Buttons.h"
#include <string>
+#include <utility>
namespace ControllerEmu
{
@@ -11,8 +12,8 @@ Buttons::Buttons(const std::string& name_) : Buttons(name_, name_)
{
}
-Buttons::Buttons(const std::string& ini_name, const std::string& group_name)
- : ControlGroup(ini_name, group_name, GroupType::Buttons)
+Buttons::Buttons(std::string ini_name, std::string group_name)
+ : ControlGroup(std::move(ini_name), std::move(group_name), GroupType::Buttons)
{
}
diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Buttons.h b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Buttons.h
index db61f1b8b2..68784310bb 100644
--- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Buttons.h
+++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Buttons.h
@@ -15,7 +15,7 @@ class Buttons : public ControlGroup
{
public:
explicit Buttons(const std::string& name_);
- Buttons(const std::string& ini_name, const std::string& group_name);
+ Buttons(std::string ini_name, std::string group_name);
template <typename C>
void GetState(C* const buttons, const C* bitmasks) const
diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/ModifySettingsButton.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/ModifySettingsButton.cpp
index 7a34d1c597..239289e748 100644
--- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/ModifySettingsButton.cpp
+++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/ModifySettingsButton.cpp
@@ -13,8 +13,7 @@
namespace ControllerEmu
{
-ModifySettingsButton::ModifySettingsButton(std::string button_name)
- : Buttons(std::move(button_name))
+ModifySettingsButton::ModifySettingsButton(const std::string& button_name) : Buttons(button_name)
{
}
diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/ModifySettingsButton.h b/Source/Core/InputCommon/ControllerEmu/ControlGroup/ModifySettingsButton.h
index af4a80e94f..6b117eda4d 100644
--- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/ModifySettingsButton.h
+++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/ModifySettingsButton.h
@@ -13,7 +13,7 @@ namespace ControllerEmu
class ModifySettingsButton : public Buttons
{
public:
- explicit ModifySettingsButton(std::string button_name);
+ explicit ModifySettingsButton(const std::string& button_name);
void AddInput(std::string button_name, bool toggle = false);
diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
index 7393de9950..9dd8cdb6a9 100644
--- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
@@ -166,7 +166,7 @@ void ControllerInterface::RefreshDevices(RefreshReason reason)
InvokeDevicesChangedCallbacks();
}
-void ControllerInterface::PlatformPopulateDevices(std::function<void()> callback)
+void ControllerInterface::PlatformPopulateDevices(const std::function<void()>& callback)
{
if (!m_is_init)
return;
diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h
index 05a3a99a05..8f7f4baf40 100644
--- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h
+++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h
@@ -97,7 +97,7 @@ public:
// This is mandatory to use on device populations functions that can be called concurrently by
// more than one thread, or that are called by a single other thread.
// Without this, our devices list might end up in a mixed state.
- void PlatformPopulateDevices(std::function<void()> callback);
+ void PlatformPopulateDevices(const std::function<void()>& callback);
bool IsInit() const { return m_is_init; }
void UpdateInput();
diff --git a/Source/Core/InputCommon/ControllerInterface/CoreDevice.cpp b/Source/Core/InputCommon/ControllerInterface/CoreDevice.cpp
index 7197aa1fed..a10edd13c9 100644
--- a/Source/Core/InputCommon/ControllerInterface/CoreDevice.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/CoreDevice.cpp
@@ -9,6 +9,7 @@
#include <sstream>
#include <string>
#include <tuple>
+#include <utility>
#include <fmt/format.h>
@@ -25,7 +26,8 @@ class CombinedInput final : public Device::Input
public:
using Inputs = std::pair<Device::Input*, Device::Input*>;
- CombinedInput(std::string name, const Inputs& inputs) : m_name(std::move(name)), m_inputs(inputs)
+ CombinedInput(std::string name, Inputs inputs)
+ : m_name(std::move(name)), m_inputs(std::move(inputs))
{
}
ControlState GetState() const override
diff --git a/Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPClient.cpp b/Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPClient.cpp
index dad0844beb..b22ace19f2 100644
--- a/Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPClient.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPClient.cpp
@@ -179,7 +179,7 @@ struct Server
m_description = std::move(other.m_description);
m_address = std::move(other.m_address);
m_port = other.m_port;
- m_port_info = std::move(other.m_port_info);
+ m_port_info = other.m_port_info;
}
Server& operator=(const Server&) = delete;
diff --git a/Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.cpp b/Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.cpp
index 20baa74be9..ce0ddb3314 100644
--- a/Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.cpp
@@ -13,6 +13,7 @@
#include <sstream>
#include <string>
#include <unistd.h>
+#include <utility>
#include <vector>
#include "Common/FileUtil.h"
@@ -73,7 +74,7 @@ void InputBackend::PopulateDevices()
}
}
-PipeDevice::PipeDevice(int fd, const std::string& name) : m_fd(fd), m_name(name)
+PipeDevice::PipeDevice(int fd, std::string name) : m_fd(fd), m_name(std::move(name))
{
for (const auto& tok : s_button_tokens)
{
diff --git a/Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.h b/Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.h
index 857d5e8128..d9e2d7b4b7 100644
--- a/Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.h
+++ b/Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.h
@@ -26,7 +26,7 @@ std::unique_ptr<ciface::InputBackend> CreateInputBackend(ControllerInterface* co
class PipeDevice : public Core::Device
{
public:
- PipeDevice(int fd, const std::string& name);
+ PipeDevice(int fd, std::string name);
~PipeDevice();
Core::DeviceRemoval UpdateInput() override;
diff --git a/Source/Core/InputCommon/ControllerInterface/Wiimote/WiimoteController.cpp b/Source/Core/InputCommon/ControllerInterface/Wiimote/WiimoteController.cpp
index b062684100..e7724c1840 100644
--- a/Source/Core/InputCommon/ControllerInterface/Wiimote/WiimoteController.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/Wiimote/WiimoteController.cpp
@@ -505,7 +505,7 @@ void Device::RunTasks()
{
static constexpr u16 MPLUS_POLL_ADDR = WiimoteEmu::MotionPlus::PASSTHROUGH_MODE_OFFSET;
ReadData(AddressSpace::I2CBus, WiimoteEmu::MotionPlus::INACTIVE_DEVICE_ADDR, MPLUS_POLL_ADDR, 1,
- [this](ReadResponse response) {
+ [this](const ReadResponse& response) {
if (!response)
{
DEBUG_LOG_FMT(WIIMOTE, "WiiRemote: M+ poll failed.");
diff --git a/Source/Core/InputCommon/GCAdapter.cpp b/Source/Core/InputCommon/GCAdapter.cpp
index 986480227d..c8b686a8b3 100644
--- a/Source/Core/InputCommon/GCAdapter.cpp
+++ b/Source/Core/InputCommon/GCAdapter.cpp
@@ -15,6 +15,8 @@
#include <chrono>
#include <mutex>
#include <optional>
+#include <utility>
+
using namespace std::chrono_literals;
#if GCADAPTER_USE_LIBUSB_IMPLEMENTATION
@@ -477,7 +479,7 @@ static void ScanThreadFunc()
void SetAdapterCallback(std::function<void(void)> func)
{
#if GCADAPTER_USE_LIBUSB_IMPLEMENTATION
- s_detect_callback = func;
+ s_detect_callback = std::move(func);
#endif
}
diff --git a/Source/Core/InputCommon/InputConfig.cpp b/Source/Core/InputCommon/InputConfig.cpp
index 5e8e4ac880..34de19b883 100644
--- a/Source/Core/InputCommon/InputConfig.cpp
+++ b/Source/Core/InputCommon/InputConfig.cpp
@@ -3,6 +3,7 @@
#include "InputCommon/InputConfig.h"
+#include <utility>
#include <vector>
#include "Common/FileUtil.h"
@@ -16,10 +17,11 @@
#include "InputCommon/ControllerInterface/ControllerInterface.h"
#include "InputCommon/InputProfile.h"
-InputConfig::InputConfig(const std::string& ini_name, const std::string& gui_name,
- const std::string& profile_directory_name, const std::string& profile_key)
- : m_ini_name(ini_name), m_gui_name(gui_name), m_profile_directory_name(profile_directory_name),
- m_profile_key(profile_key)
+InputConfig::InputConfig(std::string ini_name, std::string gui_name,
+ std::string profile_directory_name, std::string profile_key)
+ : m_ini_name(std::move(ini_name)), m_gui_name(std::move(gui_name)),
+ m_profile_directory_name(std::move(profile_directory_name)),
+ m_profile_key(std::move(profile_key))
{
}
diff --git a/Source/Core/InputCommon/InputConfig.h b/Source/Core/InputCommon/InputConfig.h
index 205f5d3623..33e98b7cbf 100644
--- a/Source/Core/InputCommon/InputConfig.h
+++ b/Source/Core/InputCommon/InputConfig.h
@@ -24,8 +24,8 @@ class EmulatedController;
class InputConfig
{
public:
- InputConfig(const std::string& ini_name, const std::string& gui_name,
- const std::string& profile_directory_name, const std::string& profile_key);
+ InputConfig(std::string ini_name, std::string gui_name, std::string profile_directory_name,
+ std::string profile_key);
~InputConfig();