Skip to content

Commit

Permalink
Wait for inputs until all PipeDevices have been flushed in blocking m…
Browse files Browse the repository at this point in the history
…ode.
  • Loading branch information
vladfi1 committed Sep 9, 2024
1 parent ff8b89b commit f10e2a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@

using namespace ciface::ExpressionParser;

extern bool g_needInputForFrame; // from EXI_DeviceSlippi.cpp

namespace
{
const ControlState INPUT_DETECT_THRESHOLD = 0.55;
Expand Down Expand Up @@ -217,6 +219,8 @@ void ControllerInterface::UpdateInput()
std::lock_guard<std::mutex> lk(m_devices_mutex, std::adopt_lock);
for (const auto& d : m_devices)
d->UpdateInput();

g_needInputForFrame = false;
}
}

Expand Down
8 changes: 5 additions & 3 deletions Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,9 @@ s32 PipeDevice::readFromPipe(PIPE_FD file_descriptor, char *in_buffer, size_t si
void PipeDevice::UpdateInput()
{
bool finished = false;
bool wait_for_inputs = SConfig::GetInstance().m_blockingPipes && g_needInputForFrame;
#ifndef _WIN32
if(SConfig::GetInstance().m_blockingPipes && g_needInputForFrame)
if(wait_for_inputs)
{
fd_set set;
FD_ZERO (&set);
Expand Down Expand Up @@ -199,7 +200,7 @@ void PipeDevice::UpdateInput()
m_buf.erase(0, newline + 1);
newline = m_buf.find("\n");
}
} while(!finished && g_needInputForFrame && SConfig::GetInstance().m_blockingPipes);
} while(!finished && wait_for_inputs);
}

void PipeDevice::AddAxis(const std::string& name, double value)
Expand Down Expand Up @@ -264,7 +265,8 @@ bool PipeDevice::ParseCommand(const std::string& command)
{
if(command == "FLUSH")
{
g_needInputForFrame = false;
// Let ControllerInterface::UpdateInputs clear the g_needInputForFrame
// flag after all PipeDevices have been queried.
return true;
}
std::vector<std::string> tokens;
Expand Down

0 comments on commit f10e2a0

Please sign in to comment.