Pierre Bourdon e149ad4f0a
treewide: convert GPLv2+ license info to SPDX tags
SPDX standardizes how source code conveys its copyright and licensing
information. See https://spdx.github.io/spdx-spec/1-rationale/ . SPDX
tags are adopted in many large projects, including things like the Linux
kernel.
2021-07-05 04:35:56 +02:00

35 lines
981 B
C++

// Copyright 2017 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "InputCommon/ControllerEmu/ControlGroup/Triggers.h"
#include <algorithm>
#include <cstddef>
#include <memory>
#include <string>
#include "Common/Common.h"
#include "InputCommon/ControlReference/ControlReference.h"
#include "InputCommon/ControllerEmu/Control/Control.h"
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
namespace ControllerEmu
{
Triggers::Triggers(const std::string& name_) : ControlGroup(name_, GroupType::Triggers)
{
AddDeadzoneSetting(&m_deadzone_setting, 50);
}
Triggers::StateData Triggers::GetState() const
{
const size_t trigger_count = controls.size();
const ControlState deadzone = m_deadzone_setting.GetValue() / 100;
StateData result(trigger_count);
for (size_t i = 0; i < trigger_count; ++i)
result.data[i] = std::min(ApplyDeadzone(controls[i]->GetState(), deadzone), 1.0);
return result;
}
} // namespace ControllerEmu