summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.cpp
diff options
context:
space:
mode:
authorScott Mansell <phiren@gmail.com>2015-11-05 20:31:03 +1300
committerScott Mansell <phiren@gmail.com>2015-11-05 20:31:03 +1300
commit290466d57aed8e7d827cc8528a3a9a7e914d25c5 (patch)
treeec6ac97254c7def09f88c1c0aee3492a5ffb7daa /Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.cpp
parent4826376f8c6d8ba4c9a203151a1e5e5a8bde5e24 (diff)
parent4faf958fee7e913b04d15d620ffa7d932f7bf65f (diff)
Merge pull request #3231 from spxtr/Pipes
Fix some bugs in Pipe input parsing
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.cpp')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.cpp b/Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.cpp
index f2923a5395..e98e31ac9f 100644
--- a/Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.cpp
@@ -111,15 +111,13 @@ void PipeDevice::UpdateInput()
bytes_read = read(m_fd, buf, sizeof buf);
}
std::size_t newline = m_buf.find("\n");
- std::size_t erase_until = 0;
while (newline != std::string::npos)
{
std::string command = m_buf.substr(0, newline);
ParseCommand(command);
- erase_until = newline + 1;
- newline = m_buf.find("\n", erase_until);
+ m_buf.erase(0, newline + 1);
+ newline = m_buf.find("\n");
}
- m_buf.erase(0, erase_until);
}
void PipeDevice::AddAxis(const std::string& name, double value)
@@ -166,7 +164,7 @@ void PipeDevice::ParseCommand(const std::string& command)
double value = strtod(tokens[2].c_str(), nullptr);
SetAxis(tokens[1], (value / 2.0) + 0.5);
}
- else
+ else if (tokens.size() == 4)
{
double x = strtod(tokens[2].c_str(), nullptr);
double y = strtod(tokens[3].c_str(), nullptr);