mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-27 16:25:36 +01:00
860e6cf5cb
In DITSpecification.cpp, MaterialAsset.cpp, and ShaderAsset.cpp, lambda predicates were replaced by pointers to member functions because ranges algorithms are able invoke those. In NetPlayClient.cpp, the non-trivial `NetPlay::Player` elements were being passed by value in `NetPlayClient::DoAllPlayersHaveGame()`. This has been fixed. In WIABlob.cpp, the second example's predicate was returning the `std::optional` by value instead of implicitly converting it to a bool. This has been fixed.
45 lines
1.4 KiB
C++
45 lines
1.4 KiB
C++
// Copyright 2019 Dolphin Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#include "InputCommon/ControllerEmu/ControlGroup/IMUAccelerometer.h"
|
|
|
|
#include <algorithm>
|
|
#include <memory>
|
|
|
|
#include "Common/Common.h"
|
|
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
|
|
#include "InputCommon/ControllerEmu/Control/Control.h"
|
|
|
|
namespace ControllerEmu
|
|
{
|
|
IMUAccelerometer::IMUAccelerometer(std::string name_, std::string ui_name_)
|
|
: ControlGroup(std::move(name_), std::move(ui_name_), GroupType::IMUAccelerometer)
|
|
{
|
|
AddInput(Translatability::Translate, _trans("Up"));
|
|
AddInput(Translatability::Translate, _trans("Down"));
|
|
AddInput(Translatability::Translate, _trans("Left"));
|
|
AddInput(Translatability::Translate, _trans("Right"));
|
|
AddInput(Translatability::Translate, _trans("Forward"));
|
|
AddInput(Translatability::Translate, _trans("Backward"));
|
|
}
|
|
|
|
bool IMUAccelerometer::AreInputsBound() const
|
|
{
|
|
return std::ranges::all_of(
|
|
controls, [](const auto& control) { return control->control_ref->BoundCount() > 0; });
|
|
}
|
|
|
|
std::optional<IMUAccelerometer::StateData> IMUAccelerometer::GetState() const
|
|
{
|
|
if (!AreInputsBound())
|
|
return std::nullopt;
|
|
|
|
StateData state;
|
|
state.x = (controls[2]->GetState() - controls[3]->GetState());
|
|
state.y = (controls[5]->GetState() - controls[4]->GetState());
|
|
state.z = (controls[0]->GetState() - controls[1]->GetState());
|
|
return state;
|
|
}
|
|
|
|
} // namespace ControllerEmu
|