mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-30 02:49:32 -06:00

Currently, `g_controller_interface` is initialized and shut down by each of `GCKeyboard`, `GCPad`, `Wiimote`, and `HotkeyManager`. This 1) is weird conceptually, because it necessitates passing a pointer to the native window to each of those classes, which don't need it, and 2) can cause issues when controller backends are initialized or shutdown multiple times in succession.
52 lines
1.0 KiB
C++
52 lines
1.0 KiB
C++
// Copyright 2015 Dolphin Emulator Project
|
|
// Licensed under GPLv2+
|
|
// Refer to the license.txt file included.
|
|
|
|
#include <cstring>
|
|
|
|
#include "Common/Common.h"
|
|
#include "Common/CommonTypes.h"
|
|
#include "Core/HW/GCKeyboard.h"
|
|
#include "Core/HW/GCKeyboardEmu.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);
|
|
}
|
|
|
|
KeyboardStatus GetStatus(int port)
|
|
{
|
|
return static_cast<GCKeyboard*>(s_config.GetController(port))->GetInput();
|
|
}
|
|
}
|