mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-01-31 11:33:27 +00:00
Yellow squiggly lines begone! Done automatically on .cpp files through `run-clang-tidy`, with manual corrections to the mistakes. If an import is directly used, but is technically unnecessary since it's recursively imported by something else, it is *not* removed. The tool doesn't touch .h files, so I did some of them by hand while fixing errors due to old recursive imports. Not everything is removed, but the cleanup should be substantial enough. Because this done on Linux, code that isn't used on it is mostly untouched. (Hopefully no open PR is depending on these imports...)
44 lines
1.1 KiB
C++
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(const std::string& ini_name, const 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
|