2019-01-01 14:32:39 +00:00
|
|
|
// Copyright 2017 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2+
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include "InputCommon/ControllerEmu/ControlGroup/Attachments.h"
|
|
|
|
|
|
|
|
namespace ControllerEmu
|
|
|
|
{
|
|
|
|
Attachments::Attachments(const std::string& name_) : ControlGroup(name_, GroupType::Attachments)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void Attachments::AddAttachment(std::unique_ptr<EmulatedController> att)
|
|
|
|
{
|
|
|
|
m_attachments.emplace_back(std::move(att));
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 Attachments::GetSelectedAttachment() const
|
|
|
|
{
|
2021-05-04 21:01:20 +00:00
|
|
|
// This is originally an int, treat it as such
|
|
|
|
const int value = m_selection_value.GetValue();
|
2020-01-18 17:19:32 +00:00
|
|
|
|
2021-05-04 21:01:20 +00:00
|
|
|
if (value > 0 && static_cast<size_t>(value) < m_attachments.size())
|
|
|
|
return u32(value);
|
2020-01-18 17:19:32 +00:00
|
|
|
|
|
|
|
return 0;
|
2019-01-01 14:32:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Attachments::SetSelectedAttachment(u32 val)
|
|
|
|
{
|
2020-01-18 17:19:32 +00:00
|
|
|
m_selection_setting.SetValue(val);
|
|
|
|
}
|
|
|
|
|
|
|
|
NumericSetting<int>& Attachments::GetSelectionSetting()
|
|
|
|
{
|
|
|
|
return m_selection_setting;
|
2019-01-01 14:32:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const std::vector<std::unique_ptr<EmulatedController>>& Attachments::GetAttachmentList() const
|
|
|
|
{
|
|
|
|
return m_attachments;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace ControllerEmu
|