Files
dolphin/Source/Core/Core/HW/GCKeyboard.cpp
Léo Lam 0d783f0869 ControllerInterface: Add a way to register callbacks
This adds RegisterHotplugCallback() to register a callback which will
be invoked by the input backends' hotplug threads when there is a new
device, so that Core (GCKeyboard, GCPad, Wiimote, Hotkey) can reload
the configuration without adding a dependency to Core from InputCommon.
2016-07-29 17:16:22 +02:00

59 lines
1.3 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();
g_controller_interface.Shutdown();
}
void Initialize(void* const hwnd)
{
if (s_config.ControllersNeedToBeCreated())
{
for (unsigned int i = 0; i < 4; ++i)
s_config.CreateController<GCKeyboard>(i);
}
g_controller_interface.Initialize(hwnd);
g_controller_interface.RegisterHotplugCallback(LoadConfig);
// Load the saved controller config
s_config.LoadConfig(true);
}
void LoadConfig()
{
s_config.LoadConfig(true);
}
void GetStatus(u8 port, KeyboardStatus* keyboard_status)
{
memset(keyboard_status, 0, sizeof(*keyboard_status));
keyboard_status->err = PAD_ERR_NONE;
// Get input
static_cast<GCKeyboard*>(s_config.GetController(port))->GetInput(keyboard_status);
}
}