Added clamping for rotation. Fixed bug with identical dict keys

This commit is contained in:
Travis Nickles 2017-07-20 04:25:15 -05:00
parent 1b0ddfd910
commit 3dcd4d94b9
2 changed files with 12 additions and 16 deletions

View File

@ -1440,28 +1440,28 @@ namespace DS4Windows
if (macroControl[24]) MappedState.RY = 0;
if (IfAxisIsNotModified(device, ShiftTrigger2(GetDS4STrigger(device, DS4Controls.LXNeg), device, cState, eState, tp, fieldMapping), DS4Controls.LXNeg))
tempControlDict.Add(DS4Controls.LXNeg, DS4Controls.LXNeg);
tempControlDict[DS4Controls.LXNeg] = DS4Controls.LXNeg;
if (IfAxisIsNotModified(device, ShiftTrigger2(GetDS4STrigger(device, DS4Controls.LXPos), device, cState, eState, tp, fieldMapping), DS4Controls.LXPos))
tempControlDict.Add(DS4Controls.LXPos, DS4Controls.LXPos);
tempControlDict[DS4Controls.LXPos] = DS4Controls.LXPos;
if (IfAxisIsNotModified(device, ShiftTrigger2(GetDS4STrigger(device, DS4Controls.LYNeg), device, cState, eState, tp, fieldMapping), DS4Controls.LYNeg))
tempControlDict.Add(DS4Controls.LYNeg, DS4Controls.LYNeg);
tempControlDict[DS4Controls.LYNeg] = DS4Controls.LYNeg;
if (IfAxisIsNotModified(device, ShiftTrigger2(GetDS4STrigger(device, DS4Controls.LYPos), device, cState, eState, tp, fieldMapping), DS4Controls.LYPos))
tempControlDict.Add(DS4Controls.LYPos, DS4Controls.LYPos);
tempControlDict[DS4Controls.LYPos] = DS4Controls.LYPos;
if (IfAxisIsNotModified(device, ShiftTrigger2(GetDS4STrigger(device, DS4Controls.RXNeg), device, cState, eState, tp, fieldMapping), DS4Controls.RXNeg))
tempControlDict.Add(DS4Controls.RXNeg, DS4Controls.RXNeg);
tempControlDict[DS4Controls.RXNeg] = DS4Controls.RXNeg;
if (IfAxisIsNotModified(device, ShiftTrigger2(GetDS4STrigger(device, DS4Controls.RXPos), device, cState, eState, tp, fieldMapping), DS4Controls.RXPos))
tempControlDict.Add(DS4Controls.RXPos, DS4Controls.RXPos);
tempControlDict[DS4Controls.RXPos] = DS4Controls.RXPos;
if (IfAxisIsNotModified(device, ShiftTrigger2(GetDS4STrigger(device, DS4Controls.RYNeg), device, cState, eState, tp, fieldMapping), DS4Controls.RYNeg))
tempControlDict.Add(DS4Controls.RYNeg, DS4Controls.RYNeg);
tempControlDict[DS4Controls.RYNeg] = DS4Controls.RYNeg;
if (IfAxisIsNotModified(device, ShiftTrigger2(GetDS4STrigger(device, DS4Controls.RYPos), device, cState, eState, tp, fieldMapping), DS4Controls.RYPos))
tempControlDict.Add(DS4Controls.RYPos, DS4Controls.RYPos);
tempControlDict[DS4Controls.RYPos] = DS4Controls.RYPos;
Dictionary<DS4Controls, DS4Controls>.KeyCollection controlKeys = tempControlDict.Keys;
//Dictionary<DS4Controls, List<DS4Controls>>.KeyCollection controlKeys = tempControlDict.Keys;

View File

@ -169,20 +169,16 @@ namespace DS4Windows
{
double sinAngle = Math.Sin(rotation), cosAngle = Math.Cos(rotation);
double tempLX = LX - 127.5, tempLY = LY - 127.5;
Byte tempx = (Byte)(tempLX * cosAngle - tempLY * sinAngle + 127.5);
Byte tempy = (Byte)(tempLX * sinAngle + tempLY * cosAngle + 127.5);
LX = tempx;
LY = tempy;
LX = (Byte)(Global.Clamp(-127.5, (tempLX * cosAngle - tempLY * sinAngle), 127.5) + 127.5);
LY = (Byte)(Global.Clamp(-127.5, (tempLX * sinAngle + tempLY * cosAngle), 127.5) + 127.5);
}
public void rotateRSCoordinates(double rotation)
{
double sinAngle = Math.Sin(rotation), cosAngle = Math.Cos(rotation);
double tempRX = RX - 127.5, tempRY = RY - 127.5;
Byte tempx = (Byte)(tempRX * cosAngle - tempRY * sinAngle + 127.5);
Byte tempy = (Byte)(tempRX * sinAngle + tempRY * cosAngle + 127.5);
RX = tempx;
RY = tempy;
RX = (Byte)(Global.Clamp(-127.5, (tempRX * cosAngle - tempRY * sinAngle), 127.5) + 127.5);
RY = (Byte)(Global.Clamp(-127.5, (tempRX * sinAngle + tempRY * cosAngle), 127.5) + 127.5);
}
}
}