2013-09-11 22:49:49 +02:00
|
|
|
#include "stdafx.h"
|
2014-06-02 19:27:24 +02:00
|
|
|
#include "rpcs3/Ini.h"
|
2013-09-11 22:49:49 +02:00
|
|
|
#include "Null/NullKeyboardHandler.h"
|
2014-08-24 19:42:19 +02:00
|
|
|
#include "Keyboard.h"
|
|
|
|
|
|
|
|
|
|
GetKeyboardHandlerCountCb GetKeyboardHandlerCount = []()
|
|
|
|
|
{
|
|
|
|
|
return 1;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
GetKeyboardHandlerCb GetKeyboardHandler = [](int i) -> KeyboardHandlerBase*
|
|
|
|
|
{
|
|
|
|
|
return new NullKeyboardHandler;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void SetGetKeyboardHandlerCountCallback(GetKeyboardHandlerCountCb cb)
|
|
|
|
|
{
|
|
|
|
|
GetKeyboardHandlerCount = cb;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetGetKeyboardHandlerCallback(GetKeyboardHandlerCb cb)
|
|
|
|
|
{
|
|
|
|
|
GetKeyboardHandler = cb;
|
|
|
|
|
}
|
2013-09-11 22:49:49 +02:00
|
|
|
|
|
|
|
|
KeyboardManager::KeyboardManager()
|
|
|
|
|
: m_keyboard_handler(nullptr)
|
|
|
|
|
, m_inited(false)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
KeyboardManager::~KeyboardManager()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KeyboardManager::Init(const u32 max_connect)
|
|
|
|
|
{
|
2014-04-01 02:02:27 +02:00
|
|
|
if(m_inited)
|
|
|
|
|
return;
|
2013-09-11 22:49:49 +02:00
|
|
|
|
2014-04-01 02:02:27 +02:00
|
|
|
// NOTE: Change these to std::make_unique assignments when C++14 comes out.
|
2014-08-24 19:42:19 +02:00
|
|
|
int numHandlers = GetKeyboardHandlerCount();
|
2014-05-02 08:30:32 +02:00
|
|
|
int selectedHandler = Ini.KeyboardHandlerMode.GetValue();
|
|
|
|
|
if (selectedHandler > numHandlers)
|
2013-09-11 22:49:49 +02:00
|
|
|
{
|
2014-05-02 08:30:32 +02:00
|
|
|
selectedHandler = 0;
|
2013-09-11 22:49:49 +02:00
|
|
|
}
|
2014-08-24 19:42:19 +02:00
|
|
|
m_keyboard_handler.reset(GetKeyboardHandler(selectedHandler));
|
2013-09-11 22:49:49 +02:00
|
|
|
|
|
|
|
|
m_keyboard_handler->Init(max_connect);
|
|
|
|
|
m_inited = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KeyboardManager::Close()
|
|
|
|
|
{
|
|
|
|
|
if(m_keyboard_handler) m_keyboard_handler->Close();
|
|
|
|
|
m_keyboard_handler = nullptr;
|
|
|
|
|
|
|
|
|
|
m_inited = false;
|
2014-07-10 23:13:45 +02:00
|
|
|
}
|