ControllerEmu: Separate ControlGroup from ControllerEmu

ControllerEmu, the class, is essentially acting like a namespace for
ControlGroup. This makes it impossible to forward declare any of the
internals. It also globs a bunch of classes together which is kind of a
pain to manage.

This splits ControlGroup and the classes it contains into their own source
files and situates them all within a namespace, which gets them out of
global scope.

Since this allows forward declarations for the once-internal classes, it
now requires significantly less files to be rebuilt if anything is changed
in the ControllerEmu portion of code.

It does not split out the settings classes yet, however, as it
would be preferable to make a settings base class that all settings derive
from, but this would be a functional change -- this commit only intends to
move around existing code. Extracting the settings class will be done in
another commit.
This commit is contained in:
Lioncash
2017-02-08 22:15:43 -05:00
parent 1385a012d9
commit 6a75ea5653
69 changed files with 1807 additions and 971 deletions

View File

@ -3,7 +3,12 @@
// Refer to the license.txt file included.
#include "Core/HW/GCKeyboardEmu.h"
#include "Common/Common.h"
#include "Common/CommonTypes.h"
#include "InputCommon/ControllerEmu/Control/Input.h"
#include "InputCommon/ControllerEmu/ControlGroup/Buttons.h"
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
#include "InputCommon/ControllerEmu/ControllerEmu.h"
#include "InputCommon/KeyboardStatus.h"
@ -48,36 +53,38 @@ static const char* const named_keys5[] = {"LEFT", "DOWN", "UP", "RIGHT", "ENTER"
GCKeyboard::GCKeyboard(const unsigned int index) : m_index(index)
{
// buttons
groups.emplace_back(m_keys0x = new Buttons(_trans("Keys")));
groups.emplace_back(m_keys0x = new ControllerEmu::Buttons(_trans("Keys")));
for (const char* key : named_keys0)
m_keys0x->controls.emplace_back(new ControlGroup::Input(key));
m_keys0x->controls.emplace_back(new ControllerEmu::Input(key));
groups.emplace_back(m_keys1x = new Buttons(_trans("Keys")));
groups.emplace_back(m_keys1x = new ControllerEmu::Buttons(_trans("Keys")));
for (const char* key : named_keys1)
m_keys1x->controls.emplace_back(new ControlGroup::Input(key));
m_keys1x->controls.emplace_back(new ControllerEmu::Input(key));
groups.emplace_back(m_keys2x = new Buttons(_trans("Keys")));
groups.emplace_back(m_keys2x = new ControllerEmu::Buttons(_trans("Keys")));
for (const char* key : named_keys2)
m_keys2x->controls.emplace_back(new ControlGroup::Input(key));
m_keys2x->controls.emplace_back(new ControllerEmu::Input(key));
groups.emplace_back(m_keys3x = new Buttons(_trans("Keys")));
groups.emplace_back(m_keys3x = new ControllerEmu::Buttons(_trans("Keys")));
for (const char* key : named_keys3)
m_keys3x->controls.emplace_back(new ControlGroup::Input(key));
m_keys3x->controls.emplace_back(new ControllerEmu::Input(key));
groups.emplace_back(m_keys4x = new Buttons(_trans("Keys")));
groups.emplace_back(m_keys4x = new ControllerEmu::Buttons(_trans("Keys")));
for (const char* key : named_keys4)
m_keys4x->controls.emplace_back(new ControlGroup::Input(key));
m_keys4x->controls.emplace_back(new ControllerEmu::Input(key));
groups.emplace_back(m_keys5x = new Buttons(_trans("Keys")));
groups.emplace_back(m_keys5x = new ControllerEmu::Buttons(_trans("Keys")));
for (const char* key : named_keys5)
m_keys5x->controls.emplace_back(new ControlGroup::Input(key));
m_keys5x->controls.emplace_back(new ControllerEmu::Input(key));
// options
groups.emplace_back(m_options = new ControlGroup(_trans("Options")));
groups.emplace_back(m_options = new ControllerEmu::ControlGroup(_trans("Options")));
m_options->boolean_settings.emplace_back(
std::make_unique<ControlGroup::BackgroundInputSetting>(_trans("Background Input")));
m_options->boolean_settings.emplace_back(std::make_unique<ControlGroup::BooleanSetting>(
_trans("Iterative Input"), false, ControlGroup::SettingType::VIRTUAL));
std::make_unique<ControllerEmu::ControlGroup::BackgroundInputSetting>(
_trans("Background Input")));
m_options->boolean_settings.emplace_back(
std::make_unique<ControllerEmu::ControlGroup::BooleanSetting>(
_trans("Iterative Input"), false, ControllerEmu::ControlGroup::SettingType::VIRTUAL));
}
std::string GCKeyboard::GetName() const
@ -110,7 +117,7 @@ ControllerEmu::ControlGroup* GCKeyboard::GetGroup(KeyboardGroup group)
KeyboardStatus GCKeyboard::GetInput() const
{
auto lock = ControllerEmu::GetStateLock();
const auto lock = GetStateLock();
KeyboardStatus kb = {};
@ -126,7 +133,7 @@ KeyboardStatus GCKeyboard::GetInput() const
void GCKeyboard::LoadDefaults(const ControllerInterface& ciface)
{
ControllerEmu::LoadDefaults(ciface);
EmulatedController::LoadDefaults(ciface);
// Buttons
m_keys0x->SetControlExpression(5, "A");