2014-03-28 02:50:40 +01:00
using System ;
using System.Collections.Generic ;
using System.Linq ;
2015-02-08 22:51:52 +01:00
2019-02-19 11:24:52 +01:00
using System.Threading ;
Rest of DS4Windows has been upped to .NET 4.5 (If you have .net 4/already can run DS4Windows, this won't affect you), thanks to this update, you can now...
Add delay to macros from one millisecond to 60 seconds, macros with delays only run once until pressed again. Without delays, the macro can be repeated while held down.
Profiles and settings are now back inside the application folder to help portability. It will remain in appdata as previous versions if DS4Windows is in a admin folder, I may try to add a setting for location saving.
Import profile option will automatically go to the appdata profile folder, auto profiles and settings will automatically copy over.
Option to delete the appdata folder if not in use in the settings tab, this way it helps with cleanup.
Another fix for auto profiles startup bug
Better reading of autoprofile program path names
Now only one instance of DS4Windows is possible, if another DS4Tool or DS4Windows that is not this version is started, this DS4Windows comes back into focus.
UI fixes
2014-06-10 21:45:09 +02:00
using System.Threading.Tasks ;
2014-12-13 21:12:03 +01:00
using System.Diagnostics ;
2015-12-05 09:55:11 +01:00
using static DS4Windows . Global ;
2019-02-19 14:19:10 +01:00
using System.Drawing ; // Point struct
2019-02-19 11:24:52 +01:00
2015-02-08 22:51:52 +01:00
namespace DS4Windows
2014-03-28 02:50:40 +01:00
{
2014-04-27 21:32:09 +02:00
public class Mapping
2014-03-28 02:50:40 +01:00
{
2014-04-27 21:32:09 +02:00
/ *
* Represent the synthetic keyboard and mouse events . Maintain counts for each so we don ' t duplicate events .
* /
2014-05-28 04:49:58 +02:00
public class SyntheticState
2014-03-28 02:50:40 +01:00
{
2014-04-27 21:32:09 +02:00
public struct MouseClick
2014-03-28 02:50:40 +01:00
{
2014-05-28 04:49:58 +02:00
public int leftCount , middleCount , rightCount , fourthCount , fifthCount , wUpCount , wDownCount , toggleCount ;
public bool toggle ;
2014-04-27 21:32:09 +02:00
}
public MouseClick previousClicks , currentClicks ;
public struct KeyPress
{
2014-05-28 04:49:58 +02:00
public int vkCount , scanCodeCount , repeatCount , toggleCount ; // repeat takes priority over non-, and scancode takes priority over non-
public bool toggle ;
2014-04-27 21:32:09 +02:00
}
public class KeyPresses
{
public KeyPress previous , current ;
}
public Dictionary < UInt16 , KeyPresses > keyPresses = new Dictionary < UInt16 , KeyPresses > ( ) ;
2018-11-01 20:13:10 +01:00
public void SaveToPrevious ( bool performClear )
2014-04-27 21:32:09 +02:00
{
previousClicks = currentClicks ;
if ( performClear )
2014-05-28 04:49:58 +02:00
currentClicks . leftCount = currentClicks . middleCount = currentClicks . rightCount = currentClicks . fourthCount = currentClicks . fifthCount = currentClicks . wUpCount = currentClicks . wDownCount = currentClicks . toggleCount = 0 ;
2017-04-22 06:22:36 +02:00
2017-04-12 23:55:35 +02:00
//foreach (KeyPresses kp in keyPresses.Values)
Dictionary < ushort , KeyPresses > . ValueCollection keyValues = keyPresses . Values ;
2019-02-16 09:16:56 +01:00
for ( var keyEnum = keyValues . GetEnumerator ( ) ; keyEnum . MoveNext ( ) ; )
//for (int i = 0, kpCount = keyValues.Count; i < kpCount; i++)
2014-04-27 21:32:09 +02:00
{
2019-02-16 09:16:56 +01:00
//KeyPresses kp = keyValues.ElementAt(i);
KeyPresses kp = keyEnum . Current ;
2014-04-27 21:32:09 +02:00
kp . previous = kp . current ;
if ( performClear )
2014-05-28 04:49:58 +02:00
{
kp . current . repeatCount = kp . current . scanCodeCount = kp . current . vkCount = kp . current . toggleCount = 0 ;
//kp.current.toggle = false;
}
2014-04-27 21:32:09 +02:00
}
}
}
Version 1.4.5
Added support for the New DS4 USB Adapater (Thanks to boganhobo and
Chamilsaan)
Implemented teokp's amazing fix for hide ds4 not working on the
anniversary update of Windows 10: when a controller fails to enter
exclusive mode, DS4Windows will ask for admin privilages to fix the
issue.
Now (near)unlimited Special Actions can be made from the previous limit
of 50
Special Action Xbox Game DVR is now no longer limited to Windows 10,
renamed multi action button: Assign a macro to single tap, double tap,
and holding down a button
Added option for White DS4Windows Icon in the notification tray (While
not merged from, thanks to tehmantra)
Added option to temporarily turn off DS4Windows when using a certain
program (togglable in the Auto Profiles Tab) (Same case as above but
thanks to dedChar to bring to light)
Fixed Options crashes in certain locales where decimal points are
repesented with commas, such as German (Thanks to kiliansch)
Added/Updated translations for many languauges, now including Japanese,
Slovenian, Hungarian, Greek, Finnish, Czech, Indonesian, and Ukrainian
2016-09-22 03:38:38 +02:00
public class ActionState
{
public bool [ ] dev = new bool [ 4 ] ;
}
2019-02-09 04:04:08 +01:00
struct ControlToXInput
{
public DS4Controls ds4input ;
public DS4Controls xoutput ;
public ControlToXInput ( DS4Controls input , DS4Controls output )
{
ds4input = input ; xoutput = output ;
}
}
static Queue < ControlToXInput > [ ] customMapQueue = new Queue < ControlToXInput > [ 4 ]
{
new Queue < ControlToXInput > ( ) , new Queue < ControlToXInput > ( ) ,
new Queue < ControlToXInput > ( ) , new Queue < ControlToXInput > ( )
} ;
2019-03-05 00:21:58 +01:00
struct DS4Vector2
{
public double x ;
public double y ;
public DS4Vector2 ( double x , double y )
{
this . x = x ;
this . y = y ;
}
}
class DS4SquareStick
{
public DS4Vector2 current ;
public DS4Vector2 squared ;
public DS4SquareStick ( )
{
current = new DS4Vector2 ( 0.0 , 0.0 ) ;
squared = new DS4Vector2 ( 0.0 , 0.0 ) ;
}
public void CircleToSquare ( )
{
const double PiOverFour = Math . PI / 4.0 ;
const double roundness = 5.0 ;
// Determine the theta angle
double angle = Math . Atan2 ( current . y , - current . x ) ;
angle + = Math . PI ;
double cosAng = Math . Cos ( angle ) ;
// Scale according to which wall we're clamping to
// X+ wall
if ( angle < = PiOverFour | | angle > 7.0 * PiOverFour )
{
double tempVal = 1.0 / cosAng ;
//Console.WriteLine("1 ANG: {0} | TEMP: {1}", angle, tempVal);
squared . x = current . x * tempVal ;
squared . y = current . y * tempVal ;
}
// Y+ wall
else if ( angle > PiOverFour & & angle < = 3.0 * PiOverFour )
{
double tempVal = 1.0 / Math . Sin ( angle ) ;
//Console.WriteLine("2 ANG: {0} | TEMP: {1}", angle, tempVal);
squared . x = current . x * tempVal ;
squared . y = current . y * tempVal ;
}
// X- wall
else if ( angle > 3.0 * PiOverFour & & angle < = 5.0 * PiOverFour )
{
double tempVal = - 1.0 / cosAng ;
//Console.WriteLine("3 ANG: {0} | TEMP: {1}", angle, tempVal);
squared . x = current . x * tempVal ;
squared . y = current . y * tempVal ;
}
// Y- wall
else if ( angle > 5.0 * PiOverFour & & angle < = 7.0 * PiOverFour )
{
double tempVal = - 1.0 / Math . Sin ( angle ) ;
//Console.WriteLine("4 ANG: {0} | TEMP: {1}", angle, tempVal);
squared . x = current . x * tempVal ;
squared . y = current . y * tempVal ;
}
else return ;
//double lengthOld = Math.Sqrt((x * x) + (y * y));
double length = current . x / cosAng ;
//Console.WriteLine("LENGTH TEST ({0}) ({1}) {2}", lengthOld, length, (lengthOld == length).ToString());
double factor = Math . Pow ( length , roundness ) ;
//double ogX = current.x, ogY = current.y;
current . x + = ( squared . x - current . x ) * factor ;
current . y + = ( squared . y - current . y ) * factor ;
//Console.WriteLine("INPUT: {0} {1} | {2} {3} | {4} {5} | {6} {7}",
// ogX, ogY, current.x, current.y, squared.x, squared.y, length, factor);
}
}
static DS4SquareStick [ ] outSqrStk = new DS4SquareStick [ 4 ] { new DS4SquareStick ( ) ,
new DS4SquareStick ( ) , new DS4SquareStick ( ) , new DS4SquareStick ( ) } ;
2019-02-19 11:24:52 +01:00
static ReaderWriterLockSlim syncStateLock = new ReaderWriterLockSlim ( ) ;
2014-05-28 04:49:58 +02:00
public static SyntheticState globalState = new SyntheticState ( ) ;
2017-07-18 22:37:01 +02:00
public static SyntheticState [ ] deviceState = new SyntheticState [ 4 ]
{ new SyntheticState ( ) , new SyntheticState ( ) , new SyntheticState ( ) ,
new SyntheticState ( ) } ;
2014-04-27 21:32:09 +02:00
2017-11-17 09:50:37 +01:00
public static DS4StateFieldMapping [ ] fieldMappings = new DS4StateFieldMapping [ 4 ] {
new DS4StateFieldMapping ( ) , new DS4StateFieldMapping ( ) , new DS4StateFieldMapping ( ) ,
new DS4StateFieldMapping ( )
} ;
public static DS4StateFieldMapping [ ] outputFieldMappings = new DS4StateFieldMapping [ 4 ]
{
new DS4StateFieldMapping ( ) , new DS4StateFieldMapping ( ) , new DS4StateFieldMapping ( ) ,
new DS4StateFieldMapping ( )
} ;
2017-11-17 19:39:39 +01:00
public static DS4StateFieldMapping [ ] previousFieldMappings = new DS4StateFieldMapping [ 4 ]
{
new DS4StateFieldMapping ( ) , new DS4StateFieldMapping ( ) , new DS4StateFieldMapping ( ) ,
new DS4StateFieldMapping ( )
} ;
2017-11-17 09:50:37 +01:00
2014-04-27 21:32:09 +02:00
// TODO When we disconnect, process a null/dead state to release any keys or buttons.
2014-05-23 04:42:07 +02:00
public static DateTime oldnow = DateTime . UtcNow ;
2014-05-06 20:49:18 +02:00
private static bool pressagain = false ;
private static int wheel = 0 , keyshelddown = 0 ;
2015-02-12 20:36:40 +01:00
//mapcustom
2017-11-27 19:43:38 +01:00
public static bool [ ] pressedonce = new bool [ 261 ] , macrodone = new bool [ 38 ] ;
2015-02-12 20:36:40 +01:00
static bool [ ] macroControl = new bool [ 25 ] ;
2017-11-23 09:31:35 +01:00
static uint macroCount = 0 ;
2015-02-12 20:36:40 +01:00
//actions
2017-07-18 22:37:01 +02:00
public static int [ ] fadetimer = new int [ 4 ] { 0 , 0 , 0 , 0 } ;
public static int [ ] prevFadetimer = new int [ 4 ] { 0 , 0 , 0 , 0 } ;
2015-02-12 20:36:40 +01:00
public static DS4Color [ ] lastColor = new DS4Color [ 4 ] ;
Version 1.4.5
Added support for the New DS4 USB Adapater (Thanks to boganhobo and
Chamilsaan)
Implemented teokp's amazing fix for hide ds4 not working on the
anniversary update of Windows 10: when a controller fails to enter
exclusive mode, DS4Windows will ask for admin privilages to fix the
issue.
Now (near)unlimited Special Actions can be made from the previous limit
of 50
Special Action Xbox Game DVR is now no longer limited to Windows 10,
renamed multi action button: Assign a macro to single tap, double tap,
and holding down a button
Added option for White DS4Windows Icon in the notification tray (While
not merged from, thanks to tehmantra)
Added option to temporarily turn off DS4Windows when using a certain
program (togglable in the Auto Profiles Tab) (Same case as above but
thanks to dedChar to bring to light)
Fixed Options crashes in certain locales where decimal points are
repesented with commas, such as German (Thanks to kiliansch)
Added/Updated translations for many languauges, now including Japanese,
Slovenian, Hungarian, Greek, Finnish, Czech, Indonesian, and Ukrainian
2016-09-22 03:38:38 +02:00
public static List < ActionState > actionDone = new List < ActionState > ( ) ;
2015-02-12 20:36:40 +01:00
public static SpecialAction [ ] untriggeraction = new SpecialAction [ 4 ] ;
public static DateTime [ ] nowAction = { DateTime . MinValue , DateTime . MinValue , DateTime . MinValue , DateTime . MinValue } ;
public static DateTime [ ] oldnowAction = { DateTime . MinValue , DateTime . MinValue , DateTime . MinValue , DateTime . MinValue } ;
2017-07-18 22:37:01 +02:00
public static int [ ] untriggerindex = new int [ 4 ] { - 1 , - 1 , - 1 , - 1 } ;
public static DateTime [ ] oldnowKeyAct = new DateTime [ 4 ] { DateTime . MinValue ,
DateTime . MinValue , DateTime . MinValue , DateTime . MinValue } ;
2017-07-23 03:48:04 +02:00
private static DS4Controls [ ] shiftTriggerMapping = new DS4Controls [ 26 ] { DS4Controls . None , DS4Controls . Cross , DS4Controls . Circle , DS4Controls . Square ,
2017-04-08 11:00:50 +02:00
DS4Controls . Triangle , DS4Controls . Options , DS4Controls . Share , DS4Controls . DpadUp , DS4Controls . DpadDown ,
DS4Controls . DpadLeft , DS4Controls . DpadRight , DS4Controls . PS , DS4Controls . L1 , DS4Controls . R1 , DS4Controls . L2 ,
DS4Controls . R2 , DS4Controls . L3 , DS4Controls . R3 , DS4Controls . TouchLeft , DS4Controls . TouchUpper , DS4Controls . TouchMulti ,
2017-07-23 03:48:04 +02:00
DS4Controls . TouchRight , DS4Controls . GyroZNeg , DS4Controls . GyroZPos , DS4Controls . GyroXPos , DS4Controls . GyroXNeg ,
2017-04-08 11:00:50 +02:00
} ;
2017-07-18 22:37:01 +02:00
2017-11-27 19:43:38 +01:00
private static int [ ] ds4ControlMapping = new int [ 38 ] { 0 , // DS4Control.None
2017-04-08 11:00:50 +02:00
16 , // DS4Controls.LXNeg
20 , // DS4Controls.LXPos
17 , // DS4Controls.LYNeg
21 , // DS4Controls.LYPos
18 , // DS4Controls.RXNeg
22 , // DS4Controls.RXPos
19 , // DS4Controls.RYNeg
23 , // DS4Controls.RYPos
3 , // DS4Controls.L1
24 , // DS4Controls.L2
5 , // DS4Controls.L3
4 , // DS4Controls.R1
25 , // DS4Controls.R2
6 , // DS4Controls.R3
13 , // DS4Controls.Square
14 , // DS4Controls.Triangle
15 , // DS4Controls.Circle
12 , // DS4Controls.Cross
7 , // DS4Controls.DpadUp
10 , // DS4Controls.DpadRight
8 , // DS4Controls.DpadDown
9 , // DS4Controls.DpadLeft
11 , // DS4Controls.PS
27 , // DS4Controls.TouchLeft
29 , // DS4Controls.TouchUpper
26 , // DS4Controls.TouchMulti
28 , // DS4Controls.TouchRight
1 , // DS4Controls.Share
2 , // DS4Controls.Options
31 , // DS4Controls.GyroXPos
30 , // DS4Controls.GyroXNeg
33 , // DS4Controls.GyroZPos
2017-11-27 19:43:38 +01:00
32 , // DS4Controls.GyroZNeg
34 , // DS4Controls.SwipeLeft
35 , // DS4Controls.SwipeRight
36 , // DS4Controls.SwipeUp
37 // DS4Controls.SwipeDown
2017-04-08 11:00:50 +02:00
} ;
2015-02-12 20:36:40 +01:00
2017-06-08 20:01:14 +02:00
// Define here to save some time processing.
// It is enough to feel a difference during gameplay.
2017-07-18 22:37:01 +02:00
private static int [ ] rsOutCurveModeArray = new int [ 4 ] { 0 , 0 , 0 , 0 } ;
private static int [ ] lsOutCurveModeArray = new int [ 4 ] { 0 , 0 , 0 , 0 } ;
2017-07-01 06:29:20 +02:00
static bool tempBool = false ;
2017-07-20 01:17:11 +02:00
private static double [ ] tempDoubleArray = new double [ 4 ] { 0.0 , 0.0 , 0.0 , 0.0 } ;
private static int [ ] tempIntArray = new int [ 4 ] { 0 , 0 , 0 , 0 } ;
2017-06-08 20:01:14 +02:00
2017-06-08 20:09:05 +02:00
// Special macros
2015-02-12 20:36:40 +01:00
static bool altTabDone = true ;
2017-07-18 22:37:01 +02:00
static DateTime altTabNow = DateTime . UtcNow ,
oldAltTabNow = DateTime . UtcNow - TimeSpan . FromSeconds ( 1 ) ;
2015-02-12 20:36:40 +01:00
2017-06-08 20:09:05 +02:00
// Mouse
2015-02-12 20:36:40 +01:00
public static int mcounter = 34 ;
public static int mouseaccel = 0 ;
public static int prevmouseaccel = 0 ;
private static double horizontalRemainder = 0.0 , verticalRemainder = 0.0 ;
2017-11-25 10:13:22 +01:00
private const int MOUSESPEEDFACTOR = 48 ;
2019-01-13 22:06:26 +01:00
private const double MOUSESTICKOFFSET = 0.0495 ;
2015-02-12 20:36:40 +01:00
2014-04-27 21:32:09 +02:00
public static void Commit ( int device )
{
SyntheticState state = deviceState [ device ] ;
2019-02-19 11:24:52 +01:00
syncStateLock . EnterWriteLock ( ) ;
globalState . currentClicks . leftCount + = state . currentClicks . leftCount - state . previousClicks . leftCount ;
globalState . currentClicks . middleCount + = state . currentClicks . middleCount - state . previousClicks . middleCount ;
globalState . currentClicks . rightCount + = state . currentClicks . rightCount - state . previousClicks . rightCount ;
globalState . currentClicks . fourthCount + = state . currentClicks . fourthCount - state . previousClicks . fourthCount ;
globalState . currentClicks . fifthCount + = state . currentClicks . fifthCount - state . previousClicks . fifthCount ;
globalState . currentClicks . wUpCount + = state . currentClicks . wUpCount - state . previousClicks . wUpCount ;
globalState . currentClicks . wDownCount + = state . currentClicks . wDownCount - state . previousClicks . wDownCount ;
globalState . currentClicks . toggleCount + = state . currentClicks . toggleCount - state . previousClicks . toggleCount ;
globalState . currentClicks . toggle = state . currentClicks . toggle ;
if ( globalState . currentClicks . toggleCount ! = 0 & & globalState . previousClicks . toggleCount = = 0 & & globalState . currentClicks . toggle )
2014-04-27 21:32:09 +02:00
{
2019-02-19 11:24:52 +01:00
if ( globalState . currentClicks . leftCount ! = 0 & & globalState . previousClicks . leftCount = = 0 )
InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_LEFTDOWN ) ;
if ( globalState . currentClicks . rightCount ! = 0 & & globalState . previousClicks . rightCount = = 0 )
InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_RIGHTDOWN ) ;
if ( globalState . currentClicks . middleCount ! = 0 & & globalState . previousClicks . middleCount = = 0 )
InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_MIDDLEDOWN ) ;
if ( globalState . currentClicks . fourthCount ! = 0 & & globalState . previousClicks . fourthCount = = 0 )
InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_XBUTTONDOWN , 1 ) ;
if ( globalState . currentClicks . fifthCount ! = 0 & & globalState . previousClicks . fifthCount = = 0 )
InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_XBUTTONDOWN , 2 ) ;
}
else if ( globalState . currentClicks . toggleCount ! = 0 & & globalState . previousClicks . toggleCount = = 0 & & ! globalState . currentClicks . toggle )
{
if ( globalState . currentClicks . leftCount ! = 0 & & globalState . previousClicks . leftCount = = 0 )
InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_LEFTUP ) ;
if ( globalState . currentClicks . rightCount ! = 0 & & globalState . previousClicks . rightCount = = 0 )
InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_RIGHTUP ) ;
if ( globalState . currentClicks . middleCount ! = 0 & & globalState . previousClicks . middleCount = = 0 )
InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_MIDDLEUP ) ;
if ( globalState . currentClicks . fourthCount ! = 0 & & globalState . previousClicks . fourthCount = = 0 )
InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_XBUTTONUP , 1 ) ;
if ( globalState . currentClicks . fifthCount ! = 0 & & globalState . previousClicks . fifthCount = = 0 )
InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_XBUTTONUP , 2 ) ;
}
if ( globalState . currentClicks . toggleCount = = 0 & & globalState . previousClicks . toggleCount = = 0 )
{
if ( globalState . currentClicks . leftCount ! = 0 & & globalState . previousClicks . leftCount = = 0 )
InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_LEFTDOWN ) ;
else if ( globalState . currentClicks . leftCount = = 0 & & globalState . previousClicks . leftCount ! = 0 )
InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_LEFTUP ) ;
if ( globalState . currentClicks . middleCount ! = 0 & & globalState . previousClicks . middleCount = = 0 )
InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_MIDDLEDOWN ) ;
else if ( globalState . currentClicks . middleCount = = 0 & & globalState . previousClicks . middleCount ! = 0 )
InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_MIDDLEUP ) ;
if ( globalState . currentClicks . rightCount ! = 0 & & globalState . previousClicks . rightCount = = 0 )
InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_RIGHTDOWN ) ;
else if ( globalState . currentClicks . rightCount = = 0 & & globalState . previousClicks . rightCount ! = 0 )
InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_RIGHTUP ) ;
if ( globalState . currentClicks . fourthCount ! = 0 & & globalState . previousClicks . fourthCount = = 0 )
InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_XBUTTONDOWN , 1 ) ;
else if ( globalState . currentClicks . fourthCount = = 0 & & globalState . previousClicks . fourthCount ! = 0 )
InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_XBUTTONUP , 1 ) ;
if ( globalState . currentClicks . fifthCount ! = 0 & & globalState . previousClicks . fifthCount = = 0 )
InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_XBUTTONDOWN , 2 ) ;
else if ( globalState . currentClicks . fifthCount = = 0 & & globalState . previousClicks . fifthCount ! = 0 )
InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_XBUTTONUP , 2 ) ;
if ( globalState . currentClicks . wUpCount ! = 0 & & globalState . previousClicks . wUpCount = = 0 )
2014-05-06 20:49:18 +02:00
{
2019-02-19 11:24:52 +01:00
InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_WHEEL , 120 ) ;
oldnow = DateTime . UtcNow ;
wheel = 120 ;
2014-05-06 20:49:18 +02:00
}
2019-02-19 11:24:52 +01:00
else if ( globalState . currentClicks . wUpCount = = 0 & & globalState . previousClicks . wUpCount ! = 0 )
wheel = 0 ;
2014-05-28 04:49:58 +02:00
2019-02-19 11:24:52 +01:00
if ( globalState . currentClicks . wDownCount ! = 0 & & globalState . previousClicks . wDownCount = = 0 )
2014-05-28 04:49:58 +02:00
{
2019-02-19 11:24:52 +01:00
InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_WHEEL , - 120 ) ;
oldnow = DateTime . UtcNow ;
wheel = - 120 ;
2014-05-28 04:49:58 +02:00
}
2019-02-19 11:24:52 +01:00
if ( globalState . currentClicks . wDownCount = = 0 & & globalState . previousClicks . wDownCount ! = 0 )
wheel = 0 ;
}
2014-05-28 04:49:58 +02:00
2014-05-06 20:49:18 +02:00
2019-02-19 11:24:52 +01:00
if ( wheel ! = 0 ) //Continue mouse wheel movement
{
DateTime now = DateTime . UtcNow ;
if ( now > = oldnow + TimeSpan . FromMilliseconds ( 100 ) & & ! pressagain )
2014-05-06 20:49:18 +02:00
{
2019-02-19 11:24:52 +01:00
oldnow = now ;
InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_WHEEL , wheel ) ;
2014-05-06 20:49:18 +02:00
}
2019-02-19 11:24:52 +01:00
}
2014-04-27 21:32:09 +02:00
2019-02-19 11:24:52 +01:00
// Merge and synthesize all key presses/releases that are present in this device's mapping.
// TODO what about the rest? e.g. repeat keys really ought to be on some set schedule
Dictionary < UInt16 , SyntheticState . KeyPresses > . KeyCollection kvpKeys = state . keyPresses . Keys ;
//foreach (KeyValuePair<UInt16, SyntheticState.KeyPresses> kvp in state.keyPresses)
//for (int i = 0, keyCount = kvpKeys.Count; i < keyCount; i++)
for ( var keyEnum = kvpKeys . GetEnumerator ( ) ; keyEnum . MoveNext ( ) ; )
{
//UInt16 kvpKey = kvpKeys.ElementAt(i);
UInt16 kvpKey = keyEnum . Current ;
SyntheticState . KeyPresses kvpValue = state . keyPresses [ kvpKey ] ;
2017-04-12 23:55:35 +02:00
2019-02-19 11:24:52 +01:00
SyntheticState . KeyPresses gkp ;
if ( globalState . keyPresses . TryGetValue ( kvpKey , out gkp ) )
{
gkp . current . vkCount + = kvpValue . current . vkCount - kvpValue . previous . vkCount ;
gkp . current . scanCodeCount + = kvpValue . current . scanCodeCount - kvpValue . previous . scanCodeCount ;
gkp . current . repeatCount + = kvpValue . current . repeatCount - kvpValue . previous . repeatCount ;
gkp . current . toggle = kvpValue . current . toggle ;
gkp . current . toggleCount + = kvpValue . current . toggleCount - kvpValue . previous . toggleCount ;
}
else
{
gkp = new SyntheticState . KeyPresses ( ) ;
gkp . current = kvpValue . current ;
globalState . keyPresses [ kvpKey ] = gkp ;
}
if ( gkp . current . toggleCount ! = 0 & & gkp . previous . toggleCount = = 0 & & gkp . current . toggle )
{
if ( gkp . current . scanCodeCount ! = 0 )
InputMethods . performSCKeyPress ( kvpKey ) ;
2014-04-27 21:32:09 +02:00
else
2019-02-19 11:24:52 +01:00
InputMethods . performKeyPress ( kvpKey ) ;
}
else if ( gkp . current . toggleCount ! = 0 & & gkp . previous . toggleCount = = 0 & & ! gkp . current . toggle )
{
if ( gkp . previous . scanCodeCount ! = 0 ) // use the last type of VK/SC
InputMethods . performSCKeyRelease ( kvpKey ) ;
else
InputMethods . performKeyRelease ( kvpKey ) ;
}
else if ( gkp . current . vkCount + gkp . current . scanCodeCount ! = 0 & & gkp . previous . vkCount + gkp . previous . scanCodeCount = = 0 )
{
if ( gkp . current . scanCodeCount ! = 0 )
2014-04-27 21:32:09 +02:00
{
2019-02-19 11:24:52 +01:00
oldnow = DateTime . UtcNow ;
InputMethods . performSCKeyPress ( kvpKey ) ;
pressagain = false ;
keyshelddown = kvpKey ;
2014-05-28 04:49:58 +02:00
}
2019-02-19 11:24:52 +01:00
else
2014-05-28 04:49:58 +02:00
{
2019-02-19 11:24:52 +01:00
oldnow = DateTime . UtcNow ;
InputMethods . performKeyPress ( kvpKey ) ;
pressagain = false ;
keyshelddown = kvpKey ;
2014-05-28 04:49:58 +02:00
}
2019-02-19 11:24:52 +01:00
}
else if ( gkp . current . toggleCount ! = 0 | | gkp . previous . toggleCount ! = 0 | | gkp . current . repeatCount ! = 0 | | // repeat or SC/VK transition
( ( gkp . previous . scanCodeCount = = 0 ) ! = ( gkp . current . scanCodeCount = = 0 ) ) ) //repeat keystroke after 500ms
{
if ( keyshelddown = = kvpKey )
2014-04-27 21:32:09 +02:00
{
2019-02-19 11:24:52 +01:00
DateTime now = DateTime . UtcNow ;
if ( now > = oldnow + TimeSpan . FromMilliseconds ( 500 ) & & ! pressagain )
2014-05-06 20:49:18 +02:00
{
2019-02-19 11:24:52 +01:00
oldnow = now ;
pressagain = true ;
2014-05-06 20:49:18 +02:00
}
2019-02-19 11:24:52 +01:00
if ( pressagain & & gkp . current . scanCodeCount ! = 0 )
2014-05-06 20:49:18 +02:00
{
2019-02-19 11:24:52 +01:00
now = DateTime . UtcNow ;
if ( now > = oldnow + TimeSpan . FromMilliseconds ( 25 ) & & pressagain )
2014-05-06 20:49:18 +02:00
{
oldnow = now ;
2019-02-19 11:24:52 +01:00
InputMethods . performSCKeyPress ( kvpKey ) ;
2014-05-06 20:49:18 +02:00
}
2019-02-19 11:24:52 +01:00
}
else if ( pressagain )
{
now = DateTime . UtcNow ;
if ( now > = oldnow + TimeSpan . FromMilliseconds ( 25 ) & & pressagain )
2014-05-06 20:49:18 +02:00
{
2019-02-19 11:24:52 +01:00
oldnow = now ;
InputMethods . performKeyPress ( kvpKey ) ;
2014-05-06 20:49:18 +02:00
}
}
2014-04-27 21:32:09 +02:00
}
2019-02-19 11:24:52 +01:00
}
if ( ( gkp . current . toggleCount = = 0 & & gkp . previous . toggleCount = = 0 ) & & gkp . current . vkCount + gkp . current . scanCodeCount = = 0 & & gkp . previous . vkCount + gkp . previous . scanCodeCount ! = 0 )
{
if ( gkp . previous . scanCodeCount ! = 0 ) // use the last type of VK/SC
2014-04-27 21:32:09 +02:00
{
2019-02-19 11:24:52 +01:00
InputMethods . performSCKeyRelease ( kvpKey ) ;
pressagain = false ;
}
else
{
InputMethods . performKeyRelease ( kvpKey ) ;
pressagain = false ;
2014-03-28 02:50:40 +01:00
}
}
2014-04-27 21:32:09 +02:00
}
2019-02-19 11:24:52 +01:00
globalState . SaveToPrevious ( false ) ;
syncStateLock . ExitWriteLock ( ) ;
2018-11-01 20:13:10 +01:00
state . SaveToPrevious ( true ) ;
2014-04-27 21:32:09 +02:00
}
2017-07-18 22:37:01 +02:00
2014-04-27 21:32:09 +02:00
public enum Click { None , Left , Middle , Right , Fourth , Fifth , WUP , WDOWN } ;
public static void MapClick ( int device , Click mouseClick )
{
switch ( mouseClick )
{
case Click . Left :
deviceState [ device ] . currentClicks . leftCount + + ;
break ;
case Click . Middle :
deviceState [ device ] . currentClicks . middleCount + + ;
break ;
case Click . Right :
deviceState [ device ] . currentClicks . rightCount + + ;
break ;
case Click . Fourth :
deviceState [ device ] . currentClicks . fourthCount + + ;
break ;
case Click . Fifth :
deviceState [ device ] . currentClicks . fifthCount + + ;
break ;
case Click . WUP :
deviceState [ device ] . currentClicks . wUpCount + + ;
break ;
case Click . WDOWN :
deviceState [ device ] . currentClicks . wDownCount + + ;
break ;
2017-04-16 07:15:54 +02:00
default : break ;
2014-04-27 21:32:09 +02:00
}
}
Rest of DS4Windows has been upped to .NET 4.5 (If you have .net 4/already can run DS4Windows, this won't affect you), thanks to this update, you can now...
Add delay to macros from one millisecond to 60 seconds, macros with delays only run once until pressed again. Without delays, the macro can be repeated while held down.
Profiles and settings are now back inside the application folder to help portability. It will remain in appdata as previous versions if DS4Windows is in a admin folder, I may try to add a setting for location saving.
Import profile option will automatically go to the appdata profile folder, auto profiles and settings will automatically copy over.
Option to delete the appdata folder if not in use in the settings tab, this way it helps with cleanup.
Another fix for auto profiles startup bug
Better reading of autoprofile program path names
Now only one instance of DS4Windows is possible, if another DS4Tool or DS4Windows that is not this version is started, this DS4Windows comes back into focus.
UI fixes
2014-06-10 21:45:09 +02:00
public static int DS4ControltoInt ( DS4Controls ctrl )
{
2017-04-08 11:00:50 +02:00
int result = 0 ;
2017-11-27 19:43:38 +01:00
if ( ctrl > = DS4Controls . None & & ctrl < = DS4Controls . SwipeDown )
Rest of DS4Windows has been upped to .NET 4.5 (If you have .net 4/already can run DS4Windows, this won't affect you), thanks to this update, you can now...
Add delay to macros from one millisecond to 60 seconds, macros with delays only run once until pressed again. Without delays, the macro can be repeated while held down.
Profiles and settings are now back inside the application folder to help portability. It will remain in appdata as previous versions if DS4Windows is in a admin folder, I may try to add a setting for location saving.
Import profile option will automatically go to the appdata profile folder, auto profiles and settings will automatically copy over.
Option to delete the appdata folder if not in use in the settings tab, this way it helps with cleanup.
Another fix for auto profiles startup bug
Better reading of autoprofile program path names
Now only one instance of DS4Windows is possible, if another DS4Tool or DS4Windows that is not this version is started, this DS4Windows comes back into focus.
UI fixes
2014-06-10 21:45:09 +02:00
{
2017-04-08 11:00:50 +02:00
result = ds4ControlMapping [ ( int ) ctrl ] ;
Rest of DS4Windows has been upped to .NET 4.5 (If you have .net 4/already can run DS4Windows, this won't affect you), thanks to this update, you can now...
Add delay to macros from one millisecond to 60 seconds, macros with delays only run once until pressed again. Without delays, the macro can be repeated while held down.
Profiles and settings are now back inside the application folder to help portability. It will remain in appdata as previous versions if DS4Windows is in a admin folder, I may try to add a setting for location saving.
Import profile option will automatically go to the appdata profile folder, auto profiles and settings will automatically copy over.
Option to delete the appdata folder if not in use in the settings tab, this way it helps with cleanup.
Another fix for auto profiles startup bug
Better reading of autoprofile program path names
Now only one instance of DS4Windows is possible, if another DS4Tool or DS4Windows that is not this version is started, this DS4Windows comes back into focus.
UI fixes
2014-06-10 21:45:09 +02:00
}
2017-04-08 11:00:50 +02:00
return result ;
Rest of DS4Windows has been upped to .NET 4.5 (If you have .net 4/already can run DS4Windows, this won't affect you), thanks to this update, you can now...
Add delay to macros from one millisecond to 60 seconds, macros with delays only run once until pressed again. Without delays, the macro can be repeated while held down.
Profiles and settings are now back inside the application folder to help portability. It will remain in appdata as previous versions if DS4Windows is in a admin folder, I may try to add a setting for location saving.
Import profile option will automatically go to the appdata profile folder, auto profiles and settings will automatically copy over.
Option to delete the appdata folder if not in use in the settings tab, this way it helps with cleanup.
Another fix for auto profiles startup bug
Better reading of autoprofile program path names
Now only one instance of DS4Windows is possible, if another DS4Tool or DS4Windows that is not this version is started, this DS4Windows comes back into focus.
UI fixes
2014-06-10 21:45:09 +02:00
}
2014-12-13 21:12:03 +01:00
static double TValue ( double value1 , double value2 , double percent )
{
percent / = 100f ;
return value1 * percent + value2 * ( 1 - percent ) ;
}
2017-05-05 18:13:12 +02:00
private static int ClampInt ( int min , int value , int max )
{
return ( value < min ) ? min : ( value > max ) ? max : value ;
}
2017-12-02 08:45:51 +01:00
public static DS4State SetCurveAndDeadzone ( int device , DS4State cState , DS4State dState )
2014-12-13 21:12:03 +01:00
{
2017-06-30 10:42:19 +02:00
double rotation = tempDoubleArray [ device ] = getLSRotation ( device ) ;
2017-07-20 07:57:14 +02:00
if ( rotation > 0.0 | | rotation < 0.0 )
2017-06-30 10:42:19 +02:00
cState . rotateLSCoordinates ( rotation ) ;
double rotationRS = tempDoubleArray [ device ] = getRSRotation ( device ) ;
2017-07-20 07:57:14 +02:00
if ( rotationRS > 0.0 | | rotationRS < 0.0 )
2017-06-30 10:42:19 +02:00
cState . rotateRSCoordinates ( rotationRS ) ;
2017-12-02 08:45:51 +01:00
cState . CopyTo ( dState ) ;
//DS4State dState = new DS4State(cState);
2014-12-13 21:12:03 +01:00
int x ;
int y ;
int curve ;
2017-04-25 16:10:36 +02:00
/* TODO: Look into curve options and make sure maximum axes values are being respected */
2017-03-31 03:00:17 +02:00
int lsCurve = getLSCurve ( device ) ;
2017-03-27 11:55:53 +02:00
if ( lsCurve > 0 )
2014-12-13 21:12:03 +01:00
{
x = cState . LX ;
y = cState . LY ;
float max = x + y ;
double curvex ;
double curvey ;
2017-03-27 11:55:53 +02:00
curve = lsCurve ;
2014-12-13 21:12:03 +01:00
double multimax = TValue ( 382.5 , max , curve ) ;
double multimin = TValue ( 127.5 , max , curve ) ;
if ( ( x > 127.5f & & y > 127.5f ) | | ( x < 127.5f & & y < 127.5f ) )
{
curvex = ( x > 127.5f ? Math . Min ( x , ( x / max ) * multimax ) : Math . Max ( x , ( x / max ) * multimin ) ) ;
curvey = ( y > 127.5f ? Math . Min ( y , ( y / max ) * multimax ) : Math . Max ( y , ( y / max ) * multimin ) ) ;
}
else
{
if ( x < 127.5f )
{
curvex = Math . Min ( x , ( x / max ) * multimax ) ;
curvey = Math . Min ( y , ( - ( y / max ) * multimax + 510 ) ) ;
}
else
{
curvex = Math . Min ( x , ( - ( x / max ) * multimax + 510 ) ) ;
curvey = Math . Min ( y , ( y / max ) * multimax ) ;
}
}
2017-04-16 11:54:34 +02:00
2014-12-13 21:12:03 +01:00
dState . LX = ( byte ) Math . Round ( curvex , 0 ) ;
dState . LY = ( byte ) Math . Round ( curvey , 0 ) ;
}
2017-03-27 11:55:53 +02:00
2017-04-25 16:10:36 +02:00
/* TODO: Look into curve options and make sure maximum axes values are being respected */
2017-03-31 03:00:17 +02:00
int rsCurve = getRSCurve ( device ) ;
2017-03-27 11:55:53 +02:00
if ( rsCurve > 0 )
2014-12-13 21:12:03 +01:00
{
x = cState . RX ;
y = cState . RY ;
float max = x + y ;
double curvex ;
double curvey ;
2017-03-27 11:55:53 +02:00
curve = rsCurve ;
2014-12-13 21:12:03 +01:00
double multimax = TValue ( 382.5 , max , curve ) ;
double multimin = TValue ( 127.5 , max , curve ) ;
if ( ( x > 127.5f & & y > 127.5f ) | | ( x < 127.5f & & y < 127.5f ) )
{
curvex = ( x > 127.5f ? Math . Min ( x , ( x / max ) * multimax ) : Math . Max ( x , ( x / max ) * multimin ) ) ;
curvey = ( y > 127.5f ? Math . Min ( y , ( y / max ) * multimax ) : Math . Max ( y , ( y / max ) * multimin ) ) ;
}
else
{
if ( x < 127.5f )
{
curvex = Math . Min ( x , ( x / max ) * multimax ) ;
curvey = Math . Min ( y , ( - ( y / max ) * multimax + 510 ) ) ;
}
else
{
curvex = Math . Min ( x , ( - ( x / max ) * multimax + 510 ) ) ;
curvey = Math . Min ( y , ( y / max ) * multimax ) ;
}
}
2017-04-16 11:54:34 +02:00
2014-12-13 21:12:03 +01:00
dState . RX = ( byte ) Math . Round ( curvex , 0 ) ;
dState . RY = ( byte ) Math . Round ( curvey , 0 ) ;
}
2017-03-27 11:55:53 +02:00
2017-03-31 03:00:17 +02:00
int lsDeadzone = getLSDeadzone ( device ) ;
int lsAntiDead = getLSAntiDeadzone ( device ) ;
2017-05-05 18:13:12 +02:00
int lsMaxZone = getLSMaxzone ( device ) ;
if ( lsDeadzone > 0 | | lsAntiDead > 0 | | lsMaxZone ! = 100 )
2014-12-13 21:12:03 +01:00
{
2019-01-13 20:32:38 +01:00
double lsSquared = Math . Pow ( cState . LX - 128f , 2 ) + Math . Pow ( cState . LY - 128f , 2 ) ;
2017-03-27 15:02:04 +02:00
double lsDeadzoneSquared = Math . Pow ( lsDeadzone , 2 ) ;
if ( lsDeadzone > 0 & & lsSquared < = lsDeadzoneSquared )
{
2019-01-13 20:32:38 +01:00
dState . LX = 128 ;
dState . LY = 128 ;
2017-03-27 15:02:04 +02:00
}
2017-05-05 18:13:12 +02:00
else if ( ( lsDeadzone > 0 & & lsSquared > lsDeadzoneSquared ) | | lsAntiDead > 0 | | lsMaxZone ! = 100 )
2017-03-27 05:55:05 +02:00
{
2019-01-13 20:32:38 +01:00
double r = Math . Atan2 ( - ( dState . LY - 128.0 ) , ( dState . LX - 128.0 ) ) ;
double maxXValue = dState . LX > = 128.0 ? 127.0 : - 128 ;
double maxYValue = dState . LY > = 128.0 ? 127.0 : - 128 ;
2017-05-05 18:13:12 +02:00
double ratio = lsMaxZone / 100.0 ;
2019-01-13 20:32:38 +01:00
double maxZoneXNegValue = ( ratio * - 128 ) + 128 ;
double maxZoneXPosValue = ( ratio * 127 ) + 128 ;
2017-05-05 18:13:12 +02:00
double maxZoneYNegValue = maxZoneXNegValue ;
double maxZoneYPosValue = maxZoneXPosValue ;
2019-01-13 20:32:38 +01:00
double maxZoneX = dState . LX > = 128.0 ? ( maxZoneXPosValue - 128.0 ) : ( maxZoneXNegValue - 128.0 ) ;
double maxZoneY = dState . LY > = 128.0 ? ( maxZoneYPosValue - 128.0 ) : ( maxZoneYNegValue - 128.0 ) ;
2017-03-27 08:03:10 +02:00
2017-03-27 15:02:04 +02:00
double tempLsXDead = 0.0 , tempLsYDead = 0.0 ;
double tempOutputX = 0.0 , tempOutputY = 0.0 ;
if ( lsDeadzone > 0 )
2017-03-27 08:03:10 +02:00
{
2017-03-27 15:02:04 +02:00
tempLsXDead = Math . Abs ( Math . Cos ( r ) ) * ( lsDeadzone / 127.0 ) * maxXValue ;
tempLsYDead = Math . Abs ( Math . Sin ( r ) ) * ( lsDeadzone / 127.0 ) * maxYValue ;
if ( lsSquared > lsDeadzoneSquared )
{
2017-05-17 10:59:09 +02:00
double currentX = Global . Clamp ( maxZoneXNegValue , dState . LX , maxZoneXPosValue ) ;
double currentY = Global . Clamp ( maxZoneYNegValue , dState . LY , maxZoneYPosValue ) ;
2019-01-13 20:32:38 +01:00
tempOutputX = ( ( currentX - 128.0 - tempLsXDead ) / ( maxZoneX - tempLsXDead ) ) ;
tempOutputY = ( ( currentY - 128.0 - tempLsYDead ) / ( maxZoneY - tempLsYDead ) ) ;
2017-03-27 15:02:04 +02:00
}
2017-03-27 08:03:10 +02:00
}
2017-03-30 09:37:01 +02:00
else
{
2017-05-17 10:59:09 +02:00
double currentX = Global . Clamp ( maxZoneXNegValue , dState . LX , maxZoneXPosValue ) ;
double currentY = Global . Clamp ( maxZoneYNegValue , dState . LY , maxZoneYPosValue ) ;
2019-01-13 20:32:38 +01:00
tempOutputX = ( currentX - 128.0 ) / maxZoneX ;
tempOutputY = ( currentY - 128.0 ) / maxZoneY ;
2017-03-30 09:37:01 +02:00
}
2017-03-27 05:55:05 +02:00
2017-03-27 15:02:04 +02:00
double tempLsXAntiDeadPercent = 0.0 , tempLsYAntiDeadPercent = 0.0 ;
if ( lsAntiDead > 0 )
{
2017-03-30 09:37:01 +02:00
tempLsXAntiDeadPercent = ( lsAntiDead * 0.01 ) * Math . Abs ( Math . Cos ( r ) ) ;
tempLsYAntiDeadPercent = ( lsAntiDead * 0.01 ) * Math . Abs ( Math . Sin ( r ) ) ;
2017-03-27 15:02:04 +02:00
}
2017-03-27 05:55:05 +02:00
2017-03-27 15:02:04 +02:00
if ( tempOutputX > 0.0 )
{
2019-01-13 20:32:38 +01:00
dState . LX = ( byte ) ( ( ( ( 1.0 - tempLsXAntiDeadPercent ) * tempOutputX + tempLsXAntiDeadPercent ) ) * maxXValue + 128.0 ) ;
2017-03-27 15:02:04 +02:00
}
else
{
2019-01-13 20:32:38 +01:00
dState . LX = 128 ;
2017-03-27 15:02:04 +02:00
}
2017-03-27 08:03:10 +02:00
2017-03-27 15:02:04 +02:00
if ( tempOutputY > 0.0 )
{
2019-01-13 20:32:38 +01:00
dState . LY = ( byte ) ( ( ( ( 1.0 - tempLsYAntiDeadPercent ) * tempOutputY + tempLsYAntiDeadPercent ) ) * maxYValue + 128.0 ) ;
2017-03-27 15:02:04 +02:00
}
else
{
2019-01-13 20:32:38 +01:00
dState . LY = 128 ;
2017-03-27 15:02:04 +02:00
}
}
2015-04-21 21:00:09 +02:00
}
2017-03-27 15:02:04 +02:00
2017-03-31 03:00:17 +02:00
int rsDeadzone = getRSDeadzone ( device ) ;
int rsAntiDead = getRSAntiDeadzone ( device ) ;
2017-05-05 18:13:12 +02:00
int rsMaxZone = getRSMaxzone ( device ) ;
if ( rsDeadzone > 0 | | rsAntiDead > 0 | | rsMaxZone ! = 100 )
2014-12-13 21:12:03 +01:00
{
2019-01-13 20:32:38 +01:00
double rsSquared = Math . Pow ( cState . RX - 128.0 , 2 ) + Math . Pow ( cState . RY - 128.0 , 2 ) ;
2017-03-27 15:02:04 +02:00
double rsDeadzoneSquared = Math . Pow ( rsDeadzone , 2 ) ;
if ( rsDeadzone > 0 & & rsSquared < = rsDeadzoneSquared )
{
2019-01-13 20:32:38 +01:00
dState . RX = 128 ;
dState . RY = 128 ;
2017-03-27 15:02:04 +02:00
}
2017-05-05 18:13:12 +02:00
else if ( ( rsDeadzone > 0 & & rsSquared > rsDeadzoneSquared ) | | rsAntiDead > 0 | | rsMaxZone ! = 100 )
2017-03-27 05:55:05 +02:00
{
2019-01-13 20:32:38 +01:00
double r = Math . Atan2 ( - ( dState . RY - 128.0 ) , ( dState . RX - 128.0 ) ) ;
double maxXValue = dState . RX > = 128.0 ? 127 : - 128 ;
double maxYValue = dState . RY > = 128.0 ? 127 : - 128 ;
2017-05-05 18:13:12 +02:00
double ratio = rsMaxZone / 100.0 ;
2019-01-13 20:32:38 +01:00
double maxZoneXNegValue = ( ratio * - 128.0 ) + 128.0 ;
double maxZoneXPosValue = ( ratio * 127.0 ) + 128.0 ;
2017-05-05 18:13:12 +02:00
double maxZoneYNegValue = maxZoneXNegValue ;
double maxZoneYPosValue = maxZoneXPosValue ;
2019-01-13 20:32:38 +01:00
double maxZoneX = dState . RX > = 128.0 ? ( maxZoneXPosValue - 128.0 ) : ( maxZoneXNegValue - 128.0 ) ;
double maxZoneY = dState . RY > = 128.0 ? ( maxZoneYPosValue - 128.0 ) : ( maxZoneYNegValue - 128.0 ) ;
2017-03-27 08:03:10 +02:00
2017-03-27 15:02:04 +02:00
double tempRsXDead = 0.0 , tempRsYDead = 0.0 ;
double tempOutputX = 0.0 , tempOutputY = 0.0 ;
if ( rsDeadzone > 0 )
2017-03-27 08:03:10 +02:00
{
2017-03-27 15:02:04 +02:00
tempRsXDead = Math . Abs ( Math . Cos ( r ) ) * ( rsDeadzone / 127.0 ) * maxXValue ;
tempRsYDead = Math . Abs ( Math . Sin ( r ) ) * ( rsDeadzone / 127.0 ) * maxYValue ;
if ( rsSquared > rsDeadzoneSquared )
{
2017-05-17 10:59:09 +02:00
double currentX = Global . Clamp ( maxZoneXNegValue , dState . RX , maxZoneXPosValue ) ;
double currentY = Global . Clamp ( maxZoneYNegValue , dState . RY , maxZoneYPosValue ) ;
2017-05-05 18:13:12 +02:00
2019-01-13 20:32:38 +01:00
tempOutputX = ( ( currentX - 128.0 - tempRsXDead ) / ( maxZoneX - tempRsXDead ) ) ;
tempOutputY = ( ( currentY - 128.0 - tempRsYDead ) / ( maxZoneY - tempRsYDead ) ) ;
2017-03-27 15:02:04 +02:00
}
2017-03-27 08:03:10 +02:00
}
2017-03-30 09:37:01 +02:00
else
{
2017-05-17 10:59:09 +02:00
double currentX = Global . Clamp ( maxZoneXNegValue , dState . RX , maxZoneXPosValue ) ;
double currentY = Global . Clamp ( maxZoneYNegValue , dState . RY , maxZoneYPosValue ) ;
2017-05-05 18:13:12 +02:00
2019-01-13 20:32:38 +01:00
tempOutputX = ( currentX - 128.0 ) / maxZoneX ;
tempOutputY = ( currentY - 128.0 ) / maxZoneY ;
2017-03-30 09:37:01 +02:00
}
2017-03-27 05:55:05 +02:00
2017-03-27 15:02:04 +02:00
double tempRsXAntiDeadPercent = 0.0 , tempRsYAntiDeadPercent = 0.0 ;
if ( rsAntiDead > 0 )
{
2017-03-30 09:37:01 +02:00
tempRsXAntiDeadPercent = ( rsAntiDead * 0.01 ) * Math . Abs ( Math . Cos ( r ) ) ;
tempRsYAntiDeadPercent = ( rsAntiDead * 0.01 ) * Math . Abs ( Math . Sin ( r ) ) ;
2017-03-27 15:02:04 +02:00
}
2017-03-27 05:55:05 +02:00
2017-03-27 15:02:04 +02:00
if ( tempOutputX > 0.0 )
{
2019-01-13 20:32:38 +01:00
dState . RX = ( byte ) ( ( ( ( 1.0 - tempRsXAntiDeadPercent ) * tempOutputX + tempRsXAntiDeadPercent ) ) * maxXValue + 128.0 ) ;
2017-03-27 15:02:04 +02:00
}
else
{
2019-01-13 20:32:38 +01:00
dState . RX = 128 ;
2017-03-27 15:02:04 +02:00
}
2017-03-27 08:03:10 +02:00
2017-03-27 15:02:04 +02:00
if ( tempOutputY > 0.0 )
{
2019-01-13 20:32:38 +01:00
dState . RY = ( byte ) ( ( ( ( 1.0 - tempRsYAntiDeadPercent ) * tempOutputY + tempRsYAntiDeadPercent ) ) * maxYValue + 128.0 ) ;
2017-03-27 15:02:04 +02:00
}
else
{
2019-01-13 20:32:38 +01:00
dState . RY = 128 ;
2017-03-27 15:02:04 +02:00
}
}
2015-04-21 21:00:09 +02:00
}
2017-03-26 00:32:45 +01:00
2017-03-31 03:00:17 +02:00
byte l2Deadzone = getL2Deadzone ( device ) ;
int l2AntiDeadzone = getL2AntiDeadzone ( device ) ;
2017-05-05 18:13:12 +02:00
int l2Maxzone = getL2Maxzone ( device ) ;
if ( l2Deadzone > 0 | | l2AntiDeadzone > 0 | | l2Maxzone ! = 100 )
2017-03-26 00:32:45 +01:00
{
2017-07-20 07:57:14 +02:00
double tempL2Output = cState . L2 / 255.0 ;
2017-03-30 09:37:01 +02:00
double tempL2AntiDead = 0.0 ;
2017-07-20 07:57:14 +02:00
double ratio = l2Maxzone / 100.0 ;
double maxValue = 255.0 * ratio ;
2017-05-05 18:13:12 +02:00
2017-03-30 09:37:01 +02:00
if ( l2Deadzone > 0 )
{
if ( cState . L2 > l2Deadzone )
{
2017-05-17 10:59:09 +02:00
double current = Global . Clamp ( 0 , dState . L2 , maxValue ) ;
2017-07-20 07:57:14 +02:00
tempL2Output = ( current - l2Deadzone ) / ( maxValue - l2Deadzone ) ;
2017-03-30 09:37:01 +02:00
}
else
{
tempL2Output = 0.0 ;
}
}
if ( l2AntiDeadzone > 0 )
{
tempL2AntiDead = l2AntiDeadzone * 0.01 ;
}
if ( tempL2Output > 0.0 )
{
2017-07-20 07:57:14 +02:00
dState . L2 = ( byte ) ( ( ( 1.0 - tempL2AntiDead ) * tempL2Output + tempL2AntiDead ) * 255.0 ) ;
2017-03-30 09:37:01 +02:00
}
else
{
dState . L2 = 0 ;
}
2017-03-26 00:32:45 +01:00
}
2017-03-31 03:00:17 +02:00
byte r2Deadzone = getR2Deadzone ( device ) ;
int r2AntiDeadzone = getR2AntiDeadzone ( device ) ;
2017-05-05 18:13:12 +02:00
int r2Maxzone = getR2Maxzone ( device ) ;
if ( r2Deadzone > 0 | | r2AntiDeadzone > 0 | | r2Maxzone ! = 100 )
2017-03-26 00:32:45 +01:00
{
2017-07-20 07:57:14 +02:00
double tempR2Output = cState . R2 / 255.0 ;
2017-03-30 09:37:01 +02:00
double tempR2AntiDead = 0.0 ;
2017-07-20 07:57:14 +02:00
double ratio = r2Maxzone / 100.0 ;
2017-05-05 18:13:12 +02:00
double maxValue = 255 * ratio ;
2017-03-30 09:37:01 +02:00
if ( r2Deadzone > 0 )
{
if ( cState . R2 > r2Deadzone )
{
2017-05-17 10:59:09 +02:00
double current = Global . Clamp ( 0 , dState . R2 , maxValue ) ;
2017-07-20 07:57:14 +02:00
tempR2Output = ( current - r2Deadzone ) / ( maxValue - r2Deadzone ) ;
2017-03-30 09:37:01 +02:00
}
else
{
tempR2Output = 0.0 ;
}
}
if ( r2AntiDeadzone > 0 )
{
tempR2AntiDead = r2AntiDeadzone * 0.01 ;
}
if ( tempR2Output > 0.0 )
2017-03-26 00:32:45 +01:00
{
2017-07-20 07:57:14 +02:00
dState . R2 = ( byte ) ( ( ( 1.0 - tempR2AntiDead ) * tempR2Output + tempR2AntiDead ) * 255.0 ) ;
2017-03-26 00:32:45 +01:00
}
else
{
dState . R2 = 0 ;
}
}
2017-03-31 03:00:17 +02:00
double lsSens = getLSSens ( device ) ;
2017-03-26 00:42:34 +01:00
if ( lsSens ! = 1.0 )
2015-12-05 09:55:11 +01:00
{
2019-04-12 01:01:06 +02:00
dState . LX = ( byte ) Global . Clamp ( 0 , lsSens * ( dState . LX - 128.0 ) + 128.0 , 255 ) ;
dState . LY = ( byte ) Global . Clamp ( 0 , lsSens * ( dState . LY - 128.0 ) + 128.0 , 255 ) ;
2015-12-05 09:55:11 +01:00
}
2017-03-26 00:42:34 +01:00
2017-03-31 03:00:17 +02:00
double rsSens = getRSSens ( device ) ;
2017-03-26 00:42:34 +01:00
if ( rsSens ! = 1.0 )
2015-12-05 09:55:11 +01:00
{
2019-04-12 01:01:06 +02:00
dState . RX = ( byte ) Global . Clamp ( 0 , rsSens * ( dState . RX - 128.0 ) + 128.0 , 255 ) ;
dState . RY = ( byte ) Global . Clamp ( 0 , rsSens * ( dState . RY - 128.0 ) + 128.0 , 255 ) ;
2015-12-05 09:55:11 +01:00
}
2017-03-26 00:42:34 +01:00
2017-03-31 03:00:17 +02:00
double l2Sens = getL2Sens ( device ) ;
2017-03-26 00:42:34 +01:00
if ( l2Sens ! = 1.0 )
2017-05-17 10:59:09 +02:00
dState . L2 = ( byte ) Global . Clamp ( 0 , l2Sens * dState . L2 , 255 ) ;
2017-03-26 00:42:34 +01:00
2017-03-31 03:00:17 +02:00
double r2Sens = getR2Sens ( device ) ;
2017-03-26 00:42:34 +01:00
if ( r2Sens ! = 1.0 )
2017-05-17 10:59:09 +02:00
dState . R2 = ( byte ) Global . Clamp ( 0 , r2Sens * dState . R2 , 255 ) ;
2017-03-26 00:42:34 +01:00
2019-03-06 09:11:55 +01:00
if ( getSquareStickLS ( device ) & & ( dState . LX ! = 128 | | dState . LY ! = 128 ) )
2019-03-05 00:21:58 +01:00
{
double capX = dState . LX > = 128 ? 127.0 : 128.0 ;
double capY = dState . LY > = 128 ? 127.0 : 128.0 ;
double tempX = ( dState . LX - 128.0 ) / capX ;
double tempY = ( dState . LY - 128.0 ) / capY ;
DS4SquareStick sqstick = outSqrStk [ device ] ;
sqstick . current . x = tempX ; sqstick . current . y = tempY ;
sqstick . CircleToSquare ( ) ;
//Console.WriteLine("Input ({0}) | Output ({1})", tempY, sqstick.current.y);
tempX = sqstick . current . x < - 1.0 ? - 1.0 : sqstick . current . x > 1.0
? 1.0 : sqstick . current . x ;
tempY = sqstick . current . y < - 1.0 ? - 1.0 : sqstick . current . y > 1.0
? 1.0 : sqstick . current . y ;
dState . LX = ( byte ) ( tempX * capX + 128.0 ) ;
dState . LY = ( byte ) ( tempY * capY + 128.0 ) ;
}
2017-06-08 23:26:50 +02:00
int lsOutCurveMode = lsOutCurveModeArray [ device ] = getLsOutCurveMode ( device ) ;
2019-03-06 09:11:55 +01:00
if ( lsOutCurveMode > 0 & & ( dState . LX ! = 128 | | dState . LY ! = 128 ) )
2017-06-08 09:37:04 +02:00
{
2019-01-13 20:32:38 +01:00
double capX = dState . LX > = 128 ? 127.0 : 128.0 ;
double capY = dState . LY > = 128 ? 127.0 : 128.0 ;
double tempX = ( dState . LX - 128.0 ) / capX ;
double tempY = ( dState . LY - 128.0 ) / capY ;
2017-06-08 09:37:04 +02:00
double signX = tempX > = 0.0 ? 1.0 : - 1.0 ;
double signY = tempY > = 0.0 ? 1.0 : - 1.0 ;
if ( lsOutCurveMode = = 1 )
{
double absX = Math . Abs ( tempX ) ;
double absY = Math . Abs ( tempY ) ;
double outputX = 0.0 ;
double outputY = 0.0 ;
if ( absX < = 0.4 )
{
2018-12-15 19:26:52 +01:00
outputX = 0.544 * absX ;
2017-06-08 09:37:04 +02:00
}
else if ( absX < = 0.75 )
{
2018-12-15 19:26:52 +01:00
outputX = absX - 0.1824 ;
2017-06-08 09:37:04 +02:00
}
else if ( absX > 0.75 )
{
2018-12-15 19:26:52 +01:00
outputX = ( absX * 1.7296 ) - 0.7296 ;
2017-06-08 09:37:04 +02:00
}
if ( absY < = 0.4 )
{
2018-12-15 19:26:52 +01:00
outputY = 0.544 * absY ;
2017-06-08 09:37:04 +02:00
}
else if ( absY < = 0.75 )
{
2018-12-15 19:26:52 +01:00
outputY = absY - 0.1824 ;
2017-06-08 09:37:04 +02:00
}
else if ( absY > 0.75 )
{
2018-12-15 19:26:52 +01:00
outputY = ( absY * 1.7296 ) - 0.7296 ;
2017-06-08 09:37:04 +02:00
}
2019-01-13 20:32:38 +01:00
dState . LX = ( byte ) ( outputX * signX * capX + 128.0 ) ;
dState . LY = ( byte ) ( outputY * signY * capY + 128.0 ) ;
2017-06-08 09:37:04 +02:00
}
else if ( lsOutCurveMode = = 2 )
{
double outputX = tempX * tempX ;
double outputY = tempY * tempY ;
2019-01-13 20:32:38 +01:00
dState . LX = ( byte ) ( outputX * signX * capX + 128.0 ) ;
dState . LY = ( byte ) ( outputY * signY * capY + 128.0 ) ;
2017-06-08 09:37:04 +02:00
}
else if ( lsOutCurveMode = = 3 )
{
double outputX = tempX * tempX * tempX ;
double outputY = tempY * tempY * tempY ;
2019-01-13 20:32:38 +01:00
dState . LX = ( byte ) ( outputX * capX + 128.0 ) ;
dState . LY = ( byte ) ( outputY * capY + 128.0 ) ;
2017-06-08 09:37:04 +02:00
}
2019-01-30 04:19:25 +01:00
else if ( lsOutCurveMode = = 4 )
{
double absX = Math . Abs ( tempX ) ;
double absY = Math . Abs ( tempY ) ;
double outputX = absX * ( absX - 2.0 ) ;
double outputY = absY * ( absY - 2.0 ) ;
dState . LX = ( byte ) ( - 1.0 * outputX * signX * capX + 128.0 ) ;
dState . LY = ( byte ) ( - 1.0 * outputY * signY * capY + 128.0 ) ;
}
2017-06-08 09:37:04 +02:00
}
2019-03-06 09:11:55 +01:00
if ( getSquareStickRS ( device ) & & ( dState . RX ! = 128 | | dState . RY ! = 128 ) )
2019-03-05 00:21:58 +01:00
{
double capX = dState . RX > = 128 ? 127.0 : 128.0 ;
double capY = dState . RY > = 128 ? 127.0 : 128.0 ;
double tempX = ( dState . RX - 128.0 ) / capX ;
double tempY = ( dState . RY - 128.0 ) / capY ;
DS4SquareStick sqstick = outSqrStk [ device ] ;
sqstick . current . x = tempX ; sqstick . current . y = tempY ;
sqstick . CircleToSquare ( ) ;
tempX = sqstick . current . x < - 1.0 ? - 1.0 : sqstick . current . x > 1.0
? 1.0 : sqstick . current . x ;
tempY = sqstick . current . y < - 1.0 ? - 1.0 : sqstick . current . y > 1.0
? 1.0 : sqstick . current . y ;
//Console.WriteLine("Input ({0}) | Output ({1})", tempY, sqstick.current.y);
dState . RX = ( byte ) ( tempX * capX + 128.0 ) ;
dState . RY = ( byte ) ( tempY * capY + 128.0 ) ;
}
2017-06-08 23:26:50 +02:00
int rsOutCurveMode = rsOutCurveModeArray [ device ] = getRsOutCurveMode ( device ) ;
2019-03-06 09:11:55 +01:00
if ( rsOutCurveMode > 0 & & ( dState . RX ! = 128 | | dState . RY ! = 128 ) )
2017-06-08 09:37:04 +02:00
{
2019-01-13 20:32:38 +01:00
double capX = dState . RX > = 128 ? 127.0 : 128.0 ;
double capY = dState . RY > = 128 ? 127.0 : 128.0 ;
double tempX = ( dState . RX - 128.0 ) / capX ;
double tempY = ( dState . RY - 128.0 ) / capY ;
2017-06-08 09:37:04 +02:00
double signX = tempX > = 0.0 ? 1.0 : - 1.0 ;
double signY = tempY > = 0.0 ? 1.0 : - 1.0 ;
if ( rsOutCurveMode = = 1 )
{
double absX = Math . Abs ( tempX ) ;
double absY = Math . Abs ( tempY ) ;
double outputX = 0.0 ;
double outputY = 0.0 ;
if ( absX < = 0.4 )
{
2018-12-14 10:54:26 +01:00
outputX = 0.544 * absX ;
2017-06-08 09:37:04 +02:00
}
else if ( absX < = 0.75 )
{
2018-12-14 10:54:26 +01:00
outputX = absX - 0.1824 ;
2017-06-08 09:37:04 +02:00
}
else if ( absX > 0.75 )
{
2018-12-14 10:54:26 +01:00
outputX = ( absX * 1.7296 ) - 0.7296 ;
2017-06-08 09:37:04 +02:00
}
if ( absY < = 0.4 )
{
2018-12-14 10:54:26 +01:00
outputY = 0.544 * absY ;
2017-06-08 09:37:04 +02:00
}
else if ( absY < = 0.75 )
{
2018-12-14 10:54:26 +01:00
outputY = absY - 0.1824 ;
2017-06-08 09:37:04 +02:00
}
else if ( absY > 0.75 )
{
2018-12-14 10:54:26 +01:00
outputY = ( absY * 1.7296 ) - 0.7296 ;
2017-06-08 09:37:04 +02:00
}
2019-01-13 20:32:38 +01:00
dState . RX = ( byte ) ( outputX * signX * capX + 128.0 ) ;
dState . RY = ( byte ) ( outputY * signY * capY + 128.0 ) ;
2017-06-08 09:37:04 +02:00
}
else if ( rsOutCurveMode = = 2 )
{
double outputX = tempX * tempX ;
double outputY = tempY * tempY ;
2019-01-13 20:32:38 +01:00
dState . RX = ( byte ) ( outputX * signX * capX + 128.0 ) ;
dState . RY = ( byte ) ( outputY * signY * capY + 128.0 ) ;
2017-06-08 09:37:04 +02:00
}
else if ( rsOutCurveMode = = 3 )
{
double outputX = tempX * tempX * tempX ;
double outputY = tempY * tempY * tempY ;
2019-01-13 20:32:38 +01:00
dState . RX = ( byte ) ( outputX * capX + 128.0 ) ;
dState . RY = ( byte ) ( outputY * capY + 128.0 ) ;
2017-07-19 22:15:59 +02:00
}
2019-01-30 04:19:25 +01:00
else if ( rsOutCurveMode = = 4 )
{
double absX = Math . Abs ( tempX ) ;
double absY = Math . Abs ( tempY ) ;
double outputX = absX * ( absX - 2.0 ) ;
double outputY = absY * ( absY - 2.0 ) ;
dState . RX = ( byte ) ( - 1.0 * outputX * signX * capX + 128.0 ) ;
dState . RY = ( byte ) ( - 1.0 * outputY * signY * capY + 128.0 ) ;
}
2017-07-19 22:15:59 +02:00
}
2017-07-20 07:57:14 +02:00
int l2OutCurveMode = tempIntArray [ device ] = getL2OutCurveMode ( device ) ;
2019-03-06 09:11:55 +01:00
if ( l2OutCurveMode > 0 & & dState . L2 ! = 0 )
2017-07-19 22:15:59 +02:00
{
double temp = dState . L2 / 255.0 ;
if ( l2OutCurveMode = = 1 )
{
double output = temp * temp ;
dState . L2 = ( byte ) ( output * 255.0 ) ;
}
else if ( l2OutCurveMode = = 2 )
{
double output = temp * temp * temp ;
dState . L2 = ( byte ) ( output * 255.0 ) ;
}
2019-01-30 04:50:29 +01:00
else if ( l2OutCurveMode = = 3 )
{
double output = temp * ( temp - 2.0 ) ;
dState . L2 = ( byte ) ( - 1.0 * output * 255.0 ) ;
}
2017-07-19 22:15:59 +02:00
}
2017-07-20 07:57:14 +02:00
int r2OutCurveMode = tempIntArray [ device ] = getR2OutCurveMode ( device ) ;
2019-03-06 09:11:55 +01:00
if ( r2OutCurveMode > 0 & & dState . R2 ! = 0 )
2017-07-19 22:15:59 +02:00
{
double temp = dState . R2 / 255.0 ;
if ( r2OutCurveMode = = 1 )
{
double output = temp * temp ;
dState . R2 = ( byte ) ( output * 255.0 ) ;
}
else if ( r2OutCurveMode = = 2 )
{
double output = temp * temp * temp ;
dState . R2 = ( byte ) ( output * 255.0 ) ;
2017-06-08 09:37:04 +02:00
}
2019-01-30 04:50:29 +01:00
else if ( r2OutCurveMode = = 3 )
{
double output = temp * ( temp - 2.0 ) ;
dState . R2 = ( byte ) ( - 1.0 * output * 255.0 ) ;
}
2017-06-08 09:37:04 +02:00
}
2017-07-18 22:37:01 +02:00
bool sOff = tempBool = isUsingSAforMouse ( device ) ;
if ( sOff = = false )
2017-07-18 21:21:03 +02:00
{
2017-12-21 05:19:40 +01:00
int SXD = ( int ) ( 128d * getSXDeadzone ( device ) ) ;
int SZD = ( int ) ( 128d * getSZDeadzone ( device ) ) ;
2017-07-19 00:28:16 +02:00
double SXMax = getSXMaxzone ( device ) ;
double SZMax = getSZMaxzone ( device ) ;
2017-07-19 02:44:55 +02:00
double sxAntiDead = getSXAntiDeadzone ( device ) ;
double szAntiDead = getSZAntiDeadzone ( device ) ;
2017-07-18 21:21:03 +02:00
double sxsens = getSXSens ( device ) ;
double szsens = getSZSens ( device ) ;
2018-01-13 13:14:52 +01:00
int result = 0 ;
2017-07-18 21:21:03 +02:00
2017-07-19 02:44:55 +02:00
int gyroX = cState . Motion . accelX , gyroZ = cState . Motion . accelZ ;
int absx = Math . Abs ( gyroX ) , absz = Math . Abs ( gyroZ ) ;
2017-07-18 21:21:03 +02:00
2017-07-19 02:44:55 +02:00
if ( SXD > 0 | | SXMax < 1.0 | | sxAntiDead > 0 )
2017-07-18 21:21:03 +02:00
{
2017-07-19 00:28:16 +02:00
int maxValue = ( int ) ( SXMax * 128d ) ;
2017-07-18 21:21:03 +02:00
if ( absx > SXD )
{
2017-07-19 03:18:01 +02:00
double ratioX = absx < maxValue ? ( absx - SXD ) / ( double ) ( maxValue - SXD ) : 1.0 ;
2017-08-09 03:19:17 +02:00
dState . Motion . outputAccelX = Math . Sign ( gyroX ) *
2017-07-19 02:44:55 +02:00
( int ) Math . Min ( 128d , sxsens * 128d * ( ( 1.0 - sxAntiDead ) * ratioX + sxAntiDead ) ) ;
2017-07-18 21:21:03 +02:00
}
else
{
2017-08-09 03:19:17 +02:00
dState . Motion . outputAccelX = 0 ;
2017-07-18 21:21:03 +02:00
}
}
else
{
2017-08-09 03:19:17 +02:00
dState . Motion . outputAccelX = Math . Sign ( gyroX ) *
2017-07-19 00:28:16 +02:00
( int ) Math . Min ( 128d , sxsens * 128d * ( absx / 128d ) ) ;
2017-07-18 21:21:03 +02:00
}
2017-07-19 02:44:55 +02:00
if ( SZD > 0 | | SZMax < 1.0 | | szAntiDead > 0 )
2017-07-18 21:21:03 +02:00
{
2017-07-19 00:28:16 +02:00
int maxValue = ( int ) ( SZMax * 128d ) ;
2017-07-18 21:21:03 +02:00
if ( absz > SZD )
{
2017-07-19 03:18:01 +02:00
double ratioZ = absz < maxValue ? ( absz - SZD ) / ( double ) ( maxValue - SZD ) : 1.0 ;
2017-08-09 03:19:17 +02:00
dState . Motion . outputAccelZ = Math . Sign ( gyroZ ) *
2017-07-19 02:44:55 +02:00
( int ) Math . Min ( 128d , szsens * 128d * ( ( 1.0 - szAntiDead ) * ratioZ + szAntiDead ) ) ;
2017-07-18 21:21:03 +02:00
}
else
{
2017-08-09 03:19:17 +02:00
dState . Motion . outputAccelZ = 0 ;
2017-07-18 21:21:03 +02:00
}
}
else
{
2017-08-09 03:19:17 +02:00
dState . Motion . outputAccelZ = Math . Sign ( gyroZ ) *
2017-07-19 02:44:55 +02:00
( int ) Math . Min ( 128d , szsens * 128d * ( absz / 128d ) ) ;
2017-07-18 21:21:03 +02:00
}
2017-07-20 01:17:11 +02:00
int sxOutCurveMode = tempIntArray [ device ] = getSXOutCurveMode ( device ) ;
2019-03-06 09:11:55 +01:00
if ( sxOutCurveMode > 0 & & dState . Motion . outputAccelX ! = 0 )
2017-07-20 01:17:11 +02:00
{
2018-01-13 11:00:57 +01:00
double temp = dState . Motion . outputAccelX / 128.0 ;
2017-07-20 01:17:11 +02:00
double sign = Math . Sign ( temp ) ;
if ( sxOutCurveMode = = 1 )
{
double output = temp * temp ;
2018-01-13 13:14:52 +01:00
result = ( int ) ( output * sign * 128.0 ) ;
dState . Motion . outputAccelX = result ;
2017-07-20 01:17:11 +02:00
}
else if ( sxOutCurveMode = = 2 )
{
double output = temp * temp * temp ;
2018-01-13 13:14:52 +01:00
result = ( int ) ( output * 128.0 ) ;
dState . Motion . outputAccelX = result ;
2017-07-20 01:17:11 +02:00
}
2019-01-30 04:50:29 +01:00
else if ( sxOutCurveMode = = 3 )
{
2019-01-30 05:11:01 +01:00
double abs = Math . Abs ( temp ) ;
double output = abs * ( abs - 2.0 ) ;
dState . Motion . outputAccelX = ( byte ) ( - 1.0 * output *
sign * 128.0 ) ;
2019-01-30 04:50:29 +01:00
}
2017-07-20 01:17:11 +02:00
}
int szOutCurveMode = tempIntArray [ device ] = getSZOutCurveMode ( device ) ;
2019-03-06 09:11:55 +01:00
if ( szOutCurveMode > 0 & & dState . Motion . outputAccelZ ! = 0 )
2017-07-20 01:17:11 +02:00
{
2018-01-13 11:00:57 +01:00
double temp = dState . Motion . outputAccelZ / 128.0 ;
2017-07-20 01:17:11 +02:00
double sign = Math . Sign ( temp ) ;
if ( szOutCurveMode = = 1 )
{
double output = temp * temp ;
2018-01-13 13:14:52 +01:00
result = ( int ) ( output * sign * 128.0 ) ;
dState . Motion . outputAccelZ = result ;
2017-07-20 01:17:11 +02:00
}
else if ( szOutCurveMode = = 2 )
{
double output = temp * temp * temp ;
2018-01-13 13:14:52 +01:00
result = ( int ) ( output * 128.0 ) ;
dState . Motion . outputAccelZ = result ;
2017-07-20 01:17:11 +02:00
}
2019-01-30 04:50:29 +01:00
else if ( szOutCurveMode = = 3 )
{
2019-01-30 05:11:01 +01:00
double abs = Math . Abs ( temp ) ;
double output = abs * ( abs - 2.0 ) ;
dState . Motion . outputAccelZ = ( byte ) ( - 1.0 * output *
sign * 128.0 ) ;
2019-01-30 04:50:29 +01:00
}
2017-07-20 01:17:11 +02:00
}
2017-07-18 21:21:03 +02:00
}
2014-12-13 21:12:03 +01:00
return dState ;
}
2017-04-22 04:58:27 +02:00
/* TODO: Possibly remove usage of this version of the method */
2015-12-18 07:25:51 +01:00
private static bool ShiftTrigger ( int trigger , int device , DS4State cState , DS4StateExposed eState , Mouse tp )
{
2017-04-08 11:00:50 +02:00
bool result = false ;
if ( trigger = = 0 )
{
result = false ;
}
else
2015-12-18 07:25:51 +01:00
{
2017-04-08 11:00:50 +02:00
DS4Controls ds = shiftTriggerMapping [ trigger ] ;
result = getBoolMapping ( device , ds , cState , eState , tp ) ;
2015-12-18 07:25:51 +01:00
}
2017-04-08 11:00:50 +02:00
return result ;
2015-12-18 07:25:51 +01:00
}
2017-04-08 11:00:50 +02:00
2017-04-21 15:29:25 +02:00
private static bool ShiftTrigger2 ( int trigger , int device , DS4State cState , DS4StateExposed eState , Mouse tp , DS4StateFieldMapping fieldMapping )
{
bool result = false ;
if ( trigger = = 0 )
{
result = false ;
}
2017-07-23 03:48:04 +02:00
else if ( trigger < 26 )
2017-04-21 15:29:25 +02:00
{
DS4Controls ds = shiftTriggerMapping [ trigger ] ;
result = getBoolMapping2 ( device , ds , cState , eState , tp , fieldMapping ) ;
}
2017-07-23 03:48:04 +02:00
else if ( trigger = = 26 )
{
result = cState . Touch1Finger ;
}
2017-04-21 15:29:25 +02:00
return result ;
}
2015-12-18 07:25:51 +01:00
private static X360Controls getX360ControlsByName ( string key )
{
X360Controls x3c ;
if ( Enum . TryParse ( key , true , out x3c ) )
return x3c ;
2017-07-18 22:37:01 +02:00
2015-12-18 07:25:51 +01:00
switch ( key )
{
case "Back" : return X360Controls . Back ;
case "Left Stick" : return X360Controls . LS ;
case "Right Stick" : return X360Controls . RS ;
case "Start" : return X360Controls . Start ;
case "Up Button" : return X360Controls . DpadUp ;
case "Right Button" : return X360Controls . DpadRight ;
case "Down Button" : return X360Controls . DpadDown ;
case "Left Button" : return X360Controls . DpadLeft ;
case "Left Bumper" : return X360Controls . LB ;
case "Right Bumper" : return X360Controls . RB ;
case "Y Button" : return X360Controls . Y ;
case "B Button" : return X360Controls . B ;
case "A Button" : return X360Controls . A ;
case "X Button" : return X360Controls . X ;
case "Guide" : return X360Controls . Guide ;
case "Left X-Axis-" : return X360Controls . LXNeg ;
case "Left Y-Axis-" : return X360Controls . LYNeg ;
case "Right X-Axis-" : return X360Controls . RXNeg ;
case "Right Y-Axis-" : return X360Controls . RYNeg ;
case "Left X-Axis+" : return X360Controls . LXPos ;
case "Left Y-Axis+" : return X360Controls . LYPos ;
case "Right X-Axis+" : return X360Controls . RXPos ;
case "Right Y-Axis+" : return X360Controls . RYPos ;
case "Left Trigger" : return X360Controls . LT ;
case "Right Trigger" : return X360Controls . RT ;
case "Left Mouse Button" : return X360Controls . LeftMouse ;
case "Right Mouse Button" : return X360Controls . RightMouse ;
case "Middle Mouse Button" : return X360Controls . MiddleMouse ;
case "4th Mouse Button" : return X360Controls . FourthMouse ;
case "5th Mouse Button" : return X360Controls . FifthMouse ;
case "Mouse Wheel Up" : return X360Controls . WUP ;
case "Mouse Wheel Down" : return X360Controls . WDOWN ;
case "Mouse Up" : return X360Controls . MouseUp ;
case "Mouse Down" : return X360Controls . MouseDown ;
case "Mouse Left" : return X360Controls . MouseLeft ;
case "Mouse Right" : return X360Controls . MouseRight ;
case "Unbound" : return X360Controls . Unbound ;
2017-07-18 22:37:01 +02:00
default : break ;
2015-12-18 07:25:51 +01:00
}
2017-07-18 22:37:01 +02:00
2015-12-18 07:25:51 +01:00
return X360Controls . Unbound ;
}
2014-12-17 19:29:22 +01:00
/// <summary>
/// Map DS4 Buttons/Axes to other DS4 Buttons/Axes (largely the same as Xinput ones) and to keyboard and mouse buttons.
/// </summary>
2015-12-18 07:25:51 +01:00
static bool [ ] held = new bool [ 4 ] ;
static int [ ] oldmouse = new int [ 4 ] { - 1 , - 1 , - 1 , - 1 } ;
2017-04-11 09:57:22 +02:00
public static void MapCustom ( int device , DS4State cState , DS4State MappedState , DS4StateExposed eState ,
Mouse tp , ControlService ctrl )
2014-04-27 21:32:09 +02:00
{
2017-03-29 03:41:17 +02:00
/* TODO: This method is slow sauce. Find ways to speed up action execution */
2017-04-14 09:55:22 +02:00
double tempMouseDeltaX = 0.0 ;
double tempMouseDeltaY = 0.0 ;
int mouseDeltaX = 0 ;
int mouseDeltaY = 0 ;
2017-04-21 11:48:13 +02:00
cState . calculateStickAngles ( ) ;
2017-11-17 09:50:37 +01:00
DS4StateFieldMapping fieldMapping = fieldMappings [ device ] ;
fieldMapping . populateFieldMapping ( cState , eState , tp ) ;
DS4StateFieldMapping outputfieldMapping = outputFieldMappings [ device ] ;
outputfieldMapping . populateFieldMapping ( cState , eState , tp ) ;
//DS4StateFieldMapping fieldMapping = new DS4StateFieldMapping(cState, eState, tp);
//DS4StateFieldMapping outputfieldMapping = new DS4StateFieldMapping(cState, eState, tp);
2017-04-24 11:43:56 +02:00
2014-04-27 21:32:09 +02:00
SyntheticState deviceState = Mapping . deviceState [ device ] ;
2019-03-05 12:14:39 +01:00
if ( getProfileActionCount ( device ) > 0 | | useTempProfile [ device ] )
2017-04-24 11:43:56 +02:00
MapCustomAction ( device , cState , MappedState , eState , tp , ctrl , fieldMapping , outputfieldMapping ) ;
2019-03-09 00:09:36 +01:00
//if (ctrl.DS4Controllers[device] == null) return;
2015-12-18 07:25:51 +01:00
2019-02-09 04:04:08 +01:00
//cState.CopyTo(MappedState);
Shift modifier: Hold an action to use another set of controls, if nothing is set to the shifted control, in falls back to the default action
View input of controls in profiles, see exactly when a deadzone is passed and check the input delay for controllers (special thanks to jhebbel), click the on sixaxis panel
Click the Empty text on in the lightbar box to copy the lightbar color from full to empty.
While opened, option to keep the window size after closing the profile's settings
Old profiles are automatically upgraded if it's missing new settings, such as how colors are now saved, sixaxis deadzones, and shift controls
Other UI changes for profile settings, flipped touchpad and other settings boxes
Others:
Fix for when clicking the semicolon in the select an action screen
Fix assigning Sixaxis action to a key
minor UI changes and bug fixes, such as auto resize of the log listview
DS4Updater: Also now works for the new numbering system, can read the version number right from the exe instead of in profiles.xml, UI additions to better notify users of errors, Bug fixes for non-portable users
2014-07-07 21:22:42 +02:00
2019-01-31 23:19:08 +01:00
//Dictionary<DS4Controls, DS4Controls> tempControlDict = new Dictionary<DS4Controls, DS4Controls>();
2017-04-24 11:43:56 +02:00
//MultiValueDict<DS4Controls, DS4Controls> tempControlDict = new MultiValueDict<DS4Controls, DS4Controls>();
2015-12-18 07:25:51 +01:00
DS4Controls usingExtra = DS4Controls . None ;
2017-04-11 10:13:27 +02:00
List < DS4ControlSettings > tempSettingsList = getDS4CSettings ( device ) ;
//foreach (DS4ControlSettings dcs in getDS4CSettings(device))
2019-02-16 22:49:36 +01:00
//for (int settingIndex = 0, arlen = tempSettingsList.Count; settingIndex < arlen; settingIndex++)
for ( var settingEnum = tempSettingsList . GetEnumerator ( ) ; settingEnum . MoveNext ( ) ; )
Shift modifier: Hold an action to use another set of controls, if nothing is set to the shifted control, in falls back to the default action
View input of controls in profiles, see exactly when a deadzone is passed and check the input delay for controllers (special thanks to jhebbel), click the on sixaxis panel
Click the Empty text on in the lightbar box to copy the lightbar color from full to empty.
While opened, option to keep the window size after closing the profile's settings
Old profiles are automatically upgraded if it's missing new settings, such as how colors are now saved, sixaxis deadzones, and shift controls
Other UI changes for profile settings, flipped touchpad and other settings boxes
Others:
Fix for when clicking the semicolon in the select an action screen
Fix assigning Sixaxis action to a key
minor UI changes and bug fixes, such as auto resize of the log listview
DS4Updater: Also now works for the new numbering system, can read the version number right from the exe instead of in profiles.xml, UI additions to better notify users of errors, Bug fixes for non-portable users
2014-07-07 21:22:42 +02:00
{
2019-02-16 22:49:36 +01:00
//DS4ControlSettings dcs = tempSettingsList[settingIndex];
DS4ControlSettings dcs = settingEnum . Current ;
2015-12-18 07:25:51 +01:00
object action = null ;
DS4ControlSettings . ActionType actionType = 0 ;
DS4KeyType keyType = DS4KeyType . None ;
2017-04-21 15:29:25 +02:00
if ( dcs . shiftAction ! = null & & ShiftTrigger2 ( dcs . shiftTrigger , device , cState , eState , tp , fieldMapping ) )
2015-12-18 07:25:51 +01:00
{
action = dcs . shiftAction ;
actionType = dcs . shiftActionType ;
keyType = dcs . shiftKeyType ;
}
else if ( dcs . action ! = null )
{
action = dcs . action ;
actionType = dcs . actionType ;
keyType = dcs . keyType ;
}
2017-04-08 02:13:19 +02:00
2017-10-26 08:37:21 +02:00
if ( usingExtra = = DS4Controls . None | | usingExtra = = dcs . control )
{
2017-11-01 00:36:48 +01:00
bool shiftE = ! string . IsNullOrEmpty ( dcs . shiftExtras ) & & ShiftTrigger2 ( dcs . shiftTrigger , device , cState , eState , tp , fieldMapping ) ;
bool regE = ! string . IsNullOrEmpty ( dcs . extras ) ;
2017-10-26 08:37:21 +02:00
if ( ( regE | | shiftE ) & & getBoolActionMapping2 ( device , dcs . control , cState , eState , tp , fieldMapping ) )
{
usingExtra = dcs . control ;
string p ;
if ( shiftE )
p = dcs . shiftExtras ;
else
p = dcs . extras ;
string [ ] extraS = p . Split ( ',' ) ;
int extrasSLen = extraS . Length ;
int [ ] extras = new int [ extrasSLen ] ;
for ( int i = 0 ; i < extrasSLen ; i + + )
{
int b ;
if ( int . TryParse ( extraS [ i ] , out b ) )
extras [ i ] = b ;
}
held [ device ] = true ;
try
{
if ( ! ( extras [ 0 ] = = extras [ 1 ] & & extras [ 1 ] = = 0 ) )
ctrl . setRumble ( ( byte ) extras [ 0 ] , ( byte ) extras [ 1 ] , device ) ;
if ( extras [ 2 ] = = 1 )
{
DS4Color color = new DS4Color { red = ( byte ) extras [ 3 ] , green = ( byte ) extras [ 4 ] , blue = ( byte ) extras [ 5 ] } ;
DS4LightBar . forcedColor [ device ] = color ;
DS4LightBar . forcedFlash [ device ] = ( byte ) extras [ 6 ] ;
DS4LightBar . forcelight [ device ] = true ;
}
if ( extras [ 7 ] = = 1 )
{
if ( oldmouse [ device ] = = - 1 )
oldmouse [ device ] = ButtonMouseSensitivity [ device ] ;
ButtonMouseSensitivity [ device ] = extras [ 8 ] ;
}
}
catch { }
}
else if ( ( regE | | shiftE ) & & held [ device ] )
{
DS4LightBar . forcelight [ device ] = false ;
DS4LightBar . forcedFlash [ device ] = 0 ;
2018-03-18 12:42:12 +01:00
if ( oldmouse [ device ] ! = - 1 )
{
ButtonMouseSensitivity [ device ] = oldmouse [ device ] ;
oldmouse [ device ] = - 1 ;
}
2017-10-26 08:37:21 +02:00
ctrl . setRumble ( 0 , 0 , device ) ;
held [ device ] = false ;
usingExtra = DS4Controls . None ;
}
}
2015-12-18 07:25:51 +01:00
if ( action ! = null )
Shift modifier: Hold an action to use another set of controls, if nothing is set to the shifted control, in falls back to the default action
View input of controls in profiles, see exactly when a deadzone is passed and check the input delay for controllers (special thanks to jhebbel), click the on sixaxis panel
Click the Empty text on in the lightbar box to copy the lightbar color from full to empty.
While opened, option to keep the window size after closing the profile's settings
Old profiles are automatically upgraded if it's missing new settings, such as how colors are now saved, sixaxis deadzones, and shift controls
Other UI changes for profile settings, flipped touchpad and other settings boxes
Others:
Fix for when clicking the semicolon in the select an action screen
Fix assigning Sixaxis action to a key
minor UI changes and bug fixes, such as auto resize of the log listview
DS4Updater: Also now works for the new numbering system, can read the version number right from the exe instead of in profiles.xml, UI additions to better notify users of errors, Bug fixes for non-portable users
2014-07-07 21:22:42 +02:00
{
2015-12-18 07:25:51 +01:00
if ( actionType = = DS4ControlSettings . ActionType . Macro )
Shift modifier: Hold an action to use another set of controls, if nothing is set to the shifted control, in falls back to the default action
View input of controls in profiles, see exactly when a deadzone is passed and check the input delay for controllers (special thanks to jhebbel), click the on sixaxis panel
Click the Empty text on in the lightbar box to copy the lightbar color from full to empty.
While opened, option to keep the window size after closing the profile's settings
Old profiles are automatically upgraded if it's missing new settings, such as how colors are now saved, sixaxis deadzones, and shift controls
Other UI changes for profile settings, flipped touchpad and other settings boxes
Others:
Fix for when clicking the semicolon in the select an action screen
Fix assigning Sixaxis action to a key
minor UI changes and bug fixes, such as auto resize of the log listview
DS4Updater: Also now works for the new numbering system, can read the version number right from the exe instead of in profiles.xml, UI additions to better notify users of errors, Bug fixes for non-portable users
2014-07-07 21:22:42 +02:00
{
2017-04-21 11:48:13 +02:00
bool active = getBoolMapping2 ( device , dcs . control , cState , eState , tp , fieldMapping ) ;
if ( active )
2015-12-18 07:25:51 +01:00
{
PlayMacro ( device , macroControl , string . Join ( "/" , ( int [ ] ) action ) , dcs . control , keyType ) ;
}
2017-04-21 11:48:13 +02:00
else
2015-12-18 07:25:51 +01:00
{
EndMacro ( device , macroControl , string . Join ( "/" , ( int [ ] ) action ) , dcs . control ) ;
}
2017-05-12 16:48:58 +02:00
// erase default mappings for things that are remapped
resetToDefaultValue2 ( dcs . control , MappedState , outputfieldMapping ) ;
Shift modifier: Hold an action to use another set of controls, if nothing is set to the shifted control, in falls back to the default action
View input of controls in profiles, see exactly when a deadzone is passed and check the input delay for controllers (special thanks to jhebbel), click the on sixaxis panel
Click the Empty text on in the lightbar box to copy the lightbar color from full to empty.
While opened, option to keep the window size after closing the profile's settings
Old profiles are automatically upgraded if it's missing new settings, such as how colors are now saved, sixaxis deadzones, and shift controls
Other UI changes for profile settings, flipped touchpad and other settings boxes
Others:
Fix for when clicking the semicolon in the select an action screen
Fix assigning Sixaxis action to a key
minor UI changes and bug fixes, such as auto resize of the log listview
DS4Updater: Also now works for the new numbering system, can read the version number right from the exe instead of in profiles.xml, UI additions to better notify users of errors, Bug fixes for non-portable users
2014-07-07 21:22:42 +02:00
}
2015-12-18 07:25:51 +01:00
else if ( actionType = = DS4ControlSettings . ActionType . Key )
Shift modifier: Hold an action to use another set of controls, if nothing is set to the shifted control, in falls back to the default action
View input of controls in profiles, see exactly when a deadzone is passed and check the input delay for controllers (special thanks to jhebbel), click the on sixaxis panel
Click the Empty text on in the lightbar box to copy the lightbar color from full to empty.
While opened, option to keep the window size after closing the profile's settings
Old profiles are automatically upgraded if it's missing new settings, such as how colors are now saved, sixaxis deadzones, and shift controls
Other UI changes for profile settings, flipped touchpad and other settings boxes
Others:
Fix for when clicking the semicolon in the select an action screen
Fix assigning Sixaxis action to a key
minor UI changes and bug fixes, such as auto resize of the log listview
DS4Updater: Also now works for the new numbering system, can read the version number right from the exe instead of in profiles.xml, UI additions to better notify users of errors, Bug fixes for non-portable users
2014-07-07 21:22:42 +02:00
{
2017-05-04 17:42:27 +02:00
ushort value = Convert . ToUInt16 ( action ) ;
2017-04-21 11:48:13 +02:00
if ( getBoolActionMapping2 ( device , dcs . control , cState , eState , tp , fieldMapping ) )
Shift modifier: Hold an action to use another set of controls, if nothing is set to the shifted control, in falls back to the default action
View input of controls in profiles, see exactly when a deadzone is passed and check the input delay for controllers (special thanks to jhebbel), click the on sixaxis panel
Click the Empty text on in the lightbar box to copy the lightbar color from full to empty.
While opened, option to keep the window size after closing the profile's settings
Old profiles are automatically upgraded if it's missing new settings, such as how colors are now saved, sixaxis deadzones, and shift controls
Other UI changes for profile settings, flipped touchpad and other settings boxes
Others:
Fix for when clicking the semicolon in the select an action screen
Fix assigning Sixaxis action to a key
minor UI changes and bug fixes, such as auto resize of the log listview
DS4Updater: Also now works for the new numbering system, can read the version number right from the exe instead of in profiles.xml, UI additions to better notify users of errors, Bug fixes for non-portable users
2014-07-07 21:22:42 +02:00
{
2015-12-18 07:25:51 +01:00
SyntheticState . KeyPresses kp ;
if ( ! deviceState . keyPresses . TryGetValue ( value , out kp ) )
deviceState . keyPresses [ value ] = kp = new SyntheticState . KeyPresses ( ) ;
2017-04-21 15:29:25 +02:00
2015-12-18 07:25:51 +01:00
if ( keyType . HasFlag ( DS4KeyType . ScanCode ) )
kp . current . scanCodeCount + + ;
else
kp . current . vkCount + + ;
2017-04-21 15:29:25 +02:00
2015-12-18 07:25:51 +01:00
if ( keyType . HasFlag ( DS4KeyType . Toggle ) )
Shift modifier: Hold an action to use another set of controls, if nothing is set to the shifted control, in falls back to the default action
View input of controls in profiles, see exactly when a deadzone is passed and check the input delay for controllers (special thanks to jhebbel), click the on sixaxis panel
Click the Empty text on in the lightbar box to copy the lightbar color from full to empty.
While opened, option to keep the window size after closing the profile's settings
Old profiles are automatically upgraded if it's missing new settings, such as how colors are now saved, sixaxis deadzones, and shift controls
Other UI changes for profile settings, flipped touchpad and other settings boxes
Others:
Fix for when clicking the semicolon in the select an action screen
Fix assigning Sixaxis action to a key
minor UI changes and bug fixes, such as auto resize of the log listview
DS4Updater: Also now works for the new numbering system, can read the version number right from the exe instead of in profiles.xml, UI additions to better notify users of errors, Bug fixes for non-portable users
2014-07-07 21:22:42 +02:00
{
2015-12-18 07:25:51 +01:00
if ( ! pressedonce [ value ] )
{
kp . current . toggle = ! kp . current . toggle ;
pressedonce [ value ] = true ;
}
kp . current . toggleCount + + ;
Shift modifier: Hold an action to use another set of controls, if nothing is set to the shifted control, in falls back to the default action
View input of controls in profiles, see exactly when a deadzone is passed and check the input delay for controllers (special thanks to jhebbel), click the on sixaxis panel
Click the Empty text on in the lightbar box to copy the lightbar color from full to empty.
While opened, option to keep the window size after closing the profile's settings
Old profiles are automatically upgraded if it's missing new settings, such as how colors are now saved, sixaxis deadzones, and shift controls
Other UI changes for profile settings, flipped touchpad and other settings boxes
Others:
Fix for when clicking the semicolon in the select an action screen
Fix assigning Sixaxis action to a key
minor UI changes and bug fixes, such as auto resize of the log listview
DS4Updater: Also now works for the new numbering system, can read the version number right from the exe instead of in profiles.xml, UI additions to better notify users of errors, Bug fixes for non-portable users
2014-07-07 21:22:42 +02:00
}
2015-12-18 07:25:51 +01:00
kp . current . repeatCount + + ;
Shift modifier: Hold an action to use another set of controls, if nothing is set to the shifted control, in falls back to the default action
View input of controls in profiles, see exactly when a deadzone is passed and check the input delay for controllers (special thanks to jhebbel), click the on sixaxis panel
Click the Empty text on in the lightbar box to copy the lightbar color from full to empty.
While opened, option to keep the window size after closing the profile's settings
Old profiles are automatically upgraded if it's missing new settings, such as how colors are now saved, sixaxis deadzones, and shift controls
Other UI changes for profile settings, flipped touchpad and other settings boxes
Others:
Fix for when clicking the semicolon in the select an action screen
Fix assigning Sixaxis action to a key
minor UI changes and bug fixes, such as auto resize of the log listview
DS4Updater: Also now works for the new numbering system, can read the version number right from the exe instead of in profiles.xml, UI additions to better notify users of errors, Bug fixes for non-portable users
2014-07-07 21:22:42 +02:00
}
2015-02-12 20:36:40 +01:00
else
2015-12-18 07:25:51 +01:00
pressedonce [ value ] = false ;
2017-05-12 16:48:58 +02:00
// erase default mappings for things that are remapped
resetToDefaultValue2 ( dcs . control , MappedState , outputfieldMapping ) ;
Shift modifier: Hold an action to use another set of controls, if nothing is set to the shifted control, in falls back to the default action
View input of controls in profiles, see exactly when a deadzone is passed and check the input delay for controllers (special thanks to jhebbel), click the on sixaxis panel
Click the Empty text on in the lightbar box to copy the lightbar color from full to empty.
While opened, option to keep the window size after closing the profile's settings
Old profiles are automatically upgraded if it's missing new settings, such as how colors are now saved, sixaxis deadzones, and shift controls
Other UI changes for profile settings, flipped touchpad and other settings boxes
Others:
Fix for when clicking the semicolon in the select an action screen
Fix assigning Sixaxis action to a key
minor UI changes and bug fixes, such as auto resize of the log listview
DS4Updater: Also now works for the new numbering system, can read the version number right from the exe instead of in profiles.xml, UI additions to better notify users of errors, Bug fixes for non-portable users
2014-07-07 21:22:42 +02:00
}
2015-12-18 07:25:51 +01:00
else if ( actionType = = DS4ControlSettings . ActionType . Button )
Shift modifier: Hold an action to use another set of controls, if nothing is set to the shifted control, in falls back to the default action
View input of controls in profiles, see exactly when a deadzone is passed and check the input delay for controllers (special thanks to jhebbel), click the on sixaxis panel
Click the Empty text on in the lightbar box to copy the lightbar color from full to empty.
While opened, option to keep the window size after closing the profile's settings
Old profiles are automatically upgraded if it's missing new settings, such as how colors are now saved, sixaxis deadzones, and shift controls
Other UI changes for profile settings, flipped touchpad and other settings boxes
Others:
Fix for when clicking the semicolon in the select an action screen
Fix assigning Sixaxis action to a key
minor UI changes and bug fixes, such as auto resize of the log listview
DS4Updater: Also now works for the new numbering system, can read the version number right from the exe instead of in profiles.xml, UI additions to better notify users of errors, Bug fixes for non-portable users
2014-07-07 21:22:42 +02:00
{
2015-12-18 07:25:51 +01:00
int keyvalue = 0 ;
2017-04-09 19:14:44 +02:00
bool isAnalog = false ;
if ( dcs . control > = DS4Controls . LXNeg & & dcs . control < = DS4Controls . RYPos )
2015-12-18 07:25:51 +01:00
{
2017-04-09 19:14:44 +02:00
isAnalog = true ;
}
else if ( dcs . control = = DS4Controls . L2 | | dcs . control = = DS4Controls . R2 )
{
isAnalog = true ;
}
else if ( dcs . control > = DS4Controls . GyroXPos & & dcs . control < = DS4Controls . GyroZNeg )
{
isAnalog = true ;
}
2017-04-11 23:56:37 +02:00
X360Controls xboxControl = X360Controls . None ;
if ( action is X360Controls )
{
xboxControl = ( X360Controls ) action ;
}
else if ( action is string )
{
xboxControl = getX360ControlsByName ( action . ToString ( ) ) ;
}
2019-02-09 04:04:08 +01:00
if ( xboxControl > = X360Controls . LXNeg & & xboxControl < = X360Controls . Start )
2017-04-09 19:14:44 +02:00
{
2017-05-04 17:42:27 +02:00
DS4Controls tempDS4Control = reverseX360ButtonMapping [ ( int ) xboxControl ] ;
2019-02-09 04:04:08 +01:00
customMapQueue [ device ] . Enqueue ( new ControlToXInput ( dcs . control , tempDS4Control ) ) ;
2019-01-31 23:19:08 +01:00
//tempControlDict.Add(dcs.control, tempDS4Control);
}
2017-04-09 19:14:44 +02:00
else if ( xboxControl > = X360Controls . LeftMouse & & xboxControl < = X360Controls . WDOWN )
{
switch ( xboxControl )
{
case X360Controls . LeftMouse :
2017-05-04 17:42:27 +02:00
{
2017-04-09 19:14:44 +02:00
keyvalue = 256 ;
2017-04-21 11:48:13 +02:00
if ( getBoolActionMapping2 ( device , dcs . control , cState , eState , tp , fieldMapping ) )
2017-04-09 19:14:44 +02:00
deviceState . currentClicks . leftCount + + ;
2017-05-04 17:42:27 +02:00
2017-04-09 19:14:44 +02:00
break ;
2017-05-04 17:42:27 +02:00
}
2017-04-09 19:14:44 +02:00
case X360Controls . RightMouse :
2017-05-04 17:42:27 +02:00
{
2017-04-09 19:14:44 +02:00
keyvalue = 257 ;
2017-04-21 11:48:13 +02:00
if ( getBoolActionMapping2 ( device , dcs . control , cState , eState , tp , fieldMapping ) )
2017-04-09 19:14:44 +02:00
deviceState . currentClicks . rightCount + + ;
2017-05-04 17:42:27 +02:00
2017-04-09 19:14:44 +02:00
break ;
2017-05-04 17:42:27 +02:00
}
2017-04-09 19:14:44 +02:00
case X360Controls . MiddleMouse :
2017-05-04 17:42:27 +02:00
{
2017-04-09 19:14:44 +02:00
keyvalue = 258 ;
2017-04-21 11:48:13 +02:00
if ( getBoolActionMapping2 ( device , dcs . control , cState , eState , tp , fieldMapping ) )
2017-04-09 19:14:44 +02:00
deviceState . currentClicks . middleCount + + ;
2017-05-04 17:42:27 +02:00
2017-04-09 19:14:44 +02:00
break ;
2017-05-04 17:42:27 +02:00
}
2017-04-09 19:14:44 +02:00
case X360Controls . FourthMouse :
2017-05-04 17:42:27 +02:00
{
2017-04-09 19:14:44 +02:00
keyvalue = 259 ;
2017-04-21 11:48:13 +02:00
if ( getBoolActionMapping2 ( device , dcs . control , cState , eState , tp , fieldMapping ) )
2017-04-09 19:14:44 +02:00
deviceState . currentClicks . fourthCount + + ;
2017-05-04 17:42:27 +02:00
2017-04-09 19:14:44 +02:00
break ;
2017-05-04 17:42:27 +02:00
}
2017-04-09 19:14:44 +02:00
case X360Controls . FifthMouse :
2017-05-04 17:42:27 +02:00
{
2017-04-09 19:14:44 +02:00
keyvalue = 260 ;
2017-04-21 11:48:13 +02:00
if ( getBoolActionMapping2 ( device , dcs . control , cState , eState , tp , fieldMapping ) )
2017-04-09 19:14:44 +02:00
deviceState . currentClicks . fifthCount + + ;
2017-05-04 17:42:27 +02:00
2017-04-09 19:14:44 +02:00
break ;
2017-05-04 17:42:27 +02:00
}
2017-04-09 19:14:44 +02:00
case X360Controls . WUP :
2017-05-04 17:42:27 +02:00
{
2017-04-21 11:48:13 +02:00
if ( getBoolActionMapping2 ( device , dcs . control , cState , eState , tp , fieldMapping ) )
2017-05-04 17:42:27 +02:00
{
2017-04-09 19:14:44 +02:00
if ( isAnalog )
getMouseWheelMapping ( device , dcs . control , cState , eState , tp , false ) ;
else
deviceState . currentClicks . wUpCount + + ;
2017-05-04 17:42:27 +02:00
}
2017-04-09 19:14:44 +02:00
break ;
2017-05-04 17:42:27 +02:00
}
2017-04-09 19:14:44 +02:00
case X360Controls . WDOWN :
2017-05-04 17:42:27 +02:00
{
2017-04-21 11:48:13 +02:00
if ( getBoolActionMapping2 ( device , dcs . control , cState , eState , tp , fieldMapping ) )
2017-05-04 17:42:27 +02:00
{
2017-04-09 19:14:44 +02:00
if ( isAnalog )
getMouseWheelMapping ( device , dcs . control , cState , eState , tp , true ) ;
else
deviceState . currentClicks . wDownCount + + ;
2017-05-04 17:42:27 +02:00
}
2017-04-09 19:14:44 +02:00
break ;
2017-05-04 17:42:27 +02:00
}
2017-04-09 19:14:44 +02:00
default : break ;
}
}
else if ( xboxControl > = X360Controls . MouseUp & & xboxControl < = X360Controls . MouseRight )
{
switch ( xboxControl )
{
case X360Controls . MouseUp :
2017-05-04 17:42:27 +02:00
{
2017-04-14 09:55:22 +02:00
if ( tempMouseDeltaY = = 0 )
2017-04-09 19:14:44 +02:00
{
2017-05-31 09:47:13 +02:00
tempMouseDeltaY = getMouseMapping ( device , dcs . control , cState , eState , fieldMapping , 0 , ctrl ) ;
2017-04-14 09:55:22 +02:00
tempMouseDeltaY = - Math . Abs ( ( tempMouseDeltaY = = - 2147483648 ? 0 : tempMouseDeltaY ) ) ;
2017-04-09 19:14:44 +02:00
}
2017-05-04 17:42:27 +02:00
2017-04-09 19:14:44 +02:00
break ;
2017-05-04 17:42:27 +02:00
}
2017-04-09 19:14:44 +02:00
case X360Controls . MouseDown :
2017-05-04 17:42:27 +02:00
{
2017-04-14 09:55:22 +02:00
if ( tempMouseDeltaY = = 0 )
2017-04-09 19:14:44 +02:00
{
2017-05-31 09:47:13 +02:00
tempMouseDeltaY = getMouseMapping ( device , dcs . control , cState , eState , fieldMapping , 1 , ctrl ) ;
2017-04-14 09:55:22 +02:00
tempMouseDeltaY = Math . Abs ( ( tempMouseDeltaY = = - 2147483648 ? 0 : tempMouseDeltaY ) ) ;
2017-04-09 19:14:44 +02:00
}
2017-05-04 17:42:27 +02:00
2017-04-09 19:14:44 +02:00
break ;
2017-05-04 17:42:27 +02:00
}
2017-04-09 19:14:44 +02:00
case X360Controls . MouseLeft :
2017-05-04 17:42:27 +02:00
{
2017-04-14 09:55:22 +02:00
if ( tempMouseDeltaX = = 0 )
2017-04-09 19:14:44 +02:00
{
2017-05-31 09:47:13 +02:00
tempMouseDeltaX = getMouseMapping ( device , dcs . control , cState , eState , fieldMapping , 2 , ctrl ) ;
2017-04-14 09:55:22 +02:00
tempMouseDeltaX = - Math . Abs ( ( tempMouseDeltaX = = - 2147483648 ? 0 : tempMouseDeltaX ) ) ;
2017-04-09 19:14:44 +02:00
}
2017-05-04 17:42:27 +02:00
2017-04-09 19:14:44 +02:00
break ;
2017-05-04 17:42:27 +02:00
}
2017-04-09 19:14:44 +02:00
case X360Controls . MouseRight :
2017-05-04 17:42:27 +02:00
{
2017-04-14 09:55:22 +02:00
if ( tempMouseDeltaX = = 0 )
2017-04-09 19:14:44 +02:00
{
2017-05-31 09:47:13 +02:00
tempMouseDeltaX = getMouseMapping ( device , dcs . control , cState , eState , fieldMapping , 3 , ctrl ) ;
2017-04-14 09:55:22 +02:00
tempMouseDeltaX = Math . Abs ( ( tempMouseDeltaX = = - 2147483648 ? 0 : tempMouseDeltaX ) ) ;
2017-04-09 19:14:44 +02:00
}
2017-05-04 17:42:27 +02:00
2017-04-09 19:14:44 +02:00
break ;
2017-05-04 17:42:27 +02:00
}
2017-04-09 19:14:44 +02:00
default : break ;
}
2015-12-18 07:25:51 +01:00
}
2017-04-09 19:14:44 +02:00
2015-12-18 07:25:51 +01:00
if ( keyType . HasFlag ( DS4KeyType . Toggle ) )
{
2017-04-21 11:48:13 +02:00
if ( getBoolActionMapping2 ( device , dcs . control , cState , eState , tp , fieldMapping ) )
Shift modifier: Hold an action to use another set of controls, if nothing is set to the shifted control, in falls back to the default action
View input of controls in profiles, see exactly when a deadzone is passed and check the input delay for controllers (special thanks to jhebbel), click the on sixaxis panel
Click the Empty text on in the lightbar box to copy the lightbar color from full to empty.
While opened, option to keep the window size after closing the profile's settings
Old profiles are automatically upgraded if it's missing new settings, such as how colors are now saved, sixaxis deadzones, and shift controls
Other UI changes for profile settings, flipped touchpad and other settings boxes
Others:
Fix for when clicking the semicolon in the select an action screen
Fix assigning Sixaxis action to a key
minor UI changes and bug fixes, such as auto resize of the log listview
DS4Updater: Also now works for the new numbering system, can read the version number right from the exe instead of in profiles.xml, UI additions to better notify users of errors, Bug fixes for non-portable users
2014-07-07 21:22:42 +02:00
{
2015-12-18 07:25:51 +01:00
if ( ! pressedonce [ keyvalue ] )
{
deviceState . currentClicks . toggle = ! deviceState . currentClicks . toggle ;
pressedonce [ keyvalue ] = true ;
}
deviceState . currentClicks . toggleCount + + ;
Shift modifier: Hold an action to use another set of controls, if nothing is set to the shifted control, in falls back to the default action
View input of controls in profiles, see exactly when a deadzone is passed and check the input delay for controllers (special thanks to jhebbel), click the on sixaxis panel
Click the Empty text on in the lightbar box to copy the lightbar color from full to empty.
While opened, option to keep the window size after closing the profile's settings
Old profiles are automatically upgraded if it's missing new settings, such as how colors are now saved, sixaxis deadzones, and shift controls
Other UI changes for profile settings, flipped touchpad and other settings boxes
Others:
Fix for when clicking the semicolon in the select an action screen
Fix assigning Sixaxis action to a key
minor UI changes and bug fixes, such as auto resize of the log listview
DS4Updater: Also now works for the new numbering system, can read the version number right from the exe instead of in profiles.xml, UI additions to better notify users of errors, Bug fixes for non-portable users
2014-07-07 21:22:42 +02:00
}
2015-12-18 07:25:51 +01:00
else
Shift modifier: Hold an action to use another set of controls, if nothing is set to the shifted control, in falls back to the default action
View input of controls in profiles, see exactly when a deadzone is passed and check the input delay for controllers (special thanks to jhebbel), click the on sixaxis panel
Click the Empty text on in the lightbar box to copy the lightbar color from full to empty.
While opened, option to keep the window size after closing the profile's settings
Old profiles are automatically upgraded if it's missing new settings, such as how colors are now saved, sixaxis deadzones, and shift controls
Other UI changes for profile settings, flipped touchpad and other settings boxes
Others:
Fix for when clicking the semicolon in the select an action screen
Fix assigning Sixaxis action to a key
minor UI changes and bug fixes, such as auto resize of the log listview
DS4Updater: Also now works for the new numbering system, can read the version number right from the exe instead of in profiles.xml, UI additions to better notify users of errors, Bug fixes for non-portable users
2014-07-07 21:22:42 +02:00
{
2015-12-18 07:25:51 +01:00
pressedonce [ keyvalue ] = false ;
Shift modifier: Hold an action to use another set of controls, if nothing is set to the shifted control, in falls back to the default action
View input of controls in profiles, see exactly when a deadzone is passed and check the input delay for controllers (special thanks to jhebbel), click the on sixaxis panel
Click the Empty text on in the lightbar box to copy the lightbar color from full to empty.
While opened, option to keep the window size after closing the profile's settings
Old profiles are automatically upgraded if it's missing new settings, such as how colors are now saved, sixaxis deadzones, and shift controls
Other UI changes for profile settings, flipped touchpad and other settings boxes
Others:
Fix for when clicking the semicolon in the select an action screen
Fix assigning Sixaxis action to a key
minor UI changes and bug fixes, such as auto resize of the log listview
DS4Updater: Also now works for the new numbering system, can read the version number right from the exe instead of in profiles.xml, UI additions to better notify users of errors, Bug fixes for non-portable users
2014-07-07 21:22:42 +02:00
}
2015-12-18 07:25:51 +01:00
}
2017-04-09 19:14:44 +02:00
2017-05-12 16:48:58 +02:00
// erase default mappings for things that are remapped
resetToDefaultValue2 ( dcs . control , MappedState , outputfieldMapping ) ;
2015-12-18 07:25:51 +01:00
}
}
2019-02-16 01:04:09 +01:00
else
{
DS4StateFieldMapping . ControlType controlType = DS4StateFieldMapping . mappedType [ ( int ) dcs . control ] ;
if ( controlType = = DS4StateFieldMapping . ControlType . AxisDir )
//if (dcs.control > DS4Controls.None && dcs.control < DS4Controls.L1)
{
2019-02-16 04:58:00 +01:00
//int current = (int)dcs.control;
//outputfieldMapping.axisdirs[current] = fieldMapping.axisdirs[current];
2019-02-16 01:04:09 +01:00
customMapQueue [ device ] . Enqueue ( new ControlToXInput ( dcs . control , dcs . control ) ) ;
}
}
2017-04-24 11:43:56 +02:00
}
2019-02-09 04:04:08 +01:00
Queue < ControlToXInput > tempControl = customMapQueue [ device ] ;
2019-02-16 04:58:00 +01:00
unchecked
2019-02-09 04:04:08 +01:00
{
2019-02-16 04:58:00 +01:00
for ( int i = 0 , len = tempControl . Count ; i < len ; i + + )
//while(tempControl.Any())
2019-02-09 04:04:08 +01:00
{
2019-02-16 04:58:00 +01:00
ControlToXInput tempMap = tempControl . Dequeue ( ) ;
int controlNum = ( int ) tempMap . ds4input ;
int tempOutControl = ( int ) tempMap . xoutput ;
if ( tempMap . xoutput > = DS4Controls . LXNeg & & tempMap . xoutput < = DS4Controls . RYPos )
{
const byte axisDead = 128 ;
DS4StateFieldMapping . ControlType controlType = DS4StateFieldMapping . mappedType [ tempOutControl ] ;
bool alt = controlType = = DS4StateFieldMapping . ControlType . AxisDir & & tempOutControl % 2 = = 0 ? true : false ;
byte axisMapping = getXYAxisMapping2 ( device , tempMap . ds4input , cState , eState , tp , fieldMapping , alt ) ;
if ( axisMapping ! = axisDead )
{
int controlRelation = tempOutControl % 2 = = 0 ? tempOutControl - 1 : tempOutControl + 1 ;
outputfieldMapping . axisdirs [ tempOutControl ] = axisMapping ;
outputfieldMapping . axisdirs [ controlRelation ] = axisMapping ;
}
2019-02-09 04:04:08 +01:00
}
else
{
2019-02-16 04:58:00 +01:00
if ( tempMap . xoutput = = DS4Controls . L2 | | tempMap . xoutput = = DS4Controls . R2 )
{
const byte axisZero = 0 ;
byte axisMapping = getByteMapping2 ( device , tempMap . ds4input , cState , eState , tp , fieldMapping ) ;
if ( axisMapping ! = axisZero )
outputfieldMapping . triggers [ tempOutControl ] = axisMapping ;
}
else
{
bool value = getBoolMapping2 ( device , tempMap . ds4input , cState , eState , tp , fieldMapping ) ;
if ( value )
outputfieldMapping . buttons [ tempOutControl ] = value ;
}
2019-02-09 04:04:08 +01:00
}
}
}
2017-04-24 11:43:56 +02:00
outputfieldMapping . populateState ( MappedState ) ;
2015-12-18 07:25:51 +01:00
2017-11-23 09:31:35 +01:00
if ( macroCount > 0 )
{
if ( macroControl [ 00 ] ) MappedState . Cross = true ;
if ( macroControl [ 01 ] ) MappedState . Circle = true ;
if ( macroControl [ 02 ] ) MappedState . Square = true ;
if ( macroControl [ 03 ] ) MappedState . Triangle = true ;
if ( macroControl [ 04 ] ) MappedState . Options = true ;
if ( macroControl [ 05 ] ) MappedState . Share = true ;
if ( macroControl [ 06 ] ) MappedState . DpadUp = true ;
if ( macroControl [ 07 ] ) MappedState . DpadDown = true ;
if ( macroControl [ 08 ] ) MappedState . DpadLeft = true ;
if ( macroControl [ 09 ] ) MappedState . DpadRight = true ;
if ( macroControl [ 10 ] ) MappedState . PS = true ;
if ( macroControl [ 11 ] ) MappedState . L1 = true ;
if ( macroControl [ 12 ] ) MappedState . R1 = true ;
if ( macroControl [ 13 ] ) MappedState . L2 = 255 ;
if ( macroControl [ 14 ] ) MappedState . R2 = 255 ;
if ( macroControl [ 15 ] ) MappedState . L3 = true ;
if ( macroControl [ 16 ] ) MappedState . R3 = true ;
if ( macroControl [ 17 ] ) MappedState . LX = 255 ;
if ( macroControl [ 18 ] ) MappedState . LX = 0 ;
if ( macroControl [ 19 ] ) MappedState . LY = 255 ;
if ( macroControl [ 20 ] ) MappedState . LY = 0 ;
if ( macroControl [ 21 ] ) MappedState . RX = 255 ;
if ( macroControl [ 22 ] ) MappedState . RX = 0 ;
if ( macroControl [ 23 ] ) MappedState . RY = 255 ;
if ( macroControl [ 24 ] ) MappedState . RY = 0 ;
}
2017-03-30 15:14:58 +02:00
2019-02-19 14:19:10 +01:00
if ( GetSASteeringWheelEmulationAxis ( device ) ! = SASteeringWheelEmulationAxisType . None )
{
MappedState . SASteeringWheelEmulationUnit = Mapping . Scale360degreeGyroAxis ( device , eState , ctrl ) ;
}
2017-04-14 09:55:22 +02:00
calculateFinalMouseMovement ( ref tempMouseDeltaX , ref tempMouseDeltaY ,
out mouseDeltaX , out mouseDeltaY ) ;
if ( mouseDeltaX ! = 0 | | mouseDeltaY ! = 0 )
2017-04-08 02:13:19 +02:00
{
2017-04-14 09:55:22 +02:00
InputMethods . MoveCursorBy ( mouseDeltaX , mouseDeltaY ) ;
2017-04-08 02:13:19 +02:00
}
Shift modifier: Hold an action to use another set of controls, if nothing is set to the shifted control, in falls back to the default action
View input of controls in profiles, see exactly when a deadzone is passed and check the input delay for controllers (special thanks to jhebbel), click the on sixaxis panel
Click the Empty text on in the lightbar box to copy the lightbar color from full to empty.
While opened, option to keep the window size after closing the profile's settings
Old profiles are automatically upgraded if it's missing new settings, such as how colors are now saved, sixaxis deadzones, and shift controls
Other UI changes for profile settings, flipped touchpad and other settings boxes
Others:
Fix for when clicking the semicolon in the select an action screen
Fix assigning Sixaxis action to a key
minor UI changes and bug fixes, such as auto resize of the log listview
DS4Updater: Also now works for the new numbering system, can read the version number right from the exe instead of in profiles.xml, UI additions to better notify users of errors, Bug fixes for non-portable users
2014-07-07 21:22:42 +02:00
}
2015-02-12 20:36:40 +01:00
2015-12-18 07:25:51 +01:00
private static bool IfAxisIsNotModified ( int device , bool shift , DS4Controls dc )
Shift modifier: Hold an action to use another set of controls, if nothing is set to the shifted control, in falls back to the default action
View input of controls in profiles, see exactly when a deadzone is passed and check the input delay for controllers (special thanks to jhebbel), click the on sixaxis panel
Click the Empty text on in the lightbar box to copy the lightbar color from full to empty.
While opened, option to keep the window size after closing the profile's settings
Old profiles are automatically upgraded if it's missing new settings, such as how colors are now saved, sixaxis deadzones, and shift controls
Other UI changes for profile settings, flipped touchpad and other settings boxes
Others:
Fix for when clicking the semicolon in the select an action screen
Fix assigning Sixaxis action to a key
minor UI changes and bug fixes, such as auto resize of the log listview
DS4Updater: Also now works for the new numbering system, can read the version number right from the exe instead of in profiles.xml, UI additions to better notify users of errors, Bug fixes for non-portable users
2014-07-07 21:22:42 +02:00
{
2017-04-02 02:46:51 +02:00
return shift ? false : GetDS4Action ( device , dc , false ) = = null ;
2015-12-18 07:25:51 +01:00
}
2017-04-21 11:48:13 +02:00
private static async void MapCustomAction ( int device , DS4State cState , DS4State MappedState ,
2017-04-24 11:43:56 +02:00
DS4StateExposed eState , Mouse tp , ControlService ctrl , DS4StateFieldMapping fieldMapping , DS4StateFieldMapping outputfieldMapping )
2015-12-18 07:25:51 +01:00
{
2017-04-01 07:42:10 +02:00
/* TODO: This method is slow sauce. Find ways to speed up action execution */
try
{
2017-04-08 02:13:19 +02:00
int actionDoneCount = actionDone . Count ;
int totalActionCount = GetActions ( ) . Count ;
2017-05-09 05:06:48 +02:00
DS4StateFieldMapping previousFieldMapping = null ;
2017-04-01 07:42:10 +02:00
List < string > profileActions = getProfileActions ( device ) ;
2017-04-12 22:54:38 +02:00
//foreach (string actionname in profileActions)
for ( int actionIndex = 0 , profileListLen = profileActions . Count ;
actionIndex < profileListLen ; actionIndex + + )
2014-05-28 04:49:58 +02:00
{
2015-12-18 07:25:51 +01:00
//DS4KeyType keyType = getShiftCustomKeyType(device, customKey.Key);
2017-04-02 02:46:51 +02:00
//SpecialAction action = GetAction(actionname);
//int index = GetActionIndexOf(actionname);
2017-04-12 22:54:38 +02:00
string actionname = profileActions [ actionIndex ] ;
2017-04-02 02:46:51 +02:00
SpecialAction action = GetProfileAction ( device , actionname ) ;
int index = GetProfileActionIndexOf ( device , actionname ) ;
2017-04-08 02:13:19 +02:00
2017-04-01 07:42:10 +02:00
if ( actionDoneCount < index + 1 )
2017-04-08 02:13:19 +02:00
{
Version 1.4.5
Added support for the New DS4 USB Adapater (Thanks to boganhobo and
Chamilsaan)
Implemented teokp's amazing fix for hide ds4 not working on the
anniversary update of Windows 10: when a controller fails to enter
exclusive mode, DS4Windows will ask for admin privilages to fix the
issue.
Now (near)unlimited Special Actions can be made from the previous limit
of 50
Special Action Xbox Game DVR is now no longer limited to Windows 10,
renamed multi action button: Assign a macro to single tap, double tap,
and holding down a button
Added option for White DS4Windows Icon in the notification tray (While
not merged from, thanks to tehmantra)
Added option to temporarily turn off DS4Windows when using a certain
program (togglable in the Auto Profiles Tab) (Same case as above but
thanks to dedChar to bring to light)
Fixed Options crashes in certain locales where decimal points are
repesented with commas, such as German (Thanks to kiliansch)
Added/Updated translations for many languauges, now including Japanese,
Slovenian, Hungarian, Greek, Finnish, Czech, Indonesian, and Ukrainian
2016-09-22 03:38:38 +02:00
actionDone . Add ( new ActionState ( ) ) ;
2017-04-08 02:13:19 +02:00
actionDoneCount + + ;
}
else if ( actionDoneCount > totalActionCount )
{
2017-04-01 07:42:10 +02:00
actionDone . RemoveAt ( actionDoneCount - 1 ) ;
2017-04-08 02:13:19 +02:00
actionDoneCount - - ;
}
2017-04-01 07:42:10 +02:00
double time = 0.0 ;
2015-12-18 07:25:51 +01:00
//If a key or button is assigned to the trigger, a key special action is used like
//a quick tap to use and hold to use the regular custom button/key
2017-04-02 02:46:51 +02:00
bool triggerToBeTapped = action . typeID = = SpecialAction . ActionTypeId . None & & action . trigger . Count = = 1 & &
2017-04-01 07:42:10 +02:00
GetDS4Action ( device , action . trigger [ 0 ] , false ) = = null ;
2017-04-02 09:17:48 +02:00
if ( ! ( action . typeID = = SpecialAction . ActionTypeId . None | | index < 0 ) )
2014-05-28 04:49:58 +02:00
{
2015-12-18 07:25:51 +01:00
bool triggeractivated = true ;
2017-04-01 07:42:10 +02:00
if ( action . delayTime > 0.0 )
2014-05-28 04:49:58 +02:00
{
2015-12-18 07:25:51 +01:00
triggeractivated = false ;
bool subtriggeractivated = true ;
2017-04-11 09:57:22 +02:00
//foreach (DS4Controls dc in action.trigger)
for ( int i = 0 , arlen = action . trigger . Count ; i < arlen ; i + + )
2014-10-21 04:31:13 +02:00
{
2017-04-11 09:57:22 +02:00
DS4Controls dc = action . trigger [ i ] ;
2019-02-26 11:13:13 +01:00
if ( ! getBoolSpecialActionMapping ( device , dc , cState , eState , tp , fieldMapping ) )
2015-12-18 07:25:51 +01:00
{
subtriggeractivated = false ;
break ;
}
2014-10-21 04:31:13 +02:00
}
2015-12-18 07:25:51 +01:00
if ( subtriggeractivated )
2014-10-21 04:31:13 +02:00
{
2015-12-18 07:25:51 +01:00
time = action . delayTime ;
nowAction [ device ] = DateTime . UtcNow ;
if ( nowAction [ device ] > = oldnowAction [ device ] + TimeSpan . FromSeconds ( time ) )
triggeractivated = true ;
2014-10-21 04:31:13 +02:00
}
2015-12-18 07:25:51 +01:00
else if ( nowAction [ device ] < DateTime . UtcNow - TimeSpan . FromMilliseconds ( 100 ) )
oldnowAction [ device ] = DateTime . UtcNow ;
}
else if ( triggerToBeTapped & & oldnowKeyAct [ device ] = = DateTime . MinValue )
{
triggeractivated = false ;
bool subtriggeractivated = true ;
2017-04-11 09:57:22 +02:00
//foreach (DS4Controls dc in action.trigger)
for ( int i = 0 , arlen = action . trigger . Count ; i < arlen ; i + + )
2014-10-21 04:31:13 +02:00
{
2017-04-11 09:57:22 +02:00
DS4Controls dc = action . trigger [ i ] ;
2019-02-26 11:13:13 +01:00
if ( ! getBoolSpecialActionMapping ( device , dc , cState , eState , tp , fieldMapping ) )
2015-12-18 07:25:51 +01:00
{
subtriggeractivated = false ;
break ;
}
2014-10-21 04:31:13 +02:00
}
2015-12-18 07:25:51 +01:00
if ( subtriggeractivated )
2014-10-21 04:31:13 +02:00
{
2015-12-18 07:25:51 +01:00
oldnowKeyAct [ device ] = DateTime . UtcNow ;
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
}
}
2015-12-18 07:25:51 +01:00
else if ( triggerToBeTapped & & oldnowKeyAct [ device ] ! = DateTime . MinValue )
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
{
2015-12-18 07:25:51 +01:00
triggeractivated = false ;
bool subtriggeractivated = true ;
2017-04-11 09:57:22 +02:00
//foreach (DS4Controls dc in action.trigger)
for ( int i = 0 , arlen = action . trigger . Count ; i < arlen ; i + + )
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
{
2017-04-11 09:57:22 +02:00
DS4Controls dc = action . trigger [ i ] ;
2019-02-26 11:13:13 +01:00
if ( ! getBoolSpecialActionMapping ( device , dc , cState , eState , tp , fieldMapping ) )
2015-12-18 07:25:51 +01:00
{
subtriggeractivated = false ;
break ;
}
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
}
2015-12-18 07:25:51 +01:00
DateTime now = DateTime . UtcNow ;
if ( ! subtriggeractivated & & now < = oldnowKeyAct [ device ] + TimeSpan . FromMilliseconds ( 250 ) )
2014-12-13 21:12:03 +01:00
{
2015-12-18 07:25:51 +01:00
await Task . Delay ( 3 ) ; //if the button is assigned to the same key use a delay so the key down is the last action, not key up
triggeractivated = true ;
oldnowKeyAct [ device ] = DateTime . MinValue ;
2014-12-13 21:12:03 +01:00
}
2015-12-18 07:25:51 +01:00
else if ( ! subtriggeractivated )
oldnowKeyAct [ device ] = DateTime . MinValue ;
2014-12-13 21:12:03 +01:00
}
2015-12-18 07:25:51 +01:00
else
2017-04-11 09:57:22 +02:00
{
//foreach (DS4Controls dc in action.trigger)
for ( int i = 0 , arlen = action . trigger . Count ; i < arlen ; i + + )
2014-12-13 21:12:03 +01:00
{
2017-04-11 09:57:22 +02:00
DS4Controls dc = action . trigger [ i ] ;
2019-02-26 11:13:13 +01:00
if ( ! getBoolSpecialActionMapping ( device , dc , cState , eState , tp , fieldMapping ) )
2015-12-18 07:25:51 +01:00
{
triggeractivated = false ;
break ;
}
2014-12-13 21:12:03 +01:00
}
2017-04-11 09:57:22 +02:00
}
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
2015-12-18 07:25:51 +01:00
bool utriggeractivated = true ;
2017-04-01 07:42:10 +02:00
int uTriggerCount = action . uTrigger . Count ;
2017-04-02 02:46:51 +02:00
if ( action . typeID = = SpecialAction . ActionTypeId . Key & & uTriggerCount > 0 )
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
{
2017-04-11 09:57:22 +02:00
//foreach (DS4Controls dc in action.uTrigger)
for ( int i = 0 , arlen = action . uTrigger . Count ; i < arlen ; i + + )
2014-12-13 21:12:03 +01:00
{
2017-04-11 09:57:22 +02:00
DS4Controls dc = action . uTrigger [ i ] ;
2019-02-26 11:13:13 +01:00
if ( ! getBoolSpecialActionMapping ( device , dc , cState , eState , tp , fieldMapping ) )
2015-12-18 07:25:51 +01:00
{
utriggeractivated = false ;
break ;
}
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
}
2015-12-18 07:25:51 +01:00
if ( action . pressRelease ) utriggeractivated = ! utriggeractivated ;
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
}
2017-04-11 09:57:22 +02:00
bool actionFound = false ;
if ( triggeractivated )
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
{
2017-04-11 09:57:22 +02:00
if ( action . typeID = = SpecialAction . ActionTypeId . Program )
2015-12-18 07:25:51 +01:00
{
2017-04-11 09:57:22 +02:00
actionFound = true ;
if ( ! actionDone [ index ] . dev [ device ] )
{
actionDone [ index ] . dev [ device ] = true ;
if ( ! string . IsNullOrEmpty ( action . extra ) )
Process . Start ( action . details , action . extra ) ;
else
Process . Start ( action . details ) ;
}
2015-12-18 07:25:51 +01:00
}
2017-04-11 09:57:22 +02:00
else if ( action . typeID = = SpecialAction . ActionTypeId . Profile )
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
{
2017-04-11 09:57:22 +02:00
actionFound = true ;
2019-04-07 13:33:42 +02:00
if ( ! actionDone [ index ] . dev [ device ] & & ( ! useTempProfile [ device ] | | untriggeraction [ device ] = = null | | untriggeraction [ device ] . typeID ! = SpecialAction . ActionTypeId . Profile ) )
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
{
2017-04-11 09:57:22 +02:00
actionDone [ index ] . dev [ device ] = true ;
2019-04-23 02:39:44 +02:00
// If Loadprofile special action doesn't have untrigger keys or automatic untrigger option is not set then don't set untrigger status. This way the new loaded profile allows yet another loadProfile action key event.
if ( action . uTrigger . Count > 0 | | action . automaticUntrigger )
2019-04-07 13:33:42 +02:00
{
untriggeraction [ device ] = action ;
untriggerindex [ device ] = index ;
2019-04-23 02:39:44 +02:00
// If the existing profile is a temp profile then store its name, because automaticUntrigger needs to know where to go back (empty name goes back to default regular profile)
untriggeraction [ device ] . prevProfileName = ( useTempProfile [ device ] ? tempprofilename [ device ] : string . Empty ) ;
2019-04-07 13:33:42 +02:00
}
2017-04-11 09:57:22 +02:00
//foreach (DS4Controls dc in action.trigger)
for ( int i = 0 , arlen = action . trigger . Count ; i < arlen ; i + + )
2015-12-18 07:25:51 +01:00
{
2017-04-11 09:57:22 +02:00
DS4Controls dc = action . trigger [ i ] ;
DS4ControlSettings dcs = getDS4CSetting ( device , dc ) ;
if ( dcs . action ! = null )
2015-12-18 07:25:51 +01:00
{
2017-04-11 09:57:22 +02:00
if ( dcs . actionType = = DS4ControlSettings . ActionType . Key )
InputMethods . performKeyRelease ( ushort . Parse ( dcs . action . ToString ( ) ) ) ;
else if ( dcs . actionType = = DS4ControlSettings . ActionType . Macro )
{
int [ ] keys = ( int [ ] ) dcs . action ;
for ( int j = 0 , keysLen = keys . Length ; j < keysLen ; j + + )
InputMethods . performKeyRelease ( ( ushort ) keys [ j ] ) ;
}
2015-12-18 07:25:51 +01:00
}
}
2019-01-08 02:35:30 +01:00
string prolog = Properties . Resources . UsingProfile . Replace ( "*number*" , ( device + 1 ) . ToString ( ) ) . Replace ( "*Profile name*" , action . details ) ;
AppLogger . LogToGui ( prolog , false ) ;
2017-04-11 09:57:22 +02:00
LoadTempProfile ( device , action . details , true , ctrl ) ;
2019-04-23 02:39:44 +02:00
if ( action . uTrigger . Count = = 0 & & ! action . automaticUntrigger )
{
// If the new profile has any actions with the same action key (controls) than this action (which doesn't have untrigger keys) then set status of those actions to wait for the release of the existing action key.
List < string > profileActionsNext = getProfileActions ( device ) ;
for ( int actionIndexNext = 0 , profileListLenNext = profileActionsNext . Count ; actionIndexNext < profileListLenNext ; actionIndexNext + + )
{
string actionnameNext = profileActionsNext [ actionIndexNext ] ;
SpecialAction actionNext = GetProfileAction ( device , actionnameNext ) ;
int indexNext = GetProfileActionIndexOf ( device , actionnameNext ) ;
if ( actionNext . controls = = action . controls )
actionDone [ indexNext ] . dev [ device ] = true ;
}
}
2017-04-11 09:57:22 +02:00
return ;
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
}
}
2017-04-11 09:57:22 +02:00
else if ( action . typeID = = SpecialAction . ActionTypeId . Macro )
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
{
2017-04-11 09:57:22 +02:00
actionFound = true ;
if ( ! actionDone [ index ] . dev [ device ] )
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
{
2017-04-11 09:57:22 +02:00
DS4KeyType keyType = action . keyType ;
actionDone [ index ] . dev [ device ] = true ;
//foreach (DS4Controls dc in action.trigger)
for ( int i = 0 , arlen = action . trigger . Count ; i < arlen ; i + + )
{
DS4Controls dc = action . trigger [ i ] ;
2017-04-24 11:43:56 +02:00
resetToDefaultValue2 ( dc , MappedState , outputfieldMapping ) ;
2017-04-11 09:57:22 +02:00
}
PlayMacro ( device , macroControl , String . Join ( "/" , action . macro ) , DS4Controls . None , keyType ) ;
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
}
2015-12-18 07:25:51 +01:00
else
2017-04-11 09:57:22 +02:00
EndMacro ( device , macroControl , String . Join ( "/" , action . macro ) , DS4Controls . None ) ;
2015-12-18 07:25:51 +01:00
}
2017-04-11 09:57:22 +02:00
else if ( action . typeID = = SpecialAction . ActionTypeId . Key )
2015-02-12 20:36:40 +01:00
{
2017-04-11 09:57:22 +02:00
actionFound = true ;
if ( uTriggerCount = = 0 | | ( uTriggerCount > 0 & & untriggerindex [ device ] = = - 1 & & ! actionDone [ index ] . dev [ device ] ) )
2017-04-06 10:19:12 +02:00
{
2017-04-11 09:57:22 +02:00
actionDone [ index ] . dev [ device ] = true ;
untriggerindex [ device ] = index ;
ushort key ;
ushort . TryParse ( action . details , out key ) ;
if ( uTriggerCount = = 0 )
{
SyntheticState . KeyPresses kp ;
if ( ! deviceState [ device ] . keyPresses . TryGetValue ( key , out kp ) )
deviceState [ device ] . keyPresses [ key ] = kp = new SyntheticState . KeyPresses ( ) ;
if ( action . keyType . HasFlag ( DS4KeyType . ScanCode ) )
kp . current . scanCodeCount + + ;
else
kp . current . vkCount + + ;
kp . current . repeatCount + + ;
}
else if ( action . keyType . HasFlag ( DS4KeyType . ScanCode ) )
InputMethods . performSCKeyPress ( key ) ;
else
InputMethods . performKeyPress ( key ) ;
2017-04-06 10:19:12 +02:00
}
2017-04-11 09:57:22 +02:00
}
else if ( action . typeID = = SpecialAction . ActionTypeId . DisconnectBT )
{
actionFound = true ;
2017-04-06 10:19:12 +02:00
2017-04-11 09:57:22 +02:00
DS4Device d = ctrl . DS4Controllers [ device ] ;
2017-07-01 06:29:20 +02:00
bool synced = tempBool = d . isSynced ( ) ;
if ( synced & & ! d . isCharging ( ) )
2015-12-18 07:25:51 +01:00
{
2017-04-21 05:09:08 +02:00
ConnectionType deviceConn = d . getConnectionType ( ) ;
2017-07-01 06:29:20 +02:00
bool exclusive = tempBool = d . isExclusive ( ) ;
2017-04-11 09:57:22 +02:00
if ( deviceConn = = ConnectionType . BT )
{
2017-04-27 03:39:33 +02:00
d . DisconnectBT ( ) ;
2017-04-11 09:57:22 +02:00
}
2017-07-01 06:29:20 +02:00
else if ( deviceConn = = ConnectionType . SONYWA & & exclusive )
{
d . DisconnectDongle ( ) ;
}
2017-04-11 09:57:22 +02:00
//foreach (DS4Controls dc in action.trigger)
for ( int i = 0 , arlen = action . trigger . Count ; i < arlen ; i + + )
2015-12-18 07:25:51 +01:00
{
2017-04-11 09:57:22 +02:00
DS4Controls dc = action . trigger [ i ] ;
DS4ControlSettings dcs = getDS4CSetting ( device , dc ) ;
if ( dcs . action ! = null )
2015-12-18 07:25:51 +01:00
{
2017-04-11 09:57:22 +02:00
if ( dcs . actionType = = DS4ControlSettings . ActionType . Key )
InputMethods . performKeyRelease ( ( ushort ) dcs . action ) ;
else if ( dcs . actionType = = DS4ControlSettings . ActionType . Macro )
{
int [ ] keys = ( int [ ] ) dcs . action ;
for ( int j = 0 , keysLen = keys . Length ; j < keysLen ; j + + )
InputMethods . performKeyRelease ( ( ushort ) keys [ j ] ) ;
}
2015-12-18 07:25:51 +01:00
}
}
2017-04-11 09:57:22 +02:00
return ;
2015-12-18 07:25:51 +01:00
}
2015-02-12 20:36:40 +01:00
}
2017-04-11 09:57:22 +02:00
else if ( action . typeID = = SpecialAction . ActionTypeId . BatteryCheck )
Version 1.4.266
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
2015-07-31 05:34:22 +02:00
{
2017-04-11 09:57:22 +02:00
actionFound = true ;
string [ ] dets = action . details . Split ( '|' ) ;
if ( dets . Length = = 1 )
dets = action . details . Split ( ',' ) ;
if ( bool . Parse ( dets [ 1 ] ) & & ! actionDone [ index ] . dev [ device ] )
{
2018-09-29 11:42:22 +02:00
AppLogger . LogToTray ( "Controller " + ( device + 1 ) + ": " +
2017-04-11 09:57:22 +02:00
ctrl . getDS4Battery ( device ) , true ) ;
}
if ( bool . Parse ( dets [ 2 ] ) )
2015-12-18 07:25:51 +01:00
{
2017-04-11 09:57:22 +02:00
DS4Device d = ctrl . DS4Controllers [ device ] ;
if ( ! actionDone [ index ] . dev [ device ] )
{
lastColor [ device ] = d . LightBarColor ;
DS4LightBar . forcelight [ device ] = true ;
}
DS4Color empty = new DS4Color ( byte . Parse ( dets [ 3 ] ) , byte . Parse ( dets [ 4 ] ) , byte . Parse ( dets [ 5 ] ) ) ;
DS4Color full = new DS4Color ( byte . Parse ( dets [ 6 ] ) , byte . Parse ( dets [ 7 ] ) , byte . Parse ( dets [ 8 ] ) ) ;
2019-02-12 06:51:26 +01:00
DS4Color trans = getTransitionedColor ( ref empty , ref full , d . Battery ) ;
2017-04-11 09:57:22 +02:00
if ( fadetimer [ device ] < 100 )
2019-02-12 06:51:26 +01:00
DS4LightBar . forcedColor [ device ] = getTransitionedColor ( ref lastColor [ device ] , ref trans , fadetimer [ device ] + = 2 ) ;
2015-12-18 07:25:51 +01:00
}
2017-04-11 09:57:22 +02:00
actionDone [ index ] . dev [ device ] = true ;
Version 1.4.266
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
2015-07-31 05:34:22 +02:00
}
2019-02-19 14:19:10 +01:00
else if ( action . typeID = = SpecialAction . ActionTypeId . SASteeringWheelEmulationCalibrate )
{
actionFound = true ;
DS4Device d = ctrl . DS4Controllers [ device ] ;
// If controller is not already in SASteeringWheelCalibration state then enable it now. If calibration is active then complete it (commit calibration values)
if ( d . WheelRecalibrateActiveState = = 0 & & DateTime . UtcNow > ( action . firstTap + TimeSpan . FromMilliseconds ( 3000 ) ) )
{
action . firstTap = DateTime . UtcNow ;
d . WheelRecalibrateActiveState = 1 ; // Start calibration process
}
else if ( d . WheelRecalibrateActiveState = = 2 & & DateTime . UtcNow > ( action . firstTap + TimeSpan . FromMilliseconds ( 3000 ) ) )
{
action . firstTap = DateTime . UtcNow ;
d . WheelRecalibrateActiveState = 3 ; // Complete calibration process
}
actionDone [ index ] . dev [ device ] = true ;
}
Version 1.4.266
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
2015-07-31 05:34:22 +02:00
}
2017-04-11 09:57:22 +02:00
else
2015-12-18 07:25:51 +01:00
{
2017-04-11 09:57:22 +02:00
if ( action . typeID = = SpecialAction . ActionTypeId . BatteryCheck )
Version 1.4.266
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
2015-07-31 05:34:22 +02:00
{
2017-04-11 09:57:22 +02:00
actionFound = true ;
if ( actionDone [ index ] . dev [ device ] )
Version 1.4.266
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
2015-07-31 05:34:22 +02:00
{
2015-12-18 07:25:51 +01:00
fadetimer [ device ] = 0 ;
2017-04-11 09:57:22 +02:00
/ * if ( prevFadetimer [ device ] = = fadetimer [ device ] )
{
prevFadetimer [ device ] = 0 ;
fadetimer [ device ] = 0 ;
}
else
prevFadetimer [ device ] = fadetimer [ device ] ; * /
DS4LightBar . forcelight [ device ] = false ;
actionDone [ index ] . dev [ device ] = false ;
Version 1.4.266
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
2015-07-31 05:34:22 +02:00
}
2017-04-11 09:57:22 +02:00
}
else if ( action . typeID ! = SpecialAction . ActionTypeId . Key & &
action . typeID ! = SpecialAction . ActionTypeId . XboxGameDVR & &
action . typeID ! = SpecialAction . ActionTypeId . MultiAction )
{
// Ignore
actionFound = true ;
Version 1.4.5
Added support for the New DS4 USB Adapater (Thanks to boganhobo and
Chamilsaan)
Implemented teokp's amazing fix for hide ds4 not working on the
anniversary update of Windows 10: when a controller fails to enter
exclusive mode, DS4Windows will ask for admin privilages to fix the
issue.
Now (near)unlimited Special Actions can be made from the previous limit
of 50
Special Action Xbox Game DVR is now no longer limited to Windows 10,
renamed multi action button: Assign a macro to single tap, double tap,
and holding down a button
Added option for White DS4Windows Icon in the notification tray (While
not merged from, thanks to tehmantra)
Added option to temporarily turn off DS4Windows when using a certain
program (togglable in the Auto Profiles Tab) (Same case as above but
thanks to dedChar to bring to light)
Fixed Options crashes in certain locales where decimal points are
repesented with commas, such as German (Thanks to kiliansch)
Added/Updated translations for many languauges, now including Japanese,
Slovenian, Hungarian, Greek, Finnish, Czech, Indonesian, and Ukrainian
2016-09-22 03:38:38 +02:00
actionDone [ index ] . dev [ device ] = false ;
Version 1.4.266
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
2015-07-31 05:34:22 +02:00
}
}
2017-04-11 09:57:22 +02:00
if ( ! actionFound )
Version 1.4.266
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
2015-07-31 05:34:22 +02:00
{
2017-04-11 09:57:22 +02:00
if ( uTriggerCount > 0 & & utriggeractivated & & action . typeID = = SpecialAction . ActionTypeId . Key )
{
actionFound = true ;
if ( untriggerindex [ device ] > - 1 & & ! actionDone [ index ] . dev [ device ] )
Version 1.4.266
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
2015-07-31 05:34:22 +02:00
{
2017-04-11 09:57:22 +02:00
actionDone [ index ] . dev [ device ] = true ;
untriggerindex [ device ] = - 1 ;
ushort key ;
ushort . TryParse ( action . details , out key ) ;
if ( action . keyType . HasFlag ( DS4KeyType . ScanCode ) )
InputMethods . performSCKeyRelease ( key ) ;
else
InputMethods . performKeyRelease ( key ) ;
Version 1.4.266
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
2015-07-31 05:34:22 +02:00
}
}
2017-04-11 09:57:22 +02:00
else if ( action . typeID = = SpecialAction . ActionTypeId . XboxGameDVR | | action . typeID = = SpecialAction . ActionTypeId . MultiAction )
{
actionFound = true ;
2017-05-22 17:06:20 +02:00
bool tappedOnce = action . tappedOnce , firstTouch = action . firstTouch ,
secondtouchbegin = action . secondtouchbegin ;
2017-05-27 03:57:46 +02:00
//DateTime pastTime = action.pastTime, firstTap = action.firstTap,
// TimeofEnd = action.TimeofEnd;
2017-05-22 17:06:20 +02:00
2017-04-11 09:57:22 +02:00
/ * if ( getCustomButton ( device , action . trigger [ 0 ] ) ! = X360Controls . Unbound )
getCustomButtons ( device ) [ action . trigger [ 0 ] ] = X360Controls . Unbound ;
if ( getCustomMacro ( device , action . trigger [ 0 ] ) ! = "0" )
getCustomMacros ( device ) . Remove ( action . trigger [ 0 ] ) ;
if ( getCustomKey ( device , action . trigger [ 0 ] ) ! = 0 )
getCustomMacros ( device ) . Remove ( action . trigger [ 0 ] ) ; * /
string [ ] dets = action . details . Split ( ',' ) ;
DS4Device d = ctrl . DS4Controllers [ device ] ;
//cus
2017-04-21 15:29:25 +02:00
2017-07-27 14:32:09 +02:00
DS4State tempPrevState = d . getPreviousStateRef ( ) ;
2017-05-09 05:06:48 +02:00
// Only create one instance of previous DS4StateFieldMapping in case more than one multi-action
// button is assigned
if ( previousFieldMapping = = null )
{
2017-11-17 19:39:39 +01:00
previousFieldMapping = previousFieldMappings [ device ] ;
previousFieldMapping . populateFieldMapping ( tempPrevState , eState , tp , true ) ;
//previousFieldMapping = new DS4StateFieldMapping(tempPrevState, eState, tp, true);
2017-05-09 05:06:48 +02:00
}
2019-02-26 11:13:13 +01:00
bool activeCur = getBoolSpecialActionMapping ( device , action . trigger [ 0 ] , cState , eState , tp , fieldMapping ) ;
bool activePrev = getBoolSpecialActionMapping ( device , action . trigger [ 0 ] , tempPrevState , eState , tp , previousFieldMapping ) ;
2017-04-21 15:29:25 +02:00
if ( activeCur & & ! activePrev )
{
// pressed down
2017-05-27 03:57:46 +02:00
action . pastTime = DateTime . UtcNow ;
2019-02-08 05:56:07 +01:00
if ( action . pastTime < = ( action . firstTap + TimeSpan . FromMilliseconds ( 150 ) ) )
2017-04-11 09:57:22 +02:00
{
2017-05-22 17:06:20 +02:00
action . tappedOnce = tappedOnce = false ;
action . secondtouchbegin = secondtouchbegin = true ;
//tappedOnce = false;
//secondtouchbegin = true;
2017-04-11 09:57:22 +02:00
}
else
2017-05-22 17:06:20 +02:00
action . firstTouch = firstTouch = true ;
//firstTouch = true;
2015-12-18 07:25:51 +01:00
}
2017-04-21 15:29:25 +02:00
else if ( ! activeCur & & activePrev )
{
// released
2017-04-11 09:57:22 +02:00
if ( secondtouchbegin )
{
2017-05-22 17:06:20 +02:00
action . firstTouch = firstTouch = false ;
action . secondtouchbegin = secondtouchbegin = false ;
//firstTouch = false;
//secondtouchbegin = false;
2017-04-11 09:57:22 +02:00
}
else if ( firstTouch )
2015-12-18 07:25:51 +01:00
{
2017-05-22 17:06:20 +02:00
action . firstTouch = firstTouch = false ;
//firstTouch = false;
2017-10-23 20:17:55 +02:00
if ( DateTime . UtcNow < = ( action . pastTime + TimeSpan . FromMilliseconds ( 150 ) ) & & ! tappedOnce )
2017-04-11 09:57:22 +02:00
{
2017-05-22 17:06:20 +02:00
action . tappedOnce = tappedOnce = true ;
//tappedOnce = true;
2017-05-27 03:57:46 +02:00
action . firstTap = DateTime . UtcNow ;
action . TimeofEnd = DateTime . UtcNow ;
2017-04-11 09:57:22 +02:00
}
2015-12-18 07:25:51 +01:00
}
}
2017-04-11 09:57:22 +02:00
int type = 0 ;
string macro = "" ;
if ( tappedOnce ) //single tap
2015-12-18 07:25:51 +01:00
{
2017-04-11 09:57:22 +02:00
if ( action . typeID = = SpecialAction . ActionTypeId . MultiAction )
{
macro = dets [ 0 ] ;
}
else if ( int . TryParse ( dets [ 0 ] , out type ) )
{
switch ( type )
{
case 0 : macro = "91/71/71/91" ; break ;
case 1 : macro = "91/164/82/82/164/91" ; break ;
case 2 : macro = "91/164/44/44/164/91" ; break ;
case 3 : macro = dets [ 3 ] + "/" + dets [ 3 ] ; break ;
case 4 : macro = "91/164/71/71/164/91" ; break ;
}
}
2017-05-22 17:06:20 +02:00
2017-05-27 03:57:46 +02:00
if ( ( DateTime . UtcNow - action . TimeofEnd ) > TimeSpan . FromMilliseconds ( 150 ) )
2015-12-18 07:25:51 +01:00
{
2017-04-11 09:57:22 +02:00
if ( macro ! = "" )
PlayMacro ( device , macroControl , macro , DS4Controls . None , DS4KeyType . None ) ;
2017-05-22 17:06:20 +02:00
2017-04-11 09:57:22 +02:00
tappedOnce = false ;
2017-05-22 17:06:20 +02:00
action . tappedOnce = false ;
2015-12-18 07:25:51 +01:00
}
2017-04-11 09:57:22 +02: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)
2015-12-18 07:25:51 +01:00
}
2017-10-23 20:17:55 +02:00
else if ( firstTouch & & ( DateTime . UtcNow - action . pastTime ) > TimeSpan . FromMilliseconds ( 500 ) ) //helddown
2015-12-18 07:25:51 +01:00
{
2017-04-11 09:57:22 +02:00
if ( action . typeID = = SpecialAction . ActionTypeId . MultiAction )
{
macro = dets [ 1 ] ;
}
else if ( int . TryParse ( dets [ 1 ] , out type ) )
{
switch ( type )
{
case 0 : macro = "91/71/71/91" ; break ;
case 1 : macro = "91/164/82/82/164/91" ; break ;
case 2 : macro = "91/164/44/44/164/91" ; break ;
case 3 : macro = dets [ 3 ] + "/" + dets [ 3 ] ; break ;
case 4 : macro = "91/164/71/71/164/91" ; break ;
}
}
2017-05-22 17:06:20 +02:00
Version 1.4.5
Added support for the New DS4 USB Adapater (Thanks to boganhobo and
Chamilsaan)
Implemented teokp's amazing fix for hide ds4 not working on the
anniversary update of Windows 10: when a controller fails to enter
exclusive mode, DS4Windows will ask for admin privilages to fix the
issue.
Now (near)unlimited Special Actions can be made from the previous limit
of 50
Special Action Xbox Game DVR is now no longer limited to Windows 10,
renamed multi action button: Assign a macro to single tap, double tap,
and holding down a button
Added option for White DS4Windows Icon in the notification tray (While
not merged from, thanks to tehmantra)
Added option to temporarily turn off DS4Windows when using a certain
program (togglable in the Auto Profiles Tab) (Same case as above but
thanks to dedChar to bring to light)
Fixed Options crashes in certain locales where decimal points are
repesented with commas, such as German (Thanks to kiliansch)
Added/Updated translations for many languauges, now including Japanese,
Slovenian, Hungarian, Greek, Finnish, Czech, Indonesian, and Ukrainian
2016-09-22 03:38:38 +02:00
if ( macro ! = "" )
PlayMacro ( device , macroControl , macro , DS4Controls . None , DS4KeyType . None ) ;
2017-05-22 17:06:20 +02:00
2017-04-11 09:57:22 +02:00
firstTouch = false ;
2017-05-22 17:06:20 +02:00
action . firstTouch = false ;
Version 1.4.5
Added support for the New DS4 USB Adapater (Thanks to boganhobo and
Chamilsaan)
Implemented teokp's amazing fix for hide ds4 not working on the
anniversary update of Windows 10: when a controller fails to enter
exclusive mode, DS4Windows will ask for admin privilages to fix the
issue.
Now (near)unlimited Special Actions can be made from the previous limit
of 50
Special Action Xbox Game DVR is now no longer limited to Windows 10,
renamed multi action button: Assign a macro to single tap, double tap,
and holding down a button
Added option for White DS4Windows Icon in the notification tray (While
not merged from, thanks to tehmantra)
Added option to temporarily turn off DS4Windows when using a certain
program (togglable in the Auto Profiles Tab) (Same case as above but
thanks to dedChar to bring to light)
Fixed Options crashes in certain locales where decimal points are
repesented with commas, such as German (Thanks to kiliansch)
Added/Updated translations for many languauges, now including Japanese,
Slovenian, Hungarian, Greek, Finnish, Czech, Indonesian, and Ukrainian
2016-09-22 03:38:38 +02:00
}
2017-04-11 09:57:22 +02:00
else if ( secondtouchbegin ) //if double tap
Version 1.4.266
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
2015-07-31 05:34:22 +02:00
{
2017-04-11 09:57:22 +02:00
if ( action . typeID = = SpecialAction . ActionTypeId . MultiAction )
2015-12-18 07:25:51 +01:00
{
2017-04-11 09:57:22 +02:00
macro = dets [ 2 ] ;
2015-12-18 07:25:51 +01:00
}
2017-04-11 09:57:22 +02:00
else if ( int . TryParse ( dets [ 2 ] , out type ) )
2015-12-18 07:25:51 +01:00
{
2017-04-11 09:57:22 +02:00
switch ( type )
{
case 0 : macro = "91/71/71/91" ; break ;
case 1 : macro = "91/164/82/82/164/91" ; break ;
case 2 : macro = "91/164/44/44/164/91" ; break ;
case 3 : macro = dets [ 3 ] + "/" + dets [ 3 ] ; break ;
case 4 : macro = "91/164/71/71/164/91" ; break ;
}
2015-12-18 07:25:51 +01:00
}
2017-05-22 17:06:20 +02:00
2017-04-11 09:57:22 +02:00
if ( macro ! = "" )
PlayMacro ( device , macroControl , macro , DS4Controls . None , DS4KeyType . None ) ;
2017-05-22 17:06:20 +02:00
2017-04-11 09:57:22 +02:00
secondtouchbegin = false ;
2017-05-22 17:06:20 +02:00
action . secondtouchbegin = false ;
Version 1.4.266
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
2015-07-31 05:34:22 +02:00
}
2017-04-11 09:57:22 +02:00
}
else
{
actionDone [ index ] . dev [ device ] = false ;
Version 1.4.266
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
2015-07-31 05:34:22 +02:00
}
}
}
2014-12-13 21:12:03 +01:00
}
}
2015-12-18 07:25:51 +01:00
catch { return ; }
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
2014-12-13 21:12:03 +01:00
if ( untriggeraction [ device ] ! = null )
{
SpecialAction action = untriggeraction [ device ] ;
int index = untriggerindex [ device ] ;
2019-04-23 02:39:44 +02:00
bool utriggeractivated ;
if ( ! action . automaticUntrigger )
2014-12-13 21:12:03 +01:00
{
2019-04-23 02:39:44 +02:00
// Untrigger keys defined and auto-untrigger (=unload) profile option is NOT set. Unload a temporary profile only when specified untrigger keys have been triggered.
utriggeractivated = true ;
//foreach (DS4Controls dc in action.uTrigger)
for ( int i = 0 , uTrigLen = action . uTrigger . Count ; i < uTrigLen ; i + + )
2014-12-13 21:12:03 +01:00
{
2019-04-23 02:39:44 +02:00
DS4Controls dc = action . uTrigger [ i ] ;
if ( ! getBoolSpecialActionMapping ( device , dc , cState , eState , tp , fieldMapping ) )
{
utriggeractivated = false ;
break ;
}
}
}
else
{
// Untrigger as soon any of the defined regular trigger keys have been released.
utriggeractivated = false ;
for ( int i = 0 , trigLen = action . trigger . Count ; i < trigLen ; i + + )
{
DS4Controls dc = action . trigger [ i ] ;
if ( ! getBoolSpecialActionMapping ( device , dc , cState , eState , tp , fieldMapping ) )
{
utriggeractivated = true ;
break ;
}
2014-12-13 21:12:03 +01:00
}
}
2017-04-02 02:46:51 +02:00
if ( utriggeractivated & & action . typeID = = SpecialAction . ActionTypeId . Profile )
2014-12-13 21:12:03 +01:00
{
Version 1.4.5
Added support for the New DS4 USB Adapater (Thanks to boganhobo and
Chamilsaan)
Implemented teokp's amazing fix for hide ds4 not working on the
anniversary update of Windows 10: when a controller fails to enter
exclusive mode, DS4Windows will ask for admin privilages to fix the
issue.
Now (near)unlimited Special Actions can be made from the previous limit
of 50
Special Action Xbox Game DVR is now no longer limited to Windows 10,
renamed multi action button: Assign a macro to single tap, double tap,
and holding down a button
Added option for White DS4Windows Icon in the notification tray (While
not merged from, thanks to tehmantra)
Added option to temporarily turn off DS4Windows when using a certain
program (togglable in the Auto Profiles Tab) (Same case as above but
thanks to dedChar to bring to light)
Fixed Options crashes in certain locales where decimal points are
repesented with commas, such as German (Thanks to kiliansch)
Added/Updated translations for many languauges, now including Japanese,
Slovenian, Hungarian, Greek, Finnish, Czech, Indonesian, and Ukrainian
2016-09-22 03:38:38 +02:00
if ( ( action . controls = = action . ucontrols & & ! actionDone [ index ] . dev [ device ] ) | | //if trigger and end trigger are the same
2014-12-13 21:12:03 +01:00
action . controls ! = action . ucontrols )
2017-04-11 09:57:22 +02:00
{
2019-03-05 12:14:39 +01:00
if ( useTempProfile [ device ] )
2014-12-13 21:12:03 +01:00
{
2017-04-11 09:57:22 +02:00
//foreach (DS4Controls dc in action.uTrigger)
for ( int i = 0 , arlen = action . uTrigger . Count ; i < arlen ; i + + )
2014-12-13 21:12:03 +01:00
{
2017-04-11 09:57:22 +02:00
DS4Controls dc = action . uTrigger [ i ] ;
Version 1.4.5
Added support for the New DS4 USB Adapater (Thanks to boganhobo and
Chamilsaan)
Implemented teokp's amazing fix for hide ds4 not working on the
anniversary update of Windows 10: when a controller fails to enter
exclusive mode, DS4Windows will ask for admin privilages to fix the
issue.
Now (near)unlimited Special Actions can be made from the previous limit
of 50
Special Action Xbox Game DVR is now no longer limited to Windows 10,
renamed multi action button: Assign a macro to single tap, double tap,
and holding down a button
Added option for White DS4Windows Icon in the notification tray (While
not merged from, thanks to tehmantra)
Added option to temporarily turn off DS4Windows when using a certain
program (togglable in the Auto Profiles Tab) (Same case as above but
thanks to dedChar to bring to light)
Fixed Options crashes in certain locales where decimal points are
repesented with commas, such as German (Thanks to kiliansch)
Added/Updated translations for many languauges, now including Japanese,
Slovenian, Hungarian, Greek, Finnish, Czech, Indonesian, and Ukrainian
2016-09-22 03:38:38 +02:00
actionDone [ index ] . dev [ device ] = true ;
2017-03-30 16:07:04 +02:00
DS4ControlSettings dcs = getDS4CSetting ( device , dc ) ;
2015-12-18 07:25:51 +01:00
if ( dcs . action ! = null )
2014-12-13 21:12:03 +01:00
{
2015-12-18 07:25:51 +01:00
if ( dcs . actionType = = DS4ControlSettings . ActionType . Key )
InputMethods . performKeyRelease ( ( ushort ) dcs . action ) ;
else if ( dcs . actionType = = DS4ControlSettings . ActionType . Macro )
{
int [ ] keys = ( int [ ] ) dcs . action ;
2017-04-11 09:57:22 +02:00
for ( int j = 0 , keysLen = keys . Length ; j < keysLen ; j + + )
InputMethods . performKeyRelease ( ( ushort ) keys [ j ] ) ;
2015-12-18 07:25:51 +01:00
}
2014-12-13 21:12:03 +01:00
}
}
2017-05-17 08:02:12 +02:00
2019-04-23 02:39:44 +02:00
string profileName = untriggeraction [ device ] . prevProfileName ;
string prolog = Properties . Resources . UsingProfile . Replace ( "*number*" , ( device + 1 ) . ToString ( ) ) . Replace ( "*Profile name*" , ( profileName = = string . Empty ? ProfilePath [ device ] : profileName ) ) ;
2019-01-08 02:35:30 +01:00
AppLogger . LogToGui ( prolog , false ) ;
2019-04-23 02:39:44 +02:00
untriggeraction [ device ] = null ;
if ( profileName = = string . Empty )
LoadProfile ( device , false , ctrl ) ; // Previous profile was a regular default profile of a controller
else
LoadTempProfile ( device , profileName , true , ctrl ) ; // Previous profile was a temporary profile, so re-load it as a temp profile
2014-12-13 21:12:03 +01:00
}
2017-04-11 09:57:22 +02:00
}
2014-12-13 21:12:03 +01:00
}
else
2017-04-11 09:57:22 +02:00
{
Version 1.4.5
Added support for the New DS4 USB Adapater (Thanks to boganhobo and
Chamilsaan)
Implemented teokp's amazing fix for hide ds4 not working on the
anniversary update of Windows 10: when a controller fails to enter
exclusive mode, DS4Windows will ask for admin privilages to fix the
issue.
Now (near)unlimited Special Actions can be made from the previous limit
of 50
Special Action Xbox Game DVR is now no longer limited to Windows 10,
renamed multi action button: Assign a macro to single tap, double tap,
and holding down a button
Added option for White DS4Windows Icon in the notification tray (While
not merged from, thanks to tehmantra)
Added option to temporarily turn off DS4Windows when using a certain
program (togglable in the Auto Profiles Tab) (Same case as above but
thanks to dedChar to bring to light)
Fixed Options crashes in certain locales where decimal points are
repesented with commas, such as German (Thanks to kiliansch)
Added/Updated translations for many languauges, now including Japanese,
Slovenian, Hungarian, Greek, Finnish, Czech, Indonesian, and Ukrainian
2016-09-22 03:38:38 +02:00
actionDone [ index ] . dev [ device ] = false ;
2017-04-11 09:57:22 +02:00
}
2014-12-13 21:12:03 +01:00
}
}
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
2015-02-12 20:36:40 +01:00
private static async void PlayMacro ( int device , bool [ ] macrocontrol , string macro , DS4Controls control , DS4KeyType keyType )
{
if ( macro . StartsWith ( "164/9/9/164" ) | | macro . StartsWith ( "18/9/9/18" ) )
{
string [ ] skeys ;
int wait = 1000 ;
if ( ! string . IsNullOrEmpty ( macro ) )
{
skeys = macro . Split ( '/' ) ;
ushort delay ;
if ( ushort . TryParse ( skeys [ skeys . Length - 1 ] , out delay ) & & delay > 300 )
wait = delay - 300 ;
}
AltTabSwapping ( wait , device ) ;
if ( control ! = DS4Controls . None )
macrodone [ DS4ControltoInt ( control ) ] = true ;
}
else
{
string [ ] skeys ;
int [ ] keys ;
if ( ! string . IsNullOrEmpty ( macro ) )
{
skeys = macro . Split ( '/' ) ;
keys = new int [ skeys . Length ] ;
}
else
{
skeys = new string [ 0 ] ;
keys = new int [ 0 ] ;
}
for ( int i = 0 ; i < keys . Length ; i + + )
2015-08-13 05:53:43 +02:00
keys [ i ] = int . Parse ( skeys [ i ] ) ;
2015-02-12 20:36:40 +01:00
bool [ ] keydown = new bool [ 286 ] ;
if ( control = = DS4Controls . None | | ! macrodone [ DS4ControltoInt ( control ) ] )
{
if ( control ! = DS4Controls . None )
macrodone [ DS4ControltoInt ( control ) ] = true ;
foreach ( int i in keys )
{
2015-08-13 05:53:43 +02:00
if ( i > = 1000000000 )
{
string lb = i . ToString ( ) . Substring ( 1 ) ;
if ( i > 1000000000 )
{
byte r = ( byte ) ( int . Parse ( lb [ 0 ] . ToString ( ) ) * 100 + int . Parse ( lb [ 1 ] . ToString ( ) ) * 10 + int . Parse ( lb [ 2 ] . ToString ( ) ) ) ;
byte g = ( byte ) ( int . Parse ( lb [ 3 ] . ToString ( ) ) * 100 + int . Parse ( lb [ 4 ] . ToString ( ) ) * 10 + int . Parse ( lb [ 5 ] . ToString ( ) ) ) ;
byte b = ( byte ) ( int . Parse ( lb [ 6 ] . ToString ( ) ) * 100 + int . Parse ( lb [ 7 ] . ToString ( ) ) * 10 + int . Parse ( lb [ 8 ] . ToString ( ) ) ) ;
DS4LightBar . forcelight [ device ] = true ;
DS4LightBar . forcedFlash [ device ] = 0 ;
DS4LightBar . forcedColor [ device ] = new DS4Color ( r , g , b ) ;
}
else
{
DS4LightBar . forcedFlash [ device ] = 0 ;
DS4LightBar . forcelight [ device ] = false ;
}
}
else if ( i > = 1000000 )
{
DS4Device d = Program . rootHub . DS4Controllers [ device ] ;
string r = i . ToString ( ) . Substring ( 1 ) ;
byte heavy = ( byte ) ( int . Parse ( r [ 0 ] . ToString ( ) ) * 100 + int . Parse ( r [ 1 ] . ToString ( ) ) * 10 + int . Parse ( r [ 2 ] . ToString ( ) ) ) ;
byte light = ( byte ) ( int . Parse ( r [ 3 ] . ToString ( ) ) * 100 + int . Parse ( r [ 4 ] . ToString ( ) ) * 10 + int . Parse ( r [ 5 ] . ToString ( ) ) ) ;
d . setRumble ( light , heavy ) ;
}
else if ( i > = 300 ) //ints over 300 used to delay
2015-02-12 20:36:40 +01:00
await Task . Delay ( i - 300 ) ;
else if ( ! keydown [ i ] )
{
if ( i = = 256 ) InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_LEFTDOWN ) ; //anything above 255 is not a keyvalue
else if ( i = = 257 ) InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_RIGHTDOWN ) ;
else if ( i = = 258 ) InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_MIDDLEDOWN ) ;
else if ( i = = 259 ) InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_XBUTTONDOWN , 1 ) ;
else if ( i = = 260 ) InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_XBUTTONDOWN , 2 ) ;
2017-11-23 09:31:35 +01:00
else if ( i = = 261 ) { macroControl [ 0 ] = true ; macroCount + + ; }
else if ( i = = 262 ) { macroControl [ 1 ] = true ; macroCount + + ; }
else if ( i = = 263 ) { macroControl [ 2 ] = true ; macroCount + + ; }
else if ( i = = 264 ) { macroControl [ 3 ] = true ; macroCount + + ; }
else if ( i = = 265 ) { macroControl [ 4 ] = true ; macroCount + + ; }
else if ( i = = 266 ) { macroControl [ 5 ] = true ; macroCount + + ; }
else if ( i = = 267 ) { macroControl [ 6 ] = true ; macroCount + + ; }
else if ( i = = 268 ) { macroControl [ 7 ] = true ; macroCount + + ; }
else if ( i = = 269 ) { macroControl [ 8 ] = true ; macroCount + + ; }
else if ( i = = 270 ) { macroControl [ 9 ] = true ; macroCount + + ; }
else if ( i = = 271 ) { macroControl [ 10 ] = true ; macroCount + + ; }
else if ( i = = 272 ) { macroControl [ 11 ] = true ; macroCount + + ; }
else if ( i = = 273 ) { macroControl [ 12 ] = true ; macroCount + + ; }
else if ( i = = 274 ) { macroControl [ 13 ] = true ; macroCount + + ; }
else if ( i = = 275 ) { macroControl [ 14 ] = true ; macroCount + + ; }
else if ( i = = 276 ) { macroControl [ 15 ] = true ; macroCount + + ; }
else if ( i = = 277 ) { macroControl [ 16 ] = true ; macroCount + + ; }
else if ( i = = 278 ) { macroControl [ 17 ] = true ; macroCount + + ; }
else if ( i = = 279 ) { macroControl [ 18 ] = true ; macroCount + + ; }
else if ( i = = 280 ) { macroControl [ 19 ] = true ; macroCount + + ; }
else if ( i = = 281 ) { macroControl [ 20 ] = true ; macroCount + + ; }
else if ( i = = 282 ) { macroControl [ 21 ] = true ; macroCount + + ; }
else if ( i = = 283 ) { macroControl [ 22 ] = true ; macroCount + + ; }
else if ( i = = 284 ) { macroControl [ 23 ] = true ; macroCount + + ; }
else if ( i = = 285 ) { macroControl [ 24 ] = true ; macroCount + + ; }
2015-02-12 20:36:40 +01:00
else if ( keyType . HasFlag ( DS4KeyType . ScanCode ) )
InputMethods . performSCKeyPress ( ( ushort ) i ) ;
else
InputMethods . performKeyPress ( ( ushort ) i ) ;
keydown [ i ] = true ;
}
else
{
if ( i = = 256 ) InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_LEFTUP ) ; //anything above 255 is not a keyvalue
else if ( i = = 257 ) InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_RIGHTUP ) ;
else if ( i = = 258 ) InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_MIDDLEUP ) ;
else if ( i = = 259 ) InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_XBUTTONUP , 1 ) ;
else if ( i = = 260 ) InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_XBUTTONUP , 2 ) ;
2017-11-23 09:31:35 +01:00
else if ( i = = 261 ) { macroControl [ 0 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 262 ) { macroControl [ 1 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 263 ) { macroControl [ 2 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 264 ) { macroControl [ 3 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 265 ) { macroControl [ 4 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 266 ) { macroControl [ 5 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 267 ) { macroControl [ 6 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 268 ) { macroControl [ 7 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 269 ) { macroControl [ 8 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 270 ) { macroControl [ 9 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 271 ) { macroControl [ 10 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 272 ) { macroControl [ 11 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 273 ) { macroControl [ 12 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 274 ) { macroControl [ 13 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 275 ) { macroControl [ 14 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 276 ) { macroControl [ 15 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 277 ) { macroControl [ 16 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 278 ) { macroControl [ 17 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 279 ) { macroControl [ 18 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 280 ) { macroControl [ 19 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 281 ) { macroControl [ 20 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 282 ) { macroControl [ 21 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 283 ) { macroControl [ 22 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 284 ) { macroControl [ 23 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 285 ) { macroControl [ 24 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
2015-02-12 20:36:40 +01:00
else if ( keyType . HasFlag ( DS4KeyType . ScanCode ) )
InputMethods . performSCKeyRelease ( ( ushort ) i ) ;
else
InputMethods . performKeyRelease ( ( ushort ) i ) ;
keydown [ i ] = false ;
}
}
2017-03-29 16:26:07 +02:00
for ( int i = 0 , arlength = keydown . Length ; i < arlength ; i + + )
2015-02-12 20:36:40 +01:00
{
if ( keydown [ i ] )
2017-04-21 15:29:25 +02:00
{
2015-02-12 20:36:40 +01:00
if ( i = = 256 ) InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_LEFTUP ) ; //anything above 255 is not a keyvalue
else if ( i = = 257 ) InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_RIGHTUP ) ;
else if ( i = = 258 ) InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_MIDDLEUP ) ;
else if ( i = = 259 ) InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_XBUTTONUP , 1 ) ;
else if ( i = = 260 ) InputMethods . MouseEvent ( InputMethods . MOUSEEVENTF_XBUTTONUP , 2 ) ;
2017-11-23 09:31:35 +01:00
else if ( i = = 261 ) { macroControl [ 0 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 262 ) { macroControl [ 1 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 263 ) { macroControl [ 2 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 264 ) { macroControl [ 3 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 265 ) { macroControl [ 4 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 266 ) { macroControl [ 5 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 267 ) { macroControl [ 6 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 268 ) { macroControl [ 7 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 269 ) { macroControl [ 8 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 270 ) { macroControl [ 9 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 271 ) { macroControl [ 10 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 272 ) { macroControl [ 11 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 273 ) { macroControl [ 12 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 274 ) { macroControl [ 13 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 275 ) { macroControl [ 14 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 276 ) { macroControl [ 15 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 277 ) { macroControl [ 16 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 278 ) { macroControl [ 17 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 279 ) { macroControl [ 18 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 280 ) { macroControl [ 19 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 281 ) { macroControl [ 20 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 282 ) { macroControl [ 21 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 283 ) { macroControl [ 22 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 284 ) { macroControl [ 23 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
else if ( i = = 285 ) { macroControl [ 24 ] = false ; if ( macroCount > 0 ) macroCount - - ; }
2015-02-12 20:36:40 +01:00
else if ( keyType . HasFlag ( DS4KeyType . ScanCode ) )
2017-03-29 16:26:07 +02:00
InputMethods . performSCKeyRelease ( ( ushort ) i ) ;
2015-02-12 20:36:40 +01:00
else
2017-03-29 16:26:07 +02:00
InputMethods . performKeyRelease ( ( ushort ) i ) ;
2017-04-21 15:29:25 +02:00
}
2015-02-12 20:36:40 +01:00
}
2017-04-21 15:29:25 +02:00
2015-08-13 05:53:43 +02:00
DS4LightBar . forcedFlash [ device ] = 0 ;
DS4LightBar . forcelight [ device ] = false ;
Program . rootHub . DS4Controllers [ device ] . setRumble ( 0 , 0 ) ;
2015-02-12 20:36:40 +01:00
if ( keyType . HasFlag ( DS4KeyType . HoldMacro ) )
{
await Task . Delay ( 50 ) ;
if ( control ! = DS4Controls . None )
macrodone [ DS4ControltoInt ( control ) ] = false ;
}
}
}
}
private static void EndMacro ( int device , bool [ ] macrocontrol , string macro , DS4Controls control )
{
if ( ( macro . StartsWith ( "164/9/9/164" ) | | macro . StartsWith ( "18/9/9/18" ) ) & & ! altTabDone )
AltTabSwappingRelease ( ) ;
2017-04-21 15:29:25 +02:00
2015-02-12 20:36:40 +01:00
if ( control ! = DS4Controls . None )
macrodone [ DS4ControltoInt ( control ) ] = false ;
}
2017-04-21 05:09:08 +02:00
2015-02-12 20:36:40 +01:00
private static void AltTabSwapping ( int wait , int device )
{
if ( altTabDone )
{
altTabDone = false ;
InputMethods . performKeyPress ( 18 ) ;
}
else
{
altTabNow = DateTime . UtcNow ;
if ( altTabNow > = oldAltTabNow + TimeSpan . FromMilliseconds ( wait ) )
{
oldAltTabNow = altTabNow ;
InputMethods . performKeyPress ( 9 ) ;
InputMethods . performKeyRelease ( 9 ) ;
}
}
}
private static void AltTabSwappingRelease ( )
{
if ( altTabNow < DateTime . UtcNow - TimeSpan . FromMilliseconds ( 10 ) ) //in case multiple controls are mapped to alt+tab
{
altTabDone = true ;
InputMethods . performKeyRelease ( 9 ) ;
InputMethods . performKeyRelease ( 18 ) ;
altTabNow = DateTime . UtcNow ;
oldAltTabNow = DateTime . UtcNow - TimeSpan . FromDays ( 1 ) ;
}
}
2017-04-24 16:16:42 +02:00
private static void getMouseWheelMapping ( int device , DS4Controls control , DS4State cState ,
DS4StateExposed eState , Mouse tp , bool down )
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
{
DateTime now = DateTime . UtcNow ;
if ( now > = oldnow + TimeSpan . FromMilliseconds ( 10 ) & & ! pressagain )
{
oldnow = now ;
2018-12-27 05:27:01 +01:00
InputMethods . MouseWheel ( ( int ) ( getByteMapping ( device , control , cState , eState , tp ) / 1.5f * ( down ? - 1 : 1 ) ) , 0 ) ;
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
}
}
2017-04-21 11:48:13 +02:00
private static double getMouseMapping ( int device , DS4Controls control , DS4State cState , DS4StateExposed eState ,
2017-05-31 09:47:13 +02:00
DS4StateFieldMapping fieldMapping , int mnum , ControlService ctrl )
2014-04-27 21:32:09 +02:00
{
2014-06-26 20:02:01 +02:00
int controlnum = DS4ControltoInt ( control ) ;
2017-04-14 09:55:22 +02:00
2018-06-07 22:33:02 +02:00
int deadzoneL = 0 ;
int deadzoneR = 0 ;
if ( getLSDeadzone ( device ) = = 0 )
deadzoneL = 3 ;
if ( getRSDeadzone ( device ) = = 0 )
deadzoneR = 3 ;
2017-04-14 05:23:44 +02:00
double value = 0.0 ;
2017-11-25 10:13:22 +01:00
int speed = ButtonMouseSensitivity [ device ] ;
2014-06-14 21:14:27 +02:00
double root = 1.002 ;
double divide = 10000d ;
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
//DateTime now = mousenow[mnum];
2017-04-14 05:23:44 +02:00
2017-04-21 11:48:13 +02:00
int controlNum = ( int ) control ;
DS4StateFieldMapping . ControlType controlType = DS4StateFieldMapping . mappedType [ controlNum ] ;
2017-06-19 17:50:28 +02:00
//long timeElapsed = ctrl.DS4Controllers[device].getLastTimeElapsed();
double timeElapsed = ctrl . DS4Controllers [ device ] . lastTimeElapsedDouble ;
2017-05-31 22:06:52 +02:00
//double mouseOffset = 0.025;
2017-06-11 04:58:30 +02:00
double tempMouseOffsetX = 0.0 , tempMouseOffsetY = 0.0 ;
2017-04-21 11:48:13 +02:00
if ( controlType = = DS4StateFieldMapping . ControlType . Button )
{
bool active = fieldMapping . buttons [ controlNum ] ;
value = ( active ? Math . Pow ( root + speed / divide , 100 ) - 1 : 0 ) ;
}
else if ( controlType = = DS4StateFieldMapping . ControlType . AxisDir )
2014-04-29 23:56:58 +02:00
{
2017-04-14 05:23:44 +02:00
switch ( control )
{
case DS4Controls . LXNeg :
2017-05-31 09:47:13 +02:00
{
2019-01-13 20:32:38 +01:00
if ( cState . LX < 128 - deadzoneL )
2017-05-31 09:47:13 +02:00
{
2019-01-13 20:32:38 +01:00
double diff = - ( cState . LX - 128 - deadzoneL ) / ( double ) ( 0 - 128 - deadzoneL ) ;
2017-06-11 02:48:34 +02:00
//tempMouseOffsetX = Math.Abs(Math.Cos(cState.LSAngleRad)) * MOUSESTICKOFFSET;
//tempMouseOffsetX = MOUSESTICKOFFSET;
tempMouseOffsetX = cState . LXUnit * MOUSESTICKOFFSET ;
2017-06-17 12:13:33 +02:00
value = ( ( speed * MOUSESPEEDFACTOR * ( timeElapsed * 0.001 ) ) - tempMouseOffsetX ) * diff + ( tempMouseOffsetX * - 1.0 ) ;
2017-05-31 22:06:52 +02:00
//value = diff * MOUSESPEEDFACTOR * (timeElapsed * 0.001) * speed;
2017-05-31 09:47:13 +02:00
//value = -(cState.LX - 127 - deadzoneL) / 2550d * speed;
}
2017-04-14 05:23:44 +02:00
break ;
2017-05-31 09:47:13 +02:00
}
2017-04-14 05:23:44 +02:00
case DS4Controls . LXPos :
2017-05-31 09:47:13 +02:00
{
2019-01-13 20:32:38 +01:00
if ( cState . LX > 128 + deadzoneL )
2017-05-31 09:47:13 +02:00
{
2019-01-13 20:32:38 +01:00
double diff = ( cState . LX - 128 + deadzoneL ) / ( double ) ( 255 - 128 + deadzoneL ) ;
2017-06-11 02:48:34 +02:00
tempMouseOffsetX = cState . LXUnit * MOUSESTICKOFFSET ;
//tempMouseOffsetX = Math.Abs(Math.Cos(cState.LSAngleRad)) * MOUSESTICKOFFSET;
//tempMouseOffsetX = MOUSESTICKOFFSET;
value = ( ( speed * MOUSESPEEDFACTOR * ( timeElapsed * 0.001 ) ) - tempMouseOffsetX ) * diff + tempMouseOffsetX ;
2017-05-31 22:06:52 +02:00
//value = diff * MOUSESPEEDFACTOR * (timeElapsed * 0.001) * speed;
2017-05-31 09:47:13 +02:00
//value = (cState.LX - 127 + deadzoneL) / 2550d * speed;
}
2017-04-14 05:23:44 +02:00
break ;
2017-05-31 09:47:13 +02:00
}
2017-04-14 05:23:44 +02:00
case DS4Controls . RXNeg :
2017-05-31 09:47:13 +02:00
{
2019-01-13 20:32:38 +01:00
if ( cState . RX < 128 - deadzoneR )
2017-05-31 09:47:13 +02:00
{
2019-01-13 20:32:38 +01:00
double diff = - ( cState . RX - 128 - deadzoneR ) / ( double ) ( 0 - 128 - deadzoneR ) ;
2017-06-11 02:48:34 +02:00
tempMouseOffsetX = cState . RXUnit * MOUSESTICKOFFSET ;
//tempMouseOffsetX = MOUSESTICKOFFSET;
//tempMouseOffsetX = Math.Abs(Math.Cos(cState.RSAngleRad)) * MOUSESTICKOFFSET;
2017-06-17 12:13:33 +02:00
value = ( ( speed * MOUSESPEEDFACTOR * ( timeElapsed * 0.001 ) ) - tempMouseOffsetX ) * diff + ( tempMouseOffsetX * - 1.0 ) ;
2017-05-31 22:06:52 +02:00
//value = diff * MOUSESPEEDFACTOR * (timeElapsed * 0.001) * speed;
2017-05-31 09:47:13 +02:00
//value = -(cState.RX - 127 - deadzoneR) / 2550d * speed;
}
2017-04-14 05:23:44 +02:00
break ;
2017-05-31 09:47:13 +02:00
}
2017-04-14 05:23:44 +02:00
case DS4Controls . RXPos :
2017-05-31 09:47:13 +02:00
{
2019-01-13 20:32:38 +01:00
if ( cState . RX > 128 + deadzoneR )
2017-05-31 09:47:13 +02:00
{
2019-01-13 20:32:38 +01:00
double diff = ( cState . RX - 128 + deadzoneR ) / ( double ) ( 255 - 128 + deadzoneR ) ;
2017-06-11 02:48:34 +02:00
tempMouseOffsetX = cState . RXUnit * MOUSESTICKOFFSET ;
//tempMouseOffsetX = MOUSESTICKOFFSET;
//tempMouseOffsetX = Math.Abs(Math.Cos(cState.RSAngleRad)) * MOUSESTICKOFFSET;
value = ( ( speed * MOUSESPEEDFACTOR * ( timeElapsed * 0.001 ) ) - tempMouseOffsetX ) * diff + tempMouseOffsetX ;
2017-05-31 22:06:52 +02:00
//value = diff * MOUSESPEEDFACTOR * (timeElapsed * 0.001) * speed;
2017-05-31 09:47:13 +02:00
//value = (cState.RX - 127 + deadzoneR) / 2550d * speed;
}
2017-04-14 05:23:44 +02:00
break ;
2017-05-31 09:47:13 +02:00
}
2017-04-14 05:23:44 +02:00
case DS4Controls . LYNeg :
2017-05-31 09:47:13 +02:00
{
2019-01-13 20:32:38 +01:00
if ( cState . LY < 128 - deadzoneL )
2017-05-31 09:47:13 +02:00
{
2019-01-13 20:32:38 +01:00
double diff = - ( cState . LY - 128 - deadzoneL ) / ( double ) ( 0 - 128 - deadzoneL ) ;
2017-06-11 02:48:34 +02:00
tempMouseOffsetY = cState . LYUnit * MOUSESTICKOFFSET ;
//tempMouseOffsetY = MOUSESTICKOFFSET;
//tempMouseOffsetY = Math.Abs(Math.Sin(cState.LSAngleRad)) * MOUSESTICKOFFSET;
2017-06-17 12:13:33 +02:00
value = ( ( speed * MOUSESPEEDFACTOR * ( timeElapsed * 0.001 ) ) - tempMouseOffsetY ) * diff + ( tempMouseOffsetY * - 1.0 ) ;
2017-05-31 22:06:52 +02:00
//value = diff * MOUSESPEEDFACTOR * (timeElapsed * 0.001) * speed;
2017-05-31 09:47:13 +02:00
//value = -(cState.LY - 127 - deadzoneL) / 2550d * speed;
}
2017-04-14 05:23:44 +02:00
break ;
2017-05-31 09:47:13 +02:00
}
2017-04-14 05:23:44 +02:00
case DS4Controls . LYPos :
2017-05-31 09:47:13 +02:00
{
2019-01-13 20:32:38 +01:00
if ( cState . LY > 128 + deadzoneL )
2017-05-31 09:47:13 +02:00
{
2019-01-13 20:32:38 +01:00
double diff = ( cState . LY - 128 + deadzoneL ) / ( double ) ( 255 - 128 + deadzoneL ) ;
2017-06-11 02:48:34 +02:00
tempMouseOffsetY = cState . LYUnit * MOUSESTICKOFFSET ;
//tempMouseOffsetY = MOUSESTICKOFFSET;
//tempMouseOffsetY = Math.Abs(Math.Sin(cState.LSAngleRad)) * MOUSESTICKOFFSET;
value = ( ( speed * MOUSESPEEDFACTOR * ( timeElapsed * 0.001 ) ) - tempMouseOffsetY ) * diff + tempMouseOffsetY ;
2017-05-31 22:06:52 +02:00
//value = diff * MOUSESPEEDFACTOR * (timeElapsed * 0.001) * speed;
2017-05-31 09:47:13 +02:00
//value = (cState.LY - 127 + deadzoneL) / 2550d * speed;
}
2017-04-14 05:23:44 +02:00
break ;
2017-05-31 09:47:13 +02:00
}
2017-04-14 05:23:44 +02:00
case DS4Controls . RYNeg :
2017-05-31 09:47:13 +02:00
{
2019-01-13 20:32:38 +01:00
if ( cState . RY < 128 - deadzoneR )
2017-05-31 09:47:13 +02:00
{
2019-01-13 20:32:38 +01:00
double diff = - ( cState . RY - 128 - deadzoneR ) / ( double ) ( 0 - 128 - deadzoneR ) ;
2017-06-11 02:48:34 +02:00
tempMouseOffsetY = cState . RYUnit * MOUSESTICKOFFSET ;
//tempMouseOffsetY = MOUSESTICKOFFSET;
//tempMouseOffsetY = Math.Abs(Math.Sin(cState.RSAngleRad)) * MOUSESTICKOFFSET;
2017-06-17 12:13:33 +02:00
value = ( ( speed * MOUSESPEEDFACTOR * ( timeElapsed * 0.001 ) ) - tempMouseOffsetY ) * diff + ( tempMouseOffsetY * - 1.0 ) ;
2017-05-31 22:06:52 +02:00
//value = diff * MOUSESPEEDFACTOR * (timeElapsed * 0.001) * speed;
2017-05-31 09:47:13 +02:00
//value = -(cState.RY - 127 - deadzoneR) / 2550d * speed;
}
2017-04-14 05:23:44 +02:00
break ;
2017-05-31 09:47:13 +02:00
}
2017-04-14 05:23:44 +02:00
case DS4Controls . RYPos :
2017-05-31 09:47:13 +02:00
{
2019-01-13 20:32:38 +01:00
if ( cState . RY > 128 + deadzoneR )
2017-05-31 09:47:13 +02:00
{
2019-01-13 20:32:38 +01:00
double diff = ( cState . RY - 128 + deadzoneR ) / ( double ) ( 255 - 128 + deadzoneR ) ;
2017-06-11 02:48:34 +02:00
tempMouseOffsetY = cState . RYUnit * MOUSESTICKOFFSET ;
//tempMouseOffsetY = MOUSESTICKOFFSET;
//tempMouseOffsetY = Math.Abs(Math.Sin(cState.RSAngleRad)) * MOUSESTICKOFFSET;
value = ( ( speed * MOUSESPEEDFACTOR * ( timeElapsed * 0.001 ) ) - tempMouseOffsetY ) * diff + tempMouseOffsetY ;
2017-05-31 22:06:52 +02:00
//value = diff * MOUSESPEEDFACTOR * (timeElapsed * 0.001) * speed;
2017-05-31 09:47:13 +02:00
//value = (cState.RY - 127 + deadzoneR) / 2550d * speed;
}
2017-04-14 05:23:44 +02:00
break ;
2017-05-31 09:47:13 +02:00
}
2017-04-14 05:23:44 +02:00
default : break ;
}
}
2017-04-21 11:48:13 +02:00
else if ( controlType = = DS4StateFieldMapping . ControlType . Trigger )
{
byte trigger = fieldMapping . triggers [ controlNum ] ;
value = Math . Pow ( root + speed / divide , trigger / 2d ) - 1 ;
}
else if ( controlType = = DS4StateFieldMapping . ControlType . GyroDir )
2017-04-14 05:23:44 +02:00
{
2017-07-18 21:21:03 +02:00
//double SXD = getSXDeadzone(device);
//double SZD = getSZDeadzone(device);
2017-04-14 09:55:22 +02:00
2017-04-14 05:23:44 +02:00
switch ( control )
{
case DS4Controls . GyroXPos :
2017-04-14 09:55:22 +02:00
{
2017-04-21 11:48:13 +02:00
int gyroX = fieldMapping . gryodirs [ controlNum ] ;
2017-07-18 21:21:03 +02:00
value = ( byte ) ( gyroX > 0 ? Math . Pow ( root + speed / divide , gyroX ) : 0 ) ;
2017-04-14 05:23:44 +02:00
break ;
2017-04-14 09:55:22 +02:00
}
2017-04-14 05:23:44 +02:00
case DS4Controls . GyroXNeg :
2017-04-14 09:55:22 +02:00
{
2017-04-21 11:48:13 +02:00
int gyroX = fieldMapping . gryodirs [ controlNum ] ;
2017-07-18 21:21:03 +02:00
value = ( byte ) ( gyroX < 0 ? Math . Pow ( root + speed / divide , - gyroX ) : 0 ) ;
2017-04-14 05:23:44 +02:00
break ;
2017-04-14 09:55:22 +02:00
}
2017-04-14 05:23:44 +02:00
case DS4Controls . GyroZPos :
2017-04-14 09:55:22 +02:00
{
2017-04-21 11:48:13 +02:00
int gyroZ = fieldMapping . gryodirs [ controlNum ] ;
2017-07-18 21:21:03 +02:00
value = ( byte ) ( gyroZ > 0 ? Math . Pow ( root + speed / divide , gyroZ ) : 0 ) ;
2017-04-14 05:23:44 +02:00
break ;
2017-04-14 09:55:22 +02:00
}
2017-04-14 05:23:44 +02:00
case DS4Controls . GyroZNeg :
2017-04-14 09:55:22 +02:00
{
2017-04-21 11:48:13 +02:00
int gyroZ = fieldMapping . gryodirs [ controlNum ] ;
2017-07-18 21:21:03 +02:00
value = ( byte ) ( gyroZ < 0 ? Math . Pow ( root + speed / divide , - gyroZ ) : 0 ) ;
2017-04-14 05:23:44 +02:00
break ;
2017-04-14 09:55:22 +02:00
}
2017-04-14 05:23:44 +02:00
default : break ;
}
2014-04-29 23:56:58 +02:00
}
2017-04-14 04:50:46 +02:00
2017-04-21 15:29:25 +02:00
if ( getMouseAccel ( device ) )
2014-06-26 20:02:01 +02:00
{
if ( value > 0 )
2014-05-28 21:47:25 +02:00
{
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
mcounter = 34 ;
mouseaccel + + ;
2014-05-28 21:47:25 +02:00
}
2017-04-21 05:09:08 +02:00
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 ( mouseaccel = = prevmouseaccel )
{
mcounter - - ;
}
2017-04-21 05:09:08 +02:00
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 ( mcounter < = 0 )
{
mouseaccel = 0 ;
mcounter = 34 ;
}
2017-04-21 05:09:08 +02:00
2017-07-18 22:37:01 +02:00
value * = 1 + Math . Min ( 20000 , ( mouseaccel ) ) / 10000d ;
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
prevmouseaccel = mouseaccel ;
}
2017-04-14 09:55:22 +02:00
return value ;
}
private static void calculateFinalMouseMovement ( ref double rawMouseX , ref double rawMouseY ,
out int mouseX , out int mouseY )
{
if ( ( rawMouseX > 0.0 & & horizontalRemainder > 0.0 ) | | ( rawMouseX < 0.0 & & horizontalRemainder < 0.0 ) )
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
{
2017-04-14 09:55:22 +02:00
rawMouseX + = horizontalRemainder ;
2014-05-28 21:47:25 +02:00
}
else
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
{
2017-04-14 09:55:22 +02:00
horizontalRemainder = 0.0 ;
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
}
2017-04-14 09:55:22 +02:00
2017-06-11 17:15:45 +02:00
//double mouseXTemp = rawMouseX - (Math.IEEERemainder(rawMouseX * 1000.0, 1.0) / 1000.0);
double mouseXTemp = rawMouseX - ( remainderCutoff ( rawMouseX * 1000.0 , 1.0 ) / 1000.0 ) ;
//double mouseXTemp = rawMouseX - (rawMouseX * 1000.0 - (1.0 * (int)(rawMouseX * 1000.0 / 1.0)));
2017-05-31 23:09:16 +02:00
mouseX = ( int ) mouseXTemp ;
horizontalRemainder = mouseXTemp - mouseX ;
//mouseX = (int)rawMouseX;
//horizontalRemainder = rawMouseX - mouseX;
2017-04-14 09:55:22 +02:00
if ( ( rawMouseY > 0.0 & & verticalRemainder > 0.0 ) | | ( rawMouseY < 0.0 & & verticalRemainder < 0.0 ) )
{
rawMouseY + = verticalRemainder ;
}
else
{
verticalRemainder = 0.0 ;
}
2017-06-11 17:15:45 +02:00
//double mouseYTemp = rawMouseY - (Math.IEEERemainder(rawMouseY * 1000.0, 1.0) / 1000.0);
double mouseYTemp = rawMouseY - ( remainderCutoff ( rawMouseY * 1000.0 , 1.0 ) / 1000.0 ) ;
2017-05-31 23:09:16 +02:00
mouseY = ( int ) mouseYTemp ;
verticalRemainder = mouseYTemp - mouseY ;
//mouseY = (int)rawMouseY;
//verticalRemainder = rawMouseY - mouseY;
2014-04-27 21:32:09 +02:00
}
2014-04-29 23:56:58 +02:00
2017-06-11 17:15:45 +02:00
private static double remainderCutoff ( double dividend , double divisor )
{
return dividend - ( divisor * ( int ) ( dividend / divisor ) ) ;
}
2014-03-28 02:50:40 +01:00
public static bool compare ( byte b1 , byte b2 )
{
2017-04-21 15:29:25 +02:00
bool result = true ;
2014-03-28 02:50:40 +01:00
if ( Math . Abs ( b1 - b2 ) > 10 )
{
2017-04-21 15:29:25 +02:00
result = false ;
2014-03-28 02:50:40 +01:00
}
2017-04-21 15:29:25 +02:00
return result ;
2014-03-28 02:50:40 +01:00
}
2014-04-27 21:32:09 +02:00
2017-04-24 16:16:42 +02:00
private static byte getByteMapping2 ( int device , DS4Controls control , DS4State cState , DS4StateExposed eState , Mouse tp ,
DS4StateFieldMapping fieldMap )
{
byte result = 0 ;
int controlNum = ( int ) control ;
DS4StateFieldMapping . ControlType controlType = DS4StateFieldMapping . mappedType [ controlNum ] ;
if ( controlType = = DS4StateFieldMapping . ControlType . Button )
{
result = ( byte ) ( fieldMap . buttons [ controlNum ] ? 255 : 0 ) ;
}
else if ( controlType = = DS4StateFieldMapping . ControlType . AxisDir )
{
byte axisValue = fieldMap . axisdirs [ controlNum ] ;
switch ( control )
{
2019-01-13 20:32:38 +01:00
case DS4Controls . LXNeg : result = ( byte ) ( axisValue - 128.0f > = 0 ? 0 : - ( axisValue - 128.0f ) * 1.9921875f ) ; break ;
case DS4Controls . LYNeg : result = ( byte ) ( axisValue - 128.0f > = 0 ? 0 : - ( axisValue - 128.0f ) * 1.9921875f ) ; break ;
case DS4Controls . RXNeg : result = ( byte ) ( axisValue - 128.0f > = 0 ? 0 : - ( axisValue - 128.0f ) * 1.9921875f ) ; break ;
case DS4Controls . RYNeg : result = ( byte ) ( axisValue - 128.0f > = 0 ? 0 : - ( axisValue - 128.0f ) * 1.9921875f ) ; break ;
default : result = ( byte ) ( axisValue - 128.0f < 0 ? 0 : ( axisValue - 128.0f ) * 2.0078740157480315f ) ; break ;
2017-04-24 16:16:42 +02:00
}
}
else if ( controlType = = DS4StateFieldMapping . ControlType . Trigger )
{
result = fieldMap . triggers [ controlNum ] ;
}
else if ( controlType = = DS4StateFieldMapping . ControlType . Touch )
{
result = ( byte ) ( tp ! = null & & fieldMap . buttons [ controlNum ] ? 255 : 0 ) ;
}
else if ( controlType = = DS4StateFieldMapping . ControlType . SwipeDir )
{
result = ( byte ) ( tp ! = null ? fieldMap . swipedirs [ controlNum ] : 0 ) ;
}
else if ( controlType = = DS4StateFieldMapping . ControlType . GyroDir )
{
bool sOff = isUsingSAforMouse ( device ) ;
switch ( control )
{
case DS4Controls . GyroXPos :
{
int gyroX = fieldMap . gryodirs [ controlNum ] ;
2017-07-18 22:37:01 +02:00
result = ( byte ) ( sOff = = false ? Math . Min ( 255 , gyroX * 2 ) : 0 ) ;
2017-04-24 16:16:42 +02:00
break ;
}
case DS4Controls . GyroXNeg :
{
int gyroX = fieldMap . gryodirs [ controlNum ] ;
2017-07-18 22:37:01 +02:00
result = ( byte ) ( sOff = = false ? Math . Min ( 255 , - gyroX * 2 ) : 0 ) ;
2017-04-24 16:16:42 +02:00
break ;
}
case DS4Controls . GyroZPos :
{
int gyroZ = fieldMap . gryodirs [ controlNum ] ;
2017-07-18 22:37:01 +02:00
result = ( byte ) ( sOff = = false ? Math . Min ( 255 , gyroZ * 2 ) : 0 ) ;
2017-04-24 16:16:42 +02:00
break ;
}
case DS4Controls . GyroZNeg :
{
int gyroZ = fieldMap . gryodirs [ controlNum ] ;
2017-07-18 22:37:01 +02:00
result = ( byte ) ( sOff = = false ? Math . Min ( 255 , - gyroZ * 2 ) : 0 ) ;
2017-04-24 16:16:42 +02:00
break ;
}
default : break ;
}
}
return result ;
}
2014-10-31 00:56:51 +01:00
public static byte getByteMapping ( int device , DS4Controls control , DS4State cState , DS4StateExposed eState , Mouse tp )
2014-03-28 02:50:40 +01:00
{
2017-04-09 09:38:33 +02:00
byte result = 0 ;
if ( control > = DS4Controls . Square & & control < = DS4Controls . Cross )
{
switch ( control )
{
case DS4Controls . Cross : result = ( byte ) ( cState . Cross ? 255 : 0 ) ; break ;
case DS4Controls . Square : result = ( byte ) ( cState . Square ? 255 : 0 ) ; break ;
case DS4Controls . Triangle : result = ( byte ) ( cState . Triangle ? 255 : 0 ) ; break ;
case DS4Controls . Circle : result = ( byte ) ( cState . Circle ? 255 : 0 ) ; break ;
default : break ;
}
}
else if ( control > = DS4Controls . L1 & & control < = DS4Controls . R3 )
{
switch ( control )
{
case DS4Controls . L1 : result = ( byte ) ( cState . L1 ? 255 : 0 ) ; break ;
case DS4Controls . L2 : result = cState . L2 ; break ;
case DS4Controls . L3 : result = ( byte ) ( cState . L3 ? 255 : 0 ) ; break ;
case DS4Controls . R1 : result = ( byte ) ( cState . R1 ? 255 : 0 ) ; break ;
case DS4Controls . R2 : result = cState . R2 ; break ;
case DS4Controls . R3 : result = ( byte ) ( cState . R3 ? 255 : 0 ) ; break ;
default : break ;
}
}
else if ( control > = DS4Controls . DpadUp & & control < = DS4Controls . DpadLeft )
{
switch ( control )
{
case DS4Controls . DpadUp : result = ( byte ) ( cState . DpadUp ? 255 : 0 ) ; break ;
case DS4Controls . DpadDown : result = ( byte ) ( cState . DpadDown ? 255 : 0 ) ; break ;
case DS4Controls . DpadLeft : result = ( byte ) ( cState . DpadLeft ? 255 : 0 ) ; break ;
case DS4Controls . DpadRight : result = ( byte ) ( cState . DpadRight ? 255 : 0 ) ; break ;
default : break ;
}
}
else if ( control > = DS4Controls . LXNeg & & control < = DS4Controls . RYPos )
{
switch ( control )
{
2019-01-13 20:32:38 +01:00
case DS4Controls . LXNeg : result = ( byte ) ( cState . LX - 128.0f > = 0 ? 0 : - ( cState . LX - 128.0f ) * 1.9921875f ) ; break ;
case DS4Controls . LYNeg : result = ( byte ) ( cState . LY - 128.0f > = 0 ? 0 : - ( cState . LY - 128.0f ) * 1.9921875f ) ; break ;
case DS4Controls . RXNeg : result = ( byte ) ( cState . RX - 128.0f > = 0 ? 0 : - ( cState . RX - 128.0f ) * 1.9921875f ) ; break ;
case DS4Controls . RYNeg : result = ( byte ) ( cState . RY - 128.0f > = 0 ? 0 : - ( cState . RY - 128.0f ) * 1.9921875f ) ; break ;
case DS4Controls . LXPos : result = ( byte ) ( cState . LX - 128.0f < 0 ? 0 : ( cState . LX - 128.0f ) * 2.0078740157480315f ) ; break ;
case DS4Controls . LYPos : result = ( byte ) ( cState . LY - 128.0f < 0 ? 0 : ( cState . LY - 128.0f ) * 2.0078740157480315f ) ; break ;
case DS4Controls . RXPos : result = ( byte ) ( cState . RX - 128.0f < 0 ? 0 : ( cState . RX - 128.0f ) * 2.0078740157480315f ) ; break ;
case DS4Controls . RYPos : result = ( byte ) ( cState . RY - 128.0f < 0 ? 0 : ( cState . RY - 128.0f ) * 2.0078740157480315f ) ; break ;
2017-04-09 09:38:33 +02:00
default : break ;
}
}
else if ( control > = DS4Controls . TouchLeft & & control < = DS4Controls . TouchRight )
2014-03-28 02:50:40 +01:00
{
2017-04-09 09:38:33 +02:00
switch ( control )
{
case DS4Controls . TouchLeft : result = ( byte ) ( tp ! = null & & tp . leftDown ? 255 : 0 ) ; break ;
case DS4Controls . TouchRight : result = ( byte ) ( tp ! = null & & tp . rightDown ? 255 : 0 ) ; break ;
case DS4Controls . TouchMulti : result = ( byte ) ( tp ! = null & & tp . multiDown ? 255 : 0 ) ; break ;
case DS4Controls . TouchUpper : result = ( byte ) ( tp ! = null & & tp . upperDown ? 255 : 0 ) ; break ;
default : break ;
}
}
else if ( control > = DS4Controls . SwipeLeft & & control < = DS4Controls . SwipeDown )
{
switch ( control )
{
case DS4Controls . SwipeUp : result = ( byte ) ( tp ! = null ? tp . swipeUpB : 0 ) ; break ;
case DS4Controls . SwipeDown : result = ( byte ) ( tp ! = null ? tp . swipeDownB : 0 ) ; break ;
case DS4Controls . SwipeLeft : result = ( byte ) ( tp ! = null ? tp . swipeLeftB : 0 ) ; break ;
case DS4Controls . SwipeRight : result = ( byte ) ( tp ! = null ? tp . swipeRightB : 0 ) ; break ;
default : break ;
}
}
else if ( control > = DS4Controls . GyroXPos & & control < = DS4Controls . GyroZNeg )
{
2017-04-14 09:55:22 +02:00
double SXD = getSXDeadzone ( device ) ;
double SZD = getSZDeadzone ( device ) ;
bool sOff = isUsingSAforMouse ( device ) ;
double sxsens = getSXSens ( device ) ;
double szsens = getSZSens ( device ) ;
2017-04-09 09:38:33 +02:00
switch ( control )
{
2017-04-14 09:55:22 +02:00
case DS4Controls . GyroXPos :
{
2017-07-16 14:11:58 +02:00
int gyroX = - eState . AccelX ;
2017-04-14 09:55:22 +02:00
result = ( byte ) ( ! sOff & & sxsens * gyroX > SXD * 10 ? Math . Min ( 255 , sxsens * gyroX * 2 ) : 0 ) ;
break ;
}
case DS4Controls . GyroXNeg :
{
2017-07-16 14:11:58 +02:00
int gyroX = - eState . AccelX ;
2017-04-14 09:55:22 +02:00
result = ( byte ) ( ! sOff & & sxsens * gyroX < - SXD * 10 ? Math . Min ( 255 , sxsens * - gyroX * 2 ) : 0 ) ;
break ;
}
case DS4Controls . GyroZPos :
{
2017-07-13 15:17:00 +02:00
int gyroZ = eState . AccelZ ;
2017-04-14 09:55:22 +02:00
result = ( byte ) ( ! sOff & & szsens * gyroZ > SZD * 10 ? Math . Min ( 255 , szsens * gyroZ * 2 ) : 0 ) ;
break ;
}
case DS4Controls . GyroZNeg :
{
2017-07-13 15:17:00 +02:00
int gyroZ = eState . AccelZ ;
2017-04-14 09:55:22 +02:00
result = ( byte ) ( ! sOff & & szsens * gyroZ < - SZD * 10 ? Math . Min ( 255 , szsens * - gyroZ * 2 ) : 0 ) ;
break ;
}
2017-04-09 09:38:33 +02:00
default : break ;
}
}
else
{
switch ( control )
{
case DS4Controls . Share : result = ( byte ) ( cState . Share ? 255 : 0 ) ; break ;
case DS4Controls . Options : result = ( byte ) ( cState . Options ? 255 : 0 ) ; break ;
case DS4Controls . PS : result = ( byte ) ( cState . PS ? 255 : 0 ) ; break ;
default : break ;
}
2014-04-27 21:32:09 +02:00
}
2017-04-09 09:38:33 +02:00
return result ;
2014-03-28 02:50:40 +01:00
}
2014-10-31 00:56:51 +01:00
2017-04-22 04:58:27 +02:00
/* TODO: Possibly remove usage of this version of the method */
2015-11-28 06:47:26 +01:00
public static bool getBoolMapping ( int device , DS4Controls control , DS4State cState , DS4StateExposed eState , Mouse tp )
2014-03-28 02:50:40 +01:00
{
2017-04-08 19:31:59 +02:00
bool result = false ;
2017-04-09 09:42:53 +02:00
2017-04-08 19:31:59 +02:00
if ( control > = DS4Controls . Square & & control < = DS4Controls . Cross )
{
switch ( control )
{
case DS4Controls . Cross : result = cState . Cross ; break ;
case DS4Controls . Square : result = cState . Square ; break ;
case DS4Controls . Triangle : result = cState . Triangle ; break ;
case DS4Controls . Circle : result = cState . Circle ; break ;
default : break ;
}
}
else if ( control > = DS4Controls . L1 & & control < = DS4Controls . R3 )
{
switch ( control )
{
case DS4Controls . L1 : result = cState . L1 ; break ;
case DS4Controls . R1 : result = cState . R1 ; break ;
case DS4Controls . L2 : result = cState . L2 > 100 ; break ;
case DS4Controls . R2 : result = cState . R2 > 100 ; break ;
case DS4Controls . L3 : result = cState . L3 ; break ;
case DS4Controls . R3 : result = cState . R3 ; break ;
default : break ;
}
}
else if ( control > = DS4Controls . DpadUp & & control < = DS4Controls . DpadLeft )
2014-03-28 02:50:40 +01:00
{
2017-04-08 19:31:59 +02:00
switch ( control )
{
case DS4Controls . DpadUp : result = cState . DpadUp ; break ;
case DS4Controls . DpadDown : result = cState . DpadDown ; break ;
case DS4Controls . DpadLeft : result = cState . DpadLeft ; break ;
case DS4Controls . DpadRight : result = cState . DpadRight ; break ;
default : break ;
}
2014-03-28 02:50:40 +01:00
}
2017-04-08 19:31:59 +02:00
else if ( control > = DS4Controls . LXNeg & & control < = DS4Controls . RYPos )
{
switch ( control )
{
2019-01-13 20:32:38 +01:00
case DS4Controls . LXNeg : result = cState . LX < 128 - 55 ; break ;
case DS4Controls . LYNeg : result = cState . LY < 128 - 55 ; break ;
case DS4Controls . RXNeg : result = cState . RX < 128 - 55 ; break ;
case DS4Controls . RYNeg : result = cState . RY < 128 - 55 ; break ;
case DS4Controls . LXPos : result = cState . LX > 128 + 55 ; break ;
case DS4Controls . LYPos : result = cState . LY > 128 + 55 ; break ;
case DS4Controls . RXPos : result = cState . RX > 128 + 55 ; break ;
case DS4Controls . RYPos : result = cState . RY > 128 + 55 ; break ;
2017-04-08 19:31:59 +02:00
default : break ;
}
}
else if ( control > = DS4Controls . TouchLeft & & control < = DS4Controls . TouchRight )
{
switch ( control )
{
case DS4Controls . TouchLeft : result = ( tp ! = null ? tp . leftDown : false ) ; break ;
case DS4Controls . TouchRight : result = ( tp ! = null ? tp . rightDown : false ) ; break ;
case DS4Controls . TouchMulti : result = ( tp ! = null ? tp . multiDown : false ) ; break ;
case DS4Controls . TouchUpper : result = ( tp ! = null ? tp . upperDown : false ) ; break ;
default : break ;
}
}
else if ( control > = DS4Controls . SwipeLeft & & control < = DS4Controls . SwipeDown )
{
switch ( control )
{
case DS4Controls . SwipeUp : result = ( tp ! = null & & tp . swipeUp ) ; break ;
case DS4Controls . SwipeDown : result = ( tp ! = null & & tp . swipeDown ) ; break ;
case DS4Controls . SwipeLeft : result = ( tp ! = null & & tp . swipeLeft ) ; break ;
case DS4Controls . SwipeRight : result = ( tp ! = null & & tp . swipeRight ) ; break ;
default : break ;
}
}
else if ( control > = DS4Controls . GyroXPos & & control < = DS4Controls . GyroZNeg )
{
2017-04-14 09:55:22 +02:00
bool sOff = isUsingSAforMouse ( device ) ;
2017-04-09 09:42:53 +02:00
2017-04-08 19:31:59 +02:00
switch ( control )
{
2017-07-16 14:11:58 +02:00
case DS4Controls . GyroXPos : result = ! sOff ? SXSens [ device ] * - eState . AccelX > 67 : false ; break ;
case DS4Controls . GyroXNeg : result = ! sOff ? SXSens [ device ] * - eState . AccelX < - 67 : false ; break ;
2017-07-13 15:17:00 +02:00
case DS4Controls . GyroZPos : result = ! sOff ? SZSens [ device ] * eState . AccelZ > 67 : false ; break ;
case DS4Controls . GyroZNeg : result = ! sOff ? SZSens [ device ] * eState . AccelZ < - 67 : false ; break ;
2017-04-08 19:31:59 +02:00
default : break ;
}
}
else
{
switch ( control )
{
case DS4Controls . PS : result = cState . PS ; break ;
case DS4Controls . Share : result = cState . Share ; break ;
case DS4Controls . Options : result = cState . Options ; break ;
default : break ;
}
}
return result ;
2014-03-28 02:50:40 +01:00
}
2017-04-21 11:48:13 +02:00
private static bool getBoolMapping2 ( int device , DS4Controls control ,
DS4State cState , DS4StateExposed eState , Mouse tp , DS4StateFieldMapping fieldMap )
{
bool result = false ;
int controlNum = ( int ) control ;
DS4StateFieldMapping . ControlType controlType = DS4StateFieldMapping . mappedType [ controlNum ] ;
if ( controlType = = DS4StateFieldMapping . ControlType . Button )
{
result = fieldMap . buttons [ controlNum ] ;
}
else if ( controlType = = DS4StateFieldMapping . ControlType . AxisDir )
{
byte axisValue = fieldMap . axisdirs [ controlNum ] ;
switch ( control )
{
2019-01-24 11:54:40 +01:00
case DS4Controls . LXNeg : result = cState . LX < 128 - 55 ; break ;
case DS4Controls . LYNeg : result = cState . LY < 128 - 55 ; break ;
case DS4Controls . RXNeg : result = cState . RX < 128 - 55 ; break ;
case DS4Controls . RYNeg : result = cState . RY < 128 - 55 ; break ;
default : result = axisValue > 128 + 55 ; break ;
2017-04-21 11:48:13 +02:00
}
}
else if ( controlType = = DS4StateFieldMapping . ControlType . Trigger )
{
result = fieldMap . triggers [ controlNum ] > 100 ;
}
else if ( controlType = = DS4StateFieldMapping . ControlType . Touch )
{
result = fieldMap . buttons [ controlNum ] ;
}
else if ( controlType = = DS4StateFieldMapping . ControlType . SwipeDir )
{
result = fieldMap . swipedirbools [ controlNum ] ;
}
else if ( controlType = = DS4StateFieldMapping . ControlType . GyroDir )
{
bool sOff = isUsingSAforMouse ( device ) ;
bool safeTest = false ;
2017-04-28 22:06:58 +02:00
switch ( control )
2017-04-21 11:48:13 +02:00
{
2017-12-14 07:26:37 +01:00
case DS4Controls . GyroXPos : safeTest = fieldMap . gryodirs [ controlNum ] > 0 ; break ;
case DS4Controls . GyroXNeg : safeTest = fieldMap . gryodirs [ controlNum ] < - 0 ; break ;
case DS4Controls . GyroZPos : safeTest = fieldMap . gryodirs [ controlNum ] > 0 ; break ;
case DS4Controls . GyroZNeg : safeTest = fieldMap . gryodirs [ controlNum ] < - 0 ; break ;
2017-04-28 22:06:58 +02:00
default : break ;
2017-04-21 11:48:13 +02:00
}
2017-07-18 22:37:01 +02:00
result = sOff = = false ? safeTest : false ;
2017-04-21 11:48:13 +02:00
}
return result ;
}
2019-02-26 11:13:13 +01:00
private static bool getBoolSpecialActionMapping ( int device , DS4Controls control ,
DS4State cState , DS4StateExposed eState , Mouse tp , DS4StateFieldMapping fieldMap )
2017-04-21 11:48:13 +02:00
{
bool result = false ;
int controlNum = ( int ) control ;
DS4StateFieldMapping . ControlType controlType = DS4StateFieldMapping . mappedType [ controlNum ] ;
if ( controlType = = DS4StateFieldMapping . ControlType . Button )
{
result = fieldMap . buttons [ controlNum ] ;
}
else if ( controlType = = DS4StateFieldMapping . ControlType . AxisDir )
{
2019-02-26 11:13:13 +01:00
byte axisValue = fieldMap . axisdirs [ controlNum ] ;
2017-04-21 11:48:13 +02:00
switch ( control )
{
2019-02-26 11:13:13 +01:00
case DS4Controls . LXNeg : result = cState . LX < 128 - 55 ; break ;
case DS4Controls . LYNeg : result = cState . LY < 128 - 55 ; break ;
case DS4Controls . RXNeg : result = cState . RX < 128 - 55 ; break ;
case DS4Controls . RYNeg : result = cState . RY < 128 - 55 ; break ;
default : result = axisValue > 128 + 55 ; break ;
2017-04-21 11:48:13 +02:00
}
}
else if ( controlType = = DS4StateFieldMapping . ControlType . Trigger )
{
2019-02-26 11:13:13 +01:00
result = fieldMap . triggers [ controlNum ] > 100 ;
2017-04-21 11:48:13 +02:00
}
else if ( controlType = = DS4StateFieldMapping . ControlType . Touch )
{
result = fieldMap . buttons [ controlNum ] ;
}
else if ( controlType = = DS4StateFieldMapping . ControlType . SwipeDir )
{
result = fieldMap . swipedirbools [ controlNum ] ;
}
else if ( controlType = = DS4StateFieldMapping . ControlType . GyroDir )
{
bool sOff = isUsingSAforMouse ( device ) ;
bool safeTest = false ;
2017-04-28 22:06:58 +02:00
switch ( control )
2017-04-21 11:48:13 +02:00
{
2019-02-26 11:13:13 +01:00
case DS4Controls . GyroXPos : safeTest = fieldMap . gryodirs [ controlNum ] > 67 ; break ;
case DS4Controls . GyroXNeg : safeTest = fieldMap . gryodirs [ controlNum ] < - 67 ; break ;
case DS4Controls . GyroZPos : safeTest = fieldMap . gryodirs [ controlNum ] > 67 ; break ;
case DS4Controls . GyroZNeg : safeTest = fieldMap . gryodirs [ controlNum ] < - 67 ; break ;
2017-04-28 22:06:58 +02:00
default : break ;
2017-04-21 11:48:13 +02:00
}
2017-07-18 22:37:01 +02:00
result = sOff = = false ? safeTest : false ;
2017-04-21 11:48:13 +02:00
}
return result ;
}
2019-02-26 11:13:13 +01:00
private static bool getBoolActionMapping2 ( int device , DS4Controls control ,
DS4State cState , DS4StateExposed eState , Mouse tp , DS4StateFieldMapping fieldMap , bool analog = false )
2017-04-15 05:11:48 +02:00
{
bool result = false ;
2019-02-26 11:13:13 +01:00
int controlNum = ( int ) control ;
DS4StateFieldMapping . ControlType controlType = DS4StateFieldMapping . mappedType [ controlNum ] ;
if ( controlType = = DS4StateFieldMapping . ControlType . Button )
2017-04-15 05:11:48 +02:00
{
2019-02-26 11:13:13 +01:00
result = fieldMap . buttons [ controlNum ] ;
2017-04-15 05:11:48 +02:00
}
2019-02-26 11:13:13 +01:00
else if ( controlType = = DS4StateFieldMapping . ControlType . AxisDir )
2017-04-15 05:11:48 +02:00
{
switch ( control )
{
case DS4Controls . LXNeg :
{
2019-02-26 11:13:13 +01:00
double angle = cState . LSAngle ;
result = cState . LX < 128 & & ( angle > = 112.5 & & angle < = 247.5 ) ;
2017-04-15 05:11:48 +02:00
break ;
}
case DS4Controls . LYNeg :
{
2019-02-26 11:13:13 +01:00
double angle = cState . LSAngle ;
result = cState . LY < 128 & & ( angle > = 22.5 & & angle < = 157.5 ) ;
2017-04-15 05:11:48 +02:00
break ;
}
case DS4Controls . RXNeg :
{
2019-02-26 11:13:13 +01:00
double angle = cState . RSAngle ;
result = cState . RX < 128 & & ( angle > = 112.5 & & angle < = 247.5 ) ;
2017-04-15 05:11:48 +02:00
break ;
}
case DS4Controls . RYNeg :
{
2019-02-26 11:13:13 +01:00
double angle = cState . RSAngle ;
result = cState . RY < 128 & & ( angle > = 22.5 & & angle < = 157.5 ) ;
2017-04-15 05:11:48 +02:00
break ;
}
case DS4Controls . LXPos :
{
2019-02-26 11:13:13 +01:00
double angle = cState . LSAngle ;
result = cState . LX > 128 & & ( angle < = 67.5 | | angle > = 292.5 ) ;
2017-04-15 05:11:48 +02:00
break ;
}
case DS4Controls . LYPos :
{
2019-02-26 11:13:13 +01:00
double angle = cState . LSAngle ;
result = cState . LY > 128 & & ( angle > = 202.5 & & angle < = 337.5 ) ;
2017-04-15 05:11:48 +02:00
break ;
}
case DS4Controls . RXPos :
{
2019-02-26 11:13:13 +01:00
double angle = cState . RSAngle ;
result = cState . RX > 128 & & ( angle < = 67.5 | | angle > = 292.5 ) ;
2017-04-15 05:11:48 +02:00
break ;
}
case DS4Controls . RYPos :
{
2019-02-26 11:13:13 +01:00
double angle = cState . RSAngle ;
result = cState . RY > 128 & & ( angle > = 202.5 & & angle < = 337.5 ) ;
2017-04-15 05:11:48 +02:00
break ;
}
default : break ;
}
}
2019-02-26 11:13:13 +01:00
else if ( controlType = = DS4StateFieldMapping . ControlType . Trigger )
2017-04-15 05:11:48 +02:00
{
2019-02-26 11:13:13 +01:00
result = fieldMap . triggers [ controlNum ] > 0 ;
2017-04-15 05:11:48 +02:00
}
2019-02-26 11:13:13 +01:00
else if ( controlType = = DS4StateFieldMapping . ControlType . Touch )
2017-04-15 05:11:48 +02:00
{
2019-02-26 11:13:13 +01:00
result = fieldMap . buttons [ controlNum ] ;
2017-04-15 05:11:48 +02:00
}
2019-02-26 11:13:13 +01:00
else if ( controlType = = DS4StateFieldMapping . ControlType . SwipeDir )
2017-04-15 05:11:48 +02:00
{
2019-02-26 11:13:13 +01:00
result = fieldMap . swipedirbools [ controlNum ] ;
2017-04-15 05:11:48 +02:00
}
2019-02-26 11:13:13 +01:00
else if ( controlType = = DS4StateFieldMapping . ControlType . GyroDir )
2017-04-15 05:11:48 +02:00
{
2019-02-26 11:13:13 +01:00
bool sOff = isUsingSAforMouse ( device ) ;
bool safeTest = false ;
2017-04-15 05:11:48 +02:00
switch ( control )
{
2019-02-26 11:13:13 +01:00
case DS4Controls . GyroXPos : safeTest = fieldMap . gryodirs [ controlNum ] > 0 ; break ;
case DS4Controls . GyroXNeg : safeTest = fieldMap . gryodirs [ controlNum ] < 0 ; break ;
case DS4Controls . GyroZPos : safeTest = fieldMap . gryodirs [ controlNum ] > 0 ; break ;
case DS4Controls . GyroZNeg : safeTest = fieldMap . gryodirs [ controlNum ] < 0 ; break ;
2017-04-15 05:11:48 +02:00
default : break ;
}
2019-02-26 11:13:13 +01:00
result = sOff = = false ? safeTest : false ;
2017-04-15 05:11:48 +02:00
}
return result ;
}
public static bool getBoolButtonMapping ( bool stateButton )
{
return stateButton ;
}
public static bool getBoolAxisDirMapping ( byte stateAxis , bool positive )
{
2019-01-13 20:32:38 +01:00
return positive ? stateAxis > 128 + 55 : stateAxis < 128 - 55 ;
2017-04-15 05:11:48 +02:00
}
public static bool getBoolTriggerMapping ( byte stateAxis )
{
return stateAxis > 100 ;
}
public static bool getBoolTouchMapping ( bool touchButton )
{
return touchButton ;
}
2017-04-24 16:16:42 +02:00
private static byte getXYAxisMapping2 ( int device , DS4Controls control , DS4State cState ,
DS4StateExposed eState , Mouse tp , DS4StateFieldMapping fieldMap , bool alt = false )
{
2019-02-16 01:04:09 +01:00
const byte falseVal = 128 ;
2017-04-24 16:16:42 +02:00
byte result = 0 ;
byte trueVal = 0 ;
if ( alt )
trueVal = 255 ;
int controlNum = ( int ) control ;
DS4StateFieldMapping . ControlType controlType = DS4StateFieldMapping . mappedType [ controlNum ] ;
if ( controlType = = DS4StateFieldMapping . ControlType . Button )
{
2017-07-18 22:37:01 +02:00
result = fieldMap . buttons [ controlNum ] ? trueVal : falseVal ;
2017-04-24 16:16:42 +02:00
}
else if ( controlType = = DS4StateFieldMapping . ControlType . AxisDir )
{
byte axisValue = fieldMap . axisdirs [ controlNum ] ;
switch ( control )
{
2019-02-16 01:04:09 +01:00
case DS4Controls . LXNeg : if ( ! alt ) result = axisValue < falseVal ? axisValue : falseVal ; else result = axisValue < falseVal ? ( byte ) ( 255 - axisValue ) : falseVal ; break ;
case DS4Controls . LYNeg : if ( ! alt ) result = axisValue < falseVal ? axisValue : falseVal ; else result = axisValue < falseVal ? ( byte ) ( 255 - axisValue ) : falseVal ; break ;
case DS4Controls . RXNeg : if ( ! alt ) result = axisValue < falseVal ? axisValue : falseVal ; else result = axisValue < falseVal ? ( byte ) ( 255 - axisValue ) : falseVal ; break ;
case DS4Controls . RYNeg : if ( ! alt ) result = axisValue < falseVal ? axisValue : falseVal ; else result = axisValue < falseVal ? ( byte ) ( 255 - axisValue ) : falseVal ; break ;
default : if ( ! alt ) result = axisValue > falseVal ? ( byte ) ( 255 - axisValue ) : falseVal ; else result = axisValue > falseVal ? axisValue : falseVal ; break ;
2017-04-24 16:16:42 +02:00
}
}
else if ( controlType = = DS4StateFieldMapping . ControlType . Trigger )
{
if ( alt )
{
2019-01-13 20:32:38 +01:00
result = ( byte ) ( 128.0f + fieldMap . triggers [ controlNum ] / 2.0078740157480315f ) ;
2017-04-24 16:16:42 +02:00
}
else
{
2019-01-13 20:32:38 +01:00
result = ( byte ) ( 128.0f - fieldMap . triggers [ controlNum ] / 2.0078740157480315f ) ;
2017-04-24 16:16:42 +02:00
}
}
else if ( controlType = = DS4StateFieldMapping . ControlType . Touch )
{
2017-07-18 22:37:01 +02:00
result = fieldMap . buttons [ controlNum ] ? trueVal : falseVal ;
2017-04-24 16:16:42 +02:00
}
else if ( controlType = = DS4StateFieldMapping . ControlType . SwipeDir )
{
if ( alt )
{
result = ( byte ) ( tp ! = null ? 127.5f + fieldMap . swipedirs [ controlNum ] / 2f : 0 ) ;
}
else
{
result = ( byte ) ( tp ! = null ? 127.5f - fieldMap . swipedirs [ controlNum ] / 2f : 0 ) ;
}
}
else if ( controlType = = DS4StateFieldMapping . ControlType . GyroDir )
{
bool sOff = isUsingSAforMouse ( device ) ;
2017-04-28 22:06:58 +02:00
switch ( control )
2017-04-24 16:16:42 +02:00
{
2017-04-28 22:06:58 +02:00
case DS4Controls . GyroXPos :
2017-04-24 16:16:42 +02:00
{
2017-07-18 22:37:01 +02:00
if ( sOff = = false & & fieldMap . gryodirs [ controlNum ] > 0 )
2017-04-24 16:16:42 +02:00
{
2017-07-18 21:21:03 +02:00
if ( alt ) result = ( byte ) Math . Min ( 255 , 127 + fieldMap . gryodirs [ controlNum ] ) ; else result = ( byte ) Math . Max ( 0 , 127 - fieldMap . gryodirs [ controlNum ] ) ;
2017-04-24 16:16:42 +02:00
}
2017-04-28 22:06:58 +02:00
else result = falseVal ;
break ;
2017-04-24 16:16:42 +02:00
}
2017-04-28 22:06:58 +02:00
case DS4Controls . GyroXNeg :
2017-04-24 16:16:42 +02:00
{
2017-07-18 22:37:01 +02:00
if ( sOff = = false & & fieldMap . gryodirs [ controlNum ] < 0 )
2017-04-24 16:16:42 +02:00
{
2017-07-18 21:21:03 +02:00
if ( alt ) result = ( byte ) Math . Min ( 255 , 127 + - fieldMap . gryodirs [ controlNum ] ) ; else result = ( byte ) Math . Max ( 0 , 127 - - fieldMap . gryodirs [ controlNum ] ) ;
2017-04-24 16:16:42 +02:00
}
2017-04-28 22:06:58 +02:00
else result = falseVal ;
break ;
}
case DS4Controls . GyroZPos :
{
2017-07-18 22:37:01 +02:00
if ( sOff = = false & & fieldMap . gryodirs [ controlNum ] > 0 )
2017-04-24 16:16:42 +02:00
{
2017-07-18 21:21:03 +02:00
if ( alt ) result = ( byte ) Math . Min ( 255 , 127 + fieldMap . gryodirs [ controlNum ] ) ; else result = ( byte ) Math . Max ( 0 , 127 - fieldMap . gryodirs [ controlNum ] ) ;
2017-04-24 16:16:42 +02:00
}
2017-04-28 22:06:58 +02:00
else return falseVal ;
break ;
2017-04-24 16:16:42 +02:00
}
2017-04-28 22:06:58 +02:00
case DS4Controls . GyroZNeg :
2017-04-24 16:16:42 +02:00
{
2017-07-18 22:37:01 +02:00
if ( sOff = = false & & fieldMap . gryodirs [ controlNum ] < 0 )
2017-04-28 22:06:58 +02:00
{
2017-07-18 21:21:03 +02:00
if ( alt ) result = ( byte ) Math . Min ( 255 , 127 + - fieldMap . gryodirs [ controlNum ] ) ; else result = ( byte ) Math . Max ( 0 , 127 - - fieldMap . gryodirs [ controlNum ] ) ;
2017-04-28 22:06:58 +02:00
}
else result = falseVal ;
break ;
2017-04-24 16:16:42 +02:00
}
2017-04-28 22:06:58 +02:00
default : break ;
2017-04-24 16:16:42 +02:00
}
}
return result ;
}
2019-01-24 11:54:40 +01:00
/* TODO: Possibly remove usage of this version of the method */
2014-10-31 00:56:51 +01:00
public static byte getXYAxisMapping ( int device , DS4Controls control , DS4State cState , DS4StateExposed eState , Mouse tp , bool alt = false )
2014-03-28 02:50:40 +01:00
{
2017-04-09 09:38:33 +02:00
byte result = 0 ;
2014-03-28 02:50:40 +01:00
byte trueVal = 0 ;
byte falseVal = 127 ;
2017-04-09 09:38:33 +02:00
2014-03-28 02:50:40 +01:00
if ( alt )
trueVal = 255 ;
2017-04-09 09:38:33 +02:00
if ( control > = DS4Controls . Square & & control < = DS4Controls . Cross )
2014-03-28 02:50:40 +01:00
{
2017-04-09 09:38:33 +02:00
switch ( control )
{
case DS4Controls . Cross : result = ( byte ) ( cState . Cross ? trueVal : falseVal ) ; break ;
case DS4Controls . Square : result = ( byte ) ( cState . Square ? trueVal : falseVal ) ; break ;
case DS4Controls . Triangle : result = ( byte ) ( cState . Triangle ? trueVal : falseVal ) ; break ;
case DS4Controls . Circle : result = ( byte ) ( cState . Circle ? trueVal : falseVal ) ; break ;
default : break ;
}
}
else if ( control > = DS4Controls . L1 & & control < = DS4Controls . R3 )
{
switch ( control )
{
case DS4Controls . L1 : result = ( byte ) ( cState . L1 ? trueVal : falseVal ) ; break ;
2019-01-13 20:32:38 +01:00
case DS4Controls . L2 : if ( alt ) result = ( byte ) ( 128.0f + cState . L2 / 2.0078740157480315f ) ; else result = ( byte ) ( 128.0f - cState . L2 / 2.0078740157480315f ) ; break ;
2017-04-09 09:38:33 +02:00
case DS4Controls . L3 : result = ( byte ) ( cState . L3 ? trueVal : falseVal ) ; break ;
case DS4Controls . R1 : result = ( byte ) ( cState . R1 ? trueVal : falseVal ) ; break ;
2019-01-13 20:32:38 +01:00
case DS4Controls . R2 : if ( alt ) result = ( byte ) ( 128.0f + cState . R2 / 2.0078740157480315f ) ; else result = ( byte ) ( 128.0f - cState . R2 / 2.0078740157480315f ) ; break ;
2017-04-09 09:38:33 +02:00
case DS4Controls . R3 : result = ( byte ) ( cState . R3 ? trueVal : falseVal ) ; break ;
default : break ;
}
}
else if ( control > = DS4Controls . DpadUp & & control < = DS4Controls . DpadLeft )
{
switch ( control )
{
case DS4Controls . DpadUp : result = ( byte ) ( cState . DpadUp ? trueVal : falseVal ) ; break ;
case DS4Controls . DpadDown : result = ( byte ) ( cState . DpadDown ? trueVal : falseVal ) ; break ;
case DS4Controls . DpadLeft : result = ( byte ) ( cState . DpadLeft ? trueVal : falseVal ) ; break ;
case DS4Controls . DpadRight : result = ( byte ) ( cState . DpadRight ? trueVal : falseVal ) ; break ;
default : break ;
}
}
else if ( control > = DS4Controls . LXNeg & & control < = DS4Controls . RYPos )
{
switch ( control )
{
case DS4Controls . LXNeg : if ( ! alt ) result = cState . LX ; else result = ( byte ) ( 255 - cState . LX ) ; break ;
case DS4Controls . LYNeg : if ( ! alt ) result = cState . LY ; else result = ( byte ) ( 255 - cState . LY ) ; break ;
case DS4Controls . RXNeg : if ( ! alt ) result = cState . RX ; else result = ( byte ) ( 255 - cState . RX ) ; break ;
case DS4Controls . RYNeg : if ( ! alt ) result = cState . RY ; else result = ( byte ) ( 255 - cState . RY ) ; break ;
case DS4Controls . LXPos : if ( ! alt ) result = ( byte ) ( 255 - cState . LX ) ; else result = cState . LX ; break ;
case DS4Controls . LYPos : if ( ! alt ) result = ( byte ) ( 255 - cState . LY ) ; else result = cState . LY ; break ;
case DS4Controls . RXPos : if ( ! alt ) result = ( byte ) ( 255 - cState . RX ) ; else result = cState . RX ; break ;
case DS4Controls . RYPos : if ( ! alt ) result = ( byte ) ( 255 - cState . RY ) ; else result = cState . RY ; break ;
default : break ;
}
}
else if ( control > = DS4Controls . TouchLeft & & control < = DS4Controls . TouchRight )
{
switch ( control )
{
case DS4Controls . TouchLeft : result = ( byte ) ( tp ! = null & & tp . leftDown ? trueVal : falseVal ) ; break ;
case DS4Controls . TouchRight : result = ( byte ) ( tp ! = null & & tp . rightDown ? trueVal : falseVal ) ; break ;
case DS4Controls . TouchMulti : result = ( byte ) ( tp ! = null & & tp . multiDown ? trueVal : falseVal ) ; break ;
case DS4Controls . TouchUpper : result = ( byte ) ( tp ! = null & & tp . upperDown ? trueVal : falseVal ) ; break ;
default : break ;
}
}
else if ( control > = DS4Controls . SwipeLeft & & control < = DS4Controls . SwipeDown )
2014-03-28 02:50:40 +01:00
{
switch ( control )
{
2017-04-09 09:38:33 +02:00
case DS4Controls . SwipeUp : if ( alt ) result = ( byte ) ( tp ! = null ? 127.5f + tp . swipeUpB / 2f : 0 ) ; else result = ( byte ) ( tp ! = null ? 127.5f - tp . swipeUpB / 2f : 0 ) ; break ;
case DS4Controls . SwipeDown : if ( alt ) result = ( byte ) ( tp ! = null ? 127.5f + tp . swipeDownB / 2f : 0 ) ; else result = ( byte ) ( tp ! = null ? 127.5f - tp . swipeDownB / 2f : 0 ) ; break ;
case DS4Controls . SwipeLeft : if ( alt ) result = ( byte ) ( tp ! = null ? 127.5f + tp . swipeLeftB / 2f : 0 ) ; else result = ( byte ) ( tp ! = null ? 127.5f - tp . swipeLeftB / 2f : 0 ) ; break ;
case DS4Controls . SwipeRight : if ( alt ) result = ( byte ) ( tp ! = null ? 127.5f + tp . swipeRightB / 2f : 0 ) ; else result = ( byte ) ( tp ! = null ? 127.5f - tp . swipeRightB / 2f : 0 ) ; break ;
default : break ;
}
}
else if ( control > = DS4Controls . GyroXPos & & control < = DS4Controls . GyroZNeg )
{
2017-04-14 09:55:22 +02:00
double SXD = getSXDeadzone ( device ) ;
double SZD = getSZDeadzone ( device ) ;
bool sOff = isUsingSAforMouse ( device ) ;
2017-04-09 09:38:33 +02:00
switch ( control )
{
case DS4Controls . GyroXPos :
{
2017-07-16 14:11:58 +02:00
if ( ! sOff & & - eState . AccelX > SXD * 10 )
2017-04-09 09:38:33 +02:00
{
2017-07-16 14:11:58 +02:00
if ( alt ) result = ( byte ) Math . Min ( 255 , 127 + SXSens [ device ] * - eState . AccelX ) ; else result = ( byte ) Math . Max ( 0 , 127 - SXSens [ device ] * - eState . AccelX ) ;
2017-04-09 09:38:33 +02:00
}
else result = falseVal ;
break ;
}
case DS4Controls . GyroXNeg :
{
2017-07-16 14:11:58 +02:00
if ( ! sOff & & - eState . AccelX < - SXD * 10 )
2017-04-09 09:38:33 +02:00
{
2017-07-16 14:11:58 +02:00
if ( alt ) result = ( byte ) Math . Min ( 255 , 127 + SXSens [ device ] * eState . AccelX ) ; else result = ( byte ) Math . Max ( 0 , 127 - SXSens [ device ] * eState . AccelX ) ;
2017-04-09 09:38:33 +02:00
}
else result = falseVal ;
break ;
}
case DS4Controls . GyroZPos :
{
2017-07-13 15:17:00 +02:00
if ( ! sOff & & eState . AccelZ > SZD * 10 )
2017-04-09 09:38:33 +02:00
{
2017-07-13 15:17:00 +02:00
if ( alt ) result = ( byte ) Math . Min ( 255 , 127 + SZSens [ device ] * eState . AccelZ ) ; else result = ( byte ) Math . Max ( 0 , 127 - SZSens [ device ] * eState . AccelZ ) ;
2017-04-09 09:38:33 +02:00
}
else return falseVal ;
break ;
}
case DS4Controls . GyroZNeg :
{
2017-07-13 15:17:00 +02:00
if ( ! sOff & & eState . AccelZ < - SZD * 10 )
2017-04-09 09:38:33 +02:00
{
2017-07-13 15:17:00 +02:00
if ( alt ) result = ( byte ) Math . Min ( 255 , 127 + SZSens [ device ] * - eState . AccelZ ) ; else result = ( byte ) Math . Max ( 0 , 127 - SZSens [ device ] * - eState . AccelZ ) ;
2017-04-09 09:38:33 +02:00
}
else result = falseVal ;
break ;
}
default : break ;
2014-03-28 02:50:40 +01:00
}
}
else
{
switch ( control )
{
2017-04-09 09:38:33 +02:00
case DS4Controls . Share : result = ( byte ) ( cState . Share ? trueVal : falseVal ) ; break ;
case DS4Controls . Options : result = ( byte ) ( cState . Options ? trueVal : falseVal ) ; break ;
case DS4Controls . PS : result = ( byte ) ( cState . PS ? trueVal : falseVal ) ; break ;
default : break ;
2014-03-28 02:50:40 +01:00
}
}
2017-04-09 09:38:33 +02:00
return result ;
2014-03-28 02:50:40 +01:00
}
2017-04-22 04:58:27 +02:00
private static void resetToDefaultValue2 ( DS4Controls control , DS4State cState ,
DS4StateFieldMapping fieldMap )
2017-04-21 11:48:13 +02:00
{
int controlNum = ( int ) control ;
DS4StateFieldMapping . ControlType controlType = DS4StateFieldMapping . mappedType [ controlNum ] ;
if ( controlType = = DS4StateFieldMapping . ControlType . Button )
{
fieldMap . buttons [ controlNum ] = false ;
}
else if ( controlType = = DS4StateFieldMapping . ControlType . AxisDir )
{
2019-01-24 11:54:40 +01:00
fieldMap . axisdirs [ controlNum ] = 128 ;
2017-05-12 16:48:58 +02:00
int controlRelation = ( controlNum % 2 = = 0 ? controlNum - 1 : controlNum + 1 ) ;
2019-01-24 11:54:40 +01:00
fieldMap . axisdirs [ controlRelation ] = 128 ;
2017-04-21 11:48:13 +02:00
}
else if ( controlType = = DS4StateFieldMapping . ControlType . Trigger )
{
fieldMap . triggers [ controlNum ] = 0 ;
}
else if ( controlType = = DS4StateFieldMapping . ControlType . Touch )
{
fieldMap . buttons [ controlNum ] = false ;
}
}
2019-02-19 14:19:10 +01:00
2019-02-23 23:27:48 +01:00
// SA steering wheel emulation mapping
private const int C_WHEEL_ANGLE_PRECISION = 10 ; // Precision of SA angle in 1/10 of degrees
2019-02-19 14:19:10 +01:00
private static readonly DS4Color calibrationColor_0 = new DS4Color { red = 0xA0 , green = 0x00 , blue = 0x00 } ;
private static readonly DS4Color calibrationColor_1 = new DS4Color { red = 0xFF , green = 0xFF , blue = 0x00 } ;
private static readonly DS4Color calibrationColor_2 = new DS4Color { red = 0x00 , green = 0x50 , blue = 0x50 } ;
private static readonly DS4Color calibrationColor_3 = new DS4Color { red = 0x00 , green = 0xC0 , blue = 0x00 } ;
private static DateTime latestDebugMsgTime ;
private static string latestDebugData ;
private static void LogToGuiSACalibrationDebugMsg ( string data , bool forceOutput = false )
{
// Print debug calibration log messages only once per 2 secs to avoid flooding the log receiver
DateTime curTime = DateTime . Now ;
if ( forceOutput | | ( ( TimeSpan ) ( curTime - latestDebugMsgTime ) ) . TotalSeconds > 2 )
{
latestDebugMsgTime = curTime ;
if ( data ! = latestDebugData )
{
AppLogger . LogToGui ( data , false ) ;
latestDebugData = data ;
}
}
}
// Return number of bits set in a value
protected static int CountNumOfSetBits ( int bitValue )
{
int count = 0 ;
while ( bitValue ! = 0 )
{
count + + ;
bitValue & = ( bitValue - 1 ) ;
}
return count ;
}
// Calculate and return the angle of the controller as -180...0...+180 value.
private static Int32 CalculateControllerAngle ( int gyroAccelX , int gyroAccelZ , DS4Device controller )
{
Int32 result ;
if ( gyroAccelX = = controller . wheelCenterPoint . X & & Math . Abs ( gyroAccelZ - controller . wheelCenterPoint . Y ) < = 1 )
{
// When the current gyro position is "close enough" the wheel center point then no need to go through the hassle of calculating an angle
result = 0 ;
}
else
{
// Calculate two vectors based on "circle center" (ie. circle represents the 360 degree wheel turn and wheelCenterPoint and currentPosition vectors both start from circle center).
// To improve accuracy both left and right turns use a decicated calibration "circle" because DS4 gyro and DoItYourselfWheelRig may return slightly different SA sensor values depending on the tilt direction (well, only one or two degree difference so nothing major).
Point vectorAB ;
Point vectorCD ;
if ( gyroAccelX > = controller . wheelCenterPoint . X )
{
// "DS4 gyro wheel" tilted to right
vectorAB = new Point ( controller . wheelCenterPoint . X - controller . wheelCircleCenterPointRight . X , controller . wheelCenterPoint . Y - controller . wheelCircleCenterPointRight . Y ) ;
vectorCD = new Point ( gyroAccelX - controller . wheelCircleCenterPointRight . X , gyroAccelZ - controller . wheelCircleCenterPointRight . Y ) ;
}
else
{
// "DS4 gyro wheel" tilted to left
vectorAB = new Point ( controller . wheelCenterPoint . X - controller . wheelCircleCenterPointLeft . X , controller . wheelCenterPoint . Y - controller . wheelCircleCenterPointLeft . Y ) ;
vectorCD = new Point ( gyroAccelX - controller . wheelCircleCenterPointLeft . X , gyroAccelZ - controller . wheelCircleCenterPointLeft . Y ) ;
}
// Calculate dot product and magnitude of vectors (center vector and the current tilt vector)
double dotProduct = vectorAB . X * vectorCD . X + vectorAB . Y * vectorCD . Y ;
double magAB = Math . Sqrt ( vectorAB . X * vectorAB . X + vectorAB . Y * vectorAB . Y ) ;
double magCD = Math . Sqrt ( vectorCD . X * vectorCD . X + vectorCD . Y * vectorCD . Y ) ;
// Calculate angle between vectors and convert radian to degrees
if ( magAB = = 0 | | magCD = = 0 )
{
result = 0 ;
}
else
{
double angle = Math . Acos ( dotProduct / ( magAB * magCD ) ) ;
result = Convert . ToInt32 ( Global . Clamp (
- 180.0 * C_WHEEL_ANGLE_PRECISION ,
2019-02-23 23:27:48 +01:00
Math . Round ( ( angle * ( 180.0 / Math . PI ) ) , 1 ) * C_WHEEL_ANGLE_PRECISION ,
2019-02-19 14:19:10 +01:00
180.0 * C_WHEEL_ANGLE_PRECISION )
) ;
}
// Left turn is -180..0 and right turn 0..180 degrees
if ( gyroAccelX < controller . wheelCenterPoint . X ) result = - result ;
}
return result ;
}
// Calibrate sixaxis steering wheel emulation. Use DS4Windows configuration screen to start a calibration or press a special action key (if defined)
private static void SAWheelEmulationCalibration ( int device , DS4StateExposed exposedState , ControlService ctrl , DS4State currentDeviceState , DS4Device controller )
{
int gyroAccelX , gyroAccelZ ;
int result ;
gyroAccelX = exposedState . getAccelX ( ) ;
gyroAccelZ = exposedState . getAccelZ ( ) ;
// State 0=Normal mode (ie. calibration process is not running), 1=Activating calibration, 2=Calibration process running, 3=Completing calibration, 4=Cancelling calibration
if ( controller . WheelRecalibrateActiveState = = 1 )
{
2019-03-19 07:52:18 +01:00
AppLogger . LogToGui ( $"Controller {1 + device} activated re-calibration of SA steering wheel emulation" , false ) ;
2019-02-19 14:19:10 +01:00
controller . WheelRecalibrateActiveState = 2 ;
controller . wheelPrevPhysicalAngle = 0 ;
controller . wheelPrevFullAngle = 0 ;
controller . wheelFullTurnCount = 0 ;
// Clear existing calibration value and use current position as "center" point.
// This initial center value may be off-center because of shaking the controller while button was pressed. The value will be overriden with correct value once controller is stabilized and hold still few secs at the center point
controller . wheelCenterPoint . X = gyroAccelX ;
controller . wheelCenterPoint . Y = gyroAccelZ ;
controller . wheel90DegPointRight . X = gyroAccelX + 20 ;
controller . wheel90DegPointLeft . X = gyroAccelX - 20 ;
// Clear bitmask for calibration points. All three calibration points need to be set before re-calibration process is valid
controller . wheelCalibratedAxisBitmask = DS4Device . WheelCalibrationPoint . None ;
controller . wheelPrevRecalibrateTime = new DateTime ( 2500 , 1 , 1 ) ;
}
else if ( controller . WheelRecalibrateActiveState = = 3 )
{
2019-03-19 07:52:18 +01:00
AppLogger . LogToGui ( $"Controller {1 + device} completed the calibration of SA steering wheel emulation. center=({controller.wheelCenterPoint.X}, {controller.wheelCenterPoint.Y}) 90L=({controller.wheel90DegPointLeft.X}, {controller.wheel90DegPointLeft.Y}) 90R=({controller.wheel90DegPointRight.X}, {controller.wheel90DegPointRight.Y})" , false ) ;
2019-02-19 14:19:10 +01:00
// If any of the calibration points (center, left 90deg, right 90deg) are missing then reset back to default calibration values
if ( ( ( controller . wheelCalibratedAxisBitmask & DS4Device . WheelCalibrationPoint . All ) = = DS4Device . WheelCalibrationPoint . All ) )
Global . SaveControllerConfigs ( controller ) ;
else
controller . wheelCenterPoint . X = controller . wheelCenterPoint . Y = 0 ;
controller . WheelRecalibrateActiveState = 0 ;
controller . wheelPrevRecalibrateTime = DateTime . Now ;
}
else if ( controller . WheelRecalibrateActiveState = = 4 )
{
2019-03-19 07:52:18 +01:00
AppLogger . LogToGui ( $"Controller {1 + device} cancelled the calibration of SA steering wheel emulation." , false ) ;
2019-02-19 14:19:10 +01:00
controller . WheelRecalibrateActiveState = 0 ;
controller . wheelPrevRecalibrateTime = DateTime . Now ;
}
if ( controller . WheelRecalibrateActiveState > 0 )
{
// Cross "X" key pressed. Set calibration point when the key is released and controller hold steady for a few seconds
if ( currentDeviceState . Cross = = true ) controller . wheelPrevRecalibrateTime = DateTime . Now ;
// Make sure controller is hold steady (velocity of gyro axis) to avoid misaligments and set calibration few secs after the "X" key was released
if ( Math . Abs ( currentDeviceState . Motion . angVelPitch ) < 0.5 & & Math . Abs ( currentDeviceState . Motion . angVelYaw ) < 0.5 & & Math . Abs ( currentDeviceState . Motion . angVelRoll ) < 0.5
& & ( ( TimeSpan ) ( DateTime . Now - controller . wheelPrevRecalibrateTime ) ) . TotalSeconds > 1 )
{
controller . wheelPrevRecalibrateTime = new DateTime ( 2500 , 1 , 1 ) ;
if ( controller . wheelCalibratedAxisBitmask = = DS4Device . WheelCalibrationPoint . None )
{
controller . wheelCenterPoint . X = gyroAccelX ;
controller . wheelCenterPoint . Y = gyroAccelZ ;
controller . wheelCalibratedAxisBitmask | = DS4Device . WheelCalibrationPoint . Center ;
}
else if ( controller . wheel90DegPointRight . X < gyroAccelX )
{
controller . wheel90DegPointRight . X = gyroAccelX ;
controller . wheel90DegPointRight . Y = gyroAccelZ ;
controller . wheelCircleCenterPointRight . X = controller . wheelCenterPoint . X ;
controller . wheelCircleCenterPointRight . Y = controller . wheel90DegPointRight . Y ;
controller . wheelCalibratedAxisBitmask | = DS4Device . WheelCalibrationPoint . Right90 ;
}
else if ( controller . wheel90DegPointLeft . X > gyroAccelX )
{
controller . wheel90DegPointLeft . X = gyroAccelX ;
controller . wheel90DegPointLeft . Y = gyroAccelZ ;
controller . wheelCircleCenterPointLeft . X = controller . wheelCenterPoint . X ;
controller . wheelCircleCenterPointLeft . Y = controller . wheel90DegPointLeft . Y ;
controller . wheelCalibratedAxisBitmask | = DS4Device . WheelCalibrationPoint . Left90 ;
}
}
// Show lightbar color feedback how the calibration process is proceeding.
// red / yellow / blue / green = No calibration anchors/one anchor/two anchors/all three anchors calibrated when color turns to green (center, 90DegLeft, 90DegRight).
int bitsSet = CountNumOfSetBits ( ( int ) controller . wheelCalibratedAxisBitmask ) ;
if ( bitsSet > = 3 ) DS4LightBar . forcedColor [ device ] = calibrationColor_3 ;
else if ( bitsSet = = 2 ) DS4LightBar . forcedColor [ device ] = calibrationColor_2 ;
else if ( bitsSet = = 1 ) DS4LightBar . forcedColor [ device ] = calibrationColor_1 ;
else DS4LightBar . forcedColor [ device ] = calibrationColor_0 ;
result = CalculateControllerAngle ( gyroAccelX , gyroAccelZ , controller ) ;
// Force lightbar flashing when controller is currently at calibration point (user can verify the calibration before accepting it by looking at flashing lightbar)
if ( ( ( controller . wheelCalibratedAxisBitmask & DS4Device . WheelCalibrationPoint . Center ) ! = 0 & & Math . Abs ( result ) < = 1 * C_WHEEL_ANGLE_PRECISION )
| | ( ( controller . wheelCalibratedAxisBitmask & DS4Device . WheelCalibrationPoint . Left90 ) ! = 0 & & result < = - 89 * C_WHEEL_ANGLE_PRECISION & & result > = - 91 * C_WHEEL_ANGLE_PRECISION )
| | ( ( controller . wheelCalibratedAxisBitmask & DS4Device . WheelCalibrationPoint . Right90 ) ! = 0 & & result > = 89 * C_WHEEL_ANGLE_PRECISION & & result < = 91 * C_WHEEL_ANGLE_PRECISION )
| | ( ( controller . wheelCalibratedAxisBitmask & DS4Device . WheelCalibrationPoint . Left90 ) ! = 0 & & Math . Abs ( result ) > = 179 * C_WHEEL_ANGLE_PRECISION ) )
DS4LightBar . forcedFlash [ device ] = 2 ;
else
DS4LightBar . forcedFlash [ device ] = 0 ;
DS4LightBar . forcelight [ device ] = true ;
LogToGuiSACalibrationDebugMsg ( $"Calibration values ({gyroAccelX}, {gyroAccelZ}) angle={result / (1.0 * C_WHEEL_ANGLE_PRECISION)}\n" ) ;
}
else
{
// Re-calibration completed or cancelled. Set lightbar color back to normal color
DS4LightBar . forcedFlash [ device ] = 0 ;
DS4LightBar . forcedColor [ device ] = Global . getMainColor ( device ) ;
DS4LightBar . forcelight [ device ] = false ;
DS4LightBar . updateLightBar ( controller , device ) ;
}
}
protected static Int32 Scale360degreeGyroAxis ( int device , DS4StateExposed exposedState , ControlService ctrl )
{
unchecked
{
DS4Device controller ;
DS4State currentDeviceState ;
int gyroAccelX , gyroAccelZ ;
int result ;
controller = ctrl . DS4Controllers [ device ] ;
if ( controller = = null ) return 0 ;
currentDeviceState = controller . getCurrentStateRef ( ) ;
// If calibration is active then do the calibration process instead of the normal "angle calculation"
if ( controller . WheelRecalibrateActiveState > 0 )
{
SAWheelEmulationCalibration ( device , exposedState , ctrl , currentDeviceState , controller ) ;
// Return center wheel position while SA wheel emuation is being calibrated
return 0 ;
}
2019-02-23 23:27:48 +01:00
// Do nothing if connection is active but the actual DS4 controller is still missing or not yet synchronized
if ( ! controller . Synced )
return 0 ;
2019-02-19 14:19:10 +01:00
gyroAccelX = exposedState . getAccelX ( ) ;
gyroAccelZ = exposedState . getAccelZ ( ) ;
// If calibration values are missing then use "educated guesses" about good starting values
if ( controller . wheelCenterPoint . IsEmpty )
{
if ( ! Global . LoadControllerConfigs ( controller ) )
{
2019-03-19 07:52:18 +01:00
AppLogger . LogToGui ( $"Controller {1 + device} sixaxis steering wheel calibration data missing. It is recommended to run steering wheel calibration process by pressing SASteeringWheelEmulationCalibration special action key. Using estimated values until the controller is calibrated at least once." , false ) ;
2019-02-19 14:19:10 +01:00
// Use current controller position as "center point". Assume DS4Windows was started while controller was hold in center position (yes, dangerous assumption but can't do much until controller is calibrated)
controller . wheelCenterPoint . X = gyroAccelX ;
controller . wheelCenterPoint . Y = gyroAccelZ ;
controller . wheel90DegPointRight . X = controller . wheelCenterPoint . X + 113 ;
controller . wheel90DegPointRight . Y = controller . wheelCenterPoint . Y + 110 ;
controller . wheel90DegPointLeft . X = controller . wheelCenterPoint . X - 127 ;
controller . wheel90DegPointLeft . Y = controller . wheel90DegPointRight . Y ;
}
controller . wheelCircleCenterPointRight . X = controller . wheelCenterPoint . X ;
controller . wheelCircleCenterPointRight . Y = controller . wheel90DegPointRight . Y ;
controller . wheelCircleCenterPointLeft . X = controller . wheelCenterPoint . X ;
controller . wheelCircleCenterPointLeft . Y = controller . wheel90DegPointLeft . Y ;
2019-03-19 07:52:18 +01:00
AppLogger . LogToGui ( $"Controller {1 + device} steering wheel emulation calibration values. Center=({controller.wheelCenterPoint.X}, {controller.wheelCenterPoint.Y}) 90L=({controller.wheel90DegPointLeft.X}, {controller.wheel90DegPointLeft.Y}) 90R=({controller.wheel90DegPointRight.X}, {controller.wheel90DegPointRight.Y}) Range={Global.GetSASteeringWheelEmulationRange(device)}" , false ) ;
2019-02-19 14:19:10 +01:00
controller . wheelPrevRecalibrateTime = DateTime . Now ;
}
int maxRangeRight = Global . GetSASteeringWheelEmulationRange ( device ) / 2 * C_WHEEL_ANGLE_PRECISION ;
int maxRangeLeft = - maxRangeRight ;
result = CalculateControllerAngle ( gyroAccelX , gyroAccelZ , controller ) ;
// Apply deadzone (SA X-deadzone value). This code assumes that 20deg is the max deadzone anyone ever might wanna use (in practice effective deadzone
// is probably just few degrees by using SXDeadZone values 0.01...0.05)
double sxDead = getSXDeadzone ( device ) ;
2019-02-25 12:29:05 +01:00
if ( sxDead > 0 )
2019-02-19 14:19:10 +01:00
{
2019-02-25 12:29:05 +01:00
int sxDeadInt = Convert . ToInt32 ( 20.0 * C_WHEEL_ANGLE_PRECISION * sxDead ) ;
if ( Math . Abs ( result ) < = sxDeadInt )
{
result = 0 ;
}
else
{
// Smooth steering angle based on deadzone range instead of just clipping the deadzone gap
result - = ( result < 0 ? - sxDeadInt : sxDeadInt ) ;
}
2019-02-19 14:19:10 +01:00
}
2019-02-25 12:29:05 +01:00
// If wrapped around from +180 to -180 side (or vice versa) then SA steering wheel keeps on turning beyond 360 degrees (if range is >360).
// Keep track of how many times the steering wheel has been turned beyond the full 360 circle and clip the result to max range.
2019-02-19 14:19:10 +01:00
int wheelFullTurnCount = controller . wheelFullTurnCount ;
if ( controller . wheelPrevPhysicalAngle < 0 & & result > 0 )
{
if ( ( result - controller . wheelPrevPhysicalAngle ) > 180 * C_WHEEL_ANGLE_PRECISION )
2019-02-25 12:29:05 +01:00
{
if ( maxRangeRight > 360 / 2 * C_WHEEL_ANGLE_PRECISION )
2019-02-19 14:19:10 +01:00
wheelFullTurnCount - - ;
else
result = maxRangeLeft ;
2019-02-25 12:29:05 +01:00
}
2019-02-19 14:19:10 +01:00
}
else if ( controller . wheelPrevPhysicalAngle > 0 & & result < 0 )
{
if ( ( controller . wheelPrevPhysicalAngle - result ) > 180 * C_WHEEL_ANGLE_PRECISION )
2019-02-25 12:29:05 +01:00
{
if ( maxRangeRight > 360 / 2 * C_WHEEL_ANGLE_PRECISION )
2019-02-19 14:19:10 +01:00
wheelFullTurnCount + + ;
else
result = maxRangeRight ;
2019-02-25 12:29:05 +01:00
}
2019-02-19 14:19:10 +01:00
}
controller . wheelPrevPhysicalAngle = result ;
if ( wheelFullTurnCount ! = 0 )
{
2019-02-25 12:29:05 +01:00
// Adjust value of result (steering wheel angle) based on num of full 360 turn counts
result + = ( wheelFullTurnCount * 180 * C_WHEEL_ANGLE_PRECISION * 2 ) ;
2019-02-19 14:19:10 +01:00
}
// If the new angle is more than 180 degrees further away then this is probably bogus value (controller shaking too much and gyro and velocity sensors went crazy).
2019-02-25 12:29:05 +01:00
// Accept the new angle only when the new angle is within a "stability threshold", otherwise use the previous full angle value and wait for controller to be stabilized.
2019-02-19 14:19:10 +01:00
if ( Math . Abs ( result - controller . wheelPrevFullAngle ) < = 180 * C_WHEEL_ANGLE_PRECISION )
{
controller . wheelPrevFullAngle = result ;
controller . wheelFullTurnCount = wheelFullTurnCount ;
}
else
{
result = controller . wheelPrevFullAngle ;
}
result = Mapping . ClampInt ( maxRangeLeft , result , maxRangeRight ) ;
// Debug log output of SA sensor values
//LogToGuiSACalibrationDebugMsg($"DBG gyro=({gyroAccelX}, {gyroAccelZ}) output=({exposedState.OutputAccelX}, {exposedState.OutputAccelZ}) PitRolYaw=({currentDeviceState.Motion.gyroPitch}, {currentDeviceState.Motion.gyroRoll}, {currentDeviceState.Motion.gyroYaw}) VelPitRolYaw=({currentDeviceState.Motion.angVelPitch}, {currentDeviceState.Motion.angVelRoll}, {currentDeviceState.Motion.angVelYaw}) angle={result / (1.0 * C_WHEEL_ANGLE_PRECISION)} fullTurns={controller.wheelFullTurnCount}", false);
// Apply anti-deadzone (SA X-antideadzone value)
double sxAntiDead = getSXAntiDeadzone ( device ) ;
2019-05-09 20:32:29 +02:00
int outputAxisMax , outputAxisMin , outputAxisZero ;
if ( Global . OutContType [ device ] = = OutContType . DS4 )
{
// DS4 analog stick axis supports only 0...255 output value range (not the best one for steering wheel usage)
outputAxisMax = 255 ;
outputAxisMin = 0 ;
outputAxisZero = 128 ;
}
else
{
// x360 (xinput) analog stick axis supports -32768...32767 output value range (more than enough for steering wheel usage)
outputAxisMax = 32767 ;
outputAxisMin = - 32768 ;
outputAxisZero = 0 ;
}
2019-02-19 14:19:10 +01:00
switch ( Global . GetSASteeringWheelEmulationAxis ( device ) )
{
case SASteeringWheelEmulationAxisType . LX :
case SASteeringWheelEmulationAxisType . LY :
case SASteeringWheelEmulationAxisType . RX :
case SASteeringWheelEmulationAxisType . RY :
// DS4 thumbstick axis output (-32768..32767 raw value range)
//return (((result - maxRangeLeft) * (32767 - (-32768))) / (maxRangeRight - maxRangeLeft)) + (-32768);
2019-05-09 20:32:29 +02:00
if ( result = = 0 ) return outputAxisZero ;
2019-02-19 14:19:10 +01:00
if ( sxAntiDead > 0 )
{
2019-05-09 20:32:29 +02:00
sxAntiDead * = ( outputAxisMax - outputAxisZero ) ;
2019-05-09 22:21:31 +02:00
if ( result < 0 ) return ( ( ( result - maxRangeLeft ) * ( outputAxisZero - Convert . ToInt32 ( sxAntiDead ) - ( outputAxisMin ) ) ) / ( 0 - maxRangeLeft ) ) + ( outputAxisMin ) ;
else return ( ( ( result - 0 ) * ( outputAxisMax - ( outputAxisZero + Convert . ToInt32 ( sxAntiDead ) ) ) ) / ( maxRangeRight - 0 ) ) + ( outputAxisZero + Convert . ToInt32 ( sxAntiDead ) ) ;
2019-02-19 14:19:10 +01:00
}
else
{
2019-05-09 20:32:29 +02:00
return ( ( ( result - maxRangeLeft ) * ( outputAxisMax - ( outputAxisMin ) ) ) / ( maxRangeRight - maxRangeLeft ) ) + ( outputAxisMin ) ;
2019-02-19 14:19:10 +01:00
}
2019-02-25 12:29:05 +01:00
2019-02-19 14:19:10 +01:00
case SASteeringWheelEmulationAxisType . L2R2 :
// DS4 Trigger axis output. L2+R2 triggers share the same axis in x360 xInput/DInput controller,
// so L2+R2 steering output supports only 360 turn range (-255..255 raw value range in the shared trigger axis)
if ( result = = 0 ) return 0 ;
result = Convert . ToInt32 ( Math . Round ( result / ( 1.0 * C_WHEEL_ANGLE_PRECISION ) ) ) ;
if ( result < 0 ) result = - 181 - result ;
if ( sxAntiDead > 0 )
{
sxAntiDead * = 255 ;
if ( result < 0 ) return ( ( ( result - ( - 180 ) ) * ( - Convert . ToInt32 ( sxAntiDead ) - ( - 255 ) ) ) / ( 0 - ( - 180 ) ) ) + ( - 255 ) ;
else return ( ( ( result - ( 0 ) ) * ( 255 - ( Convert . ToInt32 ( sxAntiDead ) ) ) ) / ( 180 - ( 0 ) ) ) + ( Convert . ToInt32 ( sxAntiDead ) ) ;
}
else
{
return ( ( ( result - ( - 180 ) ) * ( 255 - ( - 255 ) ) ) / ( 180 - ( - 180 ) ) ) + ( - 255 ) ;
}
case SASteeringWheelEmulationAxisType . VJoy1X :
case SASteeringWheelEmulationAxisType . VJoy1Y :
case SASteeringWheelEmulationAxisType . VJoy1Z :
case SASteeringWheelEmulationAxisType . VJoy2X :
case SASteeringWheelEmulationAxisType . VJoy2Y :
case SASteeringWheelEmulationAxisType . VJoy2Z :
// SASteeringWheelEmulationAxisType.VJoy1X/VJoy1Y/VJoy1Z/VJoy2X/VJoy2Y/VJoy2Z VJoy axis output (0..32767 raw value range by default)
if ( result = = 0 ) return 16384 ;
if ( sxAntiDead > 0 )
{
sxAntiDead * = 16384 ;
if ( result < 0 ) return ( ( ( result - maxRangeLeft ) * ( 16384 - Convert . ToInt32 ( sxAntiDead ) - ( - 0 ) ) ) / ( 0 - maxRangeLeft ) ) + ( - 0 ) ;
else return ( ( ( result - 0 ) * ( 32767 - ( 16384 + Convert . ToInt32 ( sxAntiDead ) ) ) ) / ( maxRangeRight - 0 ) ) + ( 16384 + Convert . ToInt32 ( sxAntiDead ) ) ;
}
else
{
return ( ( ( result - maxRangeLeft ) * ( 32767 - ( - 0 ) ) ) / ( maxRangeRight - maxRangeLeft ) ) + ( - 0 ) ;
}
default :
// Should never come here, but C# case statement syntax requires DEFAULT handler
return 0 ;
}
}
}
2014-03-28 02:50:40 +01:00
}
}