From c78108242594ab4905a9d9cf3acaeaa3bce0d456 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Fri, 26 May 2017 18:57:46 -0700 Subject: [PATCH] Add DateTime fields to SpecialAction --- DS4Windows/DS4Control/Mapping.cs | 18 ++++++++++-------- DS4Windows/DS4Control/ScpUtil.cs | 3 +++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/DS4Windows/DS4Control/Mapping.cs b/DS4Windows/DS4Control/Mapping.cs index 03e2a55..8bcbb09 100644 --- a/DS4Windows/DS4Control/Mapping.cs +++ b/DS4Windows/DS4Control/Mapping.cs @@ -83,7 +83,7 @@ namespace DS4Windows public static int[] untriggerindex = { -1, -1, -1, -1 }; public static DateTime[] oldnowKeyAct = { DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue }; //private static bool tappedOnce = false, firstTouch = false, secondtouchbegin = false; - private static DateTime pastTime, firstTap, TimeofEnd; + //private static DateTime pastTime, firstTap, TimeofEnd; private static DS4Controls[] shiftTriggerMapping = { DS4Controls.None, DS4Controls.Cross, DS4Controls.Circle, DS4Controls.Square, DS4Controls.Triangle, DS4Controls.Options, DS4Controls.Share, DS4Controls.DpadUp, DS4Controls.DpadDown, DS4Controls.DpadLeft, DS4Controls.DpadRight, DS4Controls.PS, DS4Controls.L1, DS4Controls.R1, DS4Controls.L2, @@ -1720,6 +1720,8 @@ namespace DS4Windows bool tappedOnce = action.tappedOnce, firstTouch = action.firstTouch, secondtouchbegin = action.secondtouchbegin; + //DateTime pastTime = action.pastTime, firstTap = action.firstTap, + // TimeofEnd = action.TimeofEnd; /*if (getCustomButton(device, action.trigger[0]) != X360Controls.Unbound) getCustomButtons(device)[action.trigger[0]] = X360Controls.Unbound; @@ -1744,8 +1746,8 @@ namespace DS4Windows if (activeCur && !activePrev) { // pressed down - pastTime = DateTime.UtcNow; - if (pastTime <= (firstTap + TimeSpan.FromMilliseconds(150))) + action.pastTime = DateTime.UtcNow; + if (action.pastTime <= (action.firstTap + TimeSpan.FromMilliseconds(150))) { action.tappedOnce = tappedOnce = false; action.secondtouchbegin = secondtouchbegin = true; @@ -1770,12 +1772,12 @@ namespace DS4Windows { action.firstTouch = firstTouch = false; //firstTouch = false; - if (DateTime.UtcNow <= (pastTime + TimeSpan.FromMilliseconds(200)) && !tappedOnce) + if (DateTime.UtcNow <= (action.pastTime + TimeSpan.FromMilliseconds(200)) && !tappedOnce) { action.tappedOnce = tappedOnce = true; //tappedOnce = true; - firstTap = DateTime.UtcNow; - TimeofEnd = DateTime.UtcNow; + action.firstTap = DateTime.UtcNow; + action.TimeofEnd = DateTime.UtcNow; } } } @@ -1800,7 +1802,7 @@ namespace DS4Windows } } - if ((DateTime.UtcNow - TimeofEnd) > TimeSpan.FromMilliseconds(150)) + if ((DateTime.UtcNow - action.TimeofEnd) > TimeSpan.FromMilliseconds(150)) { if (macro != "") PlayMacro(device, macroControl, macro, DS4Controls.None, DS4KeyType.None); @@ -1810,7 +1812,7 @@ namespace DS4Windows } //if it fails the method resets, and tries again with a new tester value (gives tap a delay so tap and hold can work) } - else if (firstTouch && (DateTime.UtcNow - pastTime) > TimeSpan.FromMilliseconds(1000)) //helddown + else if (firstTouch && (DateTime.UtcNow - action.pastTime) > TimeSpan.FromMilliseconds(1000)) //helddown { if (action.typeID == SpecialAction.ActionTypeId.MultiAction) { diff --git a/DS4Windows/DS4Control/ScpUtil.cs b/DS4Windows/DS4Control/ScpUtil.cs index c51576f..063f4f3 100644 --- a/DS4Windows/DS4Control/ScpUtil.cs +++ b/DS4Windows/DS4Control/ScpUtil.cs @@ -3349,6 +3349,9 @@ namespace DS4Windows public bool tappedOnce = false; public bool firstTouch = false; public bool secondtouchbegin = false; + public DateTime pastTime; + public DateTime firstTap; + public DateTime TimeofEnd; public SpecialAction(string name, string controls, string type, string details, double delay = 0, string extras = "") {