mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2025-01-10 07:19:24 +01:00
7d7d5d7391
Extended range needed for touchpad swipes actions to register UI adjustments in profile settings, such as a color box for flashing color, alignment adjustments, and the Sixaxis reading dot staying in bounds of the box Recording a macro for special actions now open up in a new window, allowing for ctrl+tab to be used When controller's latency passes 10ms, the log will show and the controller will flash red until the latency is under 10ms Hovering over the mac address shows the latency of said controller, if it's connected via bluetooth Option to choose when at low battery for the light to flash or pulse Much cleaner/neater hotkeys/about window Option to download language packs if your PC is not set to an english language Finished Italian Translations (Thanks again Giulio) Finished German Translations (Thanks Ammonjak) Updated Italian & Russian Translations Reorganized the the code so all cs files are under the same project
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)
|
|
{
|
|
if (arg.touches.Length != 2)
|
|
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);
|
|
}
|
|
}
|
|
}
|