Changed axis to button mapping routine. Now always take rotation angle into account

Related to issue #282
This commit is contained in:
Travis Nickles 2018-05-12 21:46:48 -05:00
parent a6b9fb0f4e
commit 07878dafc3

View File

@ -3123,115 +3123,51 @@ namespace DS4Windows
switch (control) switch (control)
{ {
case DS4Controls.LXNeg: case DS4Controls.LXNeg:
{
if (!analog)
{ {
double angle = cState.LSAngle; double angle = cState.LSAngle;
result = cState.LX < 127 && (angle >= 210 && angle <= 330); result = cState.LX < 127 && (angle >= 210 && angle <= 330);
}
else
{
result = cState.LX < 127;
}
break; break;
} }
case DS4Controls.LYNeg: case DS4Controls.LYNeg:
{
if (!analog)
{ {
double angle = cState.LSAngle; double angle = cState.LSAngle;
result = cState.LY < 127 && (angle >= 300 || angle <= 60); result = cState.LY < 127 && (angle >= 300 || angle <= 60);
}
else
{
result = cState.LY < 127;
}
break; break;
} }
case DS4Controls.RXNeg: case DS4Controls.RXNeg:
{
if (!analog)
{ {
double angle = cState.RSAngle; double angle = cState.RSAngle;
result = cState.RX < 127 && (angle >= 210 && angle <= 330); result = cState.RX < 127 && (angle >= 210 && angle <= 330);
}
else
{
result = cState.RX < 127;
}
break; break;
} }
case DS4Controls.RYNeg: case DS4Controls.RYNeg:
{
if (!analog)
{ {
double angle = cState.RSAngle; double angle = cState.RSAngle;
result = cState.RY < 127 && (angle >= 300 || angle <= 60); result = cState.RY < 127 && (angle >= 300 || angle <= 60);
}
else
{
result = cState.RY < 127;
}
break; break;
} }
case DS4Controls.LXPos: case DS4Controls.LXPos:
{
if (!analog)
{ {
double angle = cState.LSAngle; double angle = cState.LSAngle;
result = cState.LX > 127 && (angle >= 30 && angle <= 150); result = cState.LX > 127 && (angle >= 30 && angle <= 150);
}
else
{
result = cState.LX > 127;
}
break; break;
} }
case DS4Controls.LYPos: case DS4Controls.LYPos:
{
if (!analog)
{ {
double angle = cState.LSAngle; double angle = cState.LSAngle;
result = cState.LY > 127 && (angle >= 120 && angle <= 240); result = cState.LY > 127 && (angle >= 120 && angle <= 240);
}
else
{
result = cState.LY > 127;
}
break; break;
} }
case DS4Controls.RXPos: case DS4Controls.RXPos:
{
if (!analog)
{ {
double angle = cState.RSAngle; double angle = cState.RSAngle;
result = cState.RX > 127 && (angle >= 30 && angle <= 150); result = cState.RX > 127 && (angle >= 30 && angle <= 150);
}
else
{
result = cState.RX > 127;
}
break; break;
} }
case DS4Controls.RYPos: case DS4Controls.RYPos:
{
if (!analog)
{ {
double angle = cState.RSAngle; double angle = cState.RSAngle;
result = cState.RY > 127 && (angle >= 120 && angle <= 240); result = cState.RY > 127 && (angle >= 120 && angle <= 240);
}
else
{
result = cState.RY > 127;
}
break; break;
} }
default: break; default: break;