diff --git a/DS4Windows/DS4Control/ControlService.cs b/DS4Windows/DS4Control/ControlService.cs index d01fea6..12d25dc 100644 --- a/DS4Windows/DS4Control/ControlService.cs +++ b/DS4Windows/DS4Control/ControlService.cs @@ -1362,27 +1362,20 @@ namespace DS4Windows public bool[] touchreleased = new bool[4] { true, true, true, true }, 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) { if (!getUseTPforControls(deviceID) && cState.Touch1 && pState.PS) { - if (getTouchSensitivity(deviceID) > 0 && touchreleased[deviceID]) + if (GetTouchActive(deviceID) && touchreleased[deviceID]) { - oldtouchvalue[deviceID] = getTouchSensitivity(deviceID); - oldscrollvalue[deviceID] = getScrollSensitivity(deviceID); - getTouchSensitivity()[deviceID] = 0; - getScrollSensitivity()[deviceID] = 0; + TouchActive[deviceID] = false; LogDebug(Properties.Resources.TouchpadMovementOff); AppLogger.LogToTray(Properties.Resources.TouchpadMovementOff); touchreleased[deviceID] = false; } else if (touchreleased[deviceID]) { - getTouchSensitivity()[deviceID] = oldtouchvalue[deviceID]; - getScrollSensitivity()[deviceID] = oldscrollvalue[deviceID]; + TouchActive[deviceID] = true; LogDebug(Properties.Resources.TouchpadMovementOn); AppLogger.LogToTray(Properties.Resources.TouchpadMovementOn); touchreleased[deviceID] = false; @@ -1396,10 +1389,7 @@ namespace DS4Windows { if (deviceID < 4) { - oldtouchvalue[deviceID] = getTouchSensitivity(deviceID); - oldscrollvalue[deviceID] = getScrollSensitivity(deviceID); - TouchSensitivity[deviceID] = 0; - ScrollSensitivity[deviceID] = 0; + TouchActive[deviceID] = false; } } diff --git a/DS4Windows/DS4Control/Mouse.cs b/DS4Windows/DS4Control/Mouse.cs index f1dc6de..2d466c2 100644 --- a/DS4Windows/DS4Control/Mouse.cs +++ b/DS4Windows/DS4Control/Mouse.cs @@ -162,26 +162,41 @@ namespace DS4Windows if (Global.getUseTPforControls(deviceNum) == false) { - int[] disArray = Global.getTouchDisInvertTriggers(deviceNum); - tempBool = true; - for (int i = 0, arlen = disArray.Length; tempBool && i < arlen; i++) + if (Global.TouchActive[deviceNum]) { - if (getDS4ControlsByName(disArray[i]) == false) - tempBool = false; - } + int[] disArray = Global.getTouchDisInvertTriggers(deviceNum); + 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; - 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; + if (Global.getTrackballMode(deviceNum)) + { + int iIndex = trackballBufferTail; + trackballXBuffer[iIndex] = 0; + trackballYBuffer[iIndex] = 0; + 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 { diff --git a/DS4Windows/DS4Control/ScpUtil.cs b/DS4Windows/DS4Control/ScpUtil.cs index f5ccddc..d5715a2 100644 --- a/DS4Windows/DS4Control/ScpUtil.cs +++ b/DS4Windows/DS4Control/ScpUtil.cs @@ -240,6 +240,7 @@ namespace DS4Windows 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[] 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, X360Controls.LYNeg, X360Controls.LYPos, X360Controls.RXNeg, X360Controls.RXPos, X360Controls.RYNeg, X360Controls.RYPos, @@ -667,6 +668,12 @@ namespace DS4Windows 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 getFlashType(int index) {