Merge branch 'jay' of https://github.com/Ryochan7/DS4Windows into jay-bezierCurveOutput

This commit is contained in:
mika-n 2019-08-12 13:44:29 +03:00
commit 938c4f3f39
4 changed files with 76 additions and 24 deletions

View File

@ -1106,26 +1106,38 @@ namespace DS4Windows
double temp = dState.L2 / 255.0; double temp = dState.L2 / 255.0;
if (l2OutCurveMode == 1) if (l2OutCurveMode == 1)
{ {
double output = temp * temp; double output;
if (temp <= 0.4)
output = 0.55 * temp;
else if (temp <= 0.75)
output = temp - 0.18;
else // if (temp > 0.75)
output = (temp * 1.72) - 0.72;
dState.L2 = (byte)(output * 255.0); dState.L2 = (byte)(output * 255.0);
} }
else if (l2OutCurveMode == 2) else if (l2OutCurveMode == 2)
{ {
double output = temp * temp * temp; double output = temp * temp;
dState.L2 = (byte)(output * 255.0); dState.L2 = (byte)(output * 255.0);
} }
else if (l2OutCurveMode == 3) else if (l2OutCurveMode == 3)
{
double output = temp * temp * temp;
dState.L2 = (byte)(output * 255.0);
}
else if (l2OutCurveMode == 4)
{ {
double output = temp * (temp - 2.0); double output = temp * (temp - 2.0);
dState.L2 = (byte)(-1.0 * output * 255.0); dState.L2 = (byte)(-1.0 * output * 255.0);
} }
else if (l2OutCurveMode == 4) else if (l2OutCurveMode == 5)
{ {
double inner = Math.Abs(temp) - 1.0; double inner = Math.Abs(temp) - 1.0;
double output = inner * inner * inner + 1.0; double output = inner * inner * inner + 1.0;
dState.L2 = (byte)(-1.0 * output * 255.0); dState.L2 = (byte)(-1.0 * output * 255.0);
} }
else if (l2OutCurveMode == 5) else if (l2OutCurveMode == 6)
{ {
dState.L2 = l2OutBezierCurveObj[device].arrayBezierLUT[dState.L2]; dState.L2 = l2OutBezierCurveObj[device].arrayBezierLUT[dState.L2];
} }
@ -1137,26 +1149,38 @@ namespace DS4Windows
double temp = dState.R2 / 255.0; double temp = dState.R2 / 255.0;
if (r2OutCurveMode == 1) if (r2OutCurveMode == 1)
{ {
double output = temp * temp; double output;
if (temp <= 0.4)
output = 0.55 * temp;
else if (temp <= 0.75)
output = temp - 0.18;
else // if (temp > 0.75)
output = (temp * 1.72) - 0.72;
dState.R2 = (byte)(output * 255.0); dState.R2 = (byte)(output * 255.0);
} }
else if (r2OutCurveMode == 2) else if (r2OutCurveMode == 2)
{ {
double output = temp * temp * temp; double output = temp * temp;
dState.R2 = (byte)(output * 255.0); dState.R2 = (byte)(output * 255.0);
} }
else if (r2OutCurveMode == 3) else if (r2OutCurveMode == 3)
{
double output = temp * temp * temp;
dState.R2 = (byte)(output * 255.0);
}
else if (r2OutCurveMode == 4)
{ {
double output = temp * (temp - 2.0); double output = temp * (temp - 2.0);
dState.R2 = (byte)(-1.0 * output * 255.0); dState.R2 = (byte)(-1.0 * output * 255.0);
} }
else if (r2OutCurveMode == 4) else if (r2OutCurveMode == 5)
{ {
double inner = Math.Abs(temp) - 1.0; double inner = Math.Abs(temp) - 1.0;
double output = inner * inner * inner + 1.0; double output = inner * inner * inner + 1.0;
dState.R2 = (byte)(-1.0 * output * 255.0); dState.R2 = (byte)(-1.0 * output * 255.0);
} }
else if (r2OutCurveMode == 5) else if (r2OutCurveMode == 6)
{ {
dState.R2 = r2OutBezierCurveObj[device].arrayBezierLUT[dState.R2]; dState.R2 = r2OutBezierCurveObj[device].arrayBezierLUT[dState.R2];
} }
@ -1225,31 +1249,44 @@ namespace DS4Windows
double temp = dState.Motion.outputAccelX / 128.0; double temp = dState.Motion.outputAccelX / 128.0;
double sign = Math.Sign(temp); double sign = Math.Sign(temp);
if (sxOutCurveMode == 1) if (sxOutCurveMode == 1)
{
double output;
double abs = Math.Abs(temp);
if (abs <= 0.4)
output = 0.55 * abs;
else if (abs <= 0.75)
output = abs - 0.18;
else // if (abs > 0.75)
output = (abs * 1.72) - 0.72;
dState.Motion.outputAccelX = (byte)(output * sign * 128.0);
}
else if (sxOutCurveMode == 2)
{ {
double output = temp * temp; double output = temp * temp;
result = (int)(output * sign * 128.0); result = (int)(output * sign * 128.0);
dState.Motion.outputAccelX = result; dState.Motion.outputAccelX = result;
} }
else if (sxOutCurveMode == 2) else if (sxOutCurveMode == 3)
{ {
double output = temp * temp * temp; double output = temp * temp * temp;
result = (int)(output * 128.0); result = (int)(output * 128.0);
dState.Motion.outputAccelX = result; dState.Motion.outputAccelX = result;
} }
else if (sxOutCurveMode == 3) else if (sxOutCurveMode == 4)
{ {
double abs = Math.Abs(temp); double abs = Math.Abs(temp);
double output = abs * (abs - 2.0); double output = abs * (abs - 2.0);
dState.Motion.outputAccelX = (byte)(-1.0 * output * dState.Motion.outputAccelX = (byte)(-1.0 * output *
sign * 128.0); sign * 128.0);
} }
else if (sxOutCurveMode == 4) else if (sxOutCurveMode == 5)
{ {
double inner = Math.Abs(temp) - 1.0; double inner = Math.Abs(temp) - 1.0;
double output = inner * inner * inner + 1.0; double output = inner * inner * inner + 1.0;
dState.Motion.outputAccelX = (byte)(-1.0 * output * 255.0); dState.Motion.outputAccelX = (byte)(-1.0 * output * 255.0);
} }
else if (sxOutCurveMode == 5) else if (sxOutCurveMode == 6)
{ {
int signSA = Math.Sign(dState.Motion.outputAccelX); int signSA = Math.Sign(dState.Motion.outputAccelX);
dState.Motion.outputAccelX = sxOutBezierCurveObj[device].arrayBezierLUT[Math.Min(Math.Abs(dState.Motion.outputAccelX), 128)] * signSA; dState.Motion.outputAccelX = sxOutBezierCurveObj[device].arrayBezierLUT[Math.Min(Math.Abs(dState.Motion.outputAccelX), 128)] * signSA;
@ -1262,31 +1299,44 @@ namespace DS4Windows
double temp = dState.Motion.outputAccelZ / 128.0; double temp = dState.Motion.outputAccelZ / 128.0;
double sign = Math.Sign(temp); double sign = Math.Sign(temp);
if (szOutCurveMode == 1) if (szOutCurveMode == 1)
{
double output;
double abs = Math.Abs(temp);
if (abs <= 0.4)
output = 0.55 * abs;
else if (abs <= 0.75)
output = abs - 0.18;
else // if (abs > 0.75)
output = (abs * 1.72) - 0.72;
dState.Motion.outputAccelZ = (byte)(output * sign * 128.0);
}
else if (szOutCurveMode == 2)
{ {
double output = temp * temp; double output = temp * temp;
result = (int)(output * sign * 128.0); result = (int)(output * sign * 128.0);
dState.Motion.outputAccelZ = result; dState.Motion.outputAccelZ = result;
} }
else if (szOutCurveMode == 2) else if (szOutCurveMode == 3)
{ {
double output = temp * temp * temp; double output = temp * temp * temp;
result = (int)(output * 128.0); result = (int)(output * 128.0);
dState.Motion.outputAccelZ = result; dState.Motion.outputAccelZ = result;
} }
else if (szOutCurveMode == 3) else if (szOutCurveMode == 4)
{ {
double abs = Math.Abs(temp); double abs = Math.Abs(temp);
double output = abs * (abs - 2.0); double output = abs * (abs - 2.0);
dState.Motion.outputAccelZ = (byte)(-1.0 * output * dState.Motion.outputAccelZ = (byte)(-1.0 * output *
sign * 128.0); sign * 128.0);
} }
else if (szOutCurveMode == 4) else if (szOutCurveMode == 5)
{ {
double inner = Math.Abs(temp) - 1.0; double inner = Math.Abs(temp) - 1.0;
double output = inner * inner * inner + 1.0; double output = inner * inner * inner + 1.0;
dState.Motion.outputAccelZ = (byte)(-1.0 * output * 255.0); dState.Motion.outputAccelZ = (byte)(-1.0 * output * 255.0);
} }
else if (szOutCurveMode == 5) else if (szOutCurveMode == 6)
{ {
int signSA = Math.Sign(dState.Motion.outputAccelZ); int signSA = Math.Sign(dState.Motion.outputAccelZ);
dState.Motion.outputAccelZ = szOutBezierCurveObj[device].arrayBezierLUT[Math.Min(Math.Abs(dState.Motion.outputAccelZ), 128)] * signSA; dState.Motion.outputAccelZ = szOutBezierCurveObj[device].arrayBezierLUT[Math.Min(Math.Abs(dState.Motion.outputAccelZ), 128)] * signSA;

View File

@ -1717,11 +1717,13 @@ namespace DS4Windows
// Set bezier curve obj of axis. 0=Linear (no curve mapping), 1-5=Pre-defined curves, 6=User supplied custom curve string value of a profile (comma separated list of 4 decimal numbers) // Set bezier curve obj of axis. 0=Linear (no curve mapping), 1-5=Pre-defined curves, 6=User supplied custom curve string value of a profile (comma separated list of 4 decimal numbers)
switch (curveOptionValue) switch (curveOptionValue)
{ {
case 1: bezierCurveArray[device].InitBezierCurve(99.0, 91.0, 0.00, 0.00, axisType); break; // Enhanced Precision (hard-coded curve) (almost the same curve as bezier 0.70, 0.28, 1.00, 1.00) // Commented out case 1..5 because Mapping.cs:SetCurveAndDeadzone function has the original IF-THEN-ELSE code logic for those original 1..5 output curve mappings (ie. no need to initialize the lookup result table).
case 2: bezierCurveArray[device].InitBezierCurve(99.0, 92.0, 0.00, 0.00, axisType); break; // Quadric // Only the new bezier custom curve option 6 uses the lookup result table (initialized in BezierCurve class based on an input curve definition).
case 3: bezierCurveArray[device].InitBezierCurve(99.0, 93.0, 0.00, 0.00, axisType); break; // Cubic //case 1: bezierCurveArray[device].InitBezierCurve(99.0, 91.0, 0.00, 0.00, axisType); break; // Enhanced Precision (hard-coded curve) (almost the same curve as bezier 0.70, 0.28, 1.00, 1.00)
case 4: bezierCurveArray[device].InitBezierCurve(99.0, 94.0, 0.00, 0.00, axisType); break; // Easeout Quad //case 2: bezierCurveArray[device].InitBezierCurve(99.0, 92.0, 0.00, 0.00, axisType); break; // Quadric
case 5: bezierCurveArray[device].InitBezierCurve(99.0, 95.0, 0.00, 0.00, axisType); break; // Easeout Cubic //case 3: bezierCurveArray[device].InitBezierCurve(99.0, 93.0, 0.00, 0.00, axisType); break; // Cubic
//case 4: bezierCurveArray[device].InitBezierCurve(99.0, 94.0, 0.00, 0.00, axisType); break; // Easeout Quad
//case 5: bezierCurveArray[device].InitBezierCurve(99.0, 95.0, 0.00, 0.00, axisType); break; // Easeout Cubic
case 6: bezierCurveArray[device].InitBezierCurve(bezierCurveArray[device].CustomDefinition, axisType); break; // Custom output curve case 6: bezierCurveArray[device].InitBezierCurve(bezierCurveArray[device].CustomDefinition, axisType); break; // Custom output curve
} }
} }

View File

@ -33,7 +33,7 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.7.14")] [assembly: AssemblyVersion("1.7.15")]
[assembly: AssemblyFileVersion("1.7.14")] [assembly: AssemblyFileVersion("1.7.15")]
[assembly: NeutralResourcesLanguage("en")] [assembly: NeutralResourcesLanguage("en")]

View File

@ -1 +1 @@
1.7.14 1.7.15