2012-11-15 00:39:56 +01:00
|
|
|
#include "stdafx.h"
|
2014-06-02 19:27:24 +02:00
|
|
|
#include "rpcs3/Ini.h"
|
2012-11-15 00:39:56 +01:00
|
|
|
#include "Null/NullPadHandler.h"
|
2014-08-24 19:42:19 +02:00
|
|
|
#include "Pad.h"
|
|
|
|
|
|
|
|
|
|
GetPadHandlerCountCb GetPadHandlerCount = []()
|
|
|
|
|
{
|
|
|
|
|
return 1;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
GetPadHandlerCb GetPadHandler = [](int i) -> PadHandlerBase*
|
|
|
|
|
{
|
|
|
|
|
return new NullPadHandler;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void SetGetPadHandlerCountCallback(GetPadHandlerCountCb cb)
|
|
|
|
|
{
|
|
|
|
|
GetPadHandlerCount = cb;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetGetPadHandlerCallback(GetPadHandlerCb cb)
|
|
|
|
|
{
|
|
|
|
|
GetPadHandler = cb;
|
|
|
|
|
}
|
2012-11-15 00:39:56 +01:00
|
|
|
|
|
|
|
|
PadManager::PadManager()
|
2013-08-26 16:18:59 +02:00
|
|
|
: m_pad_handler(nullptr)
|
2012-11-15 00:39:56 +01:00
|
|
|
, m_inited(false)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PadManager::~PadManager()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PadManager::Init(const u32 max_connect)
|
|
|
|
|
{
|
2014-04-01 02:02:27 +02:00
|
|
|
if(m_inited)
|
|
|
|
|
return;
|
2012-11-15 00:39:56 +01:00
|
|
|
|
2014-04-01 02:02:27 +02:00
|
|
|
// NOTE: Change these to std::make_unique assignments when C++14 is available.
|
2014-08-24 19:42:19 +02:00
|
|
|
int numHandlers = GetPadHandlerCount();
|
2014-05-02 08:30:32 +02:00
|
|
|
int selectedHandler = Ini.PadHandlerMode.GetValue();
|
|
|
|
|
if (selectedHandler > numHandlers)
|
2012-11-15 00:39:56 +01:00
|
|
|
{
|
2014-05-02 08:30:32 +02:00
|
|
|
selectedHandler = 0;
|
2012-11-15 00:39:56 +01:00
|
|
|
}
|
2014-08-24 19:42:19 +02:00
|
|
|
m_pad_handler.reset(GetPadHandler(selectedHandler));
|
2012-11-15 00:39:56 +01:00
|
|
|
|
|
|
|
|
m_pad_handler->Init(max_connect);
|
|
|
|
|
m_inited = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PadManager::Close()
|
|
|
|
|
{
|
|
|
|
|
if(m_pad_handler) m_pad_handler->Close();
|
2013-08-26 16:18:59 +02:00
|
|
|
m_pad_handler = nullptr;
|
2012-11-15 00:39:56 +01:00
|
|
|
|
|
|
|
|
m_inited = false;
|
|
|
|
|
}
|