mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 21:30:19 -06:00
WiimoteEmu: Major renaming and cleanup.
This commit is contained in:
@ -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
|
@ -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
|
@ -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() + "/");
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ enum class GroupType
|
||||
MixedTriggers,
|
||||
Buttons,
|
||||
Force,
|
||||
Extension,
|
||||
Attachments,
|
||||
Tilt,
|
||||
Cursor,
|
||||
Triggers,
|
||||
|
@ -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
|
@ -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
|
@ -19,8 +19,5 @@ public:
|
||||
explicit Force(const std::string& name);
|
||||
|
||||
StateData GetState();
|
||||
|
||||
private:
|
||||
StateData m_swing{};
|
||||
};
|
||||
} // namespace ControllerEmu
|
||||
|
Reference in New Issue
Block a user