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
61 lines
2.5 KiB
C#
61 lines
2.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
|
|
namespace DS4Windows
|
|
{
|
|
class MouseWheel
|
|
{
|
|
private readonly int deviceNumber;
|
|
public MouseWheel(int deviceNum)
|
|
{
|
|
deviceNumber = deviceNum;
|
|
}
|
|
|
|
// Keep track of remainders when performing scrolls or we lose fractional parts.
|
|
private double horizontalRemainder = 0.0, verticalRemainder = 0.0;
|
|
|
|
public void touchesBegan(TouchpadEventArgs arg)
|
|
{
|
|
if (arg.touches.Length == 2)
|
|
horizontalRemainder = verticalRemainder = 0.0;
|
|
}
|
|
|
|
public void touchesMoved(TouchpadEventArgs arg, bool dragging)
|
|
{
|
|
if (arg.touches.Length != 2 || dragging)
|
|
return;
|
|
Touch lastT0 = arg.touches[0].previousTouch;
|
|
Touch lastT1 = arg.touches[1].previousTouch;
|
|
Touch T0 = arg.touches[0];
|
|
Touch T1 = arg.touches[1];
|
|
|
|
//mouse wheel 120 == 1 wheel click according to Windows API
|
|
double lastMidX = (lastT0.hwX + lastT1.hwX) / 2d, lastMidY = (lastT0.hwY + lastT1.hwY) / 2d,
|
|
currentMidX = (T0.hwX + T1.hwX) / 2d, currentMidY = (T0.hwY + T1.hwY) / 2d;
|
|
double coefficient = Global.ScrollSensitivity[deviceNumber];
|
|
// Adjust for touch distance: "standard" distance is 960 pixels, i.e. half the width. Scroll farther if fingers are farther apart, and vice versa, in linear proportion.
|
|
double touchXDistance = T1.hwX - T0.hwX, touchYDistance = T1.hwY - T0.hwY, touchDistance = Math.Sqrt(touchXDistance * touchXDistance + touchYDistance * touchYDistance);
|
|
coefficient *= touchDistance / 960.0;
|
|
|
|
// Collect rounding errors instead of losing motion.
|
|
double xMotion = coefficient * (currentMidX - lastMidX);
|
|
if ((xMotion > 0.0 &&horizontalRemainder > 0.0) || (xMotion < 0.0 &&horizontalRemainder < 0.0))
|
|
xMotion += horizontalRemainder;
|
|
int xAction = (int)xMotion;
|
|
horizontalRemainder = xMotion - xAction;
|
|
|
|
double yMotion = coefficient * (lastMidY - currentMidY);
|
|
if ((yMotion > 0.0 && verticalRemainder > 0.0) || (yMotion < 0.0 && verticalRemainder < 0.0))
|
|
yMotion += verticalRemainder;
|
|
int yAction = (int)yMotion;
|
|
verticalRemainder = yMotion - yAction;
|
|
|
|
if (yAction != 0 || xAction != 0)
|
|
InputMethods.MouseWheel(yAction, xAction);
|
|
}
|
|
}
|
|
}
|