2014-03-28 02:50:40 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using System.Xml;
|
|
|
|
|
using DS4Library;
|
|
|
|
|
namespace DS4Control
|
|
|
|
|
{
|
|
|
|
|
[Flags]
|
2014-04-27 21:32:09 +02:00
|
|
|
|
public enum DS4KeyType : byte { None = 0, ScanCode = 1, Repeat = 2, Unbound = 4 }; //Increment by exponents of 2*, starting at 2^0
|
2014-03-28 02:50:40 +01:00
|
|
|
|
public enum Ds3PadId : byte { None = 0xFF, One = 0x00, Two = 0x01, Three = 0x02, Four = 0x03, All = 0x04 };
|
2014-04-27 21:32:09 +02:00
|
|
|
|
public enum DS4Controls : byte { None, LXNeg, LXPos, LYNeg, LYPos, RXNeg, RXPos, RYNeg, RYPos, L1, L2, L3, R1, R2, R3, Square, Triangle, Circle, Cross, DpadUp, DpadRight, DpadDown, DpadLeft, PS, TouchLeft, TouchUpper, TouchMulti, TouchRight, Share, Options };
|
|
|
|
|
public enum X360Controls : byte { None, LXNeg, LXPos, LYNeg, LYPos, RXNeg, RXPos, RYNeg, RYPos, LB, LT, LS, RB, RT, RS, X, Y, B, A, DpadUp, DpadRight, DpadDown, DpadLeft, Guide, Back, Start, LeftMouse, RightMouse, MiddleMouse, FourthMouse, FifthMouse, WUP, WDOWN, Unbound };
|
2014-03-28 02:50:40 +01:00
|
|
|
|
|
|
|
|
|
public class DebugEventArgs : EventArgs
|
|
|
|
|
{
|
|
|
|
|
protected DateTime m_Time = DateTime.Now;
|
|
|
|
|
protected String m_Data = String.Empty;
|
|
|
|
|
|
|
|
|
|
public DebugEventArgs(String Data)
|
|
|
|
|
{
|
|
|
|
|
m_Data = Data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DateTime Time
|
|
|
|
|
{
|
|
|
|
|
get { return m_Time; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String Data
|
|
|
|
|
{
|
|
|
|
|
get { return m_Data; }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class MappingDoneEventArgs : EventArgs
|
|
|
|
|
{
|
|
|
|
|
protected int deviceNum = -1;
|
|
|
|
|
|
|
|
|
|
public MappingDoneEventArgs(int DeviceID)
|
|
|
|
|
{
|
|
|
|
|
deviceNum = DeviceID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int DeviceID
|
|
|
|
|
{
|
|
|
|
|
get { return deviceNum; }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class ReportEventArgs : EventArgs
|
|
|
|
|
{
|
|
|
|
|
protected Ds3PadId m_Pad = Ds3PadId.None;
|
|
|
|
|
protected Byte[] m_Report = new Byte[64];
|
|
|
|
|
|
|
|
|
|
public ReportEventArgs()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ReportEventArgs(Ds3PadId Pad)
|
|
|
|
|
{
|
|
|
|
|
m_Pad = Pad;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Ds3PadId Pad
|
|
|
|
|
{
|
|
|
|
|
get { return m_Pad; }
|
|
|
|
|
set { m_Pad = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Byte[] Report
|
|
|
|
|
{
|
|
|
|
|
get { return m_Report; }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class Global
|
|
|
|
|
{
|
|
|
|
|
protected static BackingStore m_Config = new BackingStore();
|
|
|
|
|
protected static Int32 m_IdleTimeout = 600000;
|
|
|
|
|
|
2014-03-29 06:29:08 +01:00
|
|
|
|
public static event EventHandler<EventArgs> ControllerStatusChange; // called when a controller is added/removed/battery or touchpad mode changes/etc.
|
|
|
|
|
public static void ControllerStatusChanged(object sender)
|
|
|
|
|
{
|
|
|
|
|
if (ControllerStatusChange != null)
|
|
|
|
|
ControllerStatusChange(sender, EventArgs.Empty);
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-28 02:50:40 +01:00
|
|
|
|
public static DS4Color loadColor(int device)
|
|
|
|
|
{
|
|
|
|
|
DS4Color color = new DS4Color();
|
2014-04-29 10:01:13 +02:00
|
|
|
|
color.red = m_Config.m_Leds[device][0];
|
|
|
|
|
color.green = m_Config.m_Leds[device][1];
|
|
|
|
|
color.blue = m_Config.m_Leds[device][2];
|
2014-03-28 02:50:40 +01:00
|
|
|
|
return color;
|
|
|
|
|
}
|
|
|
|
|
public static void saveColor(int device, byte red, byte green, byte blue)
|
|
|
|
|
{
|
2014-04-29 10:01:13 +02:00
|
|
|
|
m_Config.m_Leds[device][0] = red;
|
|
|
|
|
m_Config.m_Leds[device][1] = green;
|
|
|
|
|
m_Config.m_Leds[device][2] = blue;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static byte loadRumbleBoost(int device)
|
|
|
|
|
{
|
2014-04-29 10:01:13 +02:00
|
|
|
|
return m_Config.m_Rumble[device];
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
|
|
|
|
public static void saveRumbleBoost(int device, byte boost)
|
|
|
|
|
{
|
2014-04-29 10:01:13 +02:00
|
|
|
|
m_Config.m_Rumble[device] = boost;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-27 21:32:09 +02:00
|
|
|
|
public static bool getRumbleSwap(int device)
|
|
|
|
|
{
|
2014-04-29 10:01:13 +02:00
|
|
|
|
return m_Config.rumbleSwap[device];
|
2014-04-27 21:32:09 +02:00
|
|
|
|
}
|
|
|
|
|
public static void setRumbleSwap(int device, bool swap)
|
|
|
|
|
{
|
2014-04-29 10:01:13 +02:00
|
|
|
|
m_Config.rumbleSwap[device] = swap;
|
2014-04-27 21:32:09 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-03-28 02:50:40 +01:00
|
|
|
|
public static bool getFlushHIDQueue(int device)
|
|
|
|
|
{
|
2014-04-29 10:01:13 +02:00
|
|
|
|
return m_Config.flushHIDQueue[device];
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
|
|
|
|
public static void setFlushHIDQueue(int device, bool setting)
|
|
|
|
|
{
|
2014-04-29 10:01:13 +02:00
|
|
|
|
m_Config.flushHIDQueue[device] = setting;
|
2014-04-27 21:32:09 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static int getIdleDisconnectTimeout(int device)
|
|
|
|
|
{
|
2014-04-29 10:01:13 +02:00
|
|
|
|
return m_Config.idleDisconnectTimeout[device];
|
2014-04-27 21:32:09 +02:00
|
|
|
|
}
|
|
|
|
|
public static void setIdleDisconnectTimeout(int device, int seconds)
|
|
|
|
|
{
|
2014-04-29 10:01:13 +02:00
|
|
|
|
m_Config.idleDisconnectTimeout[device] = seconds;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static byte getTouchSensitivity(int device)
|
|
|
|
|
{
|
2014-04-29 10:01:13 +02:00
|
|
|
|
return m_Config.touchSensitivity[device];
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
|
|
|
|
public static void setTouchSensitivity(int device, byte sen)
|
|
|
|
|
{
|
2014-04-29 10:01:13 +02:00
|
|
|
|
m_Config.touchSensitivity[device] = sen;
|
2014-04-27 21:32:09 +02:00
|
|
|
|
}
|
2014-03-28 02:50:40 +01:00
|
|
|
|
|
|
|
|
|
public static void setFlashWhenLowBattery(int device, bool flash)
|
|
|
|
|
{
|
2014-04-29 10:01:13 +02:00
|
|
|
|
m_Config.flashLedLowBattery[device] = flash;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public static bool getFlashWhenLowBattery(int device)
|
|
|
|
|
{
|
2014-04-29 10:01:13 +02:00
|
|
|
|
return m_Config.flashLedLowBattery[device];
|
2014-03-28 02:50:40 +01:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void setLedAsBatteryIndicator(int device, bool ledAsBattery)
|
|
|
|
|
{
|
2014-04-29 10:01:13 +02:00
|
|
|
|
m_Config.ledAsBattery[device] = ledAsBattery;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public static bool getLedAsBatteryIndicator(int device)
|
|
|
|
|
{
|
2014-04-29 10:01:13 +02:00
|
|
|
|
return m_Config.ledAsBattery[device];
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
2014-04-27 21:32:09 +02:00
|
|
|
|
|
2014-03-28 02:50:40 +01:00
|
|
|
|
public static void setUseExclusiveMode(bool exclusive)
|
|
|
|
|
{
|
|
|
|
|
m_Config.useExclusiveMode = exclusive;
|
|
|
|
|
}
|
|
|
|
|
public static bool getUseExclusiveMode()
|
|
|
|
|
{
|
|
|
|
|
return m_Config.useExclusiveMode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// New settings
|
|
|
|
|
public static void saveLowColor(int device, byte red, byte green, byte blue)
|
|
|
|
|
{
|
2014-04-29 10:01:13 +02:00
|
|
|
|
m_Config.m_LowLeds[device][0] = red;
|
|
|
|
|
m_Config.m_LowLeds[device][1] = green;
|
|
|
|
|
m_Config.m_LowLeds[device][2] = blue;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
|
|
|
|
public static DS4Color loadLowColor(int device)
|
|
|
|
|
{
|
|
|
|
|
DS4Color color = new DS4Color();
|
2014-04-29 10:01:13 +02:00
|
|
|
|
color.red = m_Config.m_LowLeds[device][0];
|
|
|
|
|
color.green = m_Config.m_LowLeds[device][1];
|
|
|
|
|
color.blue = m_Config.m_LowLeds[device][2];
|
2014-03-28 02:50:40 +01:00
|
|
|
|
return color;
|
|
|
|
|
}
|
|
|
|
|
public static void setTapSensitivity(int device, byte sen)
|
|
|
|
|
{
|
2014-04-29 10:01:13 +02:00
|
|
|
|
m_Config.tapSensitivity[device] = sen;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
|
|
|
|
public static byte getTapSensitivity(int device)
|
|
|
|
|
{
|
2014-04-29 10:01:13 +02:00
|
|
|
|
return m_Config.tapSensitivity[device];
|
2014-04-27 21:32:09 +02:00
|
|
|
|
}
|
2014-04-29 03:14:01 +02:00
|
|
|
|
public static void setDoubleTap(int device, bool on)
|
|
|
|
|
{
|
2014-04-29 10:01:13 +02:00
|
|
|
|
m_Config.doubleTap[device] = on;
|
2014-04-29 03:14:01 +02:00
|
|
|
|
}
|
|
|
|
|
public static bool getDoubleTap(int device)
|
|
|
|
|
{
|
2014-04-29 10:01:13 +02:00
|
|
|
|
return m_Config.doubleTap[device];
|
2014-04-29 03:14:01 +02:00
|
|
|
|
}
|
2014-04-27 21:32:09 +02:00
|
|
|
|
public static bool getTap(int device)
|
|
|
|
|
{
|
2014-04-29 10:01:13 +02:00
|
|
|
|
if (m_Config.tapSensitivity[device] == 0)
|
2014-04-27 21:32:09 +02:00
|
|
|
|
return false;
|
|
|
|
|
else
|
|
|
|
|
return true;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
|
|
|
|
public static void setScrollSensitivity(int device, int sen)
|
|
|
|
|
{
|
2014-04-29 10:01:13 +02:00
|
|
|
|
m_Config.scrollSensitivity[device] = sen;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
|
|
|
|
public static int getScrollSensitivity(int device)
|
|
|
|
|
{
|
2014-04-29 10:01:13 +02:00
|
|
|
|
return m_Config.scrollSensitivity[device];
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
2014-04-27 21:32:09 +02:00
|
|
|
|
public static void setLowerRCOn(int device, bool twoFingerRC)
|
2014-03-28 02:50:40 +01:00
|
|
|
|
{
|
2014-04-29 10:01:13 +02:00
|
|
|
|
m_Config.lowerRCOn[device] = twoFingerRC;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
2014-04-27 21:32:09 +02:00
|
|
|
|
public static bool getLowerRCOn(int device)
|
2014-03-28 02:50:40 +01:00
|
|
|
|
{
|
2014-04-29 10:01:13 +02:00
|
|
|
|
return m_Config.lowerRCOn[device];
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
|
|
|
|
public static void setTouchpadJitterCompensation(int device, bool enabled)
|
|
|
|
|
{
|
2014-04-29 10:01:13 +02:00
|
|
|
|
m_Config.touchpadJitterCompensation[device] = enabled;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
|
|
|
|
public static bool getTouchpadJitterCompensation(int device)
|
|
|
|
|
{
|
2014-04-29 10:01:13 +02:00
|
|
|
|
return m_Config.touchpadJitterCompensation[device];
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
|
|
|
|
public static void setStartMinimized(bool startMinimized)
|
|
|
|
|
{
|
|
|
|
|
m_Config.startMinimized = startMinimized;
|
|
|
|
|
}
|
|
|
|
|
public static bool getStartMinimized()
|
|
|
|
|
{
|
|
|
|
|
return m_Config.startMinimized;
|
|
|
|
|
}
|
|
|
|
|
public static void setFormWidth(int size)
|
|
|
|
|
{
|
|
|
|
|
m_Config.formWidth = size;
|
|
|
|
|
}
|
|
|
|
|
public static int getFormWidth()
|
|
|
|
|
{
|
|
|
|
|
return m_Config.formWidth;
|
|
|
|
|
}
|
|
|
|
|
public static void setFormHeight(int size)
|
|
|
|
|
{
|
|
|
|
|
m_Config.formHeight = size;
|
|
|
|
|
}
|
|
|
|
|
public static int getFormHeight()
|
|
|
|
|
{
|
|
|
|
|
return m_Config.formHeight;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static double getLeftTriggerMiddle(int device)
|
|
|
|
|
{
|
2014-04-29 10:01:13 +02:00
|
|
|
|
return m_Config.m_LeftTriggerMiddle[device];
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
|
|
|
|
public static void setLeftTriggerMiddle(int device, double value)
|
|
|
|
|
{
|
2014-04-29 10:01:13 +02:00
|
|
|
|
m_Config.m_LeftTriggerMiddle[device] = value;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static double getRightTriggerMiddle(int device)
|
|
|
|
|
{
|
2014-04-29 10:01:13 +02:00
|
|
|
|
return m_Config.m_RightTriggerMiddle[device];
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
|
|
|
|
public static void setRightTriggerMiddle(int device, double value)
|
|
|
|
|
{
|
2014-04-29 10:01:13 +02:00
|
|
|
|
m_Config.m_RightTriggerMiddle[device] = value;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
2014-04-27 21:32:09 +02:00
|
|
|
|
public static void setAProfile(int device, string filepath)
|
2014-03-28 02:50:40 +01:00
|
|
|
|
{
|
2014-04-27 21:32:09 +02:00
|
|
|
|
m_Config.profilePath[device] = Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName + @"\Profiles\" + filepath + ".xml";
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
2014-04-27 21:32:09 +02:00
|
|
|
|
public static string getAProfile(int device)
|
2014-03-28 02:50:40 +01:00
|
|
|
|
{
|
2014-04-27 21:32:09 +02:00
|
|
|
|
return m_Config.profilePath[device];
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
2014-04-27 21:32:09 +02:00
|
|
|
|
public static X360Controls getCustomButton(int device, DS4Controls controlName)
|
2014-03-28 02:50:40 +01:00
|
|
|
|
{
|
2014-04-27 21:32:09 +02:00
|
|
|
|
return m_Config.GetCustomButton(device, controlName);
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
2014-04-27 21:32:09 +02:00
|
|
|
|
public static ushort getCustomKey(int device, DS4Controls controlName)
|
2014-03-28 02:50:40 +01:00
|
|
|
|
{
|
2014-04-27 21:32:09 +02:00
|
|
|
|
return m_Config.GetCustomKey(device, controlName);
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
2014-04-27 21:32:09 +02:00
|
|
|
|
public static DS4KeyType getCustomKeyType(int device, DS4Controls controlName)
|
2014-03-28 02:50:40 +01:00
|
|
|
|
{
|
2014-04-27 21:32:09 +02:00
|
|
|
|
return m_Config.GetCustomKeyType(device, controlName);
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
|
|
|
|
public static bool getHasCustomKeysorButtons(int device)
|
|
|
|
|
{
|
2014-04-29 11:19:00 +02:00
|
|
|
|
return m_Config.customMapButtons[device].Count > 0
|
|
|
|
|
|| m_Config.customMapKeys[device].Count > 0;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
2014-04-27 21:32:09 +02:00
|
|
|
|
public static Dictionary<DS4Controls, X360Controls> getCustomButtons(int device)
|
2014-03-28 02:50:40 +01:00
|
|
|
|
{
|
2014-04-29 11:19:00 +02:00
|
|
|
|
return m_Config.customMapButtons[device];
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
2014-04-27 21:32:09 +02:00
|
|
|
|
public static Dictionary<DS4Controls, ushort> getCustomKeys(int device)
|
2014-03-28 02:50:40 +01:00
|
|
|
|
{
|
2014-04-29 11:19:00 +02:00
|
|
|
|
return m_Config.customMapKeys[device];
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
2014-04-27 21:32:09 +02:00
|
|
|
|
public static Dictionary<DS4Controls, DS4KeyType> getCustomKeyTypes(int device)
|
2014-03-28 02:50:40 +01:00
|
|
|
|
{
|
2014-04-29 11:19:00 +02:00
|
|
|
|
return m_Config.customMapKeyTypes[device];
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
2014-04-29 11:19:00 +02:00
|
|
|
|
public static bool Load()
|
2014-03-28 02:50:40 +01:00
|
|
|
|
{
|
2014-04-29 11:19:00 +02:00
|
|
|
|
return m_Config.Load();
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
2014-04-27 21:32:09 +02:00
|
|
|
|
public static void LoadProfile(int device, System.Windows.Forms.Control[] buttons)
|
|
|
|
|
{
|
|
|
|
|
m_Config.LoadProfile(device, buttons);
|
|
|
|
|
}
|
|
|
|
|
public static void LoadProfile(int device)
|
|
|
|
|
{
|
|
|
|
|
m_Config.LoadProfile(device);
|
|
|
|
|
}
|
2014-03-28 02:50:40 +01:00
|
|
|
|
public static void Save()
|
|
|
|
|
{
|
|
|
|
|
m_Config.Save();
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-29 10:22:37 +02:00
|
|
|
|
public static void SaveProfile(int device, string propath, System.Windows.Forms.Control[] buttons)
|
2014-04-27 21:32:09 +02:00
|
|
|
|
{
|
2014-04-29 10:22:37 +02:00
|
|
|
|
m_Config.SaveProfile(device, propath, buttons);
|
2014-04-27 21:32:09 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-03-28 02:50:40 +01:00
|
|
|
|
private static byte applyRatio(byte b1, byte b2, uint r)
|
|
|
|
|
{
|
|
|
|
|
uint ratio = r;
|
|
|
|
|
if (b1 > b2)
|
|
|
|
|
{
|
|
|
|
|
ratio = 100 - r;
|
|
|
|
|
}
|
|
|
|
|
byte bmax = Math.Max(b1, b2);
|
|
|
|
|
byte bmin = Math.Min(b1, b2);
|
|
|
|
|
byte bdif = (byte)(bmax - bmin);
|
|
|
|
|
return (byte)(bmin + (bdif * ratio / 100));
|
|
|
|
|
}
|
2014-03-29 06:29:08 +01:00
|
|
|
|
public static DS4Color getTransitionedColor(DS4Color c1, DS4Color c2, uint ratio)
|
|
|
|
|
{;
|
|
|
|
|
c1.red = applyRatio(c1.red, c2.red, ratio);
|
|
|
|
|
c1.green = applyRatio(c1.green, c2.green, ratio);
|
|
|
|
|
c1.blue = applyRatio(c1.blue, c2.blue, ratio);
|
|
|
|
|
return c1;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class BackingStore
|
|
|
|
|
{
|
2014-04-27 21:32:09 +02:00
|
|
|
|
protected String m_Profile = Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName + @"\Profiles.xml";
|
2014-03-28 02:50:40 +01:00
|
|
|
|
protected XmlDocument m_Xdoc = new XmlDocument();
|
|
|
|
|
|
2014-04-29 10:01:13 +02:00
|
|
|
|
public Boolean[] touchpadJitterCompensation = {true, true, true, true};
|
|
|
|
|
public Boolean[] lowerRCOn = { false, false, false, false };
|
|
|
|
|
public Boolean[] ledAsBattery = { false, false, false, false };
|
|
|
|
|
public Boolean[] flashLedLowBattery = { false, false, false, false };
|
|
|
|
|
public double[] m_LeftTriggerMiddle = { 0.5, 0.5, 0.5, 0.5 }, m_RightTriggerMiddle = { 0.5, 0.5, 0.5, 0.5 };
|
2014-04-27 21:32:09 +02:00
|
|
|
|
public String[] profilePath = { String.Empty, String.Empty, String.Empty, String.Empty };
|
2014-04-29 10:01:13 +02:00
|
|
|
|
public Byte[] m_Rumble = { 100, 100, 100, 100 };
|
|
|
|
|
public Boolean[] rumbleSwap = { false, false, false, false };
|
|
|
|
|
public Byte[] touchSensitivity = { 100, 100, 100, 100 };
|
|
|
|
|
public Byte[] tapSensitivity = {0, 0, 0, 0};
|
|
|
|
|
public bool[] doubleTap = { false, false, false, false };
|
|
|
|
|
public int[] scrollSensitivity = { 0, 0, 0, 0 };
|
|
|
|
|
public Byte[][] m_LowLeds = new Byte[][]
|
|
|
|
|
{
|
|
|
|
|
new Byte[] {0,0,0},
|
|
|
|
|
new Byte[] {0,0,0},
|
|
|
|
|
new Byte[] {0,0,0},
|
|
|
|
|
new Byte[] {0,0,0}
|
|
|
|
|
};
|
|
|
|
|
public Byte[][] m_Leds = new Byte[][]
|
|
|
|
|
{
|
|
|
|
|
new Byte[] {0,0,255},
|
|
|
|
|
new Byte[] {255,0,0},
|
|
|
|
|
new Byte[] {0,255,0},
|
|
|
|
|
new Byte[] {255,0,255},
|
|
|
|
|
};
|
|
|
|
|
public bool[] flushHIDQueue = { true, true, true, true };
|
|
|
|
|
public int[] idleDisconnectTimeout = { 0, 0, 0, 0 };
|
2014-03-28 02:50:40 +01:00
|
|
|
|
|
|
|
|
|
public Boolean useExclusiveMode = false;
|
|
|
|
|
public Int32 formWidth = 782;
|
|
|
|
|
public Int32 formHeight = 550;
|
|
|
|
|
public Boolean startMinimized = false;
|
|
|
|
|
|
2014-04-29 11:19:00 +02:00
|
|
|
|
public Dictionary<DS4Controls, DS4KeyType>[] customMapKeyTypes = {null, null, null, null};
|
|
|
|
|
public Dictionary<DS4Controls, UInt16>[] customMapKeys = { null, null, null, null };
|
|
|
|
|
public Dictionary<DS4Controls, X360Controls>[] customMapButtons = { null, null, null, null };
|
2014-04-27 21:32:09 +02:00
|
|
|
|
public BackingStore()
|
|
|
|
|
{
|
2014-04-29 11:19:00 +02:00
|
|
|
|
for (int i = 0; i < 4; i++)
|
2014-04-27 21:32:09 +02:00
|
|
|
|
{
|
|
|
|
|
{
|
2014-04-29 11:19:00 +02:00
|
|
|
|
customMapKeyTypes[i] = new Dictionary<DS4Controls, DS4KeyType>();
|
|
|
|
|
customMapKeys[i] = new Dictionary<DS4Controls, UInt16>();
|
|
|
|
|
customMapButtons[i] = new Dictionary<DS4Controls, X360Controls>();
|
2014-04-27 21:32:09 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public X360Controls GetCustomButton(int device, DS4Controls controlName)
|
2014-03-28 02:50:40 +01:00
|
|
|
|
{
|
2014-04-29 11:19:00 +02:00
|
|
|
|
if (customMapButtons[device].ContainsKey(controlName))
|
|
|
|
|
return customMapButtons[device][controlName];
|
2014-04-27 21:32:09 +02:00
|
|
|
|
else return X360Controls.None;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
2014-04-27 21:32:09 +02:00
|
|
|
|
public UInt16 GetCustomKey(int device, DS4Controls controlName)
|
2014-03-28 02:50:40 +01:00
|
|
|
|
{
|
2014-04-29 11:19:00 +02:00
|
|
|
|
if (customMapKeys[device].ContainsKey(controlName))
|
|
|
|
|
return customMapKeys[device][controlName];
|
2014-03-28 02:50:40 +01:00
|
|
|
|
else return 0;
|
|
|
|
|
}
|
2014-04-27 21:32:09 +02:00
|
|
|
|
public DS4KeyType GetCustomKeyType(int device, DS4Controls controlName)
|
2014-03-28 02:50:40 +01:00
|
|
|
|
{
|
2014-04-29 11:19:00 +02:00
|
|
|
|
if (customMapKeyTypes[device].ContainsKey(controlName))
|
|
|
|
|
return customMapKeyTypes[device][controlName];
|
2014-03-28 02:50:40 +01:00
|
|
|
|
else return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-29 10:22:37 +02:00
|
|
|
|
|
|
|
|
|
public Boolean SaveProfile(int device, String propath, System.Windows.Forms.Control[] buttons)
|
2014-03-28 02:50:40 +01:00
|
|
|
|
{
|
|
|
|
|
Boolean Saved = true;
|
2014-04-27 21:32:09 +02:00
|
|
|
|
//String folderName = Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName;
|
|
|
|
|
//String pathString = System.IO.Path.Combine(folderName, "Profiles");
|
|
|
|
|
//System.IO.Directory.CreateDirectory(pathString);
|
|
|
|
|
String path = Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName + @"\Profiles\" + propath + ".xml";
|
2014-03-28 02:50:40 +01:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
XmlNode Node;
|
2014-04-27 21:32:09 +02:00
|
|
|
|
|
2014-03-28 02:50:40 +01:00
|
|
|
|
m_Xdoc.RemoveAll();
|
2014-04-27 21:32:09 +02:00
|
|
|
|
|
2014-03-28 02:50:40 +01:00
|
|
|
|
Node = m_Xdoc.CreateXmlDeclaration("1.0", "utf-8", String.Empty);
|
|
|
|
|
m_Xdoc.AppendChild(Node);
|
2014-04-27 21:32:09 +02:00
|
|
|
|
|
|
|
|
|
Node = m_Xdoc.CreateComment(String.Format(" ScpControl Configuration Data. {0} ", DateTime.Now));
|
2014-03-28 02:50:40 +01:00
|
|
|
|
m_Xdoc.AppendChild(Node);
|
2014-04-27 21:32:09 +02:00
|
|
|
|
|
2014-03-28 02:50:40 +01:00
|
|
|
|
Node = m_Xdoc.CreateWhitespace("\r\n");
|
|
|
|
|
m_Xdoc.AppendChild(Node);
|
2014-04-27 21:32:09 +02:00
|
|
|
|
|
|
|
|
|
Node = m_Xdoc.CreateNode(XmlNodeType.Element, "ScpControl", null);
|
|
|
|
|
|
2014-04-29 10:22:37 +02:00
|
|
|
|
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 xmlRed = m_Xdoc.CreateNode(XmlNodeType.Element, "Red", null); xmlRed.InnerText = m_Leds[device][0].ToString(); Node.AppendChild(xmlRed);
|
|
|
|
|
XmlNode xmlGreen = m_Xdoc.CreateNode(XmlNodeType.Element, "Green", null); xmlGreen.InnerText = m_Leds[device][1].ToString(); Node.AppendChild(xmlGreen);
|
|
|
|
|
XmlNode xmlBlue = m_Xdoc.CreateNode(XmlNodeType.Element, "Blue", null); xmlBlue.InnerText = m_Leds[device][2].ToString(); Node.AppendChild(xmlBlue);
|
|
|
|
|
XmlNode xmlRumbleBoost = m_Xdoc.CreateNode(XmlNodeType.Element, "RumbleBoost", null); xmlRumbleBoost.InnerText = m_Rumble[device].ToString(); Node.AppendChild(xmlRumbleBoost);
|
|
|
|
|
XmlNode xmlRumbleSwap = m_Xdoc.CreateNode(XmlNodeType.Element, "rumbleSwap", null); xmlRumbleSwap.InnerText = rumbleSwap[device].ToString(); Node.AppendChild(xmlRumbleSwap);
|
|
|
|
|
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 xmlTouchSensitivity = m_Xdoc.CreateNode(XmlNodeType.Element, "touchSensitivity", null); xmlTouchSensitivity.InnerText = touchSensitivity[device].ToString(); Node.AppendChild(xmlTouchSensitivity);
|
|
|
|
|
XmlNode xmlLowRed = m_Xdoc.CreateNode(XmlNodeType.Element, "LowRed", null); xmlLowRed.InnerText = m_LowLeds[device][0].ToString(); Node.AppendChild(xmlLowRed);
|
|
|
|
|
XmlNode xmlLowGreen = m_Xdoc.CreateNode(XmlNodeType.Element, "LowGreen", null); xmlLowGreen.InnerText = m_LowLeds[device][1].ToString(); Node.AppendChild(xmlLowGreen);
|
|
|
|
|
XmlNode xmlLowBlue = m_Xdoc.CreateNode(XmlNodeType.Element, "LowBlue", null); xmlLowBlue.InnerText = m_LowLeds[device][2].ToString(); Node.AppendChild(xmlLowBlue);
|
|
|
|
|
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 = m_LeftTriggerMiddle[device].ToString(); Node.AppendChild(xmlLeftTriggerMiddle);
|
|
|
|
|
XmlNode xmlRightTriggerMiddle = m_Xdoc.CreateNode(XmlNodeType.Element, "RightTriggerMiddle", null); xmlRightTriggerMiddle.InnerText = m_RightTriggerMiddle[device].ToString(); Node.AppendChild(xmlRightTriggerMiddle);
|
2014-04-27 21:32:09 +02:00
|
|
|
|
|
|
|
|
|
XmlNode NodeControl = m_Xdoc.CreateNode(XmlNodeType.Element, "Control", null);
|
2014-03-28 02:50:40 +01:00
|
|
|
|
|
|
|
|
|
XmlNode Key = m_Xdoc.CreateNode(XmlNodeType.Element, "Key", null);
|
|
|
|
|
XmlNode KeyType = m_Xdoc.CreateNode(XmlNodeType.Element, "KeyType", null);
|
|
|
|
|
XmlNode Button = m_Xdoc.CreateNode(XmlNodeType.Element, "Button", null);
|
|
|
|
|
|
|
|
|
|
foreach (var button in buttons)
|
2014-04-27 21:32:09 +02:00
|
|
|
|
// try
|
2014-03-28 02:50:40 +01:00
|
|
|
|
{
|
|
|
|
|
// Save even if string (for xbox controller buttons)
|
|
|
|
|
if (button.Tag != null)
|
|
|
|
|
{
|
|
|
|
|
XmlNode buttonNode;
|
|
|
|
|
string keyType = String.Empty;
|
2014-04-27 21:32:09 +02:00
|
|
|
|
if (button.Tag is String && (String)button.Tag == "Unbound")
|
|
|
|
|
{
|
|
|
|
|
keyType += DS4KeyType.Unbound;
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
if (button.ForeColor == System.Drawing.Color.Red)
|
|
|
|
|
keyType += DS4KeyType.Repeat;
|
|
|
|
|
if (button.Font.Bold)
|
|
|
|
|
keyType += DS4KeyType.ScanCode;
|
|
|
|
|
}
|
2014-03-28 02:50:40 +01:00
|
|
|
|
if (keyType != String.Empty)
|
|
|
|
|
{
|
|
|
|
|
buttonNode = m_Xdoc.CreateNode(XmlNodeType.Element, button.Name, null);
|
|
|
|
|
buttonNode.InnerText = keyType;
|
|
|
|
|
KeyType.AppendChild(buttonNode);
|
|
|
|
|
}
|
|
|
|
|
buttonNode = m_Xdoc.CreateNode(XmlNodeType.Element, button.Name, null);
|
|
|
|
|
buttonNode.InnerText = button.Tag.ToString();
|
|
|
|
|
if (button.Tag is Int32 || button.Tag is UInt16)
|
|
|
|
|
Key.AppendChild(buttonNode);
|
|
|
|
|
else Button.AppendChild(buttonNode);
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-04-27 21:32:09 +02:00
|
|
|
|
//catch
|
|
|
|
|
// {
|
|
|
|
|
// NodeControl.InnerText = "";
|
|
|
|
|
//}
|
|
|
|
|
Node.AppendChild(NodeControl);
|
2014-03-28 02:50:40 +01:00
|
|
|
|
if (Button.HasChildNodes)
|
2014-04-27 21:32:09 +02:00
|
|
|
|
NodeControl.AppendChild(Button);
|
2014-03-28 02:50:40 +01:00
|
|
|
|
if (Key.HasChildNodes)
|
2014-04-27 21:32:09 +02:00
|
|
|
|
NodeControl.AppendChild(Key);
|
2014-03-28 02:50:40 +01:00
|
|
|
|
if (KeyType.HasChildNodes)
|
2014-04-27 21:32:09 +02:00
|
|
|
|
NodeControl.AppendChild(KeyType);
|
|
|
|
|
m_Xdoc.AppendChild(Node);
|
|
|
|
|
if (NodeControl.HasChildNodes)
|
|
|
|
|
Node.AppendChild(NodeControl);
|
|
|
|
|
m_Xdoc.Save(path);
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { Saved = false; }
|
|
|
|
|
|
2014-03-28 02:50:40 +01:00
|
|
|
|
return Saved;
|
|
|
|
|
}
|
|
|
|
|
private DS4Controls getDS4ControlsByName(string key)
|
|
|
|
|
{
|
|
|
|
|
switch (key)
|
|
|
|
|
{
|
|
|
|
|
case "bnShare": return DS4Controls.Share;
|
|
|
|
|
case "bnL3": return DS4Controls.L3;
|
|
|
|
|
case "bnR3": return DS4Controls.R3;
|
|
|
|
|
case "bnOptions": return DS4Controls.Options;
|
|
|
|
|
case "bnUp": return DS4Controls.DpadUp;
|
|
|
|
|
case "bnRight": return DS4Controls.DpadRight;
|
|
|
|
|
case "bnDown": return DS4Controls.DpadDown;
|
|
|
|
|
case "bnLeft": return DS4Controls.DpadLeft;
|
|
|
|
|
|
|
|
|
|
case "bnL1": return DS4Controls.L1;
|
|
|
|
|
case "bnR1": return DS4Controls.R1;
|
|
|
|
|
case "bnTriangle": return DS4Controls.Triangle;
|
|
|
|
|
case "bnCircle": return DS4Controls.Circle;
|
|
|
|
|
case "bnCross": return DS4Controls.Cross;
|
|
|
|
|
case "bnSquare": return DS4Controls.Square;
|
|
|
|
|
|
|
|
|
|
case "bnPS": return DS4Controls.PS;
|
2014-04-27 21:32:09 +02:00
|
|
|
|
case "bnLSLeft": return DS4Controls.LXNeg;
|
|
|
|
|
case "bnLSUp": return DS4Controls.LYNeg;
|
|
|
|
|
case "bnRSLeft": return DS4Controls.RXNeg;
|
|
|
|
|
case "bnRSUp": return DS4Controls.RYNeg;
|
|
|
|
|
|
|
|
|
|
case "bnLSRight": return DS4Controls.LXPos;
|
|
|
|
|
case "bnLSDown": return DS4Controls.LYPos;
|
|
|
|
|
case "bnRSRight": return DS4Controls.RXPos;
|
|
|
|
|
case "bnRSDown": return DS4Controls.RYPos;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
case "bnL2": return DS4Controls.L2;
|
|
|
|
|
case "bnR2": return DS4Controls.R2;
|
|
|
|
|
|
2014-04-27 21:32:09 +02:00
|
|
|
|
case "bnTouchLeft": return DS4Controls.TouchLeft;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
case "bnTouchMulti": return DS4Controls.TouchMulti;
|
|
|
|
|
case "bnTouchUpper": return DS4Controls.TouchUpper;
|
2014-04-27 21:32:09 +02:00
|
|
|
|
case "bnTouchRight": return DS4Controls.TouchRight;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
private X360Controls getX360ControlsByName(string key)
|
|
|
|
|
{
|
|
|
|
|
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;
|
2014-04-27 21:32:09 +02:00
|
|
|
|
|
|
|
|
|
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 "Unbound": return X360Controls.Unbound;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return X360Controls.Unbound;
|
|
|
|
|
}
|
2014-04-27 21:32:09 +02:00
|
|
|
|
public Boolean LoadProfile(int device, System.Windows.Forms.Control[] buttons)
|
2014-03-28 02:50:40 +01:00
|
|
|
|
{
|
|
|
|
|
Boolean Loaded = true;
|
2014-04-27 21:32:09 +02:00
|
|
|
|
Dictionary<DS4Controls, DS4KeyType> customMapKeyTypes = new Dictionary<DS4Controls, DS4KeyType>();
|
|
|
|
|
Dictionary<DS4Controls, UInt16> customMapKeys = new Dictionary<DS4Controls, UInt16>();
|
|
|
|
|
Dictionary<DS4Controls, X360Controls> customMapButtons = new Dictionary<DS4Controls, X360Controls>();
|
2014-03-28 02:50:40 +01:00
|
|
|
|
Boolean missingSetting = false;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2014-04-27 21:32:09 +02:00
|
|
|
|
if (File.Exists(profilePath[device]))
|
2014-03-28 02:50:40 +01:00
|
|
|
|
{
|
|
|
|
|
XmlNode Item;
|
|
|
|
|
|
2014-04-27 21:32:09 +02:00
|
|
|
|
m_Xdoc.Load(profilePath[device]);
|
|
|
|
|
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/flushHIDQueue"); Boolean.TryParse(Item.InnerText, out flushHIDQueue[device]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
2014-03-28 02:50:40 +01:00
|
|
|
|
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/idleDisconnectTimeout"); Int32.TryParse(Item.InnerText, out idleDisconnectTimeout[device]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
|
|
|
|
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/Red"); Byte.TryParse(Item.InnerText, out m_Leds[device][0]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
|
|
|
|
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/Green"); Byte.TryParse(Item.InnerText, out m_Leds[device][1]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
|
|
|
|
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/Blue"); Byte.TryParse(Item.InnerText, out m_Leds[device][2]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
|
|
|
|
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/RumbleBoost"); Byte.TryParse(Item.InnerText, out m_Rumble[device]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
|
|
|
|
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/rumbleSwap"); Boolean.TryParse(Item.InnerText, out rumbleSwap[device]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
|
|
|
|
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/ledAsBatteryIndicator"); Boolean.TryParse(Item.InnerText, out ledAsBattery[device]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
|
|
|
|
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/lowBatteryFlash"); Boolean.TryParse(Item.InnerText, out flashLedLowBattery[device]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
|
|
|
|
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/touchSensitivity"); Byte.TryParse(Item.InnerText, out touchSensitivity[device]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
|
|
|
|
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/LowRed"); Byte.TryParse(Item.InnerText, out m_LowLeds[device][0]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/LowGreen"); Byte.TryParse(Item.InnerText, out m_LowLeds[device][1]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/LowBlue"); Byte.TryParse(Item.InnerText, out m_LowLeds[device][2]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/touchpadJitterCompensation"); Boolean.TryParse(Item.InnerText, out touchpadJitterCompensation[device]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/lowerRCOn"); Boolean.TryParse(Item.InnerText, out lowerRCOn[device]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/tapSensitivity"); Byte.TryParse(Item.InnerText, out tapSensitivity[device]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/doubleTap"); Boolean.TryParse(Item.InnerText, out doubleTap[device]); }
|
2014-04-29 03:14:01 +02:00
|
|
|
|
catch { missingSetting = true; }
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/scrollSensitivity"); Int32.TryParse(Item.InnerText, out scrollSensitivity[device]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/LeftTriggerMiddle"); Double.TryParse(Item.InnerText, out m_LeftTriggerMiddle[device]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/RightTriggerMiddle"); Double.TryParse(Item.InnerText, out m_RightTriggerMiddle[device]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
|
|
|
|
|
|
|
|
|
DS4KeyType keyType;
|
|
|
|
|
UInt16 wvk;
|
|
|
|
|
foreach (var button in buttons)
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//bool foundBinding = false;
|
|
|
|
|
Item = m_Xdoc.SelectSingleNode(String.Format("/ScpControl/Control/KeyType/{0}", button.Name));
|
|
|
|
|
if (Item != null)
|
|
|
|
|
{
|
|
|
|
|
//foundBinding = true;
|
|
|
|
|
keyType = DS4KeyType.None;
|
|
|
|
|
if (Item.InnerText.Contains(DS4KeyType.Unbound.ToString()))
|
|
|
|
|
{
|
|
|
|
|
keyType = DS4KeyType.Unbound;
|
|
|
|
|
button.Tag = "Unbound";
|
|
|
|
|
button.Text = "Unbound";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (Item.InnerText.Contains(DS4KeyType.ScanCode.ToString()))
|
|
|
|
|
{
|
|
|
|
|
keyType |= DS4KeyType.ScanCode;
|
|
|
|
|
button.Font = new System.Drawing.Font(button.Font, System.Drawing.FontStyle.Bold);
|
|
|
|
|
}
|
|
|
|
|
if (Item.InnerText.Contains(DS4KeyType.Repeat.ToString()))
|
|
|
|
|
{
|
|
|
|
|
keyType |= DS4KeyType.Repeat;
|
|
|
|
|
button.ForeColor = System.Drawing.Color.Red;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (keyType != DS4KeyType.None)
|
|
|
|
|
customMapKeyTypes.Add(getDS4ControlsByName(Item.Name), keyType);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Item = m_Xdoc.SelectSingleNode(String.Format("/ScpControl/Control/Key/{0}", button.Name));
|
|
|
|
|
if (Item != null)
|
|
|
|
|
{
|
|
|
|
|
if (UInt16.TryParse(Item.InnerText, out wvk))
|
|
|
|
|
{
|
|
|
|
|
//foundBinding = true;
|
|
|
|
|
customMapKeys.Add(getDS4ControlsByName(Item.Name), wvk);
|
|
|
|
|
button.Tag = wvk;
|
|
|
|
|
button.Text = ((System.Windows.Forms.Keys)wvk).ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Item = m_Xdoc.SelectSingleNode(String.Format("/ScpControl/Control/Button/{0}", button.Name));
|
|
|
|
|
if (Item != null)
|
|
|
|
|
{
|
|
|
|
|
//foundBinding = true;
|
|
|
|
|
button.Tag = Item.InnerText;
|
|
|
|
|
button.Text = Item.InnerText;
|
|
|
|
|
customMapButtons.Add(getDS4ControlsByName(button.Name), getX360ControlsByName(Item.InnerText));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch { Loaded = false; }
|
|
|
|
|
|
|
|
|
|
if (Loaded)
|
|
|
|
|
{
|
2014-04-29 11:19:00 +02:00
|
|
|
|
this.customMapButtons[device] = customMapButtons;
|
|
|
|
|
this.customMapKeys[device] = customMapKeys;
|
|
|
|
|
this.customMapKeyTypes[device] = customMapKeyTypes;
|
2014-04-27 21:32:09 +02:00
|
|
|
|
}
|
|
|
|
|
// Only add missing settings if the actual load was graceful
|
|
|
|
|
if (missingSetting && Loaded)
|
2014-04-29 10:22:37 +02:00
|
|
|
|
SaveProfile(device, profilePath[device], buttons);
|
2014-04-27 21:32:09 +02:00
|
|
|
|
|
|
|
|
|
return Loaded;
|
|
|
|
|
}
|
|
|
|
|
public Boolean LoadProfile(int device)
|
|
|
|
|
{
|
|
|
|
|
Boolean Loaded = true;
|
|
|
|
|
Dictionary<DS4Controls, DS4KeyType> customMapKeyTypes = new Dictionary<DS4Controls, DS4KeyType>();
|
|
|
|
|
Dictionary<DS4Controls, UInt16> customMapKeys = new Dictionary<DS4Controls, UInt16>();
|
|
|
|
|
Dictionary<DS4Controls, X360Controls> customMapButtons = new Dictionary<DS4Controls, X360Controls>();
|
|
|
|
|
Boolean missingSetting = false;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (File.Exists(profilePath[device]))
|
|
|
|
|
{
|
|
|
|
|
XmlNode Item;
|
|
|
|
|
|
|
|
|
|
m_Xdoc.Load(profilePath[device]);
|
|
|
|
|
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/flushHIDQueue"); Boolean.TryParse(Item.InnerText, out flushHIDQueue[device]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
|
|
|
|
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/idleDisconnectTimeout"); Int32.TryParse(Item.InnerText, out idleDisconnectTimeout[device]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
|
|
|
|
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/Red"); Byte.TryParse(Item.InnerText, out m_Leds[device][0]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
|
|
|
|
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/Green"); Byte.TryParse(Item.InnerText, out m_Leds[device][1]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
|
|
|
|
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/Blue"); Byte.TryParse(Item.InnerText, out m_Leds[device][2]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
|
|
|
|
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/RumbleBoost"); Byte.TryParse(Item.InnerText, out m_Rumble[device]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
|
|
|
|
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/rumbleSwap"); Boolean.TryParse(Item.InnerText, out rumbleSwap[device]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
|
|
|
|
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/ledAsBatteryIndicator"); Boolean.TryParse(Item.InnerText, out ledAsBattery[device]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
|
|
|
|
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/lowBatteryFlash"); Boolean.TryParse(Item.InnerText, out flashLedLowBattery[device]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
|
|
|
|
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/touchSensitivity"); Byte.TryParse(Item.InnerText, out touchSensitivity[device]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
|
|
|
|
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/LowRed"); Byte.TryParse(Item.InnerText, out m_LowLeds[device][0]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/LowGreen"); Byte.TryParse(Item.InnerText, out m_LowLeds[device][1]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/LowBlue"); Byte.TryParse(Item.InnerText, out m_LowLeds[device][2]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/touchpadJitterCompensation"); Boolean.TryParse(Item.InnerText, out touchpadJitterCompensation[device]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/lowerRCOn"); Boolean.TryParse(Item.InnerText, out lowerRCOn[device]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/tapSensitivity"); Byte.TryParse(Item.InnerText, out tapSensitivity[device]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/doubleTap"); Boolean.TryParse(Item.InnerText, out doubleTap[device]); }
|
2014-04-29 03:14:01 +02:00
|
|
|
|
catch { missingSetting = true; }
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/scrollSensitivity"); Int32.TryParse(Item.InnerText, out scrollSensitivity[device]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/LeftTriggerMiddle"); Double.TryParse(Item.InnerText, out m_LeftTriggerMiddle[device]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
2014-04-29 10:01:13 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/RightTriggerMiddle"); Double.TryParse(Item.InnerText, out m_RightTriggerMiddle[device]); }
|
2014-04-27 21:32:09 +02:00
|
|
|
|
catch { missingSetting = true; }
|
2014-03-28 02:50:40 +01:00
|
|
|
|
|
2014-04-27 21:32:09 +02:00
|
|
|
|
DS4KeyType keyType;
|
|
|
|
|
UInt16 wvk;
|
|
|
|
|
XmlNode ParentItem = m_Xdoc.SelectSingleNode("/ScpControl/Control/Button");
|
|
|
|
|
if (ParentItem != null)
|
|
|
|
|
foreach (XmlNode item in ParentItem.ChildNodes)
|
|
|
|
|
customMapButtons.Add(getDS4ControlsByName(item.Name), getX360ControlsByName(item.InnerText));
|
|
|
|
|
ParentItem = m_Xdoc.SelectSingleNode("/ScpControl/Control/Key");
|
|
|
|
|
if (ParentItem != null)
|
|
|
|
|
foreach (XmlNode item in ParentItem.ChildNodes)
|
|
|
|
|
if (UInt16.TryParse(item.InnerText, out wvk))
|
|
|
|
|
customMapKeys.Add(getDS4ControlsByName(item.Name), wvk);
|
|
|
|
|
ParentItem = m_Xdoc.SelectSingleNode("/ScpControl/Control/KeyType");
|
|
|
|
|
if (ParentItem != null)
|
|
|
|
|
foreach (XmlNode item in ParentItem.ChildNodes)
|
|
|
|
|
if (item != null)
|
|
|
|
|
{
|
|
|
|
|
keyType = DS4KeyType.None;
|
|
|
|
|
if (item.InnerText.Contains(DS4KeyType.ScanCode.ToString()))
|
|
|
|
|
keyType |= DS4KeyType.ScanCode;
|
|
|
|
|
if (item.InnerText.Contains(DS4KeyType.Repeat.ToString()))
|
|
|
|
|
keyType |= DS4KeyType.Repeat;
|
|
|
|
|
if (item.InnerText.Contains(DS4KeyType.Unbound.ToString()))
|
|
|
|
|
keyType |= DS4KeyType.Unbound;
|
|
|
|
|
if (keyType != DS4KeyType.None)
|
|
|
|
|
customMapKeyTypes.Add(getDS4ControlsByName(item.Name), keyType);
|
|
|
|
|
}
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch { Loaded = false; }
|
|
|
|
|
|
2014-04-27 21:32:09 +02:00
|
|
|
|
if (Loaded)
|
|
|
|
|
{
|
2014-04-29 11:19:00 +02:00
|
|
|
|
this.customMapButtons[device] = customMapButtons;
|
|
|
|
|
this.customMapKeys[device] = customMapKeys;
|
|
|
|
|
this.customMapKeyTypes[device] = customMapKeyTypes;
|
2014-04-27 21:32:09 +02:00
|
|
|
|
}
|
2014-03-28 02:50:40 +01:00
|
|
|
|
// Only add missing settings if the actual load was graceful
|
|
|
|
|
if (missingSetting && Loaded)
|
2014-04-29 10:22:37 +02:00
|
|
|
|
SaveProfile(device, profilePath[device], null);
|
2014-04-27 21:32:09 +02:00
|
|
|
|
|
|
|
|
|
return Loaded;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Load()
|
|
|
|
|
{
|
|
|
|
|
Boolean Loaded = true;
|
2014-04-29 11:19:00 +02:00
|
|
|
|
/*Boolean missingSetting = false;
|
2014-04-27 21:32:09 +02:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (File.Exists(m_Profile))
|
|
|
|
|
{
|
|
|
|
|
XmlNode Item;
|
|
|
|
|
|
|
|
|
|
m_Xdoc.Load(m_Profile);
|
|
|
|
|
|
2014-03-28 02:50:40 +01:00
|
|
|
|
|
2014-04-27 21:32:09 +02:00
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/Profile/useExclusiveMode"); Boolean.TryParse(Item.InnerText, out useExclusiveMode); }
|
|
|
|
|
catch { missingSetting = true; }
|
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/Profile/startMinimized"); Boolean.TryParse(Item.InnerText, out startMinimized); }
|
|
|
|
|
catch { missingSetting = true; }
|
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/Profile/formWidth"); Int32.TryParse(Item.InnerText, out formWidth); }
|
|
|
|
|
catch { missingSetting = true; }
|
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/Profile/formHeight"); Int32.TryParse(Item.InnerText, out formHeight); }
|
|
|
|
|
catch { missingSetting = true; }
|
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/Profile/Controller1"); profilePath[0] = Item.InnerText; }
|
|
|
|
|
catch { missingSetting = true; }
|
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/Profile/Controller2"); profilePath[1] = Item.InnerText; }
|
|
|
|
|
catch { missingSetting = true; }
|
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/Profile/Controller3"); profilePath[2] = Item.InnerText; }
|
|
|
|
|
catch { missingSetting = true; }
|
|
|
|
|
try { Item = m_Xdoc.SelectSingleNode("/Profile/Controller4"); profilePath[3] = Item.InnerText; }
|
|
|
|
|
catch { missingSetting = true; }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch { }
|
|
|
|
|
if (missingSetting)
|
2014-04-29 11:19:00 +02:00
|
|
|
|
Save(); */
|
|
|
|
|
return Loaded;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
2014-04-27 21:32:09 +02:00
|
|
|
|
public bool Save()
|
2014-03-28 02:50:40 +01:00
|
|
|
|
{
|
|
|
|
|
Boolean Saved = true;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2014-04-27 21:32:09 +02:00
|
|
|
|
XmlNode Node;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
|
|
|
|
|
m_Xdoc.RemoveAll();
|
|
|
|
|
|
|
|
|
|
Node = m_Xdoc.CreateXmlDeclaration("1.0", "utf-8", String.Empty);
|
|
|
|
|
m_Xdoc.AppendChild(Node);
|
|
|
|
|
|
2014-04-27 21:32:09 +02:00
|
|
|
|
Node = m_Xdoc.CreateComment(String.Format(" Profile Configuration Data. {0} ", DateTime.Now));
|
2014-03-28 02:50:40 +01:00
|
|
|
|
m_Xdoc.AppendChild(Node);
|
|
|
|
|
|
|
|
|
|
Node = m_Xdoc.CreateWhitespace("\r\n");
|
|
|
|
|
m_Xdoc.AppendChild(Node);
|
|
|
|
|
|
2014-04-27 21:32:09 +02:00
|
|
|
|
Node = m_Xdoc.CreateNode(XmlNodeType.Element, "Profile", null);
|
|
|
|
|
|
2014-03-28 02:50:40 +01:00
|
|
|
|
|
|
|
|
|
XmlNode xmlUseExclNode = m_Xdoc.CreateNode(XmlNodeType.Element, "useExclusiveMode", null); xmlUseExclNode.InnerText = useExclusiveMode.ToString(); Node.AppendChild(xmlUseExclNode);
|
|
|
|
|
XmlNode xmlStartMinimized = m_Xdoc.CreateNode(XmlNodeType.Element, "startMinimized", null); xmlStartMinimized.InnerText = startMinimized.ToString(); Node.AppendChild(xmlStartMinimized);
|
|
|
|
|
XmlNode xmlFormWidth = m_Xdoc.CreateNode(XmlNodeType.Element, "formWidth", null); xmlFormWidth.InnerText = formWidth.ToString(); Node.AppendChild(xmlFormWidth);
|
|
|
|
|
XmlNode xmlFormHeight = m_Xdoc.CreateNode(XmlNodeType.Element, "formHeight", null); xmlFormHeight.InnerText = formHeight.ToString(); Node.AppendChild(xmlFormHeight);
|
2014-04-27 21:32:09 +02:00
|
|
|
|
|
|
|
|
|
XmlNode xmlController1 = m_Xdoc.CreateNode(XmlNodeType.Element, "Controller1", null); xmlController1.InnerText = profilePath[0]; Node.AppendChild(xmlController1);
|
|
|
|
|
XmlNode xmlController2 = m_Xdoc.CreateNode(XmlNodeType.Element, "Controller2", null); xmlController2.InnerText = profilePath[1]; Node.AppendChild(xmlController2);
|
|
|
|
|
XmlNode xmlController3 = m_Xdoc.CreateNode(XmlNodeType.Element, "Controller3", null); xmlController3.InnerText = profilePath[2]; Node.AppendChild(xmlController3);
|
|
|
|
|
XmlNode xmlController4 = m_Xdoc.CreateNode(XmlNodeType.Element, "Controller4", null); xmlController4.InnerText = profilePath[3]; Node.AppendChild(xmlController4);
|
2014-03-28 02:50:40 +01:00
|
|
|
|
|
|
|
|
|
m_Xdoc.AppendChild(Node);
|
|
|
|
|
|
2014-04-27 21:32:09 +02:00
|
|
|
|
m_Xdoc.Save(m_Profile);
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
|
|
|
|
catch { Saved = false; }
|
|
|
|
|
|
|
|
|
|
return Saved;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|