mirror of
https://github.com/cathery/sys-con.git
synced 2024-11-05 08:26:32 +00:00
6898d056d4
It makes more sense that all threads check if they can still run after they've completed their cycle, not before it
61 lines
1.7 KiB
C++
61 lines
1.7 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, 0x3B).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, 0x3B).GetValue());
|
|
m_outputThreadIsRunning = true;
|
|
return m_outputThread.Start().GetValue();
|
|
}
|
|
|
|
void SwitchVirtualGamepadHandler::ExitOutputThread()
|
|
{
|
|
m_outputThreadIsRunning = false;
|
|
m_outputThread.CancelSynchronization();
|
|
m_outputThread.Join();
|
|
} |