Trim some property usage

This commit is contained in:
Travis Nickles 2017-04-15 22:15:54 -07:00
parent efeaf852ac
commit 5aff8d95f0
4 changed files with 39 additions and 13 deletions

View File

@ -365,6 +365,7 @@ namespace DS4Windows
case Click.WDOWN:
deviceState[device].currentClicks.wDownCount++;
break;
default: break;
}
}

View File

@ -73,7 +73,9 @@ namespace DS4Windows
case 16: return s.Options;
case 17: return s.Share;
case 18: return s.PS;
default: break;
}
return false;
}
@ -98,11 +100,13 @@ namespace DS4Windows
swipeLeftB = (byte)Math.Min(255, Math.Max(0, firstTouch.hwX - arg.touches[0].hwX));
swipeRightB = (byte)Math.Min(255, Math.Max(0, arg.touches[0].hwX - firstTouch.hwX));
}
if (Math.Abs(firstTouch.hwY - arg.touches[0].hwY) < 50 && arg.touches.Length == 2)
if (arg.touches[0].hwX - firstTouch.hwX > 200 && !slideleft)
slideright = true;
else if (firstTouch.hwX - arg.touches[0].hwX > 200 && !slideright)
slideleft = true;
dev.getCurrentState(s);
synthesizeMouseButtons();
}
@ -113,14 +117,17 @@ namespace DS4Windows
cursor.touchesBegan(arg);
wheel.touchesBegan(arg);
}
pastTime = arg.timeStamp;
firstTouch = arg.touches[0];
if (Global.DoubleTap[deviceNum])
{
DateTime test = arg.timeStamp;
if (test <= (firstTap + TimeSpan.FromMilliseconds((double)Global.TapSensitivity[deviceNum] * 1.5)) && !arg.touchButtonPressed)
secondtouchbegin = true;
}
dev.getCurrentState(s);
synthesizeMouseButtons();
}
@ -129,16 +136,17 @@ namespace DS4Windows
slideright = slideleft = false;
swipeUp = swipeDown = swipeLeft = swipeRight = false;
swipeUpB = swipeDownB = swipeLeftB = swipeRightB = 0;
if (Global.TapSensitivity[deviceNum] != 0 && !Global.UseTPforControls[deviceNum])
byte tapSensitivity = Global.TapSensitivity[deviceNum];
if (tapSensitivity != 0 && !Global.UseTPforControls[deviceNum])
{
if (secondtouchbegin)
{
tappedOnce = false;
secondtouchbegin = false;
}
DateTime test = arg.timeStamp;
if (test <= (pastTime + TimeSpan.FromMilliseconds((double)Global.TapSensitivity[deviceNum] * 2)) && !arg.touchButtonPressed && !tappedOnce)
if (test <= (pastTime + TimeSpan.FromMilliseconds((double)tapSensitivity * 2)) && !arg.touchButtonPressed && !tappedOnce)
if (Math.Abs(firstTouch.hwX - arg.touches[0].hwX) < 10 && Math.Abs(firstTouch.hwY - arg.touches[0].hwY) < 10)
if (Global.DoubleTap[deviceNum])
{
@ -149,6 +157,7 @@ namespace DS4Windows
else
Mapping.MapClick(deviceNum, Mapping.Click.Left); //this way no delay if disabled
}
dev.getCurrentState(s);
synthesizeMouseButtons();
}
@ -174,19 +183,23 @@ namespace DS4Windows
public bool dragging, dragging2;
private void synthesizeMouseButtons()
{
if (Global.GetDS4Action(deviceNum, DS4Controls.TouchLeft.ToString(), false) == null && leftDown)
if (Global.GetDS4Action(deviceNum, DS4Controls.TouchLeft, false) == null && leftDown)
{
Mapping.MapClick(deviceNum, Mapping.Click.Left);
dragging2 = true;
}
else
{
dragging2 = false;
if (Global.GetDS4Action(deviceNum, DS4Controls.TouchUpper.ToString(), false) == null && upperDown)
}
if (Global.GetDS4Action(deviceNum, DS4Controls.TouchUpper, false) == null && upperDown)
Mapping.MapClick(deviceNum, Mapping.Click.Middle);
if (Global.GetDS4Action(deviceNum, DS4Controls.TouchRight.ToString(), false) == null && rightDown)
if (Global.GetDS4Action(deviceNum, DS4Controls.TouchRight, false) == null && rightDown)
Mapping.MapClick(deviceNum, Mapping.Click.Left);
if (Global.GetDS4Action(deviceNum, DS4Controls.TouchMulti.ToString(), false) == null && multiDown)
if (Global.GetDS4Action(deviceNum, DS4Controls.TouchMulti, false) == null && multiDown)
Mapping.MapClick(deviceNum, Mapping.Click.Right);
if (!Global.UseTPforControls[deviceNum])
{
if (tappedOnce)
@ -205,8 +218,11 @@ namespace DS4Windows
dragging = true;
}
else
{
dragging = false;
}
}
s = remapped;
//remapped.CopyTo(s);
}
@ -231,11 +247,13 @@ namespace DS4Windows
{
if ((Global.LowerRCOn[deviceNum] && arg.touches[0].hwX > (1920 * 3) / 4 && arg.touches[0].hwY > (960 * 3) / 4))
Mapping.MapClick(deviceNum, Mapping.Click.Right);
if (isLeft(arg.touches[0]))
leftDown = true;
else if (isRight(arg.touches[0]))
rightDown = true;
}
dev.getCurrentState(s);
synthesizeMouseButtons();
}

View File

@ -42,10 +42,14 @@ namespace DS4Windows
int yAction = (int)yMotion;
vRemainder += yMotion - yAction;
vRemainder -= (int)vRemainder;
if (Global.GyroInvert[deviceNumber] == 2 || Global.GyroInvert[deviceNumber] == 3)
int gyroInvert = Global.GyroInvert[deviceNumber];
if (gyroInvert == 2 || gyroInvert == 3)
xAction *= -1;
if (Global.GyroInvert[deviceNumber] == 1 || Global.GyroInvert[deviceNumber] == 3)
if (gyroInvert == 1 || gyroInvert == 3)
yAction *= -1;
if (yAction != 0 || xAction != 0)
InputMethods.MoveCursorBy(xAction, yAction);
@ -65,8 +69,10 @@ namespace DS4Windows
private byte lastTouchID;
public void touchesMoved(TouchpadEventArgs arg, bool dragging)
{
if ((!dragging && arg.touches.Length != 1) || (dragging && arg.touches.Length < 1))
int touchesLen = arg.touches.Length;
if ((!dragging && touchesLen != 1) || (dragging && touchesLen < 1))
return;
int deltaX, deltaY;
if (arg.touches[0].touchID != lastTouchID)
{
@ -78,8 +84,7 @@ namespace DS4Windows
else if (Global.TouchpadJitterCompensation[deviceNumber])
{
// Often the DS4's internal jitter compensation kicks in and starts hiding changes, ironically creating jitter...
if (dragging && arg.touches.Length > 1)
if (dragging && touchesLen > 1)
{
deltaX = arg.touches[1].deltaX;
deltaY = arg.touches[1].deltaY;
@ -89,6 +94,7 @@ namespace DS4Windows
deltaX = arg.touches[0].deltaX;
deltaY = arg.touches[0].deltaY;
}
// allow only very fine, slow motions, when changing direction, even from neutral
// TODO maybe just consume it completely?
if (deltaX <= -1)
@ -127,7 +133,7 @@ namespace DS4Windows
}
else
{
if (dragging && arg.touches.Length > 1)
if (dragging && touchesLen > 1)
{
deltaX = arg.touches[1].deltaX;
deltaY = arg.touches[1].deltaY;

View File

@ -27,6 +27,7 @@ namespace DS4Windows
{
if (arg.touches.Length != 2 || dragging)
return;
Touch lastT0 = arg.touches[0].previousTouch;
Touch lastT1 = arg.touches[1].previousTouch;
Touch T0 = arg.touches[0];