diff --git a/include/Engine/Input/InputProxy.h b/include/Engine/Input/InputProxy.h index c7817c22..c9ba5ada 100644 --- a/include/Engine/Input/InputProxy.h +++ b/include/Engine/Input/InputProxy.h @@ -1,6 +1,7 @@ #ifndef InputProxy_h__ #define InputProxy_h__ +#include #include "../Common.h" #include "../Core/ResourceManager.h" #include "../Core/ConfigFile.h" diff --git a/resources/DefaultInput.ini b/resources/DefaultInput.ini index 95ebbc22..5ed46241 100644 --- a/resources/DefaultInput.ini +++ b/resources/DefaultInput.ini @@ -6,10 +6,10 @@ InvertPitch=false MouseLeft=PrimaryFire MouseX=Yaw MouseY=Pitch -W=+Forward -S=-Forward -D=+Right -A=-Right +W=Forward,1 +S=Forward,-1 +D=Right,1 +A=Right,-1 R=Reload Space=Jump LeftControl=Crouch diff --git a/src/Engine/Input/InputProxy.cpp b/src/Engine/Input/InputProxy.cpp index ad589df3..7e977542 100644 --- a/src/Engine/Input/InputProxy.cpp +++ b/src/Engine/Input/InputProxy.cpp @@ -20,15 +20,16 @@ void InputProxy::LoadBindings(std::string file) for (auto& origin : config->GetAll("Bindings")) { Events::BindOrigin e; e.Origin = origin.first; - e.Command = origin.second; - e.Value = 1.f; - if (!e.Command.empty()) { - char prefix = e.Command.at(0); - if (prefix == '+' || prefix == '-') { - e.Command = e.Command.substr(1); - if (prefix == '-') { - e.Value *= -1.f; - } + const std::string& command = origin.second; + if (!command.empty()) { + boost::char_separator separator(", "); + boost::tokenizer tokenizer(command, separator); + auto token = tokenizer.begin(); + e.Command = *token; + if (++token != tokenizer.end()) { + e.Value = boost::lexical_cast(*token); + } else { + e.Value = 1.f; } OnBindOrigin(e); } @@ -62,7 +63,7 @@ void InputProxy::Process() e.Command = command; e.Value = currentValue; m_EventBroker->Publish(e); - //LOG_DEBUG("Input: Published command %s=%f for player %i", e.Command.c_str(), e.Value, e.PlayerID); + LOG_DEBUG("Input: Published command %s=%f for player %i", e.Command.c_str(), e.Value, e.PlayerID); m_LastCommandValues[command] = currentValue; } } @@ -78,7 +79,7 @@ void InputProxy::Process() } //e.Value = std::max(-1.f, std::min(e.Value, 1.f)); m_EventBroker->Publish(e); - //LOG_DEBUG("Input: Published command %s=%f for player %i", e.Command.c_str(), e.Value, e.PlayerID); + LOG_DEBUG("Input: Published command %s=%f for player %i", e.Command.c_str(), e.Value, e.PlayerID); } m_CommandQueue.clear(); }