mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-11-26 11:04:21 +01:00
86079b029e
Flash Lightbar when at high latency now has the option to choose what you decide is high latency Show Notifications now has the option to only show warnings, such as when a controller cannot be grabbed exclusively Speaking of bad news for Windows 10 users: Hide DS4 has now been disabled, until i can figure out why this is, it will be disabled, this means some games that rely on this may not work properly or at all, sorry about that As for good news for Windows 10, did you know you can press Windows + G to open a game bar which can record games. For Windows 10 users, there's a new special action: Xbox Game DVR. Pick a trigger (only one button) and tapping/holding/or double tapping does various things, such as start/stop recording, save an ongoing recording, take a screenshot (via the xbox app's option or your own hotkey ie form steam), or just open the gamebar Much of the code has been updated with c# 6.0 Added manifest so DS4Windows can notice Windows 10 and high DPIs, also reorganized files
148 lines
5.2 KiB
C#
148 lines
5.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
|
|
namespace DS4Windows
|
|
{
|
|
class MouseCursor
|
|
{
|
|
private readonly int deviceNumber;
|
|
public MouseCursor(int deviceNum)
|
|
{
|
|
deviceNumber = deviceNum;
|
|
}
|
|
|
|
// Keep track of remainders when performing moves or we lose fractional parts.
|
|
private double horizontalRemainder = 0.0, verticalRemainder = 0.0;
|
|
/** Indicate x/y direction for doing jitter compensation, etc. */
|
|
public enum Direction { Negative, Neutral, Positive }
|
|
// Track direction vector separately and very trivially for now.
|
|
private Direction horizontalDirection = Direction.Neutral, verticalDirection = Direction.Neutral;
|
|
|
|
public void touchesBegan(TouchpadEventArgs arg)
|
|
{
|
|
if (arg.touches.Length == 1)
|
|
{
|
|
horizontalRemainder = verticalRemainder = 0.0;
|
|
horizontalDirection = verticalDirection = Direction.Neutral;
|
|
}
|
|
}
|
|
|
|
private byte lastTouchID;
|
|
public void touchesMoved(TouchpadEventArgs arg, bool dragging)
|
|
{
|
|
if ((!dragging && arg.touches.Length != 1) || (dragging && arg.touches.Length < 1))
|
|
return;
|
|
int deltaX, deltaY;
|
|
if (arg.touches[0].touchID != lastTouchID)
|
|
{
|
|
deltaX = deltaY = 0;
|
|
horizontalRemainder = verticalRemainder = 0.0;
|
|
horizontalDirection = verticalDirection = Direction.Neutral;
|
|
lastTouchID = arg.touches[0].touchID;
|
|
}
|
|
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)
|
|
{
|
|
deltaX = arg.touches[1].deltaX;
|
|
deltaY = arg.touches[1].deltaY;
|
|
}
|
|
else
|
|
{
|
|
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)
|
|
{
|
|
if (horizontalDirection != Direction.Negative)
|
|
{
|
|
deltaX = -1;
|
|
horizontalRemainder = 0.0;
|
|
}
|
|
}
|
|
else if (deltaX >= 1)
|
|
{
|
|
if (horizontalDirection != Direction.Positive)
|
|
{
|
|
deltaX = 1;
|
|
horizontalRemainder = 0.0;
|
|
}
|
|
}
|
|
|
|
if (deltaY <= -1)
|
|
{
|
|
if (verticalDirection != Direction.Negative)
|
|
{
|
|
deltaY = -1;
|
|
verticalRemainder = 0.0;
|
|
}
|
|
}
|
|
else if (deltaY >= 1)
|
|
{
|
|
if (verticalDirection != Direction.Positive)
|
|
{
|
|
deltaY = 1;
|
|
verticalRemainder = 0.0;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (dragging && arg.touches.Length > 1)
|
|
{
|
|
deltaX = arg.touches[1].deltaX;
|
|
deltaY = arg.touches[1].deltaY;
|
|
}
|
|
else
|
|
{
|
|
deltaX = arg.touches[0].deltaX;
|
|
deltaY = arg.touches[0].deltaY;
|
|
}
|
|
}
|
|
|
|
double coefficient = Global.TouchSensitivity[deviceNumber] / 100.0;
|
|
// Collect rounding errors instead of losing motion.
|
|
double xMotion = coefficient * deltaX;
|
|
if (xMotion > 0.0)
|
|
{
|
|
if (horizontalRemainder > 0.0)
|
|
xMotion += horizontalRemainder;
|
|
}
|
|
else if (xMotion < 0.0)
|
|
{
|
|
if (horizontalRemainder < 0.0)
|
|
xMotion += horizontalRemainder;
|
|
}
|
|
int xAction = (int)xMotion;
|
|
horizontalRemainder = xMotion - xAction;
|
|
|
|
double yMotion = coefficient * deltaY;
|
|
if (yMotion > 0.0)
|
|
{
|
|
if (verticalRemainder > 0.0)
|
|
yMotion += verticalRemainder;
|
|
}
|
|
else if (yMotion < 0.0)
|
|
{
|
|
if (verticalRemainder < 0.0)
|
|
yMotion += verticalRemainder;
|
|
}
|
|
int yAction = (int)yMotion;
|
|
verticalRemainder = yMotion - yAction;
|
|
|
|
if (yAction != 0 || xAction != 0)
|
|
InputMethods.MoveCursorBy(xAction, yAction);
|
|
|
|
horizontalDirection = xMotion > 0.0 ? Direction.Positive : xMotion < 0.0 ? Direction.Negative : Direction.Neutral;
|
|
verticalDirection = yMotion > 0.0 ? Direction.Positive : yMotion < 0.0 ? Direction.Negative : Direction.Neutral;
|
|
}
|
|
}
|
|
}
|