summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.cpp
diff options
context:
space:
mode:
authorPierre Bourdon <delroth@gmail.com>2016-01-21 14:04:38 +0100
committerPierre Bourdon <delroth@gmail.com>2016-01-21 14:04:38 +0100
commit912555968dd92e340852b39791cae0c7fd0b4a08 (patch)
treed166ed5004f52f2e9aadc1877fb6ae37b3d4d378 /Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.cpp
parentfa785d70b1e5e802a37eea99cb26546851d1ca95 (diff)
parent64e2f93f385d5ab5e014a984ebbbd2995c5466cb (diff)
Merge pull request #3538 from mathieui/pipes_locale
[Pipe input] Make the commands locale-unaware
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.cpp')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.cpp b/Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.cpp
index e98e31ac9f..cff69fabfc 100644
--- a/Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/Pipes/Pipes.cpp
@@ -6,7 +6,9 @@
#include <cstdlib>
#include <fcntl.h>
#include <iostream>
+#include <locale>
#include <map>
+#include <sstream>
#include <string>
#include <unistd.h>
#include <vector>
@@ -50,6 +52,16 @@ static const std::array<std::string, 2> s_axis_tokens
"C"
}};
+static double StringToDouble(const std::string& text)
+{
+ std::istringstream is(text);
+ // ignore current locale
+ is.imbue(std::locale::classic());
+ double result;
+ is >> result;
+ return result;
+}
+
void Init(std::vector<Core::Device*>& devices)
{
// Search the Pipes directory for files that we can open in read-only,
@@ -161,13 +173,13 @@ void PipeDevice::ParseCommand(const std::string& command)
{
if (tokens.size() == 3)
{
- double value = strtod(tokens[2].c_str(), nullptr);
+ double value = StringToDouble(tokens[2]);
SetAxis(tokens[1], (value / 2.0) + 0.5);
}
else if (tokens.size() == 4)
{
- double x = strtod(tokens[2].c_str(), nullptr);
- double y = strtod(tokens[3].c_str(), nullptr);
+ double x = StringToDouble(tokens[2]);
+ double y = StringToDouble(tokens[3]);
SetAxis(tokens[1] + " X", x);
SetAxis(tokens[1] + " Y", y);
}