2019-10-31 18:00:42 +00:00
|
|
|
#include "SwitchVirtualGamepadHandler.h"
|
|
|
|
|
|
|
|
SwitchVirtualGamepadHandler::SwitchVirtualGamepadHandler(std::unique_ptr<IController> &&controller)
|
|
|
|
: m_controllerHandler(std::move(controller))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SwitchVirtualGamepadHandler::~SwitchVirtualGamepadHandler()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Result SwitchVirtualGamepadHandler::Initialize()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwitchVirtualGamepadHandler::Exit()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-12-04 18:44:01 +00:00
|
|
|
void SwitchVirtualGamepadHandler::InputThreadLoop(void *handler)
|
2019-10-31 18:00:42 +00:00
|
|
|
{
|
2020-03-02 15:21:40 +00:00
|
|
|
do {
|
2020-02-20 00:27:19 +00:00
|
|
|
static_cast<SwitchVirtualGamepadHandler *>(handler)->UpdateInput();
|
2020-03-02 15:21:40 +00:00
|
|
|
} while (static_cast<SwitchVirtualGamepadHandler*>(handler)->m_inputThreadIsRunning);
|
2019-10-31 18:00:42 +00:00
|
|
|
}
|
|
|
|
|
2019-12-04 18:44:01 +00:00
|
|
|
void SwitchVirtualGamepadHandler::OutputThreadLoop(void *handler)
|
2019-10-31 18:00:42 +00:00
|
|
|
{
|
2020-03-02 15:21:40 +00:00
|
|
|
do {
|
2020-02-20 00:27:19 +00:00
|
|
|
static_cast<SwitchVirtualGamepadHandler *>(handler)->UpdateOutput();
|
2020-03-02 15:21:40 +00:00
|
|
|
} while (static_cast<SwitchVirtualGamepadHandler*>(handler)->m_outputThreadIsRunning);
|
2019-10-31 18:00:42 +00:00
|
|
|
}
|
|
|
|
|
2019-11-06 12:28:56 +00:00
|
|
|
Result SwitchVirtualGamepadHandler::InitInputThread()
|
2019-10-31 18:00:42 +00:00
|
|
|
{
|
2020-03-12 14:47:41 +00:00
|
|
|
R_TRY(m_inputThread.Initialize(&SwitchVirtualGamepadHandler::InputThreadLoop, this, 0x30).GetValue());
|
2020-02-20 00:27:19 +00:00
|
|
|
m_inputThreadIsRunning = true;
|
|
|
|
return m_inputThread.Start().GetValue();
|
2019-10-31 18:00:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SwitchVirtualGamepadHandler::ExitInputThread()
|
|
|
|
{
|
2020-02-20 00:27:19 +00:00
|
|
|
m_inputThreadIsRunning = false;
|
|
|
|
m_inputThread.Join();
|
2019-10-31 18:00:42 +00:00
|
|
|
}
|
|
|
|
|
2019-11-06 12:28:56 +00:00
|
|
|
Result SwitchVirtualGamepadHandler::InitOutputThread()
|
2019-10-31 18:00:42 +00:00
|
|
|
{
|
2020-03-12 14:47:41 +00:00
|
|
|
R_TRY(m_outputThread.Initialize(&SwitchVirtualGamepadHandler::OutputThreadLoop, this, 0x30).GetValue());
|
2020-02-20 00:27:19 +00:00
|
|
|
m_outputThreadIsRunning = true;
|
|
|
|
return m_outputThread.Start().GetValue();
|
2019-10-31 18:00:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SwitchVirtualGamepadHandler::ExitOutputThread()
|
|
|
|
{
|
2020-02-20 00:27:19 +00:00
|
|
|
m_outputThreadIsRunning = false;
|
|
|
|
m_outputThread.Join();
|
2019-10-31 18:00:42 +00:00
|
|
|
}
|