mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-11-23 01:39:17 +01:00
Add deadzone routine to Gyro mouse
Not sure if this will stay
This commit is contained in:
parent
bf774ba6f7
commit
162092800e
@ -26,6 +26,12 @@ namespace DS4Windows
|
|||||||
//Console.WriteLine(arg.sixAxis.deltaX);
|
//Console.WriteLine(arg.sixAxis.deltaX);
|
||||||
|
|
||||||
double coefficient = Global.GyroSensitivity[deviceNumber] / 100f * 0.008;
|
double coefficient = Global.GyroSensitivity[deviceNumber] / 100f * 0.008;
|
||||||
|
double offset = 0.1;
|
||||||
|
double tempAngle = System.Math.Atan2(-deltaY, deltaX);
|
||||||
|
double normX = System.Math.Abs(System.Math.Cos(tempAngle));
|
||||||
|
double normY = System.Math.Abs(System.Math.Sin(tempAngle));
|
||||||
|
int signX = System.Math.Sign(deltaX);
|
||||||
|
int signY = System.Math.Sign(deltaY);
|
||||||
|
|
||||||
if ((hRemainder > 0) != (deltaX > 0))
|
if ((hRemainder > 0) != (deltaX > 0))
|
||||||
{
|
{
|
||||||
@ -37,15 +43,56 @@ namespace DS4Windows
|
|||||||
vRemainder = 0.0;
|
vRemainder = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
double xMotion = coefficient * deltaX;
|
int deadzone = 15;
|
||||||
xMotion += hRemainder;
|
//int deadzone = 0;
|
||||||
int xAction = (int)xMotion;
|
int deadzoneX = (int)System.Math.Abs(normX * deadzone);
|
||||||
hRemainder = xMotion - xAction;
|
int deadzoneY = (int)System.Math.Abs(normY * deadzone);
|
||||||
|
|
||||||
|
if (System.Math.Abs(deltaX) > deadzoneX)
|
||||||
|
{
|
||||||
|
deltaX -= signX * deadzoneX;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
deltaX = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (System.Math.Abs(deltaY) > deadzoneY)
|
||||||
|
{
|
||||||
|
deltaY -= signY * deadzoneY;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
deltaY = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
double xMotion = deltaX != 0 ? coefficient * deltaX + (normX * (offset * signX)) : 0;
|
||||||
|
int xAction = 0;
|
||||||
|
if (xMotion != 0.0)
|
||||||
|
{
|
||||||
|
xMotion += hRemainder;
|
||||||
|
xAction = (int)xMotion;
|
||||||
|
hRemainder = xMotion - xAction;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hRemainder = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
//hRemainder -= (int)hRemainder;
|
//hRemainder -= (int)hRemainder;
|
||||||
double yMotion = coefficient * deltaY;
|
double yMotion = deltaY != 0 ? coefficient * deltaY + (normY * (offset * signY)) : 0;
|
||||||
yMotion += vRemainder;
|
int yAction = 0;
|
||||||
int yAction = (int)yMotion;
|
if (yMotion != 0.0)
|
||||||
vRemainder = yMotion - yAction;
|
{
|
||||||
|
yMotion += vRemainder;
|
||||||
|
yAction = (int)yMotion;
|
||||||
|
vRemainder = yMotion - yAction;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vRemainder = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
//vRemainder -= (int)vRemainder;
|
//vRemainder -= (int)vRemainder;
|
||||||
|
|
||||||
int gyroInvert = Global.GyroInvert[deviceNumber];
|
int gyroInvert = Global.GyroInvert[deviceNumber];
|
||||||
|
Loading…
Reference in New Issue
Block a user