Files
dolphin/Source/Core/InputCommon/ControllerEmu/ControlGroup/Buttons.h
Martino Fontana 95dec13203 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.
2026-04-17 12:39:46 +02:00

44 lines
1.1 KiB
C++

// Copyright 2017 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <cmath>
#include <string>
#include "InputCommon/ControllerEmu/Control/Control.h"
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
namespace ControllerEmu
{
class Buttons : public ControlGroup
{
public:
explicit Buttons(const std::string& name_);
Buttons(std::string ini_name, std::string group_name);
template <typename C>
void GetState(C* const buttons, const C* bitmasks) const
{
for (auto& control : controls)
*buttons |= *(bitmasks++) * control->GetState<bool>();
}
template <typename C>
void GetState(C* const buttons, const C* bitmasks,
const InputOverrideFunction& override_func) const
{
if (!override_func)
return GetState(buttons, bitmasks);
for (auto& control : controls)
{
ControlState state = control->GetState();
if (std::optional<ControlState> state_override = override_func(name, control->name, state))
state = *state_override;
*buttons |= *(bitmasks++) * (std::lround(state) > 0);
}
}
};
} // namespace ControllerEmu