2014-03-29 06:56:30 +01:00
using System ;
using System.Collections.Generic ;
using System.Linq ;
using System.Text ;
2015-02-08 22:51:52 +01:00
namespace DS4Windows
2014-03-29 06:56:30 +01:00
{
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 ;
}
2015-06-01 21:04:22 +02:00
public void touchesMoved ( TouchpadEventArgs arg , bool dragging )
2014-03-29 06:56:30 +01:00
{
2015-06-01 21:04:22 +02:00
if ( arg . touches . Length ! = 2 | | dragging )
2014-03-29 06:56:30 +01:00
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
2014-06-09 01:41:36 +02:00
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 ;
2015-02-08 22:51:52 +01:00
double coefficient = Global . ScrollSensitivity [ deviceNumber ] ;
2014-03-29 06:56:30 +01:00
// 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 ) ;
Version 1.4.222
Added Press/Toggle Key to Special Actions, you can hold a trigger to
hold a key or toggle a key with one set of buttons, and untoggle it by
pressing or releasing another set of buttons
Added Disconnect BT to Special Actions, PS+Options to d/c is now added
to Special actions and can be enabled for each profile. You can now set
Disconnect BT to any control(s) and how long you need to hold the
control(s) to take affect
Added Partial German Translation (Thanks Michél)
Added 95% Finished Russian Translation (Thanks overclockers.ru members:
KoNoRIMCI & Sr_psycho)
Added Partial Italian Translation (Thanks Giulio)
Updates to the translations sheets, they should now have every bit of
text in DS4Windows, minus the controls of the controller
English Spelling fixes
Main/Starting tab only shows info for connected controllers, and context
menu only shows options for connected controllers.
Mouse wheel scrolling with analog sticks/triggers/gyro, the mouse now
scrolls smoothly
Slightly reworked analog mouse movement + mouse acceleration (not as
janky anymore)
When starting DS4Windows, if no controllers are connected, DS4Windows
defaults to the profile tab
Certain log warnings (Like unable to get controller exclusively) shows
up in red
Easter egg: try pressing a few buttons in sequence while in the log tab
Fixed Start Profile with TP off being unchecked next time a profile is
opened
Other minor Bug Fixes, such as clearing the log then moving to a new tab
crashing DS4W
2015-01-17 21:16:48 +01:00
if ( ( xMotion > 0.0 & & horizontalRemainder > 0.0 ) | | ( xMotion < 0.0 & & horizontalRemainder < 0.0 ) )
2014-03-29 06:56:30 +01:00
xMotion + = horizontalRemainder ;
int xAction = ( int ) xMotion ;
horizontalRemainder = xMotion - xAction ;
double yMotion = coefficient * ( lastMidY - currentMidY ) ;
Version 1.4.222
Added Press/Toggle Key to Special Actions, you can hold a trigger to
hold a key or toggle a key with one set of buttons, and untoggle it by
pressing or releasing another set of buttons
Added Disconnect BT to Special Actions, PS+Options to d/c is now added
to Special actions and can be enabled for each profile. You can now set
Disconnect BT to any control(s) and how long you need to hold the
control(s) to take affect
Added Partial German Translation (Thanks Michél)
Added 95% Finished Russian Translation (Thanks overclockers.ru members:
KoNoRIMCI & Sr_psycho)
Added Partial Italian Translation (Thanks Giulio)
Updates to the translations sheets, they should now have every bit of
text in DS4Windows, minus the controls of the controller
English Spelling fixes
Main/Starting tab only shows info for connected controllers, and context
menu only shows options for connected controllers.
Mouse wheel scrolling with analog sticks/triggers/gyro, the mouse now
scrolls smoothly
Slightly reworked analog mouse movement + mouse acceleration (not as
janky anymore)
When starting DS4Windows, if no controllers are connected, DS4Windows
defaults to the profile tab
Certain log warnings (Like unable to get controller exclusively) shows
up in red
Easter egg: try pressing a few buttons in sequence while in the log tab
Fixed Start Profile with TP off being unchecked next time a profile is
opened
Other minor Bug Fixes, such as clearing the log then moving to a new tab
crashing DS4W
2015-01-17 21:16:48 +01:00
if ( ( yMotion > 0.0 & & verticalRemainder > 0.0 ) | | ( yMotion < 0.0 & & verticalRemainder < 0.0 ) )
2014-03-29 06:56:30 +01:00
yMotion + = verticalRemainder ;
int yAction = ( int ) yMotion ;
verticalRemainder = yMotion - yAction ;
if ( yAction ! = 0 | | xAction ! = 0 )
InputMethods . MouseWheel ( yAction , xAction ) ;
}
}
}