1
0
mirror of https://github.com/cathery/sys-con.git synced 2024-11-16 23:11:25 +00:00
sys-con/source/ControllerSwitch/SwitchVirtualGamepadHandler.cpp
2020-03-13 13:38:32 +03:00

61 lines
1.6 KiB
C++

#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()
{
}
void SwitchVirtualGamepadHandler::InputThreadLoop(void *handler)
{
do {
static_cast<SwitchVirtualGamepadHandler *>(handler)->UpdateInput();
} while (static_cast<SwitchVirtualGamepadHandler*>(handler)->m_inputThreadIsRunning);
}
void SwitchVirtualGamepadHandler::OutputThreadLoop(void *handler)
{
do {
static_cast<SwitchVirtualGamepadHandler *>(handler)->UpdateOutput();
} while (static_cast<SwitchVirtualGamepadHandler*>(handler)->m_outputThreadIsRunning);
}
Result SwitchVirtualGamepadHandler::InitInputThread()
{
R_TRY(m_inputThread.Initialize(&SwitchVirtualGamepadHandler::InputThreadLoop, this, 0x3E).GetValue());
m_inputThreadIsRunning = true;
return m_inputThread.Start().GetValue();
}
void SwitchVirtualGamepadHandler::ExitInputThread()
{
m_inputThreadIsRunning = false;
m_inputThread.CancelSynchronization();
m_inputThread.Join();
}
Result SwitchVirtualGamepadHandler::InitOutputThread()
{
R_TRY(m_outputThread.Initialize(&SwitchVirtualGamepadHandler::OutputThreadLoop, this, 0x3E).GetValue());
m_outputThreadIsRunning = true;
return m_outputThread.Start().GetValue();
}
void SwitchVirtualGamepadHandler::ExitOutputThread()
{
m_outputThreadIsRunning = false;
m_inputThread.CancelSynchronization();
m_outputThread.Join();
}