diff --git a/DS4Control/Control.cs b/DS4Control/Control.cs
index 74a34e530c..e83af4d132 100644
--- a/DS4Control/Control.cs
+++ b/DS4Control/Control.cs
@@ -6,6 +6,7 @@
using System.IO;
using System.Reflection;
using System.Media;
+using DS4Control.Enums;
namespace DS4Control
{
public class Control
@@ -444,23 +445,40 @@ protected virtual void On_Report(object sender, EventArgs e)
{
if (Global.getFlushHIDQueue(ind))
device.FlushHID();
- if (!string.IsNullOrEmpty(device.error))
+
+ //This shouldn't be altering the collection from outside.
+ //something to fix
+ while (device.currentErrors.Count() > 0)
{
- LogDebug(device.error);
+ LogDebug(device.currentErrors[0]);
+ device.currentErrors.RemoveAt(0);
}
+
device.getExposedState(ExposedState[ind], CurrentState[ind]);
DS4State cState = CurrentState[ind];
device.getPreviousState(PreviousState[ind]);
DS4State pState = PreviousState[ind];
+
if (pState.Battery != cState.Battery)
+ {
Global.ControllerStatusChanged(this);
+ }
+
CheckForHotkeys(ind, cState, pState);
if (eastertime)
+ {
EasterTime(ind);
+ }
+
GetInputkeys(ind);
+
if (Global.getLSCurve(ind) + Global.getRSCurve(ind) + Global.getLSDeadzone(ind) + Global.getRSDeadzone(ind) +
- Global.getL2Deadzone(ind) + Global.getR2Deadzone(ind) > 0) //if a curve or deadzone is in place
+ Global.getL2Deadzone(ind) + Global.getR2Deadzone(ind) > 0)
+ {
+ //if a curve or deadzone is in place
cState = Mapping.SetCurveAndDeadzone(ind, cState);
+ }
+
if (!recordingMacro && (!string.IsNullOrEmpty(Global.tempprofilename[ind]) ||
Global.getHasCustomKeysorButtons(ind) || Global.getHasShiftCustomKeysorButtons(ind) || Global.GetProfileActions(ind).Count > 0))
{
@@ -733,7 +751,9 @@ protected virtual void CheckForHotkeys(int deviceID, DS4State cState, DS4State p
}
}
else
- touchreleased[deviceID] = true;
+ {
+ touchreleased[deviceID] = true;
+ }
}
public virtual void StartTPOff(int deviceID)
@@ -746,8 +766,8 @@ public virtual void StartTPOff(int deviceID)
Global.setScrollSensitivity(deviceID, 0);
}
}
-
- public virtual string TouchpadSlide(int ind)
+
+ public virtual string TouchpadSlideString(int ind)
{
DS4State cState = CurrentState[ind];
string slidedir = "none";
@@ -771,6 +791,32 @@ public virtual string TouchpadSlide(int ind)
}
return slidedir;
}
+
+ public virtual TouchpadSlideDirections TouchpadSlideEnum(int ind)
+ {
+ DS4State cState = CurrentState[ind];
+ TouchpadSlideDirections slidedir = TouchpadSlideDirections.none;
+ if (DS4Controllers[ind] != null)
+ if (cState.Touch2)
+ if (DS4Controllers[ind] != null)
+ if (touchPad[ind].slideright && !touchslid[ind])
+ {
+ slidedir = TouchpadSlideDirections.right;
+ touchslid[ind] = true;
+ }
+ else if (touchPad[ind].slideleft && !touchslid[ind])
+ {
+ slidedir = TouchpadSlideDirections.left;
+ touchslid[ind] = true;
+ }
+ else if (!touchPad[ind].slideleft && !touchPad[ind].slideright)
+ {
+ slidedir = TouchpadSlideDirections.none;
+ touchslid[ind] = false;
+ }
+ return slidedir;
+ }
+
public virtual void LogDebug(String Data, bool warning = false)
{
Console.WriteLine(System.DateTime.Now.ToString("G") + "> " + Data);
diff --git a/DS4Control/DS4Control.csproj b/DS4Control/DS4Control.csproj
index a8120f6ec5..07a9d2b37d 100644
--- a/DS4Control/DS4Control.csproj
+++ b/DS4Control/DS4Control.csproj
@@ -45,6 +45,7 @@
+
@@ -57,6 +58,7 @@
True
Resources.resx
+
Component
@@ -79,6 +81,9 @@
ScpHub.cs
+
+
+
diff --git a/DS4Control/Enums/TouchpadSlideDirections.cs b/DS4Control/Enums/TouchpadSlideDirections.cs
new file mode 100644
index 0000000000..4a5c979419
--- /dev/null
+++ b/DS4Control/Enums/TouchpadSlideDirections.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DS4Control.Enums
+{
+ public enum TouchpadSlideDirections
+ {
+ none = 0,
+ right,
+ left
+ }
+}
diff --git a/DS4Control/Mapping.cs b/DS4Control/Mapping.cs
index 030a9b37ed..72a29c337f 100644
--- a/DS4Control/Mapping.cs
+++ b/DS4Control/Mapping.cs
@@ -55,6 +55,7 @@ public void SavePrevious(bool performClear)
public static DateTime oldnow = DateTime.UtcNow;
private static bool pressagain = false;
private static int wheel = 0, keyshelddown = 0;
+
public static void Commit(int device)
{
SyntheticState state = deviceState[device];
@@ -329,20 +330,59 @@ static double TValue(double value1, double value2, double percent)
return value1 * percent + value2 * (1 - percent);
}
+ private static void ProccessCurveState(int curve, DS4State cState, DS4State dState)
+ {
+ int x = cState.LX;
+ int y = cState.LY;
+
+ float max = x + y;
+ double curvex;
+ double curvey;
+ //curve = Global.getLSCurve(device);
+ 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));
+ //btnLSTrack.Location = new Point((int)(dpix * curvex / 2.09 + lbLSTrack.Location.X), (int)(dpiy * curvey / 2.09 + lbLSTrack.Location.Y));
+ }
+ 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);
+ }
+ }
+
+ dState.LX = (byte)Math.Round(curvex, 0);
+ dState.LY = (byte)Math.Round(curvey, 0);
+ }
+
public static DS4State SetCurveAndDeadzone(int device, DS4State cState)
{
+ //Copy constructor...
DS4State dState = new DS4State(cState);
- int x;
- int y;
+
+ //int x;
+ //int y;
int curve;
- if (Global.getLSCurve(device) > 0)
+ if ((curve = Global.getLSCurve(device)) > 0)
{
+
+ /*
x = cState.LX;
y = cState.LY;
float max = x + y;
double curvex;
double curvey;
- curve = Global.getLSCurve(device);
+ //curve = Global.getLSCurve(device);
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))
@@ -365,10 +405,15 @@ public static DS4State SetCurveAndDeadzone(int device, DS4State cState)
}
}
dState.LX = (byte)Math.Round(curvex, 0);
- dState.LY = (byte)Math.Round(curvey, 0);
+ dState.LY = (byte)Math.Round(curvey, 0);*/
+
+ ProccessCurveState(curve, cState, dState);
}
- if (Global.getRSCurve(device) > 0)
+
+ if ((curve = Global.getRSCurve(device)) > 0)
{
+
+ /*
x = cState.RX;
y = cState.RY;
float max = x + y;
@@ -377,6 +422,7 @@ public static DS4State SetCurveAndDeadzone(int device, DS4State cState)
curve = Global.getRSCurve(device);
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));
@@ -396,30 +442,37 @@ public static DS4State SetCurveAndDeadzone(int device, DS4State cState)
}
}
dState.RX = (byte)Math.Round(curvex, 0);
- dState.RY = (byte)Math.Round(curvey, 0);
+ dState.RY = (byte)Math.Round(curvey, 0);*/
+
+ ProccessCurveState(curve, cState, dState);
}
+
if (Global.getLSDeadzone(device) > 0 &&
Math.Sqrt(Math.Pow(cState.LX - 127.5f, 2) + Math.Pow(cState.LY - 127.5f, 2)) < Global.getLSDeadzone(device))
{
dState.LX = 127;
dState.LY = 127;
}
+
if (Global.getRSDeadzone(device) > 0
&& Math.Sqrt(Math.Pow(cState.RX - 127.5f, 2) + Math.Pow(cState.RY - 127.5f, 2)) < Global.getLSDeadzone(device))
{
dState.RX = 127;
dState.RY = 127;
}
+
if (Global.getL2Deadzone(device) > 0 && cState.L2 < Global.getL2Deadzone(device))
dState.L2 = 0;
if (Global.getR2Deadzone(device) > 0 && cState.R2 < Global.getR2Deadzone(device))
dState.R2 = 0;
+
return dState;
}
public static bool[] pressedonce = new bool[261], macrodone = new bool[34];
public static int test = 0;
static bool[] macroControl = new bool[25];
+
///
/// Map DS4 Buttons/Axes to other DS4 Buttons/Axes (largely the same as Xinput ones) and to keyboard and mouse buttons.
///
@@ -463,7 +516,10 @@ public static async void MapCustom(int device, DS4State cState, DS4State MappedS
}
cState.CopyTo(MappedState);
if (shift)
- MapShiftCustom(device, cState, MappedState, eState, tp);
+ {
+ MapShiftCustom(device, cState, MappedState, eState, tp);
+ }
+
foreach (KeyValuePair customKey in Global.getCustomMacros(device))
{
if (shift == false ||
@@ -497,27 +553,34 @@ public static async void MapCustom(int device, DS4State cState, DS4State MappedS
if (!macrodone[DS4ControltoInt(customKey.Key)])
{
macrodone[DS4ControltoInt(customKey.Key)] = true;
+
for (int i = 0; i < keys.Length; i++)
{
if (keys[i] >= 300) //ints over 300 used to delay
+ {
await Task.Delay(keys[i] - 300);
+ }
else if (!keydown[keys[i]])
{
- if (keys[i] == 256) InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_LEFTDOWN); //anything above 255 is not a keyvalue
+ if (keys[i] == 256)
+ {
+ InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_LEFTDOWN); //anything above 255 is not a keyvalue
+ }
+
else if (keys[i] == 257) InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_RIGHTDOWN);
else if (keys[i] == 258) InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_MIDDLEDOWN);
else if (keys[i] == 259) InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_XBUTTONDOWN, 1);
else if (keys[i] == 260) InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_XBUTTONDOWN, 2);
- else if (keys[i] == 261) macroControl[0] = true;
- else if (keys[i] == 262) macroControl[1] = true;
- else if (keys[i] == 263) macroControl[2] = true;
- else if (keys[i] == 264) macroControl[3] = true;
- else if (keys[i] == 265) macroControl[4] = true;
- else if (keys[i] == 266) macroControl[5] = true;
- else if (keys[i] == 267) macroControl[6] = true;
- else if (keys[i] == 268) macroControl[7] = true;
- else if (keys[i] == 269) macroControl[8] = true;
- else if (keys[i] == 270) macroControl[9] = true;
+ else if (keys[i] == 261) macroControl[0] = true;
+ else if (keys[i] == 262) macroControl[1] = true;
+ else if (keys[i] == 263) macroControl[2] = true;
+ else if (keys[i] == 264) macroControl[3] = true;
+ else if (keys[i] == 265) macroControl[4] = true;
+ else if (keys[i] == 266) macroControl[5] = true;
+ else if (keys[i] == 267) macroControl[6] = true;
+ else if (keys[i] == 268) macroControl[7] = true;
+ else if (keys[i] == 269) macroControl[8] = true;
+ else if (keys[i] == 270) macroControl[9] = true;
else if (keys[i] == 271) macroControl[10] = true;
else if (keys[i] == 272) macroControl[11] = true;
else if (keys[i] == 273) macroControl[12] = true;
@@ -541,21 +604,25 @@ public static async void MapCustom(int device, DS4State cState, DS4State MappedS
}
else
{
- if (keys[i] == 256) InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_LEFTUP); //anything above 255 is not a keyvalue
+ if (keys[i] == 256)
+ {
+ InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_LEFTUP); //anything above 255 is not a keyvalue
+ }
+
else if (keys[i] == 257) InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_RIGHTUP);
else if (keys[i] == 258) InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_MIDDLEUP);
else if (keys[i] == 259) InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_XBUTTONUP, 1);
else if (keys[i] == 260) InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_XBUTTONUP, 2);
- else if (keys[i] == 261) macroControl[0] = false;
- else if (keys[i] == 262) macroControl[1] = false;
- else if (keys[i] == 263) macroControl[2] = false;
- else if (keys[i] == 264) macroControl[3] = false;
- else if (keys[i] == 265) macroControl[4] = false;
- else if (keys[i] == 266) macroControl[5] = false;
- else if (keys[i] == 267) macroControl[6] = false;
- else if (keys[i] == 268) macroControl[7] = false;
- else if (keys[i] == 269) macroControl[8] = false;
- else if (keys[i] == 270) macroControl[9] = false;
+ else if (keys[i] == 261) macroControl[0] = false;
+ else if (keys[i] == 262) macroControl[1] = false;
+ else if (keys[i] == 263) macroControl[2] = false;
+ else if (keys[i] == 264) macroControl[3] = false;
+ else if (keys[i] == 265) macroControl[4] = false;
+ else if (keys[i] == 266) macroControl[5] = false;
+ else if (keys[i] == 267) macroControl[6] = false;
+ else if (keys[i] == 268) macroControl[7] = false;
+ else if (keys[i] == 269) macroControl[8] = false;
+ else if (keys[i] == 270) macroControl[9] = false;
else if (keys[i] == 271) macroControl[10] = false;
else if (keys[i] == 272) macroControl[11] = false;
else if (keys[i] == 273) macroControl[12] = false;
@@ -695,6 +762,7 @@ public static async void MapCustom(int device, DS4State cState, DS4State MappedS
List RXP = new List();
List RYN = new List();
List RYP = new List();
+
foreach (KeyValuePair customButton in Global.getCustomButtons(device))
{
if (shift == false ||
diff --git a/DS4Control/MouseWheel.cs b/DS4Control/MouseWheel.cs
index d4b80bbd9d..9c682dce30 100644
--- a/DS4Control/MouseWheel.cs
+++ b/DS4Control/MouseWheel.cs
@@ -35,6 +35,7 @@ public void touchesMoved(TouchpadEventArgs arg)
//mouse wheel 120 == 1 wheel click according to Windows API
double lastMidX = (lastT0.hwX + lastT1.hwX) / 2d, lastMidY = (lastT0.hwY + lastT1.hwY) / 2d,
currentMidX = (T0.hwX + T1.hwX) / 2d, currentMidY = (T0.hwY + T1.hwY) / 2d;
+
double coefficient = Global.getScrollSensitivity(deviceNumber);
// Adjust for touch distance: "standard" distance is 960 pixels, i.e. half the width. Scroll farther if fingers are farther apart, and vice versa, in linear proportion.
double touchXDistance = T1.hwX - T0.hwX, touchYDistance = T1.hwY - T0.hwY, touchDistance = Math.Sqrt(touchXDistance * touchXDistance + touchYDistance * touchYDistance);
diff --git a/DS4Control/ScpUtil.cs b/DS4Control/ScpUtil.cs
index 9e6354121e..a46f0f6681 100644
--- a/DS4Control/ScpUtil.cs
+++ b/DS4Control/ScpUtil.cs
@@ -8,6 +8,9 @@
using System.Drawing;
using DS4Library;
using System.Security.Principal;
+using DS4Windows.XML_Files;
+using System.Xml.Serialization;
+using DS4Control.XML_FIles;
namespace DS4Control
{
[Flags]
@@ -1026,10 +1029,91 @@ public DS4KeyType GetShiftCustomKeyType(int device, DS4Controls controlName)
catch { return 0; }
}
+ private void CreateXMLNode(XmlNode parentNode, XmlDocument document, string name, string textData)
+ {
+ XmlNode newNode = m_Xdoc.CreateNode(XmlNodeType.Element, name, null);
+ newNode.InnerText = textData;
+ parentNode.AppendChild(newNode);
+ }
+
public Boolean SaveProfile(int device, String propath, System.Windows.Forms.Control[] buttons, System.Windows.Forms.Control[] shiftbuttons)
{
Boolean Saved = true;
String path = Global.appdatapath + @"\Profiles\" + Path.GetFileNameWithoutExtension(propath) + ".xml";
+
+ //New System to replace save. Right now this is on hold while I clean up the existing implementation
+ //ProfileXML file = new ProfileXML
+ //{
+ // flushHIDQueue = flushHIDQueue[device],
+ // idleDisconnectTimeout = idleDisconnectTimeout[device],
+ // color = new DS4Color
+ // {
+ // red = m_Leds[device][0],
+ // green = m_Leds[device][1],
+ // blue = m_Leds[device][2]
+ // },
+ // RumbleBoost = rumble[device],
+ // ledAsBatteryIndicator = ledAsBattery[device],
+ // lowBatteryFlash = flashLedLowBattery[device],
+ // flashBatteryAt = flashAt[device],
+ // touchSensitivity = touchSensitivity[device],
+ // LowColor = new DS4Color
+ // {
+ // red = m_LowLeds[device][0],
+ // green = m_LowLeds[device][1],
+ // blue = m_LowLeds[device][2]
+ // },
+ // ChargingColor = new DS4Color
+ // {
+ // red = m_ChargingLeds[device][0],
+ // green = m_ChargingLeds[device][1],
+ // blue = m_ChargingLeds[device][2]
+ // },
+ // ShiftColor = new DS4Color
+ // {
+ // red = m_ShiftLeds[device][0],
+ // green = m_ShiftLeds[device][1],
+ // blue = m_ShiftLeds[device][2]
+ // },
+ // ShiftColorOn = shiftColorOn[device],
+ // FlashColor = new DS4Color
+ // {
+ // red = m_FlashLeds[device][0],
+ // green = m_FlashLeds[device][1],
+ // blue = m_FlashLeds[device][2]
+ // },
+ // touchpadJitterCompensation = touchpadJitterCompensation[device],
+ // lowerRCOn = lowerRCOn[device],
+ // tapSensitivity = tapSensitivity[device],
+ // doubleTap = doubleTap[device],
+ // scrollSensitivity = scrollSensitivity[device],
+ // LeftTriggerMiddle = l2Deadzone[device],
+ // RightTriggerMiddle = r2Deadzone[device],
+ // ButtonMouseSensitivity = buttonMouseSensitivity[device],
+ // Rainbow = rainbow[device],
+ // LSDeadZone = LSDeadzone[device],
+ // RSDeadZone = RSDeadzone[device],
+ // SXDeadZone = SXDeadzone[device],
+ // SZDeadZone = SZDeadzone[device],
+ // ChargingType = chargingType[device],
+ // MouseAcceleration = mouseAccel[device],
+ // ShiftModifier = shiftModifier[device],
+ // LaunchProgram = launchProgram[device],
+ // DinputOnly = dinputOnly[device],
+ // StartTouchpadOff = startTouchpadOff[device],
+ // UseTPforControls = useTPforControls[device],
+ // LSCurve = lsCurve[device],
+ // RSCurve = rsCurve[device],
+ // ProfileActions = profileActions[device],
+ // Controls = new List()
+ //};
+
+ //using (FileStream stream = new FileStream("testXML.xml", FileMode.Create))
+ //{
+ // XmlSerializer serializer = new XmlSerializer(typeof(ProfileXML));
+ // serializer.Serialize(stream, file);
+ //}
+
try
{
XmlNode Node;
@@ -1048,52 +1132,43 @@ public Boolean SaveProfile(int device, String propath, System.Windows.Forms.Cont
Node = m_Xdoc.CreateNode(XmlNodeType.Element, "DS4Windows", null);
- XmlNode xmlFlushHIDQueue = m_Xdoc.CreateNode(XmlNodeType.Element, "flushHIDQueue", null); xmlFlushHIDQueue.InnerText = flushHIDQueue[device].ToString(); Node.AppendChild(xmlFlushHIDQueue);
- XmlNode xmlIdleDisconnectTimeout = m_Xdoc.CreateNode(XmlNodeType.Element, "idleDisconnectTimeout", null); xmlIdleDisconnectTimeout.InnerText = idleDisconnectTimeout[device].ToString(); Node.AppendChild(xmlIdleDisconnectTimeout);
- XmlNode xmlColor = m_Xdoc.CreateNode(XmlNodeType.Element, "Color", null);
- xmlColor.InnerText = m_Leds[device][0].ToString() + "," + m_Leds[device][1].ToString() + "," + m_Leds[device][2].ToString();
- Node.AppendChild(xmlColor);
- XmlNode xmlRumbleBoost = m_Xdoc.CreateNode(XmlNodeType.Element, "RumbleBoost", null); xmlRumbleBoost.InnerText = rumble[device].ToString(); Node.AppendChild(xmlRumbleBoost);
- XmlNode xmlLedAsBatteryIndicator = m_Xdoc.CreateNode(XmlNodeType.Element, "ledAsBatteryIndicator", null); xmlLedAsBatteryIndicator.InnerText = ledAsBattery[device].ToString(); Node.AppendChild(xmlLedAsBatteryIndicator);
- XmlNode xmlLowBatteryFlash = m_Xdoc.CreateNode(XmlNodeType.Element, "lowBatteryFlash", null); xmlLowBatteryFlash.InnerText = flashLedLowBattery[device].ToString(); Node.AppendChild(xmlLowBatteryFlash);
- XmlNode xmlFlashBatterAt = m_Xdoc.CreateNode(XmlNodeType.Element, "flashBatteryAt", null); xmlFlashBatterAt.InnerText = flashAt[device].ToString(); Node.AppendChild(xmlFlashBatterAt);
- XmlNode xmlTouchSensitivity = m_Xdoc.CreateNode(XmlNodeType.Element, "touchSensitivity", null); xmlTouchSensitivity.InnerText = touchSensitivity[device].ToString(); Node.AppendChild(xmlTouchSensitivity);
- XmlNode xmlLowColor = m_Xdoc.CreateNode(XmlNodeType.Element, "LowColor", null);
- xmlLowColor.InnerText = m_LowLeds[device][0].ToString() + "," + m_LowLeds[device][1].ToString() + "," + m_LowLeds[device][2].ToString();
- Node.AppendChild(xmlLowColor);
- XmlNode xmlChargingColor = m_Xdoc.CreateNode(XmlNodeType.Element, "ChargingColor", null);
- xmlChargingColor.InnerText = m_ChargingLeds[device][0].ToString() + "," + m_ChargingLeds[device][1].ToString() + "," + m_ChargingLeds[device][2].ToString();
- Node.AppendChild(xmlChargingColor);
- XmlNode xmlShiftColor = m_Xdoc.CreateNode(XmlNodeType.Element, "ShiftColor", null);
- xmlShiftColor.InnerText = m_ShiftLeds[device][0].ToString() + "," + m_ShiftLeds[device][1].ToString() + "," + m_ShiftLeds[device][2].ToString();
- Node.AppendChild(xmlShiftColor);
- XmlNode xmlShiftColorOn = m_Xdoc.CreateNode(XmlNodeType.Element, "ShiftColorOn", null); xmlShiftColorOn.InnerText = shiftColorOn[device].ToString(); Node.AppendChild(xmlShiftColorOn);
- XmlNode xmlFlashColor = m_Xdoc.CreateNode(XmlNodeType.Element, "FlashColor", null);
- xmlFlashColor.InnerText = m_FlashLeds[device][0].ToString() + "," + m_FlashLeds[device][1].ToString() + "," + m_FlashLeds[device][2].ToString();
- Node.AppendChild(xmlFlashColor);
- XmlNode xmlTouchpadJitterCompensation = m_Xdoc.CreateNode(XmlNodeType.Element, "touchpadJitterCompensation", null); xmlTouchpadJitterCompensation.InnerText = touchpadJitterCompensation[device].ToString(); Node.AppendChild(xmlTouchpadJitterCompensation);
- XmlNode xmlLowerRCOn = m_Xdoc.CreateNode(XmlNodeType.Element, "lowerRCOn", null); xmlLowerRCOn.InnerText = lowerRCOn[device].ToString(); Node.AppendChild(xmlLowerRCOn);
- XmlNode xmlTapSensitivity = m_Xdoc.CreateNode(XmlNodeType.Element, "tapSensitivity", null); xmlTapSensitivity.InnerText = tapSensitivity[device].ToString(); Node.AppendChild(xmlTapSensitivity);
- XmlNode xmlDouble = m_Xdoc.CreateNode(XmlNodeType.Element, "doubleTap", null); xmlDouble.InnerText = doubleTap[device].ToString(); Node.AppendChild(xmlDouble);
- XmlNode xmlScrollSensitivity = m_Xdoc.CreateNode(XmlNodeType.Element, "scrollSensitivity", null); xmlScrollSensitivity.InnerText = scrollSensitivity[device].ToString(); Node.AppendChild(xmlScrollSensitivity);
- XmlNode xmlLeftTriggerMiddle = m_Xdoc.CreateNode(XmlNodeType.Element, "LeftTriggerMiddle", null); xmlLeftTriggerMiddle.InnerText = l2Deadzone[device].ToString(); Node.AppendChild(xmlLeftTriggerMiddle);
- XmlNode xmlRightTriggerMiddle = m_Xdoc.CreateNode(XmlNodeType.Element, "RightTriggerMiddle", null); xmlRightTriggerMiddle.InnerText = r2Deadzone[device].ToString(); Node.AppendChild(xmlRightTriggerMiddle);
- XmlNode xmlButtonMouseSensitivity = m_Xdoc.CreateNode(XmlNodeType.Element, "ButtonMouseSensitivity", null); xmlButtonMouseSensitivity.InnerText = buttonMouseSensitivity[device].ToString(); Node.AppendChild(xmlButtonMouseSensitivity);
- XmlNode xmlRainbow = m_Xdoc.CreateNode(XmlNodeType.Element, "Rainbow", null); xmlRainbow.InnerText = rainbow[device].ToString(); Node.AppendChild(xmlRainbow);
- XmlNode xmlLSD = m_Xdoc.CreateNode(XmlNodeType.Element, "LSDeadZone", null); xmlLSD.InnerText = LSDeadzone[device].ToString(); Node.AppendChild(xmlLSD);
- XmlNode xmlRSD = m_Xdoc.CreateNode(XmlNodeType.Element, "RSDeadZone", null); xmlRSD.InnerText = RSDeadzone[device].ToString(); Node.AppendChild(xmlRSD);
- XmlNode xmlSXD = m_Xdoc.CreateNode(XmlNodeType.Element, "SXDeadZone", null); xmlSXD.InnerText = SXDeadzone[device].ToString(); Node.AppendChild(xmlSXD);
- XmlNode xmlSZD = m_Xdoc.CreateNode(XmlNodeType.Element, "SZDeadZone", null); xmlSZD.InnerText = SZDeadzone[device].ToString(); Node.AppendChild(xmlSZD);
- XmlNode xmlChargingType = m_Xdoc.CreateNode(XmlNodeType.Element, "ChargingType", null); xmlChargingType.InnerText = chargingType[device].ToString(); Node.AppendChild(xmlChargingType);
- XmlNode xmlMouseAccel = m_Xdoc.CreateNode(XmlNodeType.Element, "MouseAcceleration", null); xmlMouseAccel.InnerText = mouseAccel[device].ToString(); Node.AppendChild(xmlMouseAccel);
- XmlNode xmlShiftMod = m_Xdoc.CreateNode(XmlNodeType.Element, "ShiftModifier", null); xmlShiftMod.InnerText = shiftModifier[device].ToString(); Node.AppendChild(xmlShiftMod);
- XmlNode xmlLaunchProgram = m_Xdoc.CreateNode(XmlNodeType.Element, "LaunchProgram", null); xmlLaunchProgram.InnerText = launchProgram[device].ToString(); Node.AppendChild(xmlLaunchProgram);
- XmlNode xmlDinput = m_Xdoc.CreateNode(XmlNodeType.Element, "DinputOnly", null); xmlDinput.InnerText = dinputOnly[device].ToString(); Node.AppendChild(xmlDinput);
- XmlNode xmlStartTouchpadOff = m_Xdoc.CreateNode(XmlNodeType.Element, "StartTouchpadOff", null); xmlStartTouchpadOff.InnerText = startTouchpadOff[device].ToString(); Node.AppendChild(xmlStartTouchpadOff);
- XmlNode xmlUseTPforControls = m_Xdoc.CreateNode(XmlNodeType.Element, "UseTPforControls", null); xmlUseTPforControls.InnerText = useTPforControls[device].ToString(); Node.AppendChild(xmlUseTPforControls);
- XmlNode xmlLSC = m_Xdoc.CreateNode(XmlNodeType.Element, "LSCurve", null); xmlLSC.InnerText = lsCurve[device].ToString(); Node.AppendChild(xmlLSC);
- XmlNode xmlRSC = m_Xdoc.CreateNode(XmlNodeType.Element, "RSCurve", null); xmlRSC.InnerText = rsCurve[device].ToString(); Node.AppendChild(xmlRSC);
- XmlNode xmlProfileActions = m_Xdoc.CreateNode(XmlNodeType.Element, "ProfileActions", null); xmlProfileActions.InnerText = string.Join("/", profileActions[device]); Node.AppendChild(xmlProfileActions);
+ this.CreateXMLNode(Node, m_Xdoc, "flushHIDQueue", flushHIDQueue[device].ToString());
+ this.CreateXMLNode(Node, m_Xdoc, "idleDisconnectTimeout", idleDisconnectTimeout[device].ToString());
+ this.CreateXMLNode(Node, m_Xdoc, "Color", m_Leds[device][0].ToString() + "," + m_Leds[device][1].ToString() + "," + m_Leds[device][2].ToString());
+ this.CreateXMLNode(Node, m_Xdoc, "RumbleBoost", rumble[device].ToString());
+ this.CreateXMLNode(Node, m_Xdoc, "ledAsBatteryIndicator", ledAsBattery[device].ToString());
+ this.CreateXMLNode(Node, m_Xdoc, "lowBatteryFlash", flashLedLowBattery[device].ToString());
+ this.CreateXMLNode(Node, m_Xdoc, "flashBatteryAt", flashAt[device].ToString());
+ this.CreateXMLNode(Node, m_Xdoc, "touchSensitivity", touchSensitivity[device].ToString());
+ this.CreateXMLNode(Node, m_Xdoc, "LowColor", m_LowLeds[device][0].ToString() + "," + m_LowLeds[device][1].ToString() + "," + m_LowLeds[device][2].ToString());
+ this.CreateXMLNode(Node, m_Xdoc, "ChargingColor", m_ChargingLeds[device][0].ToString() + "," + m_ChargingLeds[device][1].ToString() + "," + m_ChargingLeds[device][2].ToString());
+ this.CreateXMLNode(Node, m_Xdoc, "ShiftColor", m_ShiftLeds[device][0].ToString() + "," + m_ShiftLeds[device][1].ToString() + "," + m_ShiftLeds[device][2].ToString());
+ this.CreateXMLNode(Node, m_Xdoc, "ShiftColorOn", shiftColorOn[device].ToString());
+ this.CreateXMLNode(Node, m_Xdoc, "FlashColor", m_FlashLeds[device][0].ToString() + "," + m_FlashLeds[device][1].ToString() + "," + m_FlashLeds[device][2].ToString());
+ this.CreateXMLNode(Node, m_Xdoc, "touchpadJitterCompensation", touchpadJitterCompensation[device].ToString());
+ this.CreateXMLNode(Node, m_Xdoc, "lowerRCOn", lowerRCOn[device].ToString());
+ this.CreateXMLNode(Node, m_Xdoc, "tapSensitivity", tapSensitivity[device].ToString());
+ this.CreateXMLNode(Node, m_Xdoc, "doubleTap", doubleTap[device].ToString());
+ this.CreateXMLNode(Node, m_Xdoc, "scrollSensitivity", scrollSensitivity[device].ToString());
+ this.CreateXMLNode(Node, m_Xdoc, "LeftTriggerMiddle", l2Deadzone[device].ToString());
+ this.CreateXMLNode(Node, m_Xdoc, "RightTriggerMiddle", r2Deadzone[device].ToString());
+ this.CreateXMLNode(Node, m_Xdoc, "ButtonMouseSensitivity", buttonMouseSensitivity[device].ToString());
+ this.CreateXMLNode(Node, m_Xdoc, "Rainbow", rainbow[device].ToString());
+ this.CreateXMLNode(Node, m_Xdoc, "LSDeadZone", LSDeadzone[device].ToString());
+ this.CreateXMLNode(Node, m_Xdoc, "RSDeadZone", RSDeadzone[device].ToString());
+ this.CreateXMLNode(Node, m_Xdoc, "SXDeadZone", SXDeadzone[device].ToString());
+ this.CreateXMLNode(Node, m_Xdoc, "SZDeadZone", SZDeadzone[device].ToString());
+ this.CreateXMLNode(Node, m_Xdoc, "ChargingType", chargingType[device].ToString());
+ this.CreateXMLNode(Node, m_Xdoc, "MouseAcceleration", mouseAccel[device].ToString());
+ this.CreateXMLNode(Node, m_Xdoc, "ShiftModifier", shiftModifier[device].ToString());
+ this.CreateXMLNode(Node, m_Xdoc, "LaunchProgram", launchProgram[device].ToString());
+ this.CreateXMLNode(Node, m_Xdoc, "DinputOnly", dinputOnly[device].ToString());
+ this.CreateXMLNode(Node, m_Xdoc, "StartTouchpadOff", startTouchpadOff[device].ToString());
+ this.CreateXMLNode(Node, m_Xdoc, "UseTPforControls", useTPforControls[device].ToString());
+ this.CreateXMLNode(Node, m_Xdoc, "LSCurve", lsCurve[device].ToString());
+ this.CreateXMLNode(Node, m_Xdoc, "RSCurve", rsCurve[device].ToString());
+ this.CreateXMLNode(Node, m_Xdoc, "ProfileActions", string.Join("/", profileActions[device]));
+
XmlNode NodeControl = m_Xdoc.CreateNode(XmlNodeType.Element, "Control", null);
XmlNode Key = m_Xdoc.CreateNode(XmlNodeType.Element, "Key", null);
@@ -1101,93 +1176,16 @@ public Boolean SaveProfile(int device, String propath, System.Windows.Forms.Cont
XmlNode KeyType = m_Xdoc.CreateNode(XmlNodeType.Element, "KeyType", null);
XmlNode Button = m_Xdoc.CreateNode(XmlNodeType.Element, "Button", null);
XmlNode Extras = m_Xdoc.CreateNode(XmlNodeType.Element, "Extras", null);
+
if (buttons != null)
{
- foreach (var button in buttons)
- {
- // Save even if string (for xbox controller buttons)
- if (button.Tag != null)
- {
- XmlNode buttonNode;
- string keyType = String.Empty;
-
- if (button.Tag is KeyValuePair)
- if (((KeyValuePair)button.Tag).Key == "Unbound")
- keyType += DS4KeyType.Unbound;
-
- if (button.Font.Strikeout)
- keyType += DS4KeyType.HoldMacro;
- if (button.Font.Underline)
- keyType += DS4KeyType.Macro;
- if (button.Font.Italic)
- keyType += DS4KeyType.Toggle;
- if (button.Font.Bold)
- keyType += DS4KeyType.ScanCode;
- if (keyType != String.Empty)
- {
- buttonNode = m_Xdoc.CreateNode(XmlNodeType.Element, button.Name, null);
- buttonNode.InnerText = keyType;
- KeyType.AppendChild(buttonNode);
- }
-
- string[] extras;
- buttonNode = m_Xdoc.CreateNode(XmlNodeType.Element, button.Name, null);
- if (button.Tag is KeyValuePair, string> || button.Tag is KeyValuePair || button.Tag is KeyValuePair)
- {
- KeyValuePair tag = (KeyValuePair)button.Tag;
- int[] ii = tag.Key;
- buttonNode.InnerText = string.Join("/", ii);
- Macro.AppendChild(buttonNode);
- extras = tag.Value.Split(',');
- }
- else if (button.Tag is KeyValuePair || button.Tag is KeyValuePair || button.Tag is KeyValuePair)
- {
- KeyValuePair tag = (KeyValuePair)button.Tag;
- buttonNode.InnerText = tag.Key.ToString();
- Key.AppendChild(buttonNode);
- extras = tag.Value.Split(',');
- }
- else if (button.Tag is KeyValuePair)
- {
- KeyValuePair tag = (KeyValuePair)button.Tag;
- buttonNode.InnerText = tag.Key;
- Button.AppendChild(buttonNode);
- extras = tag.Value.Split(',');
- }
- else
- {
- KeyValuePair