WiimoteEmu: Major renaming and cleanup.

This commit is contained in:
Jordan Woyak
2019-01-01 08:32:39 -06:00
parent b1f350ab1c
commit 0d1fbe7bbc
64 changed files with 4140 additions and 3185 deletions

View File

@ -0,0 +1,33 @@
// 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
{
return m_selected_attachment;
}
void Attachments::SetSelectedAttachment(u32 val)
{
m_selected_attachment = val;
}
const std::vector<std::unique_ptr<EmulatedController>>& Attachments::GetAttachmentList() const
{
return m_attachments;
}
} // namespace ControllerEmu

View File

@ -0,0 +1,37 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <atomic>
#include <memory>
#include <string>
#include <vector>
#include "Common/CommonTypes.h"
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
#include "InputCommon/ControllerEmu/ControllerEmu.h"
namespace ControllerEmu
{
// A container of the selected and available attachments
// for configuration saving/loading purposes
class Attachments : public ControlGroup
{
public:
explicit Attachments(const std::string& name);
void AddAttachment(std::unique_ptr<EmulatedController> att);
u32 GetSelectedAttachment() const;
void SetSelectedAttachment(u32 val);
const std::vector<std::unique_ptr<EmulatedController>>& GetAttachmentList() const;
private:
std::vector<std::unique_ptr<EmulatedController>> m_attachments;
std::atomic<u32> m_selected_attachment;
};
} // namespace ControllerEmu

View File

@ -9,7 +9,7 @@
#include "InputCommon/ControlReference/ControlReference.h"
#include "InputCommon/ControllerEmu/Control/Control.h"
#include "InputCommon/ControllerEmu/ControlGroup/Extension.h"
#include "InputCommon/ControllerEmu/ControlGroup/Attachments.h"
#include "InputCommon/ControllerEmu/ControllerEmu.h"
#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h"
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
@ -67,22 +67,22 @@ void ControlGroup::LoadConfig(IniFile::Section* sec, const std::string& defdev,
}
// extensions
if (type == GroupType::Extension)
if (type == GroupType::Attachments)
{
Extension* const ext = (Extension*)this;
auto* const ext = static_cast<Attachments*>(this);
ext->switch_extension = 0;
ext->SetSelectedAttachment(0);
u32 n = 0;
std::string extname;
sec->Get(base + name, &extname, "");
for (auto& ai : ext->attachments)
for (auto& ai : ext->GetAttachmentList())
{
ai->SetDefaultDevice(defdev);
ai->LoadConfig(sec, base + ai->GetName() + "/");
if (ai->GetName() == extname)
ext->switch_extension = n;
ext->SetSelectedAttachment(n);
n++;
}
@ -120,12 +120,13 @@ void ControlGroup::SaveConfig(IniFile::Section* sec, const std::string& defdev,
}
// extensions
if (type == GroupType::Extension)
if (type == GroupType::Attachments)
{
Extension* const ext = (Extension*)this;
sec->Set(base + name, ext->attachments[ext->switch_extension]->GetName(), "None");
auto* const ext = static_cast<Attachments*>(this);
sec->Set(base + name, ext->GetAttachmentList()[ext->GetSelectedAttachment()]->GetName(),
"None");
for (auto& ai : ext->attachments)
for (auto& ai : ext->GetAttachmentList())
ai->SaveConfig(sec, base + ai->GetName() + "/");
}
}

View File

@ -24,7 +24,7 @@ enum class GroupType
MixedTriggers,
Buttons,
Force,
Extension,
Attachments,
Tilt,
Cursor,
Triggers,

View File

@ -1,16 +0,0 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "InputCommon/ControllerEmu/ControlGroup/Extension.h"
#include <string>
#include "InputCommon/ControllerEmu/ControllerEmu.h"
namespace ControllerEmu
{
Extension::Extension(const std::string& name_) : ControlGroup(name_, GroupType::Extension)
{
}
} // namespace ControllerEmu

View File

@ -1,31 +0,0 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <memory>
#include <string>
#include <vector>
#include "Common/CommonTypes.h"
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
namespace ControllerEmu
{
class EmulatedController;
class Extension : public ControlGroup
{
public:
explicit Extension(const std::string& name);
void GetState(u8* data);
bool IsButtonPressed() const;
std::vector<std::unique_ptr<EmulatedController>> attachments;
int switch_extension = 0;
int active_extension = 0;
};
} // namespace ControllerEmu

View File

@ -19,8 +19,5 @@ public:
explicit Force(const std::string& name);
StateData GetState();
private:
StateData m_swing{};
};
} // namespace ControllerEmu