/// Filters input for things called Up and Down while considering the client's AllowUD_LR option.
/// This is a bit gross but it is unclear how to do it more nicely
/// </summary>
publicclassUD_LR_ControllerAdapter:IController
{
publicControllerDefinitionDefinition
{
get{returnSource.Definition;}
}
publicboolIsPressed(stringbutton)
{
boolPriorityUD_LR=!Global.Config.AllowUD_LR&&!Global.Config.ForbidUD_LR;// implied by neither of the others being set (left as non-enum for back-compatibility)
if(Global.Config.AllowUD_LR)
{
returnSource.IsPressed(button);
}
stringprefix;
//" C " is for N64 "P1 C Up" and the like, which should not be subject to mutexing
//regarding the unpressing and UDLR logic...... don't think about it. don't question it. don't look at it.
if(button.Contains("Down")&&!button.Contains(" C "))
{
if(!Source.IsPressed(button))
{
Unpresses.Remove(button);
}
prefix=button.GetPrecedingString("Down");
stringother=prefix+"Up";
if(Source.IsPressed(other))
{
if(Unpresses.Contains(button))
{
returnfalse;
}
if(Global.Config.ForbidUD_LR)
{
returnfalse;
}
Unpresses.Add(other);
}
else
{
Unpresses.Remove(button);
}
}
if(button.Contains("Up")&&!button.Contains(" C "))
{
if(!Source.IsPressed(button))
{
Unpresses.Remove(button);
}
prefix=button.GetPrecedingString("Up");
stringother=prefix+"Down";
if(Source.IsPressed(other))
{
if(Unpresses.Contains(button))
{
returnfalse;
}
if(Global.Config.ForbidUD_LR)
{
returnfalse;
}
Unpresses.Add(other);
}
else
{
Unpresses.Remove(button);
}
}
if(button.Contains("Right")&&!button.Contains(" C "))
{
if(!Source.IsPressed(button))
{
Unpresses.Remove(button);
}
prefix=button.GetPrecedingString("Right");
stringother=prefix+"Left";
if(Source.IsPressed(other))
{
if(Unpresses.Contains(button))
{
returnfalse;
}
if(Global.Config.ForbidUD_LR)
{
returnfalse;
}
Unpresses.Add(other);
}
else
{
Unpresses.Remove(button);
}
}
if(button.Contains("Left")&&!button.Contains(" C "))