From d66c98c13939444d328c6ec33914767e4e45c90f Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Sat, 2 Dec 2017 01:45:51 -0600 Subject: [PATCH] Remove new DS4State object creation per poll --- DS4Windows/DS4Control/ControlService.cs | 4 +++- DS4Windows/DS4Control/Mapping.cs | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/DS4Windows/DS4Control/ControlService.cs b/DS4Windows/DS4Control/ControlService.cs index c23c409..a303b17 100644 --- a/DS4Windows/DS4Control/ControlService.cs +++ b/DS4Windows/DS4Control/ControlService.cs @@ -21,6 +21,7 @@ namespace DS4Windows private DS4State[] MappedState = new DS4State[DS4_CONTROLLER_COUNT]; private DS4State[] CurrentState = new DS4State[DS4_CONTROLLER_COUNT]; private DS4State[] PreviousState = new DS4State[DS4_CONTROLLER_COUNT]; + private DS4State[] TempState = new DS4State[DS4_CONTROLLER_COUNT]; public DS4StateExposed[] ExposedState = new DS4StateExposed[DS4_CONTROLLER_COUNT]; public bool recordingMacro = false; public event EventHandler Debug = null; @@ -61,6 +62,7 @@ namespace DS4Windows processingData[i] = new X360Data(); MappedState[i] = new DS4State(); CurrentState[i] = new DS4State(); + TempState[i] = new DS4State(); PreviousState[i] = new DS4State(); ExposedState[i] = new DS4StateExposed(CurrentState[i]); } @@ -789,7 +791,7 @@ namespace DS4Windows if (getEnableTouchToggle(ind)) CheckForTouchToggle(ind, cState, pState); - cState = Mapping.SetCurveAndDeadzone(ind, cState); + cState = Mapping.SetCurveAndDeadzone(ind, cState, TempState[ind]); if (!recordingMacro && (!string.IsNullOrEmpty(tempprofilename[ind]) || containsCustomAction(ind) || containsCustomExtras(ind) || diff --git a/DS4Windows/DS4Control/Mapping.cs b/DS4Windows/DS4Control/Mapping.cs index faaa53d..492fe01 100644 --- a/DS4Windows/DS4Control/Mapping.cs +++ b/DS4Windows/DS4Control/Mapping.cs @@ -424,7 +424,7 @@ namespace DS4Windows return (value < min) ? min : (value > max) ? max : value; } - public static DS4State SetCurveAndDeadzone(int device, DS4State cState) + public static DS4State SetCurveAndDeadzone(int device, DS4State cState, DS4State dState) { double rotation = tempDoubleArray[device] = getLSRotation(device); if (rotation > 0.0 || rotation < 0.0) @@ -434,7 +434,8 @@ namespace DS4Windows if (rotationRS > 0.0 || rotationRS < 0.0) cState.rotateRSCoordinates(rotationRS); - DS4State dState = new DS4State(cState); + cState.CopyTo(dState); + //DS4State dState = new DS4State(cState); int x; int y; int curve;