diff --git a/DS4Windows/DS4Control/Mapping.cs b/DS4Windows/DS4Control/Mapping.cs index 4d8acb4..5851706 100644 --- a/DS4Windows/DS4Control/Mapping.cs +++ b/DS4Windows/DS4Control/Mapping.cs @@ -3811,7 +3811,7 @@ namespace DS4Windows controller.wheelCircleCenterPointLeft.X = controller.wheelCenterPoint.X; controller.wheelCircleCenterPointLeft.Y = controller.wheel90DegPointLeft.Y; - AppLogger.LogToGui($"Controller {ctrl.x360Bus.FirstController + device} steering wheel emulation calibration values. center=({controller.wheelCenterPoint.X}, {controller.wheelCenterPoint.Y}) 90L=({controller.wheel90DegPointLeft.X}, {controller.wheel90DegPointLeft.Y}) 90R=({controller.wheel90DegPointRight.X}, {controller.wheel90DegPointRight.Y})", false); + AppLogger.LogToGui($"Controller {ctrl.x360Bus.FirstController + device} steering wheel emulation calibration values. Center=({controller.wheelCenterPoint.X}, {controller.wheelCenterPoint.Y}) 90L=({controller.wheel90DegPointLeft.X}, {controller.wheel90DegPointLeft.Y}) 90R=({controller.wheel90DegPointRight.X}, {controller.wheel90DegPointRight.Y}) Range={Global.GetSASteeringWheelEmulationRange(device)}", false); controller.wheelPrevRecalibrateTime = DateTime.Now; } @@ -3824,41 +3824,53 @@ namespace DS4Windows // Apply deadzone (SA X-deadzone value). This code assumes that 20deg is the max deadzone anyone ever might wanna use (in practice effective deadzone // is probably just few degrees by using SXDeadZone values 0.01...0.05) double sxDead = getSXDeadzone(device); - if (sxDead > 0 && result != 0 && Math.Abs(result) < (20.0 * C_WHEEL_ANGLE_PRECISION * sxDead)) + if (sxDead > 0) { - result = 0; + int sxDeadInt = Convert.ToInt32(20.0 * C_WHEEL_ANGLE_PRECISION * sxDead); + if (Math.Abs(result) <= sxDeadInt) + { + result = 0; + } + else + { + // Smooth steering angle based on deadzone range instead of just clipping the deadzone gap + result -= (result < 0 ? -sxDeadInt : sxDeadInt); + } } - // If wrapped around from +180 to -180 side (or vice versa) then SA steering wheel keeps on turning beyond 360 degrees (if range is >360) + // If wrapped around from +180 to -180 side (or vice versa) then SA steering wheel keeps on turning beyond 360 degrees (if range is >360). + // Keep track of how many times the steering wheel has been turned beyond the full 360 circle and clip the result to max range. int wheelFullTurnCount = controller.wheelFullTurnCount; if (controller.wheelPrevPhysicalAngle < 0 && result > 0) { if ((result - controller.wheelPrevPhysicalAngle) > 180 * C_WHEEL_ANGLE_PRECISION) - if (maxRangeRight > 360 * C_WHEEL_ANGLE_PRECISION) + { + if (maxRangeRight > 360/2 * C_WHEEL_ANGLE_PRECISION) wheelFullTurnCount--; else result = maxRangeLeft; + } } else if (controller.wheelPrevPhysicalAngle > 0 && result < 0) { if ((controller.wheelPrevPhysicalAngle - result) > 180 * C_WHEEL_ANGLE_PRECISION) - if (maxRangeRight > 360 * C_WHEEL_ANGLE_PRECISION) + { + if (maxRangeRight > 360/2 * C_WHEEL_ANGLE_PRECISION) wheelFullTurnCount++; else result = maxRangeRight; + } } controller.wheelPrevPhysicalAngle = result; if (wheelFullTurnCount != 0) { - if (wheelFullTurnCount > 0) - result = (wheelFullTurnCount * 180 * C_WHEEL_ANGLE_PRECISION) + ((wheelFullTurnCount * 180 * C_WHEEL_ANGLE_PRECISION) + result); - else - result = (wheelFullTurnCount * 180 * C_WHEEL_ANGLE_PRECISION) - ((wheelFullTurnCount * -180 * C_WHEEL_ANGLE_PRECISION) - result); + // Adjust value of result (steering wheel angle) based on num of full 360 turn counts + result += (wheelFullTurnCount * 180 * C_WHEEL_ANGLE_PRECISION * 2); } // If the new angle is more than 180 degrees further away then this is probably bogus value (controller shaking too much and gyro and velocity sensors went crazy). - // Accept the new angle only when the new angle is within a "stability threshold", otherwise use the previous full angle value. + // Accept the new angle only when the new angle is within a "stability threshold", otherwise use the previous full angle value and wait for controller to be stabilized. if (Math.Abs(result - controller.wheelPrevFullAngle) <= 180 * C_WHEEL_ANGLE_PRECISION) { controller.wheelPrevFullAngle = result; @@ -3897,7 +3909,7 @@ namespace DS4Windows { return (((result - maxRangeLeft) * (32767 - (-32768))) / (maxRangeRight - maxRangeLeft)) + (-32768); } - + case SASteeringWheelEmulationAxisType.L2R2: // DS4 Trigger axis output. L2+R2 triggers share the same axis in x360 xInput/DInput controller, // so L2+R2 steering output supports only 360 turn range (-255..255 raw value range in the shared trigger axis) diff --git a/DS4Windows/Properties/Resources.Designer.cs b/DS4Windows/Properties/Resources.Designer.cs index d468473..60e5a65 100644 --- a/DS4Windows/Properties/Resources.Designer.cs +++ b/DS4Windows/Properties/Resources.Designer.cs @@ -1630,7 +1630,7 @@ namespace DS4Windows.Properties { /// /// Looks up a localized string similar to Calibration of sixaxis wheel emulation. /// - internal static string SASteeringWheelEmulationCalibrate { + public static string SASteeringWheelEmulationCalibrate { get { return ResourceManager.GetString("SASteeringWheelEmulationCalibrate", resourceCulture); } @@ -1639,7 +1639,7 @@ namespace DS4Windows.Properties { /// /// Looks up a localized string similar to All calibraton points are set when lightbar color turns to green. While turning the controller the lightbar color flashes when the controller is at calibration point. Accept calibration with OK button. /// - internal static string SASteeringWheelEmulationCalibrateInstruction { + public static string SASteeringWheelEmulationCalibrateInstruction { get { return ResourceManager.GetString("SASteeringWheelEmulationCalibrateInstruction", resourceCulture); } @@ -1648,7 +1648,7 @@ namespace DS4Windows.Properties { /// /// Looks up a localized string similar to (1) Center the controller, hold it steady and press "X". /// - internal static string SASteeringWheelEmulationCalibrateInstruction1 { + public static string SASteeringWheelEmulationCalibrateInstruction1 { get { return ResourceManager.GetString("SASteeringWheelEmulationCalibrateInstruction1", resourceCulture); } @@ -1657,7 +1657,7 @@ namespace DS4Windows.Properties { /// /// Looks up a localized string similar to (2) Turn to 90° left (or right) position and press "X". /// - internal static string SASteeringWheelEmulationCalibrateInstruction2 { + public static string SASteeringWheelEmulationCalibrateInstruction2 { get { return ResourceManager.GetString("SASteeringWheelEmulationCalibrateInstruction2", resourceCulture); } @@ -1666,7 +1666,7 @@ namespace DS4Windows.Properties { /// /// Looks up a localized string similar to (3) Turn to 90° right (or left) position and press "X". /// - internal static string SASteeringWheelEmulationCalibrateInstruction3 { + public static string SASteeringWheelEmulationCalibrateInstruction3 { get { return ResourceManager.GetString("SASteeringWheelEmulationCalibrateInstruction3", resourceCulture); } @@ -1675,7 +1675,7 @@ namespace DS4Windows.Properties { /// /// Looks up a localized string similar to Cannot calibrate gyro (sixaxis) steering wheel emulation values without a controller. Connect a controller via bluetooth or usb. /// - internal static string SASteeringWheelEmulationCalibrateNoControllerError { + public static string SASteeringWheelEmulationCalibrateNoControllerError { get { return ResourceManager.GetString("SASteeringWheelEmulationCalibrateNoControllerError", resourceCulture); } @@ -1684,7 +1684,7 @@ namespace DS4Windows.Properties { /// /// Looks up a localized string similar to Gyro steering wheel emulation axis option is set to NONE (emulation is not used). Please select an axis option before calibrating the sixaxis gyro steering wheel emulation. /// - internal static string SASteeringWheelEmulationCalibrateNoneAxisError { + public static string SASteeringWheelEmulationCalibrateNoneAxisError { get { return ResourceManager.GetString("SASteeringWheelEmulationCalibrateNoneAxisError", resourceCulture); } diff --git a/DS4Windows/Properties/Resources.fi.resx b/DS4Windows/Properties/Resources.fi.resx index e314f7d..0c79338 100644 --- a/DS4Windows/Properties/Resources.fi.resx +++ b/DS4Windows/Properties/Resources.fi.resx @@ -1,4 +1,4 @@ - +