mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-12 23:48:58 +01:00
![Lioncash](/assets/img/avatar_default.png)
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.
61 lines
1.3 KiB
C++
61 lines
1.3 KiB
C++
// Copyright 2015 Dolphin Emulator Project
|
|
// Licensed under GPLv2+
|
|
// Refer to the license.txt file included.
|
|
|
|
#include "Core/HW/GCKeyboard.h"
|
|
|
|
#include <cstring>
|
|
|
|
#include "Common/Common.h"
|
|
#include "Common/CommonTypes.h"
|
|
|
|
#include "Core/HW/GCKeyboardEmu.h"
|
|
|
|
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
|
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
|
#include "InputCommon/InputConfig.h"
|
|
#include "InputCommon/KeyboardStatus.h"
|
|
|
|
namespace Keyboard
|
|
{
|
|
static InputConfig s_config("GCKeyNew", _trans("Keyboard"), "GCKey");
|
|
InputConfig* GetConfig()
|
|
{
|
|
return &s_config;
|
|
}
|
|
|
|
void Shutdown()
|
|
{
|
|
s_config.ClearControllers();
|
|
}
|
|
|
|
void Initialize()
|
|
{
|
|
if (s_config.ControllersNeedToBeCreated())
|
|
{
|
|
for (unsigned int i = 0; i < 4; ++i)
|
|
s_config.CreateController<GCKeyboard>(i);
|
|
}
|
|
|
|
g_controller_interface.RegisterHotplugCallback(LoadConfig);
|
|
|
|
// Load the saved controller config
|
|
s_config.LoadConfig(true);
|
|
}
|
|
|
|
void LoadConfig()
|
|
{
|
|
s_config.LoadConfig(true);
|
|
}
|
|
|
|
ControllerEmu::ControlGroup* GetGroup(int port, KeyboardGroup group)
|
|
{
|
|
return static_cast<GCKeyboard*>(s_config.GetController(port))->GetGroup(group);
|
|
}
|
|
|
|
KeyboardStatus GetStatus(int port)
|
|
{
|
|
return static_cast<GCKeyboard*>(s_config.GetController(port))->GetInput();
|
|
}
|
|
}
|