mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-11-23 01:39:17 +01:00
Custom curve GUI tweaks.
This commit is contained in:
parent
acc1b3f952
commit
13150015f0
@ -49,7 +49,7 @@ namespace DS4Windows
|
|||||||
private static double SUBDIVISION_PRECISION = 0.0000001;
|
private static double SUBDIVISION_PRECISION = 0.0000001;
|
||||||
private static int SUBDIVISION_MAX_ITERATIONS = 10;
|
private static int SUBDIVISION_MAX_ITERATIONS = 10;
|
||||||
|
|
||||||
private double mX1 = 0, mY1 = 0, mX2 = 0, mY2 = 0; // Bezier curve definition (0, 0, 0, 0 = Linear)
|
private double mX1 = 0, mY1 = 0, mX2 = 0, mY2 = 0; // Bezier curve definition (0, 0, 0, 0 = Linear. 99, 99, 0, 0 = Pre-defined hard-coded EnhancedPrecision curve)
|
||||||
|
|
||||||
// Set or Get string representation of the bezier curve definition value (Note! Set doesn't initialize the lookup table. InitBezierCurve needs to be called to actually initalize the calculation)
|
// Set or Get string representation of the bezier curve definition value (Note! Set doesn't initialize the lookup table. InitBezierCurve needs to be called to actually initalize the calculation)
|
||||||
public string AsString
|
public string AsString
|
||||||
@ -64,8 +64,7 @@ namespace DS4Windows
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Custom definition set by DS4Windows options screens. This string is not validated (ie. the value is as user entered it and could be even ab invalid curve definition strimg value).
|
// Custom definition set by DS4Windows options screens. This string is not validated (ie. the value is as user entered it and could be an invalid curve definition). This value is saved in a profile XML file.
|
||||||
// AsString property returns the currently effective and validated value.
|
|
||||||
public string CustomDefinition { get; set; }
|
public string CustomDefinition { get; set; }
|
||||||
public string ToString() { return this.CustomDefinition; }
|
public string ToString() { return this.CustomDefinition; }
|
||||||
|
|
||||||
@ -79,40 +78,51 @@ namespace DS4Windows
|
|||||||
CustomDefinition = "";
|
CustomDefinition = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool InitBezierCurve(string bezierCurveDefinition, AxisType gamepadAxisType)
|
public bool InitBezierCurve(string bezierCurveDefinition, AxisType gamepadAxisType, bool setCustomDefinitionProperty = false)
|
||||||
{
|
{
|
||||||
|
if (setCustomDefinitionProperty)
|
||||||
|
this.CustomDefinition = bezierCurveDefinition;
|
||||||
|
|
||||||
this.AsString = bezierCurveDefinition;
|
this.AsString = bezierCurveDefinition;
|
||||||
return InitBezierCurve(mX1, mY1, mX2, mY2, gamepadAxisType);
|
return InitBezierCurve(mX1, mY1, mX2, mY2, gamepadAxisType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool InitBezierCurve(double x1, double y1, double x2, double y2, AxisType gamepadAxisType)
|
public bool InitBezierCurve(double x1, double y1, double x2, double y2, AxisType gamepadAxisType)
|
||||||
{
|
{
|
||||||
|
bool bRetValue = true;
|
||||||
|
|
||||||
if (arrayBezierLUT == null)
|
if (arrayBezierLUT == null)
|
||||||
arrayBezierLUT = new byte[256];
|
arrayBezierLUT = new byte[256];
|
||||||
|
|
||||||
if (x1 == 99.0)
|
if (x1 == 99.0)
|
||||||
{
|
{
|
||||||
// If x1 is 99 then curve is a pre-defined fixed curve and not a customizable bezier curve
|
// If curve is "99.0, 99.0, 0.0, 0.0" then curve is a pre-defined fixed EnchPrecision curve and not a customizable bezier curve
|
||||||
if (y1 == 99.0) return InitEnhancedPrecision(gamepadAxisType);
|
if (y1 == 99.0) return InitEnhancedPrecision(gamepadAxisType);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x1 < 0 || x1 > 1 || x2 < 0 || x2 > 1)
|
if (x1 < 0 || x1 > 1 || x2 < 0 || x2 > 1)
|
||||||
return false;
|
{
|
||||||
//throw new Exception("INVALID VALUE. BezierCurve X1 and X2 should be in [0, 1] range");
|
// throw new Exception("INVALID VALUE. BezierCurve X1 and X2 should be in [0, 1] range");
|
||||||
|
AppLogger.LogToGui($"WARNING. Invalid custom bezier curve \"{x1}, {y1}, {x2}, {y2}\" in {gamepadAxisType} axis. x1 and x2 should be in 0..1 range. Using linear curve.", true);
|
||||||
mX1 = x1;
|
mX1 = mY1 = mX2 = mY2 = 0;
|
||||||
mY1 = y1;
|
bRetValue = false;
|
||||||
mX2 = x2;
|
}
|
||||||
mY2 = y2;
|
else
|
||||||
|
{
|
||||||
|
mX1 = x1;
|
||||||
|
mY1 = y1;
|
||||||
|
mX2 = x2;
|
||||||
|
mY2 = y2;
|
||||||
|
}
|
||||||
axisType = gamepadAxisType;
|
axisType = gamepadAxisType;
|
||||||
|
|
||||||
// If this is linear definition then init the lookup table with 1-on-1 mapping
|
// If this is linear definition then init the lookup table with 1-on-1 mapping
|
||||||
if(x1 == 0 && y1 == 0 && x2 == 0 && y2 == 0)
|
if (x1 == 0 && y1 == 0 && ((x2 == 0 && y2 == 0) || (x2 == 1 && y2 == 1)))
|
||||||
{
|
{
|
||||||
for (int idx = 0; idx <= 255; idx++)
|
for (int idx = 0; idx <= 255; idx++)
|
||||||
arrayBezierLUT[idx] = (byte)idx;
|
arrayBezierLUT[idx] = (byte)idx;
|
||||||
|
|
||||||
return true;
|
return bRetValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -160,7 +170,7 @@ namespace DS4Windows
|
|||||||
arraySampleValues = null;
|
arraySampleValues = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return bRetValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize a special "hard-coded" and pre-defined EnhancedPrecision output curve as a lookup result table
|
// Initialize a special "hard-coded" and pre-defined EnhancedPrecision output curve as a lookup result table
|
||||||
|
@ -1717,7 +1717,7 @@ 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, 99.0, 0.00, 0.00, axisType); break; // Enhanced Precision (hard-coded curve 0.99, 0.99) (Bezier EnchCurve 0.70, 0.28, 1.00, 1.00)
|
case 1: bezierCurveArray[device].InitBezierCurve(99.0, 99.0, 0.00, 0.00, axisType); break; // Enhanced Precision (hard-coded curve) (The same curve as bezier 0.70, 0.28, 1.00, 1.00)
|
||||||
case 2: bezierCurveArray[device].InitBezierCurve(0.55, 0.09, 0.68, 0.53, axisType); break; // Quadric
|
case 2: bezierCurveArray[device].InitBezierCurve(0.55, 0.09, 0.68, 0.53, axisType); break; // Quadric
|
||||||
case 3: bezierCurveArray[device].InitBezierCurve(0.74, 0.12, 0.64, 0.29, axisType); break; // Cubic
|
case 3: bezierCurveArray[device].InitBezierCurve(0.74, 0.12, 0.64, 0.29, axisType); break; // Cubic
|
||||||
case 4: bezierCurveArray[device].InitBezierCurve(0.00, 0.00, 0.41, 0.96, axisType); break; // Easeout Quad
|
case 4: bezierCurveArray[device].InitBezierCurve(0.00, 0.00, 0.41, 0.96, axisType); break; // Easeout Quad
|
||||||
|
@ -3289,56 +3289,41 @@ namespace DS4Windows.Forms
|
|||||||
|
|
||||||
private void tBCustomOutputCurve_Leave(object sender, EventArgs e)
|
private void tBCustomOutputCurve_Leave(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
// Focus leaves the custom output curve editbox. Store the new custom curve value into LS/RS/L2/R2/SX/SZ bezierCurve object
|
if (loading == false)
|
||||||
switch (lbCurveEditorURL.Text.Substring(0, 2))
|
|
||||||
{
|
{
|
||||||
case "LS":
|
// Focus leaves the custom output curve editbox. Store the new custom curve value into LS/RS/L2/R2/SX/SZ bezierCurve object
|
||||||
if (lsOutCurveComboBox.SelectedIndex == lsOutCurveComboBox.Items.Count - 1)
|
switch (lbCurveEditorURL.Text.Substring(0, 2))
|
||||||
{
|
{
|
||||||
lsOutBezierCurveObj[device].CustomDefinition = tBCustomOutputCurve.Text;
|
case "LS":
|
||||||
lsOutBezierCurveObj[device].InitBezierCurve(tBCustomOutputCurve.Text, BezierCurve.AxisType.LSRS);
|
if (lsOutCurveComboBox.SelectedIndex == lsOutCurveComboBox.Items.Count - 1)
|
||||||
}
|
lsOutBezierCurveObj[device].InitBezierCurve(tBCustomOutputCurve.Text, BezierCurve.AxisType.LSRS, true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "RS":
|
case "RS":
|
||||||
if (rsOutCurveComboBox.SelectedIndex == rsOutCurveComboBox.Items.Count - 1)
|
if (rsOutCurveComboBox.SelectedIndex == rsOutCurveComboBox.Items.Count - 1)
|
||||||
{
|
rsOutBezierCurveObj[device].InitBezierCurve(tBCustomOutputCurve.Text, BezierCurve.AxisType.LSRS, true);
|
||||||
rsOutBezierCurveObj[device].CustomDefinition = tBCustomOutputCurve.Text;
|
break;
|
||||||
rsOutBezierCurveObj[device].InitBezierCurve(tBCustomOutputCurve.Text, BezierCurve.AxisType.LSRS);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "L2":
|
case "L2":
|
||||||
if (cBL2OutputCurve.SelectedIndex == cBL2OutputCurve.Items.Count - 1)
|
if (cBL2OutputCurve.SelectedIndex == cBL2OutputCurve.Items.Count - 1)
|
||||||
{
|
l2OutBezierCurveObj[device].InitBezierCurve(tBCustomOutputCurve.Text, BezierCurve.AxisType.L2R2, true);
|
||||||
l2OutBezierCurveObj[device].CustomDefinition = tBCustomOutputCurve.Text;
|
break;
|
||||||
l2OutBezierCurveObj[device].InitBezierCurve(tBCustomOutputCurve.Text, BezierCurve.AxisType.L2R2);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "R2":
|
case "R2":
|
||||||
if (cBR2OutputCurve.SelectedIndex == cBR2OutputCurve.Items.Count - 1)
|
if (cBR2OutputCurve.SelectedIndex == cBR2OutputCurve.Items.Count - 1)
|
||||||
{
|
r2OutBezierCurveObj[device].InitBezierCurve(tBCustomOutputCurve.Text, BezierCurve.AxisType.L2R2, true);
|
||||||
r2OutBezierCurveObj[device].CustomDefinition = tBCustomOutputCurve.Text;
|
break;
|
||||||
r2OutBezierCurveObj[device].InitBezierCurve(tBCustomOutputCurve.Text, BezierCurve.AxisType.L2R2);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "SX":
|
case "SX":
|
||||||
if (cBSixaxisXOutputCurve.SelectedIndex == cBSixaxisXOutputCurve.Items.Count - 1)
|
if (cBSixaxisXOutputCurve.SelectedIndex == cBSixaxisXOutputCurve.Items.Count - 1)
|
||||||
{
|
sxOutBezierCurveObj[device].InitBezierCurve(tBCustomOutputCurve.Text, BezierCurve.AxisType.SA, true);
|
||||||
sxOutBezierCurveObj[device].CustomDefinition = tBCustomOutputCurve.Text;
|
break;
|
||||||
sxOutBezierCurveObj[device].InitBezierCurve(tBCustomOutputCurve.Text, BezierCurve.AxisType.SA);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "SZ":
|
case "SZ":
|
||||||
if (cBSixaxisZOutputCurve.SelectedIndex == cBSixaxisZOutputCurve.Items.Count - 1)
|
if (cBSixaxisZOutputCurve.SelectedIndex == cBSixaxisZOutputCurve.Items.Count - 1)
|
||||||
{
|
szOutBezierCurveObj[device].InitBezierCurve(tBCustomOutputCurve.Text, BezierCurve.AxisType.SA, true);
|
||||||
szOutBezierCurveObj[device].CustomDefinition = tBCustomOutputCurve.Text;
|
break;
|
||||||
szOutBezierCurveObj[device].InitBezierCurve(tBCustomOutputCurve.Text, BezierCurve.AxisType.SA);
|
}
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user