Use runtime option for toggling touchpad.

Related to issue #637.
This commit is contained in:
Travis Nickles 2019-04-02 00:54:29 -05:00
parent 592a0245b7
commit 79a90b828c
3 changed files with 42 additions and 30 deletions

View File

@ -1362,27 +1362,20 @@ namespace DS4Windows
public bool[] touchreleased = new bool[4] { true, true, true, true }, public bool[] touchreleased = new bool[4] { true, true, true, true },
touchslid = new bool[4] { false, false, false, false }; touchslid = new bool[4] { false, false, false, false };
public byte[] oldtouchvalue = new byte[4] { 0, 0, 0, 0 };
public int[] oldscrollvalue = new int[4] { 0, 0, 0, 0 };
protected virtual void CheckForTouchToggle(int deviceID, DS4State cState, DS4State pState) protected virtual void CheckForTouchToggle(int deviceID, DS4State cState, DS4State pState)
{ {
if (!getUseTPforControls(deviceID) && cState.Touch1 && pState.PS) if (!getUseTPforControls(deviceID) && cState.Touch1 && pState.PS)
{ {
if (getTouchSensitivity(deviceID) > 0 && touchreleased[deviceID]) if (GetTouchActive(deviceID) && touchreleased[deviceID])
{ {
oldtouchvalue[deviceID] = getTouchSensitivity(deviceID); TouchActive[deviceID] = false;
oldscrollvalue[deviceID] = getScrollSensitivity(deviceID);
getTouchSensitivity()[deviceID] = 0;
getScrollSensitivity()[deviceID] = 0;
LogDebug(Properties.Resources.TouchpadMovementOff); LogDebug(Properties.Resources.TouchpadMovementOff);
AppLogger.LogToTray(Properties.Resources.TouchpadMovementOff); AppLogger.LogToTray(Properties.Resources.TouchpadMovementOff);
touchreleased[deviceID] = false; touchreleased[deviceID] = false;
} }
else if (touchreleased[deviceID]) else if (touchreleased[deviceID])
{ {
getTouchSensitivity()[deviceID] = oldtouchvalue[deviceID]; TouchActive[deviceID] = true;
getScrollSensitivity()[deviceID] = oldscrollvalue[deviceID];
LogDebug(Properties.Resources.TouchpadMovementOn); LogDebug(Properties.Resources.TouchpadMovementOn);
AppLogger.LogToTray(Properties.Resources.TouchpadMovementOn); AppLogger.LogToTray(Properties.Resources.TouchpadMovementOn);
touchreleased[deviceID] = false; touchreleased[deviceID] = false;
@ -1396,10 +1389,7 @@ namespace DS4Windows
{ {
if (deviceID < 4) if (deviceID < 4)
{ {
oldtouchvalue[deviceID] = getTouchSensitivity(deviceID); TouchActive[deviceID] = false;
oldscrollvalue[deviceID] = getScrollSensitivity(deviceID);
TouchSensitivity[deviceID] = 0;
ScrollSensitivity[deviceID] = 0;
} }
} }

View File

@ -162,26 +162,41 @@ namespace DS4Windows
if (Global.getUseTPforControls(deviceNum) == false) if (Global.getUseTPforControls(deviceNum) == false)
{ {
int[] disArray = Global.getTouchDisInvertTriggers(deviceNum); if (Global.TouchActive[deviceNum])
tempBool = true;
for (int i = 0, arlen = disArray.Length; tempBool && i < arlen; i++)
{ {
if (getDS4ControlsByName(disArray[i]) == false) int[] disArray = Global.getTouchDisInvertTriggers(deviceNum);
tempBool = false; tempBool = true;
} for (int i = 0, arlen = disArray.Length; tempBool && i < arlen; i++)
{
if (getDS4ControlsByName(disArray[i]) == false)
tempBool = false;
}
if (Global.getTrackballMode(deviceNum)) if (Global.getTrackballMode(deviceNum))
{
int iIndex = trackballBufferTail;
trackballXBuffer[iIndex] = (arg.touches[0].deltaX * TRACKBALL_SCALE) / dev.getCurrentStateRef().elapsedTime;
trackballYBuffer[iIndex] = (arg.touches[0].deltaY * TRACKBALL_SCALE) / dev.getCurrentStateRef().elapsedTime;
trackballBufferTail = (iIndex + 1) % TRACKBALL_BUFFER_LEN;
if (trackballBufferHead == trackballBufferTail)
trackballBufferHead = (trackballBufferHead + 1) % TRACKBALL_BUFFER_LEN;
}
cursor.touchesMoved(arg, dragging || dragging2, tempBool);
wheel.touchesMoved(arg, dragging || dragging2);
}
else
{ {
int iIndex = trackballBufferTail; if (Global.getTrackballMode(deviceNum))
trackballXBuffer[iIndex] = (arg.touches[0].deltaX * TRACKBALL_SCALE) / dev.getCurrentStateRef().elapsedTime; {
trackballYBuffer[iIndex] = (arg.touches[0].deltaY * TRACKBALL_SCALE) / dev.getCurrentStateRef().elapsedTime; int iIndex = trackballBufferTail;
trackballBufferTail = (iIndex + 1) % TRACKBALL_BUFFER_LEN; trackballXBuffer[iIndex] = 0;
if (trackballBufferHead == trackballBufferTail) trackballYBuffer[iIndex] = 0;
trackballBufferHead = (trackballBufferHead + 1) % TRACKBALL_BUFFER_LEN; trackballBufferTail = (iIndex + 1) % TRACKBALL_BUFFER_LEN;
if (trackballBufferHead == trackballBufferTail)
trackballBufferHead = (trackballBufferHead + 1) % TRACKBALL_BUFFER_LEN;
}
} }
cursor.touchesMoved(arg, dragging || dragging2, tempBool);
wheel.touchesMoved(arg, dragging || dragging2);
} }
else else
{ {

View File

@ -240,6 +240,7 @@ namespace DS4Windows
public static bool[] tempprofileDistance = new bool[5] { false, false, false, false, false }; public static bool[] tempprofileDistance = new bool[5] { false, false, false, false, false };
public static bool[] useDInputOnly = new bool[5] { true, true, true, true, true }; public static bool[] useDInputOnly = new bool[5] { true, true, true, true, true };
public static bool[] linkedProfileCheck = new bool[4] { true, true, true, true }; public static bool[] linkedProfileCheck = new bool[4] { true, true, true, true };
public static bool[] touchpadActive = new bool[5] { true, true, true, true, true };
public static X360Controls[] defaultButtonMapping = { X360Controls.None, X360Controls.LXNeg, X360Controls.LXPos, public static X360Controls[] defaultButtonMapping = { X360Controls.None, X360Controls.LXNeg, X360Controls.LXPos,
X360Controls.LYNeg, X360Controls.LYPos, X360Controls.RXNeg, X360Controls.RXPos, X360Controls.RYNeg, X360Controls.RYPos, X360Controls.LYNeg, X360Controls.LYPos, X360Controls.RXNeg, X360Controls.RXPos, X360Controls.RYNeg, X360Controls.RYPos,
@ -667,6 +668,12 @@ namespace DS4Windows
return m_Config.touchSensitivity[index]; return m_Config.touchSensitivity[index];
} }
public static bool[] TouchActive => touchpadActive;
public static bool GetTouchActive(int index)
{
return touchpadActive[index];
}
public static byte[] FlashType => m_Config.flashType; public static byte[] FlashType => m_Config.flashType;
public static byte getFlashType(int index) public static byte getFlashType(int index)
{ {