mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-11-26 11:04:21 +01:00
Pre-defined output curves initialized using a pre-fixed formula. Now only the "Custom" output curve goes through bezier curve logic, but at runtime all output curve options are mapped using a lookup table (better performance and easier code maintenance).
This commit is contained in:
parent
af9557e53b
commit
f85e0d413a
@ -68,7 +68,9 @@ namespace DS4Windows
|
|||||||
public string CustomDefinition { get; set; }
|
public string CustomDefinition { get; set; }
|
||||||
public string ToString() { return this.CustomDefinition; }
|
public string ToString() { return this.CustomDefinition; }
|
||||||
|
|
||||||
public AxisType axisType;
|
public AxisType axisType; // Axis type of curve object (LS/RS/R2/L2/SA)
|
||||||
|
private double axisMaxDouble; // Max range of axis (range of positive values)
|
||||||
|
private double axisCenterPosDouble; // Center pos of axis (LS/RS has 128 as "stick center", other axies has 0 as zero center point)
|
||||||
|
|
||||||
// Lookup result table is always either in 0..128 or 0..255 range depending on the DS4 analog axis range. LUT table set as public to let DS4Win reading thread to access it directly (every CPU cycle matters)
|
// Lookup result table is always either in 0..128 or 0..255 range depending on the DS4 analog axis range. LUT table set as public to let DS4Win reading thread to access it directly (every CPU cycle matters)
|
||||||
public byte[] arrayBezierLUT = null;
|
public byte[] arrayBezierLUT = null;
|
||||||
@ -94,10 +96,42 @@ namespace DS4Windows
|
|||||||
if (arrayBezierLUT == null)
|
if (arrayBezierLUT == null)
|
||||||
arrayBezierLUT = new byte[256];
|
arrayBezierLUT = new byte[256];
|
||||||
|
|
||||||
|
// Axis type and max range per axis
|
||||||
|
axisType = gamepadAxisType;
|
||||||
|
switch (gamepadAxisType)
|
||||||
|
{
|
||||||
|
case AxisType.LSRS:
|
||||||
|
axisMaxDouble = 127; // DS4 LS/RS axis has a "center position" at 128. Left turn has 0..127 positions and right turn 128..255 positions
|
||||||
|
axisCenterPosDouble = 128;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AxisType.L2R2:
|
||||||
|
axisMaxDouble = 255; // L2R2 analog trigger range 0..255
|
||||||
|
axisCenterPosDouble = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
axisMaxDouble = 128; // SixAxis x/z/y range 0..128
|
||||||
|
axisCenterPosDouble = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If x1 = 99.0 then this is probably just a dummy bezier curve value
|
||||||
if (x1 == 99.0)
|
if (x1 == 99.0)
|
||||||
{
|
{
|
||||||
// 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
|
mX1 = 99.0;
|
||||||
if (y1 == 99.0) return InitEnhancedPrecision(gamepadAxisType);
|
mY1 = y1;
|
||||||
|
mX2 = x2;
|
||||||
|
mY2 = y2;
|
||||||
|
|
||||||
|
switch (y1)
|
||||||
|
{
|
||||||
|
case 91.0: return InitEnhancedPrecision_91();
|
||||||
|
case 92.0: return InitQuadric_92();
|
||||||
|
case 93.0: return InitCubic_93();
|
||||||
|
case 94.0: return InitEaseoutQuad_94();
|
||||||
|
case 95.0: return InitEaseoutCubic_95();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x1 < 0 || x1 > 1 || x2 < 0 || x2 > 1)
|
if (x1 < 0 || x1 > 1 || x2 < 0 || x2 > 1)
|
||||||
@ -114,7 +148,6 @@ namespace DS4Windows
|
|||||||
mX2 = x2;
|
mX2 = x2;
|
||||||
mY2 = y2;
|
mY2 = y2;
|
||||||
}
|
}
|
||||||
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) || (x2 == 1 && y2 == 1)))
|
if (x1 == 0 && y1 == 0 && ((x2 == 0 && y2 == 0) || (x2 == 1 && y2 == 1)))
|
||||||
@ -127,27 +160,6 @@ namespace DS4Windows
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
double axisMaxDouble;
|
|
||||||
double axisCenterPosDouble;
|
|
||||||
|
|
||||||
switch (gamepadAxisType)
|
|
||||||
{
|
|
||||||
case AxisType.LSRS:
|
|
||||||
axisMaxDouble = 127; // DS4 LS/RS axis has a "center position" at 128. Left turn has 0..127 positions and right turn 128..255 positions.
|
|
||||||
axisCenterPosDouble = 128;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case AxisType.L2R2:
|
|
||||||
axisMaxDouble = 255; // L2R2 analog trigger range 0..255
|
|
||||||
axisCenterPosDouble = 0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
axisMaxDouble = 128; // SixAxis x/z/y range 0..128
|
|
||||||
axisCenterPosDouble = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
arraySampleValues = new double[BezierCurve.kSplineTableSize];
|
arraySampleValues = new double[BezierCurve.kSplineTableSize];
|
||||||
for (int idx = 0; idx < BezierCurve.kSplineTableSize; idx++)
|
for (int idx = 0; idx < BezierCurve.kSplineTableSize; idx++)
|
||||||
arraySampleValues[idx] = CalcBezier(idx * BezierCurve.kSampleStepSize, mX1, mX2);
|
arraySampleValues[idx] = CalcBezier(idx * BezierCurve.kSampleStepSize, mX1, mX2);
|
||||||
@ -174,44 +186,12 @@ namespace DS4Windows
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
||||||
private bool InitEnhancedPrecision(AxisType gamepadAxisType)
|
private bool InitEnhancedPrecision_91()
|
||||||
{
|
{
|
||||||
mX1 = mY1 = 99; // x1=99, y1=99 is a dummy curve identifier of hard-coded EnhancedPrecision "curve"
|
|
||||||
mX2 = mY2 = 0;
|
|
||||||
axisType = gamepadAxisType;
|
|
||||||
|
|
||||||
double axisMaxDouble;
|
|
||||||
double axisCenterPosDouble;
|
|
||||||
|
|
||||||
switch (gamepadAxisType)
|
|
||||||
{
|
|
||||||
case AxisType.LSRS:
|
|
||||||
axisMaxDouble = 127; // DS4 LS/RS axis has a "center position" at 128. Left turn has 0..127 positions and right turn 128..255 positions.
|
|
||||||
axisCenterPosDouble = 128;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case AxisType.L2R2:
|
|
||||||
axisMaxDouble = 255; // L2R2 analog trigger range 0..255
|
|
||||||
axisCenterPosDouble = 0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
axisMaxDouble = 128; // SixAxis x/z/y range 0..128
|
|
||||||
axisCenterPosDouble = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
double abs, output;
|
double abs, output;
|
||||||
// double temp, cap, sign;
|
|
||||||
|
|
||||||
for (byte idx = 0; idx <= axisMaxDouble; idx++)
|
for (byte idx = 0; idx <= axisMaxDouble; idx++)
|
||||||
{
|
{
|
||||||
//cap = dState.RX >=128 ? 127.0 : 128.0;
|
|
||||||
//temp = (dState.RX - 128.0) / cap;
|
|
||||||
//sign = temp >= 0.0 ? 1.0 : -1.0;
|
|
||||||
//abs = Math.Abs(temp);
|
|
||||||
//output = 0.0;
|
|
||||||
|
|
||||||
abs = idx / axisMaxDouble;
|
abs = idx / axisMaxDouble;
|
||||||
if (abs <= 0.4)
|
if (abs <= 0.4)
|
||||||
output = 0.55 * abs;
|
output = 0.55 * abs;
|
||||||
@ -220,11 +200,84 @@ namespace DS4Windows
|
|||||||
else //if (abs > 0.75)
|
else //if (abs > 0.75)
|
||||||
output = (abs * 1.72) - 0.72;
|
output = (abs * 1.72) - 0.72;
|
||||||
|
|
||||||
// dState.RX = output * sign * cap + 128.0;
|
|
||||||
arrayBezierLUT[idx + (byte)axisCenterPosDouble] = (byte)(output * axisMaxDouble + axisCenterPosDouble);
|
arrayBezierLUT[idx + (byte)axisCenterPosDouble] = (byte)(output * axisMaxDouble + axisCenterPosDouble);
|
||||||
|
|
||||||
// Invert curve from a right side of the center position (128) to the left tilted stick axis (or from up tilt to down tilt)
|
// Invert curve from a right side of the center position (128) to the left tilted stick axis (or from up tilt to down tilt)
|
||||||
if (gamepadAxisType == AxisType.LSRS)
|
if (this.axisType == AxisType.LSRS)
|
||||||
|
arrayBezierLUT[127 - idx] = (byte)(255 - arrayBezierLUT[idx + (byte)axisCenterPosDouble]);
|
||||||
|
|
||||||
|
// If the axisMaxDouble is 255 then we need this to break the look (byte is unsigned 0..255, so the FOR loop never reaches 256 idx value. C# would throw an overflow exceptio)
|
||||||
|
if (idx == axisMaxDouble) break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool InitQuadric_92()
|
||||||
|
{
|
||||||
|
double temp;
|
||||||
|
for (byte idx = 0; idx <= axisMaxDouble; idx++)
|
||||||
|
{
|
||||||
|
temp = idx / axisMaxDouble;
|
||||||
|
arrayBezierLUT[idx + (byte)axisCenterPosDouble] = (byte)((temp * temp * axisMaxDouble) + axisCenterPosDouble);
|
||||||
|
|
||||||
|
// Invert curve from a right side of the center position (128) to the left tilted stick axis (or from up tilt to down tilt)
|
||||||
|
if (this.axisType == AxisType.LSRS)
|
||||||
|
arrayBezierLUT[127 - idx] = (byte)(255 - arrayBezierLUT[idx + (byte)axisCenterPosDouble]);
|
||||||
|
|
||||||
|
// If the axisMaxDouble is 255 then we need this to break the look (byte is unsigned 0..255, so the FOR loop never reaches 256 idx value. C# would throw an overflow exceptio)
|
||||||
|
if (idx == axisMaxDouble) break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool InitCubic_93()
|
||||||
|
{
|
||||||
|
double temp;
|
||||||
|
for (byte idx = 0; idx <= axisMaxDouble; idx++)
|
||||||
|
{
|
||||||
|
temp = idx / axisMaxDouble;
|
||||||
|
arrayBezierLUT[idx + (byte)axisCenterPosDouble] = (byte)((temp * temp * temp * axisMaxDouble) + axisCenterPosDouble);
|
||||||
|
|
||||||
|
// Invert curve from a right side of the center position (128) to the left tilted stick axis (or from up tilt to down tilt)
|
||||||
|
if (this.axisType == AxisType.LSRS)
|
||||||
|
arrayBezierLUT[127 - idx] = (byte)(255 - arrayBezierLUT[idx + (byte)axisCenterPosDouble]);
|
||||||
|
|
||||||
|
// If the axisMaxDouble is 255 then we need this to break the look (byte is unsigned 0..255, so the FOR loop never reaches 256 idx value. C# would throw an overflow exceptio)
|
||||||
|
if (idx == axisMaxDouble) break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool InitEaseoutQuad_94()
|
||||||
|
{
|
||||||
|
double abs, output;
|
||||||
|
for (byte idx = 0; idx <= axisMaxDouble; idx++)
|
||||||
|
{
|
||||||
|
abs = idx / axisMaxDouble;
|
||||||
|
output = abs * (abs - 2.0);
|
||||||
|
arrayBezierLUT[idx + (byte)axisCenterPosDouble] = (byte)((-1.0 * output * axisMaxDouble) + axisCenterPosDouble);
|
||||||
|
|
||||||
|
// Invert curve from a right side of the center position (128) to the left tilted stick axis (or from up tilt to down tilt)
|
||||||
|
if (this.axisType == AxisType.LSRS)
|
||||||
|
arrayBezierLUT[127 - idx] = (byte)(255 - arrayBezierLUT[idx + (byte)axisCenterPosDouble]);
|
||||||
|
|
||||||
|
// If the axisMaxDouble is 255 then we need this to break the look (byte is unsigned 0..255, so the FOR loop never reaches 256 idx value. C# would throw an overflow exceptio)
|
||||||
|
if (idx == axisMaxDouble) break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool InitEaseoutCubic_95()
|
||||||
|
{
|
||||||
|
double inner, output;
|
||||||
|
for (byte idx = 0; idx <= axisMaxDouble; idx++)
|
||||||
|
{
|
||||||
|
inner = (idx / axisMaxDouble) - 1.0;
|
||||||
|
output = (inner * inner * inner) + 1.0;
|
||||||
|
arrayBezierLUT[idx + (byte)axisCenterPosDouble] = (byte)((1.0 * output * axisMaxDouble) + axisCenterPosDouble);
|
||||||
|
|
||||||
|
// Invert curve from a right side of the center position (128) to the left tilted stick axis (or from up tilt to down tilt)
|
||||||
|
if (this.axisType == AxisType.LSRS)
|
||||||
arrayBezierLUT[127 - idx] = (byte)(255 - arrayBezierLUT[idx + (byte)axisCenterPosDouble]);
|
arrayBezierLUT[127 - idx] = (byte)(255 - arrayBezierLUT[idx + (byte)axisCenterPosDouble]);
|
||||||
|
|
||||||
// If the axisMaxDouble is 255 then we need this to break the look (byte is unsigned 0..255, so the FOR loop never reaches 256 idx value. C# would throw an overflow exceptio)
|
// If the axisMaxDouble is 255 then we need this to break the look (byte is unsigned 0..255, so the FOR loop never reaches 256 idx value. C# would throw an overflow exceptio)
|
||||||
|
@ -911,90 +911,11 @@ namespace DS4Windows
|
|||||||
dState.LY = (byte)(tempY * capY + 128.0);
|
dState.LY = (byte)(tempY * capY + 128.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int lsOutCurveMode = getLsOutCurveMode(device);
|
if (getLsOutCurveMode(device) > 0)
|
||||||
if (lsOutCurveMode > 0 && (dState.LX != 128 || dState.LY != 128))
|
|
||||||
{
|
|
||||||
double capX = dState.LX >= 128 ? 127.0 : 128.0;
|
|
||||||
double capY = dState.LY >= 128 ? 127.0 : 128.0;
|
|
||||||
double tempX = (dState.LX - 128.0) / capX;
|
|
||||||
double tempY = (dState.LY - 128.0) / capY;
|
|
||||||
double signX = tempX >= 0.0 ? 1.0 : -1.0;
|
|
||||||
double signY = tempY >= 0.0 ? 1.0 : -1.0;
|
|
||||||
|
|
||||||
if (lsOutCurveMode == 1)
|
|
||||||
{
|
|
||||||
double absX = Math.Abs(tempX);
|
|
||||||
double absY = Math.Abs(tempY);
|
|
||||||
double outputX = 0.0;
|
|
||||||
double outputY = 0.0;
|
|
||||||
|
|
||||||
if (absX <= 0.4)
|
|
||||||
{
|
|
||||||
outputX = 0.55 * absX;
|
|
||||||
}
|
|
||||||
else if (absX <= 0.75)
|
|
||||||
{
|
|
||||||
outputX = absX - 0.18;
|
|
||||||
}
|
|
||||||
else if (absX > 0.75)
|
|
||||||
{
|
|
||||||
outputX = (absX * 1.72) - 0.72;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (absY <= 0.4)
|
|
||||||
{
|
|
||||||
outputY = 0.55 * absY;
|
|
||||||
}
|
|
||||||
else if (absY <= 0.75)
|
|
||||||
{
|
|
||||||
outputY = absY - 0.18;
|
|
||||||
}
|
|
||||||
else if (absY > 0.75)
|
|
||||||
{
|
|
||||||
outputY = (absY * 1.72) - 0.72;
|
|
||||||
}
|
|
||||||
|
|
||||||
dState.LX = (byte)(outputX * signX * capX + 128.0);
|
|
||||||
dState.LY = (byte)(outputY * signY * capY + 128.0);
|
|
||||||
}
|
|
||||||
else if (lsOutCurveMode == 2)
|
|
||||||
{
|
|
||||||
double outputX = tempX * tempX;
|
|
||||||
double outputY = tempY * tempY;
|
|
||||||
dState.LX = (byte)(outputX * signX * capX + 128.0);
|
|
||||||
dState.LY = (byte)(outputY * signY * capY + 128.0);
|
|
||||||
}
|
|
||||||
else if (lsOutCurveMode == 3)
|
|
||||||
{
|
|
||||||
double outputX = tempX * tempX * tempX;
|
|
||||||
double outputY = tempY * tempY * tempY;
|
|
||||||
dState.LX = (byte)(outputX * capX + 128.0);
|
|
||||||
dState.LY = (byte)(outputY * capY + 128.0);
|
|
||||||
}
|
|
||||||
else if (lsOutCurveMode == 4)
|
|
||||||
{
|
|
||||||
double absX = Math.Abs(tempX);
|
|
||||||
double absY = Math.Abs(tempY);
|
|
||||||
double outputX = absX * (absX - 2.0);
|
|
||||||
double outputY = absY * (absY - 2.0);
|
|
||||||
dState.LX = (byte)(-1.0 * outputX * signX * capX + 128.0);
|
|
||||||
dState.LY = (byte)(-1.0 * outputY * signY * capY + 128.0);
|
|
||||||
}
|
|
||||||
else if (lsOutCurveMode == 5)
|
|
||||||
{
|
|
||||||
double innerX = Math.Abs(tempX) - 1.0;
|
|
||||||
double innerY = Math.Abs(tempY) - 1.0;
|
|
||||||
double outputX = innerX * innerX * innerX + 1.0;
|
|
||||||
double outputY = innerY * innerY * innerY + 1.0;
|
|
||||||
dState.LX = (byte)(1.0 * outputX * signX * capX + 128.0);
|
|
||||||
dState.LY = (byte)(1.0 * outputY * signY * capY + 128.0);
|
|
||||||
}
|
|
||||||
else if (lsOutCurveMode == 6)
|
|
||||||
{
|
{
|
||||||
dState.LX = lsOutBezierCurveObj[device].arrayBezierLUT[dState.LX];
|
dState.LX = lsOutBezierCurveObj[device].arrayBezierLUT[dState.LX];
|
||||||
dState.LY = lsOutBezierCurveObj[device].arrayBezierLUT[dState.LY];
|
dState.LY = lsOutBezierCurveObj[device].arrayBezierLUT[dState.LY];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (squStk.rsMode && (dState.RX != 128 || dState.RY != 128))
|
if (squStk.rsMode && (dState.RX != 128 || dState.RY != 128))
|
||||||
{
|
{
|
||||||
@ -1014,152 +935,21 @@ namespace DS4Windows
|
|||||||
dState.RY = (byte)(tempY * capY + 128.0);
|
dState.RY = (byte)(tempY * capY + 128.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int rsOutCurveMode = getRsOutCurveMode(device);
|
if (getRsOutCurveMode(device) > 0)
|
||||||
if (rsOutCurveMode > 0 && (dState.RX != 128 || dState.RY != 128))
|
|
||||||
{
|
|
||||||
double capX = dState.RX >= 128 ? 127.0 : 128.0;
|
|
||||||
double capY = dState.RY >= 128 ? 127.0 : 128.0;
|
|
||||||
double tempX = (dState.RX - 128.0) / capX;
|
|
||||||
double tempY = (dState.RY - 128.0) / capY;
|
|
||||||
double signX = tempX >= 0.0 ? 1.0 : -1.0;
|
|
||||||
double signY = tempY >= 0.0 ? 1.0 : -1.0;
|
|
||||||
|
|
||||||
if (rsOutCurveMode == 1)
|
|
||||||
{
|
|
||||||
double absX = Math.Abs(tempX);
|
|
||||||
double absY = Math.Abs(tempY);
|
|
||||||
double outputX = 0.0;
|
|
||||||
double outputY = 0.0;
|
|
||||||
|
|
||||||
if (absX <= 0.4)
|
|
||||||
{
|
|
||||||
outputX = 0.55 * absX;
|
|
||||||
}
|
|
||||||
else if (absX <= 0.75)
|
|
||||||
{
|
|
||||||
outputX = absX - 0.18;
|
|
||||||
}
|
|
||||||
else if (absX > 0.75)
|
|
||||||
{
|
|
||||||
outputX = (absX * 1.72) - 0.72;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (absY <= 0.4)
|
|
||||||
{
|
|
||||||
outputY = 0.55 * absY;
|
|
||||||
}
|
|
||||||
else if (absY <= 0.75)
|
|
||||||
{
|
|
||||||
outputY = absY - 0.18;
|
|
||||||
}
|
|
||||||
else if (absY > 0.75)
|
|
||||||
{
|
|
||||||
outputY = (absY * 1.72) - 0.72;
|
|
||||||
}
|
|
||||||
|
|
||||||
dState.RX = (byte)(outputX * signX * capX + 128.0);
|
|
||||||
dState.RY = (byte)(outputY * signY * capY + 128.0);
|
|
||||||
}
|
|
||||||
else if (rsOutCurveMode == 2)
|
|
||||||
{
|
|
||||||
double outputX = tempX * tempX;
|
|
||||||
double outputY = tempY * tempY;
|
|
||||||
dState.RX = (byte)(outputX * signX * capX + 128.0);
|
|
||||||
dState.RY = (byte)(outputY * signY * capY + 128.0);
|
|
||||||
}
|
|
||||||
else if (rsOutCurveMode == 3)
|
|
||||||
{
|
|
||||||
double outputX = tempX * tempX * tempX;
|
|
||||||
double outputY = tempY * tempY * tempY;
|
|
||||||
dState.RX = (byte)(outputX * capX + 128.0);
|
|
||||||
dState.RY = (byte)(outputY * capY + 128.0);
|
|
||||||
}
|
|
||||||
else if (rsOutCurveMode == 4)
|
|
||||||
{
|
|
||||||
double absX = Math.Abs(tempX);
|
|
||||||
double absY = Math.Abs(tempY);
|
|
||||||
double outputX = absX * (absX - 2.0);
|
|
||||||
double outputY = absY * (absY - 2.0);
|
|
||||||
dState.RX = (byte)(-1.0 * outputX * signX * capX + 128.0);
|
|
||||||
dState.RY = (byte)(-1.0 * outputY * signY * capY + 128.0);
|
|
||||||
}
|
|
||||||
else if (rsOutCurveMode == 5)
|
|
||||||
{
|
|
||||||
double innerX = Math.Abs(tempX) - 1.0;
|
|
||||||
double innerY = Math.Abs(tempY) - 1.0;
|
|
||||||
double outputX = innerX * innerX * innerX + 1.0;
|
|
||||||
double outputY = innerY * innerY * innerY + 1.0;
|
|
||||||
dState.RX = (byte)(1.0 * outputX * signX * capX + 128.0);
|
|
||||||
dState.RY = (byte)(1.0 * outputY * signY * capY + 128.0);
|
|
||||||
}
|
|
||||||
else if (rsOutCurveMode == 6)
|
|
||||||
{
|
{
|
||||||
dState.RX = rsOutBezierCurveObj[device].arrayBezierLUT[dState.RX];
|
dState.RX = rsOutBezierCurveObj[device].arrayBezierLUT[dState.RX];
|
||||||
dState.RY = rsOutBezierCurveObj[device].arrayBezierLUT[dState.RY];
|
dState.RY = rsOutBezierCurveObj[device].arrayBezierLUT[dState.RY];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int l2OutCurveMode = getL2OutCurveMode(device);
|
if (getL2OutCurveMode(device) > 0)
|
||||||
if (l2OutCurveMode > 0 && dState.L2 != 0)
|
|
||||||
{
|
|
||||||
double temp = dState.L2 / 255.0;
|
|
||||||
if (l2OutCurveMode == 1)
|
|
||||||
{
|
|
||||||
double output = temp * temp;
|
|
||||||
dState.L2 = (byte)(output * 255.0);
|
|
||||||
}
|
|
||||||
else if (l2OutCurveMode == 2)
|
|
||||||
{
|
|
||||||
double output = temp * temp * temp;
|
|
||||||
dState.L2 = (byte)(output * 255.0);
|
|
||||||
}
|
|
||||||
else if (l2OutCurveMode == 3)
|
|
||||||
{
|
|
||||||
double output = temp * (temp - 2.0);
|
|
||||||
dState.L2 = (byte)(-1.0 * output * 255.0);
|
|
||||||
}
|
|
||||||
else if (l2OutCurveMode == 4)
|
|
||||||
{
|
|
||||||
double inner = Math.Abs(temp) - 1.0;
|
|
||||||
double output = inner * inner * inner + 1.0;
|
|
||||||
dState.L2 = (byte)(-1.0 * output * 255.0);
|
|
||||||
}
|
|
||||||
else if (l2OutCurveMode == 5)
|
|
||||||
{
|
{
|
||||||
dState.L2 = l2OutBezierCurveObj[device].arrayBezierLUT[dState.L2];
|
dState.L2 = l2OutBezierCurveObj[device].arrayBezierLUT[dState.L2];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int r2OutCurveMode = getR2OutCurveMode(device);
|
if (getR2OutCurveMode(device) > 0)
|
||||||
if (r2OutCurveMode > 0 && dState.R2 != 0)
|
|
||||||
{
|
|
||||||
double temp = dState.R2 / 255.0;
|
|
||||||
if (r2OutCurveMode == 1)
|
|
||||||
{
|
|
||||||
double output = temp * temp;
|
|
||||||
dState.R2 = (byte)(output * 255.0);
|
|
||||||
}
|
|
||||||
else if (r2OutCurveMode == 2)
|
|
||||||
{
|
|
||||||
double output = temp * temp * temp;
|
|
||||||
dState.R2 = (byte)(output * 255.0);
|
|
||||||
}
|
|
||||||
else if (r2OutCurveMode == 3)
|
|
||||||
{
|
|
||||||
double output = temp * (temp - 2.0);
|
|
||||||
dState.R2 = (byte)(-1.0 * output * 255.0);
|
|
||||||
}
|
|
||||||
else if (r2OutCurveMode == 4)
|
|
||||||
{
|
|
||||||
double inner = Math.Abs(temp) - 1.0;
|
|
||||||
double output = inner * inner * inner + 1.0;
|
|
||||||
dState.R2 = (byte)(-1.0 * output * 255.0);
|
|
||||||
}
|
|
||||||
else if (r2OutCurveMode == 5)
|
|
||||||
{
|
{
|
||||||
dState.R2 = r2OutBezierCurveObj[device].arrayBezierLUT[dState.R2];
|
dState.R2 = r2OutBezierCurveObj[device].arrayBezierLUT[dState.R2];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool sOff = /*tempBool =*/ isUsingSAforMouse(device);
|
bool sOff = /*tempBool =*/ isUsingSAforMouse(device);
|
||||||
@ -1218,80 +1008,18 @@ namespace DS4Windows
|
|||||||
(int)Math.Min(128d, szsens * 128d * (absz / 128d));
|
(int)Math.Min(128d, szsens * 128d * (absz / 128d));
|
||||||
}
|
}
|
||||||
|
|
||||||
int sxOutCurveMode = getSXOutCurveMode(device);
|
if (getSXOutCurveMode(device) > 0)
|
||||||
if (sxOutCurveMode > 0)
|
|
||||||
{
|
|
||||||
double temp = dState.Motion.outputAccelX / 128.0;
|
|
||||||
double sign = Math.Sign(temp);
|
|
||||||
if (sxOutCurveMode == 1)
|
|
||||||
{
|
|
||||||
double output = temp * temp;
|
|
||||||
result = (int)(output * sign * 128.0);
|
|
||||||
dState.Motion.outputAccelX = result;
|
|
||||||
}
|
|
||||||
else if (sxOutCurveMode == 2)
|
|
||||||
{
|
|
||||||
double output = temp * temp * temp;
|
|
||||||
result = (int)(output * 128.0);
|
|
||||||
dState.Motion.outputAccelX = result;
|
|
||||||
}
|
|
||||||
else if (sxOutCurveMode == 3)
|
|
||||||
{
|
|
||||||
double abs = Math.Abs(temp);
|
|
||||||
double output = abs * (abs - 2.0);
|
|
||||||
dState.Motion.outputAccelX = (byte)(-1.0 * output *
|
|
||||||
sign * 128.0);
|
|
||||||
}
|
|
||||||
else if (sxOutCurveMode == 4)
|
|
||||||
{
|
|
||||||
double inner = Math.Abs(temp) - 1.0;
|
|
||||||
double output = inner * inner * inner + 1.0;
|
|
||||||
dState.Motion.outputAccelX = (byte)(-1.0 * output * 255.0);
|
|
||||||
}
|
|
||||||
else if (sxOutCurveMode == 5)
|
|
||||||
{
|
{
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int szOutCurveMode = getSZOutCurveMode(device);
|
if (getSZOutCurveMode(device) > 0)
|
||||||
if (szOutCurveMode > 0 && dState.Motion.outputAccelZ != 0)
|
|
||||||
{
|
|
||||||
double temp = dState.Motion.outputAccelZ / 128.0;
|
|
||||||
double sign = Math.Sign(temp);
|
|
||||||
if (szOutCurveMode == 1)
|
|
||||||
{
|
|
||||||
double output = temp * temp;
|
|
||||||
result = (int)(output * sign * 128.0);
|
|
||||||
dState.Motion.outputAccelZ = result;
|
|
||||||
}
|
|
||||||
else if (szOutCurveMode == 2)
|
|
||||||
{
|
|
||||||
double output = temp * temp * temp;
|
|
||||||
result = (int)(output * 128.0);
|
|
||||||
dState.Motion.outputAccelZ = result;
|
|
||||||
}
|
|
||||||
else if (szOutCurveMode == 3)
|
|
||||||
{
|
|
||||||
double abs = Math.Abs(temp);
|
|
||||||
double output = abs * (abs - 2.0);
|
|
||||||
dState.Motion.outputAccelZ = (byte)(-1.0 * output *
|
|
||||||
sign * 128.0);
|
|
||||||
}
|
|
||||||
else if (szOutCurveMode == 4)
|
|
||||||
{
|
|
||||||
double inner = Math.Abs(temp) - 1.0;
|
|
||||||
double output = inner * inner * inner + 1.0;
|
|
||||||
dState.Motion.outputAccelZ = (byte)(-1.0 * output * 255.0);
|
|
||||||
}
|
|
||||||
else if (szOutCurveMode == 5)
|
|
||||||
{
|
{
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return dState;
|
return dState;
|
||||||
}
|
}
|
||||||
|
@ -1717,11 +1717,11 @@ 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) (The same curve as bezier 0.70, 0.28, 1.00, 1.00)
|
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 2: bezierCurveArray[device].InitBezierCurve(0.55, 0.09, 0.68, 0.53, axisType); break; // Quadric
|
case 2: bezierCurveArray[device].InitBezierCurve(99.0, 92.0, 0.00, 0.00, axisType); break; // Quadric
|
||||||
case 3: bezierCurveArray[device].InitBezierCurve(0.74, 0.12, 0.64, 0.29, axisType); break; // Cubic
|
case 3: bezierCurveArray[device].InitBezierCurve(99.0, 93.0, 0.00, 0.00, 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(99.0, 94.0, 0.00, 0.00, axisType); break; // Easeout Quad
|
||||||
case 5: bezierCurveArray[device].InitBezierCurve(0.08, 0.22, 0.22, 0.91, axisType); break; // Easeout Cubic
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user