2014-03-28 02:50:40 +01:00
|
|
|
|
using System;
|
2015-02-08 22:51:52 +01:00
|
|
|
|
|
|
|
|
|
namespace DS4Windows
|
2014-03-28 02:50:40 +01:00
|
|
|
|
{
|
|
|
|
|
public class Mouse : ITouchpadBehaviour
|
|
|
|
|
{
|
2014-04-29 03:14:01 +02:00
|
|
|
|
protected DateTime pastTime, firstTap, TimeofEnd;
|
2014-06-02 19:29:38 +02:00
|
|
|
|
protected Touch firstTouch, secondTouch;
|
2014-04-27 21:32:09 +02:00
|
|
|
|
private DS4State s = new DS4State();
|
2014-03-28 02:50:40 +01:00
|
|
|
|
protected int deviceNum;
|
2014-04-27 21:32:09 +02:00
|
|
|
|
private DS4Device dev = null;
|
2014-03-29 06:29:08 +01:00
|
|
|
|
private readonly MouseCursor cursor;
|
|
|
|
|
private readonly MouseWheel wheel;
|
2014-04-29 03:14:01 +02:00
|
|
|
|
private bool tappedOnce = false, secondtouchbegin = false;
|
2014-11-14 20:44:50 +01:00
|
|
|
|
public bool swipeLeft, swipeRight, swipeUp, swipeDown;
|
2017-06-05 10:31:29 +02:00
|
|
|
|
public bool priorSwipeLeft, priorSwipeRight, priorSwipeUp, priorSwipeDown;
|
2014-11-15 22:54:14 +01:00
|
|
|
|
public byte swipeLeftB, swipeRightB, swipeUpB, swipeDownB, swipedB;
|
2017-06-05 10:31:29 +02:00
|
|
|
|
public byte priorSwipeLeftB, priorSwipeRightB, priorSwipeUpB, priorSwipeDownB, priorSwipedB;
|
2014-10-31 00:56:51 +01:00
|
|
|
|
public bool slideleft, slideright;
|
2017-06-05 10:31:29 +02:00
|
|
|
|
public bool priorSlideLeft, priorSlideright;
|
2014-10-31 00:56:51 +01:00
|
|
|
|
// touch area stuff
|
|
|
|
|
public bool leftDown, rightDown, upperDown, multiDown;
|
2017-06-05 10:31:29 +02:00
|
|
|
|
public bool priorLeftDown, priorRightDown, priorUpperDown, priorMultiDown;
|
2014-10-31 00:56:51 +01:00
|
|
|
|
protected DS4Controls pushed = DS4Controls.None;
|
|
|
|
|
protected Mapping.Click clicked = Mapping.Click.None;
|
2019-01-31 17:59:00 +01:00
|
|
|
|
public int CursorGyroDead { get => cursor.GyroCursorDeadZone; set => cursor.GyroCursorDeadZone = value; }
|
2014-03-28 02:50:40 +01:00
|
|
|
|
|
2018-01-01 19:21:35 +01:00
|
|
|
|
internal const int TRACKBALL_INIT_FICTION = 10;
|
2018-01-03 11:31:25 +01:00
|
|
|
|
internal const int TRACKBALL_MASS = 45;
|
2018-01-01 19:21:35 +01:00
|
|
|
|
internal const double TRACKBALL_RADIUS = 0.0245;
|
|
|
|
|
|
|
|
|
|
private double TRACKBALL_INERTIA = 2.0 * (TRACKBALL_MASS * TRACKBALL_RADIUS * TRACKBALL_RADIUS) / 5.0;
|
|
|
|
|
private double TRACKBALL_SCALE = 0.004;
|
2018-01-03 11:31:25 +01:00
|
|
|
|
private const int TRACKBALL_BUFFER_LEN = 8;
|
2018-01-01 19:21:35 +01:00
|
|
|
|
private double[] trackballXBuffer = new double[TRACKBALL_BUFFER_LEN];
|
|
|
|
|
private double[] trackballYBuffer = new double[TRACKBALL_BUFFER_LEN];
|
|
|
|
|
private int trackballBufferTail = 0;
|
|
|
|
|
private int trackballBufferHead = 0;
|
|
|
|
|
private double trackballAccel = 0.0;
|
|
|
|
|
private double trackballXVel = 0.0;
|
|
|
|
|
private double trackballYVel = 0.0;
|
|
|
|
|
private bool trackballActive = false;
|
|
|
|
|
private double trackballDXRemain = 0.0;
|
|
|
|
|
private double trackballDYRemain = 0.0;
|
|
|
|
|
|
2014-04-27 21:32:09 +02:00
|
|
|
|
public Mouse(int deviceID, DS4Device d)
|
2014-03-28 02:50:40 +01:00
|
|
|
|
{
|
|
|
|
|
deviceNum = deviceID;
|
2014-04-27 21:32:09 +02:00
|
|
|
|
dev = d;
|
2014-03-29 06:29:08 +01:00
|
|
|
|
cursor = new MouseCursor(deviceNum);
|
|
|
|
|
wheel = new MouseWheel(deviceNum);
|
2018-01-01 19:21:35 +01:00
|
|
|
|
trackballAccel = TRACKBALL_RADIUS * TRACKBALL_INIT_FICTION / TRACKBALL_INERTIA;
|
2018-01-12 07:45:16 +01:00
|
|
|
|
firstTouch = new Touch(0, 0, 0, null);
|
2018-01-01 19:21:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ResetTrackAccel(double friction)
|
|
|
|
|
{
|
|
|
|
|
trackballAccel = TRACKBALL_RADIUS * friction / TRACKBALL_INERTIA;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-07 04:42:34 +01:00
|
|
|
|
public void ResetToggleGyroM()
|
|
|
|
|
{
|
|
|
|
|
currentToggleGyroM = false;
|
2019-04-23 21:43:45 +02:00
|
|
|
|
previousTriggerActivated = false;
|
|
|
|
|
triggeractivated = false;
|
2019-02-07 04:42:34 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-06-22 18:02:51 +02:00
|
|
|
|
bool triggeractivated = false;
|
2019-02-07 04:42:34 +01:00
|
|
|
|
bool previousTriggerActivated = false;
|
2017-06-22 18:02:51 +02:00
|
|
|
|
bool useReverseRatchet = false;
|
2019-02-07 04:42:34 +01:00
|
|
|
|
bool toggleGyroMouse = true;
|
|
|
|
|
public bool ToggleGyroMouse { get => toggleGyroMouse;
|
|
|
|
|
set { toggleGyroMouse = value; ResetToggleGyroM(); } }
|
|
|
|
|
bool currentToggleGyroM = false;
|
2017-06-22 18:02:51 +02:00
|
|
|
|
|
2019-02-25 00:11:52 +01:00
|
|
|
|
public virtual void sixaxisMoved(DS4SixAxis sender, SixAxisEventArgs arg)
|
2015-11-28 06:47:26 +01:00
|
|
|
|
{
|
2019-08-23 05:03:03 +02:00
|
|
|
|
GyroOutMode outMode = Global.GetGyroOutMode(deviceNum);
|
|
|
|
|
if (outMode == GyroOutMode.Mouse && Global.getGyroSensitivity(deviceNum) > 0)
|
2015-11-28 06:47:26 +01:00
|
|
|
|
{
|
2017-07-26 13:13:18 +02:00
|
|
|
|
s = dev.getCurrentStateRef();
|
|
|
|
|
|
2017-06-22 18:02:51 +02:00
|
|
|
|
useReverseRatchet = Global.getGyroTriggerTurns(deviceNum);
|
2015-11-28 06:47:26 +01:00
|
|
|
|
int i = 0;
|
2017-06-22 09:43:44 +02:00
|
|
|
|
string[] ss = Global.getSATriggers(deviceNum).Split(',');
|
2018-09-30 04:54:25 +02:00
|
|
|
|
bool andCond = Global.getSATriggerCond(deviceNum);
|
|
|
|
|
triggeractivated = andCond ? true : false;
|
2015-12-13 22:30:54 +01:00
|
|
|
|
if (!string.IsNullOrEmpty(ss[0]))
|
2017-06-05 10:31:29 +02:00
|
|
|
|
{
|
2017-06-22 09:43:44 +02:00
|
|
|
|
string s = string.Empty;
|
2018-09-30 04:54:25 +02:00
|
|
|
|
for (int index = 0, arlen = ss.Length; index < arlen; index++)
|
2017-06-05 10:31:29 +02:00
|
|
|
|
{
|
2017-06-22 09:43:44 +02:00
|
|
|
|
s = ss[index];
|
2018-09-30 04:54:25 +02:00
|
|
|
|
if (andCond && !(int.TryParse(s, out i) && getDS4ControlsByName(i)))
|
2017-06-22 09:43:44 +02:00
|
|
|
|
{
|
2015-12-13 22:30:54 +01:00
|
|
|
|
triggeractivated = false;
|
2018-09-30 04:54:25 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else if (!andCond && int.TryParse(s, out i) && getDS4ControlsByName(i))
|
|
|
|
|
{
|
|
|
|
|
triggeractivated = true;
|
|
|
|
|
break;
|
2017-06-22 09:43:44 +02:00
|
|
|
|
}
|
2017-06-05 10:31:29 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-07 04:42:34 +01:00
|
|
|
|
if (toggleGyroMouse)
|
|
|
|
|
{
|
|
|
|
|
if (triggeractivated && triggeractivated != previousTriggerActivated)
|
|
|
|
|
{
|
|
|
|
|
currentToggleGyroM = !currentToggleGyroM;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
previousTriggerActivated = triggeractivated;
|
|
|
|
|
triggeractivated = currentToggleGyroM;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
previousTriggerActivated = triggeractivated;
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-22 09:43:44 +02:00
|
|
|
|
if (useReverseRatchet && triggeractivated)
|
|
|
|
|
cursor.sixaxisMoved(arg);
|
|
|
|
|
else if (!useReverseRatchet && !triggeractivated)
|
2015-11-28 06:47:26 +01:00
|
|
|
|
cursor.sixaxisMoved(arg);
|
2017-06-22 16:36:40 +02:00
|
|
|
|
else
|
|
|
|
|
cursor.mouseRemainderReset();
|
2019-08-23 05:03:03 +02:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (outMode == GyroOutMode.MouseJoystick)
|
|
|
|
|
{
|
|
|
|
|
s = dev.getCurrentStateRef();
|
|
|
|
|
|
|
|
|
|
useReverseRatchet = Global.GetGyroMouseStickTriggerTurns(deviceNum);
|
|
|
|
|
int i = 0;
|
|
|
|
|
string[] ss = Global.GetSAMousestickTriggers(deviceNum).Split(',');
|
|
|
|
|
bool andCond = Global.GetSAMouseStickTriggerCond(deviceNum);
|
|
|
|
|
triggeractivated = andCond ? true : false;
|
|
|
|
|
if (!string.IsNullOrEmpty(ss[0]))
|
|
|
|
|
{
|
|
|
|
|
string s = string.Empty;
|
|
|
|
|
for (int index = 0, arlen = ss.Length; index < arlen; index++)
|
|
|
|
|
{
|
|
|
|
|
s = ss[index];
|
|
|
|
|
if (andCond && !(int.TryParse(s, out i) && getDS4ControlsByName(i)))
|
|
|
|
|
{
|
|
|
|
|
triggeractivated = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else if (!andCond && int.TryParse(s, out i) && getDS4ControlsByName(i))
|
|
|
|
|
{
|
|
|
|
|
triggeractivated = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
previousTriggerActivated = triggeractivated;
|
|
|
|
|
if (toggleGyroMouse)
|
|
|
|
|
{
|
|
|
|
|
if (triggeractivated && triggeractivated != previousTriggerActivated)
|
|
|
|
|
{
|
|
|
|
|
currentToggleGyroM = !currentToggleGyroM;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
previousTriggerActivated = triggeractivated;
|
|
|
|
|
triggeractivated = currentToggleGyroM;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
previousTriggerActivated = triggeractivated;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (useReverseRatchet && triggeractivated)
|
|
|
|
|
SixMouseStick(arg);
|
|
|
|
|
else if (!useReverseRatchet && !triggeractivated)
|
|
|
|
|
SixMouseStick(arg);
|
|
|
|
|
//else
|
|
|
|
|
// SixMouseReset(arg);
|
2015-11-28 06:47:26 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-23 05:03:03 +02:00
|
|
|
|
/*private const int GyroMouseStickDeadZone = 50;
|
|
|
|
|
private const int GyroMouseStickMaxZone = 880;
|
|
|
|
|
private const int GyroMouseStickFuzz = 20;
|
|
|
|
|
private const int SMOOTH_BUFFER_LEN = 3;
|
|
|
|
|
private int[] xSmoothBuffer = new int[SMOOTH_BUFFER_LEN];
|
|
|
|
|
private int[] ySmoothBuffer = new int[SMOOTH_BUFFER_LEN];
|
|
|
|
|
private int smoothBufferTail = 0;
|
|
|
|
|
|
|
|
|
|
private void SixMouseReset(SixAxisEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
int iIndex = smoothBufferTail % SMOOTH_BUFFER_LEN;
|
|
|
|
|
xSmoothBuffer[iIndex] = 0;
|
|
|
|
|
ySmoothBuffer[iIndex] = 0;
|
|
|
|
|
smoothBufferTail = iIndex + 1;
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
private void SixMouseStick(SixAxisEventArgs arg)
|
|
|
|
|
{
|
|
|
|
|
int deltaX = 0, deltaY = 0;
|
|
|
|
|
deltaX = Global.getGyroMouseStickHorizontalAxis(0) == 0 ? arg.sixAxis.gyroYawFull :
|
|
|
|
|
arg.sixAxis.gyroRollFull;
|
|
|
|
|
deltaY = -arg.sixAxis.gyroPitchFull;
|
|
|
|
|
//int inputX = deltaX, inputY = deltaY;
|
|
|
|
|
int maxDirX = deltaX >= 0 ? 127 : -128;
|
|
|
|
|
int maxDirY = deltaY >= 0 ? 127 : -128;
|
|
|
|
|
|
|
|
|
|
GyroMouseStickInfo msinfo = Global.GetGyroMouseStickInfo(deviceNum);
|
|
|
|
|
|
|
|
|
|
double tempAngle = Math.Atan2(-deltaY, deltaX);
|
|
|
|
|
double normX = Math.Abs(Math.Cos(tempAngle));
|
|
|
|
|
double normY = Math.Abs(Math.Sin(tempAngle));
|
|
|
|
|
int signX = Math.Sign(deltaX);
|
|
|
|
|
int signY = Math.Sign(deltaY);
|
|
|
|
|
|
|
|
|
|
int deadzoneX = (int)Math.Abs(normX * msinfo.deadZone);
|
|
|
|
|
int deadzoneY = (int)Math.Abs(normY * msinfo.deadZone);
|
|
|
|
|
|
|
|
|
|
int maxValX = signX * msinfo.maxZone;
|
|
|
|
|
int maxValY = signY * msinfo.maxZone;
|
|
|
|
|
|
|
|
|
|
double xratio = 0.0, yratio = 0.0;
|
|
|
|
|
double antiX = msinfo.antiDeadX * normX;
|
|
|
|
|
double antiY = msinfo.antiDeadY * normY;
|
|
|
|
|
|
|
|
|
|
if (Math.Abs(deltaX) > deadzoneX)
|
|
|
|
|
{
|
|
|
|
|
deltaX -= signX * deadzoneX;
|
|
|
|
|
deltaX = (deltaX < 0 && deltaX < maxValX) ? maxValX :
|
|
|
|
|
(deltaX > 0 && deltaX > maxValX) ? maxValX : deltaX;
|
|
|
|
|
//if (deltaX != maxValX) deltaX -= deltaX % (signX * GyroMouseFuzz);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
deltaX = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Math.Abs(deltaY) > deadzoneY)
|
|
|
|
|
{
|
|
|
|
|
deltaY -= signY * deadzoneY;
|
|
|
|
|
deltaY = (deltaY < 0 && deltaY < maxValY) ? maxValY :
|
|
|
|
|
(deltaY > 0 && deltaY > maxValY) ? maxValY : deltaY;
|
|
|
|
|
//if (deltaY != maxValY) deltaY -= deltaY % (signY * GyroMouseFuzz);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
deltaY = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*int iIndex = smoothBufferTail % SMOOTH_BUFFER_LEN;
|
|
|
|
|
xSmoothBuffer[iIndex] = deltaX;
|
|
|
|
|
ySmoothBuffer[iIndex] = deltaY;
|
|
|
|
|
smoothBufferTail = iIndex + 1;
|
|
|
|
|
|
|
|
|
|
double currentWeight = 1.0;
|
|
|
|
|
double finalWeight = 0.0;
|
|
|
|
|
double x_out = 0.0, y_out = 0.0;
|
|
|
|
|
int idx = 0;
|
|
|
|
|
for (int i = 0; i < SMOOTH_BUFFER_LEN; i++)
|
|
|
|
|
{
|
|
|
|
|
idx = (smoothBufferTail - i - 1 + SMOOTH_BUFFER_LEN) % SMOOTH_BUFFER_LEN;
|
|
|
|
|
x_out += xSmoothBuffer[idx] * currentWeight;
|
|
|
|
|
y_out += ySmoothBuffer[idx] * currentWeight;
|
|
|
|
|
finalWeight += currentWeight;
|
|
|
|
|
currentWeight *= 0.5;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
x_out /= finalWeight;
|
|
|
|
|
deltaX = (int)x_out;
|
|
|
|
|
y_out /= finalWeight;
|
|
|
|
|
deltaY = (int)y_out;
|
|
|
|
|
|
|
|
|
|
maxValX = deltaX < 0 ? -msinfo.maxZone : msinfo.maxZone;
|
|
|
|
|
maxValY = deltaY < 0 ? -msinfo.maxZone : msinfo.maxZone;
|
|
|
|
|
maxDirX = deltaX >= 0 ? 127 : -128;
|
|
|
|
|
maxDirY = deltaY >= 0 ? 127 : -128;
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if (deltaX != 0) xratio = deltaX / (double)maxValX;
|
|
|
|
|
if (deltaY != 0) yratio = deltaY / (double)maxValY;
|
|
|
|
|
|
|
|
|
|
double xNorm = 0.0, yNorm = 0.0;
|
|
|
|
|
if (xratio != 0.0)
|
|
|
|
|
{
|
|
|
|
|
xNorm = (1.0 - antiX) * xratio + antiX;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (yratio != 0.0)
|
|
|
|
|
{
|
|
|
|
|
yNorm = (1.0 - antiY) * yratio + antiY;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (msinfo.inverted != 0)
|
|
|
|
|
{
|
|
|
|
|
if ((msinfo.inverted & 1) == 1)
|
|
|
|
|
{
|
|
|
|
|
// Invert max dir value
|
|
|
|
|
maxDirX = deltaX >= 0 ? -128 : 127;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((msinfo.inverted & 2) == 2)
|
|
|
|
|
{
|
|
|
|
|
// Invert max dir value
|
|
|
|
|
maxDirY = deltaY >= 0 ? -128 : 127;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
byte axisXOut = (byte)(xNorm * maxDirX + 128.0);
|
|
|
|
|
byte axisYOut = (byte)(yNorm * maxDirY + 128.0);
|
|
|
|
|
Mapping.gyroStickX[deviceNum] = axisXOut;
|
|
|
|
|
Mapping.gyroStickY[deviceNum] = axisYOut;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-28 06:47:26 +01:00
|
|
|
|
private bool getDS4ControlsByName(int key)
|
|
|
|
|
{
|
|
|
|
|
switch (key)
|
|
|
|
|
{
|
2015-12-13 22:30:54 +01:00
|
|
|
|
case -1: return true;
|
2015-11-28 06:47:26 +01:00
|
|
|
|
case 0: return s.Cross;
|
|
|
|
|
case 1: return s.Circle;
|
|
|
|
|
case 2: return s.Square;
|
|
|
|
|
case 3: return s.Triangle;
|
|
|
|
|
case 4: return s.L1;
|
2019-01-13 20:32:38 +01:00
|
|
|
|
case 5: return s.L2 > 128;
|
2015-11-28 06:47:26 +01:00
|
|
|
|
case 6: return s.R1;
|
2019-01-13 20:32:38 +01:00
|
|
|
|
case 7: return s.R2 > 128;
|
2015-11-28 06:47:26 +01:00
|
|
|
|
case 8: return s.DpadUp;
|
|
|
|
|
case 9: return s.DpadDown;
|
|
|
|
|
case 10: return s.DpadLeft;
|
|
|
|
|
case 11: return s.DpadRight;
|
|
|
|
|
case 12: return s.L3;
|
|
|
|
|
case 13: return s.R3;
|
2017-06-22 12:24:51 +02:00
|
|
|
|
case 14: return s.Touch1Finger;
|
|
|
|
|
case 15: return s.Touch2Fingers;
|
2015-11-28 06:47:26 +01:00
|
|
|
|
case 16: return s.Options;
|
|
|
|
|
case 17: return s.Share;
|
2015-12-13 22:30:54 +01:00
|
|
|
|
case 18: return s.PS;
|
2017-04-16 07:15:54 +02:00
|
|
|
|
default: break;
|
2015-11-28 06:47:26 +01:00
|
|
|
|
}
|
2017-04-16 07:15:54 +02:00
|
|
|
|
|
2015-11-28 06:47:26 +01:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-05 05:36:46 +02:00
|
|
|
|
private bool tempBool = false;
|
2019-02-25 00:11:52 +01:00
|
|
|
|
public virtual void touchesMoved(DS4Touchpad sender, TouchpadEventArgs arg)
|
2014-03-28 02:50:40 +01:00
|
|
|
|
{
|
2017-08-05 05:36:46 +02:00
|
|
|
|
s = dev.getCurrentStateRef();
|
|
|
|
|
|
|
|
|
|
if (Global.getUseTPforControls(deviceNum) == false)
|
2014-11-14 20:44:50 +01:00
|
|
|
|
{
|
2019-04-02 08:01:04 +02:00
|
|
|
|
if (Global.GetTouchActive(deviceNum))
|
2017-08-05 05:36:46 +02:00
|
|
|
|
{
|
2019-04-02 07:54:29 +02:00
|
|
|
|
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))
|
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
}
|
2017-08-05 05:36:46 +02:00
|
|
|
|
|
2019-04-02 07:54:29 +02:00
|
|
|
|
cursor.touchesMoved(arg, dragging || dragging2, tempBool);
|
|
|
|
|
wheel.touchesMoved(arg, dragging || dragging2);
|
|
|
|
|
}
|
|
|
|
|
else
|
2018-01-01 19:21:35 +01:00
|
|
|
|
{
|
2019-04-02 07:54:29 +02:00
|
|
|
|
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;
|
|
|
|
|
}
|
2018-01-01 19:21:35 +01:00
|
|
|
|
}
|
2014-11-14 20:44:50 +01:00
|
|
|
|
}
|
2014-11-15 22:54:14 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (!(swipeUp || swipeDown || swipeLeft || swipeRight) && arg.touches.Length == 1)
|
|
|
|
|
{
|
2015-02-08 22:51:52 +01:00
|
|
|
|
if (arg.touches[0].hwX - firstTouch.hwX > 400) swipeRight = true;
|
|
|
|
|
if (arg.touches[0].hwX - firstTouch.hwX < -400) swipeLeft = true;
|
|
|
|
|
if (arg.touches[0].hwY - firstTouch.hwY > 300) swipeDown = true;
|
|
|
|
|
if (arg.touches[0].hwY - firstTouch.hwY < -300) swipeUp = true;
|
2014-11-15 22:54:14 +01:00
|
|
|
|
}
|
2017-06-05 10:31:29 +02:00
|
|
|
|
|
2014-11-15 22:54:14 +01:00
|
|
|
|
swipeUpB = (byte)Math.Min(255, Math.Max(0, (firstTouch.hwY - arg.touches[0].hwY) * 1.5f));
|
|
|
|
|
swipeDownB = (byte)Math.Min(255, Math.Max(0, (arg.touches[0].hwY - firstTouch.hwY) * 1.5f));
|
|
|
|
|
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));
|
|
|
|
|
}
|
2017-04-16 07:15:54 +02:00
|
|
|
|
|
2014-11-15 22:54:14 +01:00
|
|
|
|
if (Math.Abs(firstTouch.hwY - arg.touches[0].hwY) < 50 && arg.touches.Length == 2)
|
2017-06-05 10:31:29 +02:00
|
|
|
|
{
|
2014-11-15 22:54:14 +01:00
|
|
|
|
if (arg.touches[0].hwX - firstTouch.hwX > 200 && !slideleft)
|
|
|
|
|
slideright = true;
|
|
|
|
|
else if (firstTouch.hwX - arg.touches[0].hwX > 200 && !slideright)
|
|
|
|
|
slideleft = true;
|
2017-06-05 10:31:29 +02:00
|
|
|
|
}
|
2017-04-16 07:15:54 +02:00
|
|
|
|
|
2014-04-27 21:32:09 +02:00
|
|
|
|
synthesizeMouseButtons();
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
2017-06-05 10:31:29 +02:00
|
|
|
|
|
2019-02-25 00:11:52 +01:00
|
|
|
|
public virtual void touchesBegan(DS4Touchpad sender, TouchpadEventArgs arg)
|
2014-03-28 02:50:40 +01:00
|
|
|
|
{
|
2015-02-08 22:51:52 +01:00
|
|
|
|
if (!Global.UseTPforControls[deviceNum])
|
2014-11-15 22:54:14 +01:00
|
|
|
|
{
|
2018-01-01 19:21:35 +01:00
|
|
|
|
Array.Clear(trackballXBuffer, 0, TRACKBALL_BUFFER_LEN);
|
|
|
|
|
Array.Clear(trackballXBuffer, 0, TRACKBALL_BUFFER_LEN);
|
|
|
|
|
trackballXVel = 0.0;
|
|
|
|
|
trackballYVel = 0.0;
|
|
|
|
|
trackballActive = false;
|
|
|
|
|
trackballBufferTail = 0;
|
|
|
|
|
trackballBufferHead = 0;
|
|
|
|
|
trackballDXRemain = 0.0;
|
|
|
|
|
trackballDYRemain = 0.0;
|
|
|
|
|
|
2014-11-15 22:54:14 +01:00
|
|
|
|
cursor.touchesBegan(arg);
|
|
|
|
|
wheel.touchesBegan(arg);
|
|
|
|
|
}
|
2017-04-16 07:15:54 +02:00
|
|
|
|
|
2014-03-28 02:50:40 +01:00
|
|
|
|
pastTime = arg.timeStamp;
|
2018-01-12 07:45:16 +01:00
|
|
|
|
firstTouch.populate(arg.touches[0].hwX, arg.touches[0].hwY, arg.touches[0].touchID,
|
|
|
|
|
arg.touches[0].previousTouch);
|
2017-04-16 07:15:54 +02:00
|
|
|
|
|
2018-01-01 19:21:35 +01:00
|
|
|
|
if (Global.getDoubleTap(deviceNum))
|
2014-04-29 03:14:01 +02:00
|
|
|
|
{
|
|
|
|
|
DateTime test = arg.timeStamp;
|
2015-02-08 22:51:52 +01:00
|
|
|
|
if (test <= (firstTap + TimeSpan.FromMilliseconds((double)Global.TapSensitivity[deviceNum] * 1.5)) && !arg.touchButtonPressed)
|
2014-04-29 03:14:01 +02:00
|
|
|
|
secondtouchbegin = true;
|
|
|
|
|
}
|
2017-04-16 07:15:54 +02:00
|
|
|
|
|
2017-07-26 13:13:18 +02:00
|
|
|
|
s = dev.getCurrentStateRef();
|
2014-11-15 22:54:14 +01:00
|
|
|
|
synthesizeMouseButtons();
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
2017-06-05 10:31:29 +02:00
|
|
|
|
|
2019-02-25 00:11:52 +01:00
|
|
|
|
public virtual void touchesEnded(DS4Touchpad sender, TouchpadEventArgs arg)
|
2014-03-28 02:50:40 +01:00
|
|
|
|
{
|
2018-01-01 19:21:35 +01:00
|
|
|
|
s = dev.getCurrentStateRef();
|
2014-05-30 22:39:39 +02:00
|
|
|
|
slideright = slideleft = false;
|
2014-11-14 20:44:50 +01:00
|
|
|
|
swipeUp = swipeDown = swipeLeft = swipeRight = false;
|
2014-11-15 22:54:14 +01:00
|
|
|
|
swipeUpB = swipeDownB = swipeLeftB = swipeRightB = 0;
|
2018-01-01 19:21:35 +01:00
|
|
|
|
byte tapSensitivity = Global.getTapSensitivity(deviceNum);
|
|
|
|
|
if (tapSensitivity != 0 && !Global.getUseTPforControls(deviceNum))
|
2014-03-28 02:50:40 +01:00
|
|
|
|
{
|
2014-04-29 03:14:01 +02:00
|
|
|
|
if (secondtouchbegin)
|
2014-03-28 02:50:40 +01:00
|
|
|
|
{
|
2014-04-29 03:14:01 +02:00
|
|
|
|
tappedOnce = false;
|
|
|
|
|
secondtouchbegin = false;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
2017-04-16 07:15:54 +02:00
|
|
|
|
|
2014-04-29 03:14:01 +02:00
|
|
|
|
DateTime test = arg.timeStamp;
|
2017-04-16 07:15:54 +02:00
|
|
|
|
if (test <= (pastTime + TimeSpan.FromMilliseconds((double)tapSensitivity * 2)) && !arg.touchButtonPressed && !tappedOnce)
|
2017-06-05 10:31:29 +02:00
|
|
|
|
{
|
2014-04-29 03:14:01 +02:00
|
|
|
|
if (Math.Abs(firstTouch.hwX - arg.touches[0].hwX) < 10 && Math.Abs(firstTouch.hwY - arg.touches[0].hwY) < 10)
|
2017-06-05 10:31:29 +02:00
|
|
|
|
{
|
2018-01-01 19:21:35 +01:00
|
|
|
|
if (Global.getDoubleTap(deviceNum))
|
2014-11-15 22:54:14 +01:00
|
|
|
|
{
|
|
|
|
|
tappedOnce = true;
|
|
|
|
|
firstTap = arg.timeStamp;
|
|
|
|
|
TimeofEnd = DateTime.Now; //since arg can't be used in synthesizeMouseButtons
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
Mapping.MapClick(deviceNum, Mapping.Click.Left); //this way no delay if disabled
|
2017-06-05 10:31:29 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
2018-01-01 19:21:35 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (Global.getUseTPforControls(deviceNum) == 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 (!trackballActive)
|
|
|
|
|
{
|
|
|
|
|
double currentWeight = 1.0;
|
|
|
|
|
double finalWeight = 0.0;
|
|
|
|
|
double x_out = 0.0, y_out = 0.0;
|
|
|
|
|
int idx = -1;
|
|
|
|
|
for (int i = 0; i < TRACKBALL_BUFFER_LEN && idx != trackballBufferHead; i++)
|
|
|
|
|
{
|
|
|
|
|
idx = (trackballBufferTail - i - 1 + TRACKBALL_BUFFER_LEN) % TRACKBALL_BUFFER_LEN;
|
|
|
|
|
x_out += trackballXBuffer[idx] * currentWeight;
|
|
|
|
|
y_out += trackballYBuffer[idx] * currentWeight;
|
|
|
|
|
finalWeight += currentWeight;
|
|
|
|
|
currentWeight *= 1.0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
x_out /= finalWeight;
|
|
|
|
|
trackballXVel = x_out;
|
|
|
|
|
y_out /= finalWeight;
|
|
|
|
|
trackballYVel = y_out;
|
|
|
|
|
|
|
|
|
|
trackballActive = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double tempAngle = Math.Atan2(-trackballYVel, trackballXVel);
|
|
|
|
|
double normX = Math.Abs(Math.Cos(tempAngle));
|
|
|
|
|
double normY = Math.Abs(Math.Sin(tempAngle));
|
|
|
|
|
int signX = Math.Sign(trackballXVel);
|
|
|
|
|
int signY = Math.Sign(trackballYVel);
|
|
|
|
|
|
2018-01-03 10:55:40 +01:00
|
|
|
|
double trackXvDecay = Math.Min(Math.Abs(trackballXVel), trackballAccel * s.elapsedTime * normX);
|
|
|
|
|
double trackYvDecay = Math.Min(Math.Abs(trackballYVel), trackballAccel * s.elapsedTime * normY);
|
2018-01-01 19:21:35 +01:00
|
|
|
|
double xVNew = trackballXVel - (trackXvDecay * signX);
|
|
|
|
|
double yVNew = trackballYVel - (trackYvDecay * signY);
|
2018-01-03 10:55:40 +01:00
|
|
|
|
double xMotion = (xVNew * s.elapsedTime) / TRACKBALL_SCALE;
|
|
|
|
|
double yMotion = (yVNew * s.elapsedTime) / TRACKBALL_SCALE;
|
2018-01-01 19:21:35 +01:00
|
|
|
|
if (xMotion != 0.0)
|
|
|
|
|
{
|
|
|
|
|
xMotion += trackballDXRemain;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
trackballDXRemain = 0.0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int dx = (int)xMotion;
|
|
|
|
|
trackballDXRemain = xMotion - dx;
|
|
|
|
|
|
|
|
|
|
if (yMotion != 0.0)
|
|
|
|
|
{
|
|
|
|
|
yMotion += trackballDYRemain;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
trackballDYRemain = 0.0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int dy = (int)yMotion;
|
|
|
|
|
trackballDYRemain = yMotion - dy;
|
|
|
|
|
|
|
|
|
|
trackballXVel = xVNew;
|
|
|
|
|
trackballYVel = yVNew;
|
|
|
|
|
|
|
|
|
|
if (dx == 0 && dy == 0)
|
|
|
|
|
{
|
|
|
|
|
trackballActive = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cursor.TouchMoveCursor(dx, dy, tempBool);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-04-16 07:15:54 +02:00
|
|
|
|
|
2014-04-27 21:32:09 +02:00
|
|
|
|
synthesizeMouseButtons();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool isLeft(Touch t)
|
|
|
|
|
{
|
|
|
|
|
return t.hwX < 1920 * 2 / 5;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool isRight(Touch t)
|
|
|
|
|
{
|
|
|
|
|
return t.hwX >= 1920 * 2 / 5;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-25 00:11:52 +01:00
|
|
|
|
public virtual void touchUnchanged(DS4Touchpad sender, EventArgs unused)
|
2014-04-27 21:32:09 +02:00
|
|
|
|
{
|
2017-07-26 13:13:18 +02:00
|
|
|
|
s = dev.getCurrentStateRef();
|
2018-01-01 19:21:35 +01:00
|
|
|
|
|
|
|
|
|
if (trackballActive)
|
|
|
|
|
{
|
|
|
|
|
if (Global.getUseTPforControls(deviceNum) == 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double tempAngle = Math.Atan2(-trackballYVel, trackballXVel);
|
|
|
|
|
double normX = Math.Abs(Math.Cos(tempAngle));
|
|
|
|
|
double normY = Math.Abs(Math.Sin(tempAngle));
|
|
|
|
|
int signX = Math.Sign(trackballXVel);
|
|
|
|
|
int signY = Math.Sign(trackballYVel);
|
2018-01-03 10:55:40 +01:00
|
|
|
|
double trackXvDecay = Math.Min(Math.Abs(trackballXVel), trackballAccel * s.elapsedTime * normX);
|
|
|
|
|
double trackYvDecay = Math.Min(Math.Abs(trackballYVel), trackballAccel * s.elapsedTime * normY);
|
2018-01-01 19:21:35 +01:00
|
|
|
|
double xVNew = trackballXVel - (trackXvDecay * signX);
|
|
|
|
|
double yVNew = trackballYVel - (trackYvDecay * signY);
|
2018-01-03 10:55:40 +01:00
|
|
|
|
double xMotion = (xVNew * s.elapsedTime) / TRACKBALL_SCALE;
|
|
|
|
|
double yMotion = (yVNew * s.elapsedTime) / TRACKBALL_SCALE;
|
2018-01-01 19:21:35 +01:00
|
|
|
|
if (xMotion != 0.0)
|
|
|
|
|
{
|
|
|
|
|
xMotion += trackballDXRemain;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
trackballDXRemain = 0.0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int dx = (int)xMotion;
|
|
|
|
|
trackballDXRemain = xMotion - dx;
|
|
|
|
|
|
|
|
|
|
if (yMotion != 0.0)
|
|
|
|
|
{
|
|
|
|
|
yMotion += trackballDYRemain;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
trackballDYRemain = 0.0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int dy = (int)yMotion;
|
|
|
|
|
trackballDYRemain = yMotion - dy;
|
|
|
|
|
|
|
|
|
|
trackballXVel = xVNew;
|
|
|
|
|
trackballYVel = yVNew;
|
|
|
|
|
|
|
|
|
|
if (dx == 0 && dy == 0)
|
|
|
|
|
{
|
|
|
|
|
trackballActive = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cursor.TouchMoveCursor(dx, dy, tempBool);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-01-08 04:56:28 +01:00
|
|
|
|
|
|
|
|
|
if (s.TouchButton)
|
|
|
|
|
synthesizeMouseButtons();
|
2014-04-27 21:32:09 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-01 21:04:22 +02:00
|
|
|
|
public bool dragging, dragging2;
|
2019-01-31 17:59:00 +01:00
|
|
|
|
|
2014-04-27 21:32:09 +02:00
|
|
|
|
private void synthesizeMouseButtons()
|
|
|
|
|
{
|
2017-04-16 07:15:54 +02:00
|
|
|
|
if (Global.GetDS4Action(deviceNum, DS4Controls.TouchLeft, false) == null && leftDown)
|
2015-06-01 21:04:22 +02:00
|
|
|
|
{
|
2014-10-21 04:31:13 +02:00
|
|
|
|
Mapping.MapClick(deviceNum, Mapping.Click.Left);
|
2015-06-01 21:04:22 +02:00
|
|
|
|
dragging2 = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
2017-04-16 07:15:54 +02:00
|
|
|
|
{
|
2015-06-01 21:04:22 +02:00
|
|
|
|
dragging2 = false;
|
2017-04-16 07:15:54 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Global.GetDS4Action(deviceNum, DS4Controls.TouchUpper, false) == null && upperDown)
|
2014-10-21 04:31:13 +02:00
|
|
|
|
Mapping.MapClick(deviceNum, Mapping.Click.Middle);
|
2017-06-05 10:31:29 +02:00
|
|
|
|
|
2017-04-16 07:15:54 +02:00
|
|
|
|
if (Global.GetDS4Action(deviceNum, DS4Controls.TouchRight, false) == null && rightDown)
|
2014-10-21 04:31:13 +02:00
|
|
|
|
Mapping.MapClick(deviceNum, Mapping.Click.Left);
|
2017-06-05 10:31:29 +02:00
|
|
|
|
|
2017-04-16 07:15:54 +02:00
|
|
|
|
if (Global.GetDS4Action(deviceNum, DS4Controls.TouchMulti, false) == null && multiDown)
|
2014-10-21 04:31:13 +02:00
|
|
|
|
Mapping.MapClick(deviceNum, Mapping.Click.Right);
|
2017-04-16 07:15:54 +02:00
|
|
|
|
|
2015-02-08 22:51:52 +01:00
|
|
|
|
if (!Global.UseTPforControls[deviceNum])
|
2014-04-29 03:14:01 +02:00
|
|
|
|
{
|
2014-11-15 22:54:14 +01:00
|
|
|
|
if (tappedOnce)
|
|
|
|
|
{
|
|
|
|
|
DateTime tester = DateTime.Now;
|
2015-02-08 22:51:52 +01:00
|
|
|
|
if (tester > (TimeofEnd + TimeSpan.FromMilliseconds((double)(Global.TapSensitivity[deviceNum]) * 1.5)))
|
2014-04-29 03:14:01 +02:00
|
|
|
|
{
|
2014-11-15 22:54:14 +01:00
|
|
|
|
Mapping.MapClick(deviceNum, Mapping.Click.Left);
|
2014-04-29 03:14:01 +02:00
|
|
|
|
tappedOnce = false;
|
|
|
|
|
}
|
2014-11-15 22:54:14 +01:00
|
|
|
|
//if it fails the method resets, and tries again with a new tester value (gives tap a delay so tap and hold can work)
|
|
|
|
|
}
|
|
|
|
|
if (secondtouchbegin) //if tap and hold (also works as double tap)
|
2015-06-01 21:04:22 +02:00
|
|
|
|
{
|
2014-11-15 22:54:14 +01:00
|
|
|
|
Mapping.MapClick(deviceNum, Mapping.Click.Left);
|
2015-06-01 21:04:22 +02:00
|
|
|
|
dragging = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
2017-04-16 07:15:54 +02:00
|
|
|
|
{
|
2015-06-01 21:04:22 +02:00
|
|
|
|
dragging = false;
|
2017-04-16 07:15:54 +02:00
|
|
|
|
}
|
2014-04-29 03:14:01 +02:00
|
|
|
|
}
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-25 00:11:52 +01:00
|
|
|
|
public virtual void touchButtonUp(DS4Touchpad sender, TouchpadEventArgs arg)
|
2014-03-28 02:50:40 +01:00
|
|
|
|
{
|
2014-04-27 21:32:09 +02:00
|
|
|
|
pushed = DS4Controls.None;
|
|
|
|
|
upperDown = leftDown = rightDown = multiDown = false;
|
2017-07-26 13:13:18 +02:00
|
|
|
|
s = dev.getCurrentStateRef();
|
2014-04-27 21:32:09 +02:00
|
|
|
|
if (s.Touch1 || s.Touch2)
|
|
|
|
|
synthesizeMouseButtons();
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-25 00:11:52 +01:00
|
|
|
|
public virtual void touchButtonDown(DS4Touchpad sender, TouchpadEventArgs arg)
|
2014-03-28 02:50:40 +01:00
|
|
|
|
{
|
|
|
|
|
if (arg.touches == null)
|
2014-04-27 21:32:09 +02:00
|
|
|
|
upperDown = true;
|
2014-11-15 22:54:14 +01:00
|
|
|
|
else if (arg.touches.Length > 1)
|
2014-04-27 21:32:09 +02:00
|
|
|
|
multiDown = true;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
2015-02-08 22:51:52 +01:00
|
|
|
|
if ((Global.LowerRCOn[deviceNum] && arg.touches[0].hwX > (1920 * 3) / 4 && arg.touches[0].hwY > (960 * 3) / 4))
|
2014-04-27 21:32:09 +02:00
|
|
|
|
Mapping.MapClick(deviceNum, Mapping.Click.Right);
|
2017-04-16 07:15:54 +02:00
|
|
|
|
|
2014-04-27 21:32:09 +02:00
|
|
|
|
if (isLeft(arg.touches[0]))
|
|
|
|
|
leftDown = true;
|
|
|
|
|
else if (isRight(arg.touches[0]))
|
|
|
|
|
rightDown = true;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
2017-04-16 07:15:54 +02:00
|
|
|
|
|
2017-07-26 13:13:18 +02:00
|
|
|
|
s = dev.getCurrentStateRef();
|
2014-04-27 21:32:09 +02:00
|
|
|
|
synthesizeMouseButtons();
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-06-05 10:31:29 +02:00
|
|
|
|
public void populatePriorButtonStates()
|
|
|
|
|
{
|
|
|
|
|
priorUpperDown = upperDown;
|
|
|
|
|
priorLeftDown = leftDown;
|
|
|
|
|
priorRightDown = rightDown;
|
|
|
|
|
priorMultiDown = multiDown;
|
|
|
|
|
|
|
|
|
|
priorSwipeLeft = swipeLeft; priorSwipeRight = swipeRight;
|
|
|
|
|
priorSwipeUp = swipeUp; priorSwipeDown = swipeDown;
|
|
|
|
|
priorSwipeLeftB = swipeLeftB; priorSwipeRightB = swipeRightB; priorSwipeUpB = swipeUpB;
|
|
|
|
|
priorSwipeDownB = swipeDownB; priorSwipedB = swipedB;
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-27 21:32:09 +02:00
|
|
|
|
public DS4State getDS4State()
|
|
|
|
|
{
|
|
|
|
|
return s;
|
|
|
|
|
}
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
|
|
|
|
}
|