mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-23 04:27:18 +01:00

Because the last commit made us use separate folders for GCPad and GCKey profiles, we should also use separate game INI keys for them. Otherwise setting e.g. PadProfile1 in a game INI will make both GCPad and GCKey try to load it, typically with one of them succeeding and the other one showing a panic alert due to the profile not existing in its folder. Better do this breaking change for GCKeys in the same PR as the other breaking change rather than later.
65 lines
1.3 KiB
C++
65 lines
1.3 KiB
C++
// Copyright 2021 Dolphin Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#include "Core/HW/GBAPad.h"
|
|
|
|
#include "Core/HW/GBAPadEmu.h"
|
|
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
|
#include "InputCommon/GCPadStatus.h"
|
|
#include "InputCommon/InputConfig.h"
|
|
|
|
namespace Pad
|
|
{
|
|
static InputConfig s_config("GBA", _trans("Pad"), "GBA", "GBA");
|
|
InputConfig* GetGBAConfig()
|
|
{
|
|
return &s_config;
|
|
}
|
|
|
|
void ShutdownGBA()
|
|
{
|
|
s_config.UnregisterHotplugCallback();
|
|
|
|
s_config.ClearControllers();
|
|
}
|
|
|
|
void InitializeGBA()
|
|
{
|
|
if (s_config.ControllersNeedToBeCreated())
|
|
{
|
|
for (unsigned int i = 0; i < 4; ++i)
|
|
s_config.CreateController<GBAPad>(i);
|
|
}
|
|
|
|
s_config.RegisterHotplugCallback();
|
|
|
|
// Load the saved controller config
|
|
s_config.LoadConfig();
|
|
}
|
|
|
|
void LoadGBAConfig()
|
|
{
|
|
s_config.LoadConfig();
|
|
}
|
|
|
|
bool IsGBAInitialized()
|
|
{
|
|
return !s_config.ControllersNeedToBeCreated();
|
|
}
|
|
|
|
GCPadStatus GetGBAStatus(int pad_num)
|
|
{
|
|
return static_cast<GBAPad*>(s_config.GetController(pad_num))->GetInput();
|
|
}
|
|
|
|
void SetGBAReset(int pad_num, bool reset)
|
|
{
|
|
static_cast<GBAPad*>(s_config.GetController(pad_num))->SetReset(reset);
|
|
}
|
|
|
|
ControllerEmu::ControlGroup* GetGBAGroup(int pad_num, GBAPadGroup group)
|
|
{
|
|
return static_cast<GBAPad*>(s_config.GetController(pad_num))->GetGroup(group);
|
|
}
|
|
} // namespace Pad
|