Dead zone of analogue control has been made programmable by KMetalMind.

The parameter is in %, and is defined by deadZone in controls.conf, with a default value of 3 (current RetroFE behavior).
This commit is contained in:
Pieter Hulshoff 2016-05-28 18:47:27 +02:00
parent bf24f6cba2
commit 1ab7d129d0
2 changed files with 14 additions and 5 deletions

View File

@ -14,6 +14,8 @@ select = Space
back = Escape back = Escape
quit = Q quit = Q
# Define controller analogue dead zone. Default (when not configured) is 3%.
# deadZone = 3
############################################################################## ##############################################################################
# MOUSE CODES # MOUSE CODES

View File

@ -193,18 +193,25 @@ bool UserInput::MapKey(std::string keyDescription, KeyCode_E key, bool required)
unsigned int axis; unsigned int axis;
Sint16 min; Sint16 min;
Sint16 max; Sint16 max;
int deadZone;
joydesc = Utils::replace(joydesc, "axis", ""); joydesc = Utils::replace(joydesc, "axis", "");
if(!config_.getProperty("controls.deadZone", deadZone))
{
deadZone = 3;
}
// string is now 0+ // string is now 0+
if(joydesc.find("-") != std::string::npos) if(joydesc.find("-") != std::string::npos)
{ {
min = -32768; min = -32768;
max = -1000; max = -32768 / 100 * deadZone;
joydesc = Utils::replace(joydesc, "-", ""); joydesc = Utils::replace(joydesc, "-", "");
} }
else if(joydesc.find("+") != std::string::npos) else if(joydesc.find("+") != std::string::npos)
{ {
min = 1000; min = 32767 / 100 * deadZone;
max = 32767; max = 32767;
joydesc = Utils::replace(joydesc, "+", ""); joydesc = Utils::replace(joydesc, "+", "");
} }
@ -213,7 +220,7 @@ bool UserInput::MapKey(std::string keyDescription, KeyCode_E key, bool required)
std::stringstream ss; std::stringstream ss;
ss << joydesc; ss << joydesc;
ss >> axis; ss >> axis;
Logger::write(Logger::ZONE_INFO, "Input", "Binding joypad axis " + ss.str() ); Logger::write(Logger::ZONE_INFO, "Input", "Binding joypad axis " + ss.str());
keyHandlers_[key] = new JoyAxisHandler(joynum, axis, min, max); keyHandlers_[key] = new JoyAxisHandler(joynum, axis, min, max);
return true; return true;
} }