2019-09-06 15:09:30 +00:00
|
|
|
// Copyright 2019 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2+
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include "InputCommon/ControllerEmu/ControlGroup/IMUGyroscope.h"
|
|
|
|
|
2019-11-22 20:19:45 +00:00
|
|
|
#include <memory>
|
2019-09-06 15:09:30 +00:00
|
|
|
|
2019-11-22 20:19:45 +00:00
|
|
|
#include "Common/Common.h"
|
2019-09-06 15:09:30 +00:00
|
|
|
|
|
|
|
#include "InputCommon/ControlReference/ControlReference.h"
|
|
|
|
#include "InputCommon/ControllerEmu/Control/Control.h"
|
|
|
|
#include "InputCommon/ControllerEmu/Control/Input.h"
|
|
|
|
|
|
|
|
namespace ControllerEmu
|
|
|
|
{
|
|
|
|
IMUGyroscope::IMUGyroscope(std::string name, std::string ui_name)
|
|
|
|
: ControlGroup(std::move(name), std::move(ui_name), GroupType::IMUGyroscope)
|
|
|
|
{
|
2019-10-27 16:04:08 +00:00
|
|
|
AddInput(Translate, _trans("Pitch Up"));
|
|
|
|
AddInput(Translate, _trans("Pitch Down"));
|
|
|
|
AddInput(Translate, _trans("Roll Left"));
|
|
|
|
AddInput(Translate, _trans("Roll Right"));
|
|
|
|
AddInput(Translate, _trans("Yaw Left"));
|
|
|
|
AddInput(Translate, _trans("Yaw Right"));
|
2019-09-06 15:09:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::optional<IMUGyroscope::StateData> IMUGyroscope::GetState() const
|
|
|
|
{
|
2020-01-18 19:56:11 +00:00
|
|
|
if (controls[0]->control_ref->BoundCount() == 0)
|
|
|
|
return std::nullopt;
|
|
|
|
|
2019-09-06 15:09:30 +00:00
|
|
|
StateData state;
|
2020-02-09 02:36:26 +00:00
|
|
|
state.x = (controls[1]->GetState() - controls[0]->GetState());
|
|
|
|
state.y = (controls[2]->GetState() - controls[3]->GetState());
|
|
|
|
state.z = (controls[4]->GetState() - controls[5]->GetState());
|
2020-01-18 19:56:11 +00:00
|
|
|
return state;
|
2019-09-06 15:09:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace ControllerEmu
|