diff --git a/DS4Windows/DS4Control/Mapping.cs b/DS4Windows/DS4Control/Mapping.cs index 033ed41..8d858cb 100644 --- a/DS4Windows/DS4Control/Mapping.cs +++ b/DS4Windows/DS4Control/Mapping.cs @@ -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.KeyCollection controlKeys = tempControlDict.Keys; //Dictionary>.KeyCollection controlKeys = tempControlDict.Keys; diff --git a/DS4Windows/DS4Library/DS4State.cs b/DS4Windows/DS4Library/DS4State.cs index 21e1e55..d7fb3de 100644 --- a/DS4Windows/DS4Library/DS4State.cs +++ b/DS4Windows/DS4Library/DS4State.cs @@ -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); } } }