mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-11-29 12:34:18 +01:00
Calculate stick angles for each state change
This commit is contained in:
parent
92b4e2da24
commit
6c83ca2470
@ -510,11 +510,10 @@ namespace DS4Windows
|
||||
CheckForHotkeys(ind, cState, pState);
|
||||
if (eastertime)
|
||||
EasterTime(ind);
|
||||
/*if (LSCurve[ind] != 0 || RSCurve[ind] != 0 || LSDeadzone[ind] != 0 || RSDeadzone[ind] != 0 ||
|
||||
L2Deadzone[ind] != 0 || R2Deadzone[ind] != 0 || LSSens[ind] != 0 || RSSens[ind] != 0 ||
|
||||
L2Sens[ind] != 0 || R2Sens[ind] != 0) //if a curve or deadzone is in place
|
||||
*/
|
||||
cState = Mapping.SetCurveAndDeadzone(ind, cState);
|
||||
|
||||
cState = Mapping.SetCurveAndDeadzone(ind, cState);
|
||||
cState.calculateStickAngles();
|
||||
|
||||
if (!recordingMacro && (!string.IsNullOrEmpty(tempprofilename[ind]) ||
|
||||
containsCustomAction(ind) || containsCustomExtras(ind) || getProfileActionCount(ind) > 0))
|
||||
{
|
||||
|
@ -431,6 +431,7 @@ namespace DS4Windows
|
||||
curvey = Math.Min(y, (y / max) * multimax);
|
||||
}
|
||||
}
|
||||
|
||||
dState.LX = (byte)Math.Round(curvex, 0);
|
||||
dState.LY = (byte)Math.Round(curvey, 0);
|
||||
}
|
||||
@ -464,6 +465,7 @@ namespace DS4Windows
|
||||
curvey = Math.Min(y, (y / max) * multimax);
|
||||
}
|
||||
}
|
||||
|
||||
dState.RX = (byte)Math.Round(curvex, 0);
|
||||
dState.RY = (byte)Math.Round(curvey, 0);
|
||||
}
|
||||
@ -2555,8 +2557,7 @@ namespace DS4Windows
|
||||
{
|
||||
if (!analog)
|
||||
{
|
||||
double angle = Math.Atan2((cState.LX - 127), -(cState.LY - 127));
|
||||
angle = (angle >= 0 ? angle : (2 * Math.PI + angle)) * 180 / Math.PI;
|
||||
double angle = cState.LSAngle;
|
||||
result = cState.LX < 127 && (angle >= 210 && angle <= 330);
|
||||
}
|
||||
else
|
||||
@ -2570,8 +2571,7 @@ namespace DS4Windows
|
||||
{
|
||||
if (!analog)
|
||||
{
|
||||
double angle = Math.Atan2((cState.LX - 127), -(cState.LY - 127));
|
||||
angle = (angle >= 0 ? angle : (2 * Math.PI + angle)) * 180 / Math.PI;
|
||||
double angle = cState.LSAngle;
|
||||
result = cState.LY < 127 && (angle >= 300 || angle <= 60);
|
||||
}
|
||||
else
|
||||
@ -2585,8 +2585,7 @@ namespace DS4Windows
|
||||
{
|
||||
if (!analog)
|
||||
{
|
||||
double angle = Math.Atan2((cState.RX - 127), -(cState.RY - 127));
|
||||
angle = (angle >= 0 ? angle : (2 * Math.PI + angle)) * 180 / Math.PI;
|
||||
double angle = cState.RSAngle;
|
||||
result = cState.RX < 127 && (angle >= 210 && angle <= 330);
|
||||
}
|
||||
else
|
||||
@ -2600,8 +2599,7 @@ namespace DS4Windows
|
||||
{
|
||||
if (!analog)
|
||||
{
|
||||
double angle = Math.Atan2((cState.RX - 127), -(cState.RY - 127));
|
||||
angle = (angle >= 0 ? angle : (2 * Math.PI + angle)) * 180 / Math.PI;
|
||||
double angle = cState.RSAngle;
|
||||
result = cState.RY < 127 && (angle >= 300 || angle <= 60);
|
||||
}
|
||||
else
|
||||
@ -2615,8 +2613,7 @@ namespace DS4Windows
|
||||
{
|
||||
if (!analog)
|
||||
{
|
||||
double angle = Math.Atan2((cState.LX - 127), -(cState.LY - 127));
|
||||
angle = (angle >= 0 ? angle : (2 * Math.PI + angle)) * 180 / Math.PI;
|
||||
double angle = cState.LSAngle;
|
||||
result = cState.LX > 127 && (angle >= 30 && angle <= 150);
|
||||
}
|
||||
else
|
||||
@ -2630,8 +2627,7 @@ namespace DS4Windows
|
||||
{
|
||||
if (!analog)
|
||||
{
|
||||
double angle = Math.Atan2((cState.LX - 127), -(cState.LY - 127));
|
||||
angle = (angle >= 0 ? angle : (2 * Math.PI + angle)) * 180 / Math.PI;
|
||||
double angle = cState.LSAngle;
|
||||
result = cState.LY > 127 && (angle >= 120 && angle <= 240);
|
||||
}
|
||||
else
|
||||
@ -2645,8 +2641,7 @@ namespace DS4Windows
|
||||
{
|
||||
if (!analog)
|
||||
{
|
||||
double angle = Math.Atan2((cState.RX - 127), -(cState.RY - 127));
|
||||
angle = (angle >= 0 ? angle : (2 * Math.PI + angle)) * 180 / Math.PI;
|
||||
double angle = cState.RSAngle;
|
||||
result = cState.RX > 127 && (angle >= 30 && angle <= 150);
|
||||
}
|
||||
else
|
||||
@ -2660,8 +2655,7 @@ namespace DS4Windows
|
||||
{
|
||||
if (!analog)
|
||||
{
|
||||
double angle = Math.Atan2((cState.RX - 127), -(cState.RY - 127));
|
||||
angle = (angle >= 0 ? angle : (2 * Math.PI + angle)) * 180 / Math.PI;
|
||||
double angle = cState.RSAngle;
|
||||
result = cState.RY > 127 && (angle >= 120 && angle <= 240);
|
||||
}
|
||||
else
|
||||
|
@ -17,6 +17,8 @@ namespace DS4Windows
|
||||
public byte FrameCounter; // 0, 1, 2...62, 63, 0....
|
||||
public byte TouchPacketCounter; // we break these out automatically
|
||||
public byte Battery; // 0 for charging, 10/20/30/40/50/60/70/80/90/100 for percentage of full
|
||||
public double LSAngle;
|
||||
public double RSAngle;
|
||||
|
||||
public DS4State()
|
||||
{
|
||||
@ -29,6 +31,8 @@ namespace DS4Windows
|
||||
FrameCounter = 255; // only actually has 6 bits, so this is a null indicator
|
||||
TouchPacketCounter = 255; // 8 bits, no great junk value
|
||||
Battery = 0;
|
||||
LSAngle = 0.0;
|
||||
RSAngle = 0.0;
|
||||
}
|
||||
|
||||
public DS4State(DS4State state)
|
||||
@ -65,6 +69,8 @@ namespace DS4Windows
|
||||
RY = state.RY;
|
||||
FrameCounter = state.FrameCounter;
|
||||
Battery = state.Battery;
|
||||
LSAngle = state.LSAngle;
|
||||
RSAngle = state.RSAngle;
|
||||
}
|
||||
|
||||
public DS4State Clone()
|
||||
@ -106,7 +112,19 @@ namespace DS4Windows
|
||||
state.RY = RY;
|
||||
state.FrameCounter = FrameCounter;
|
||||
state.Battery = Battery;
|
||||
state.LSAngle = LSAngle;
|
||||
state.RSAngle = RSAngle;
|
||||
}
|
||||
|
||||
public void calculateStickAngles()
|
||||
{
|
||||
double lsangle = Math.Atan2((LX - 127), -(LY - 127));
|
||||
lsangle = (lsangle >= 0 ? lsangle : (2 * Math.PI + lsangle)) * 180 / Math.PI;
|
||||
LSAngle = lsangle;
|
||||
|
||||
double rsangle = Math.Atan2((RX - 127), -(RY - 127));
|
||||
rsangle = (rsangle >= 0 ? rsangle : (2 * Math.PI + rsangle)) * 180 / Math.PI;
|
||||
RSAngle = rsangle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user