Skip to content

Commit

Permalink
Version 1.4.0.6
Browse files Browse the repository at this point in the history
Profile option to turn off touchpad at start
Better disabling and re-enabling of the vitrual x360 for dinput only
mode
Bottom text of DS4Windows now hosts the description of items in profile
options instead of a floating tool tip
If first startup of DS4Windows/no profiles are found, a default profile
is made
Extra tip in driver window
Update to french translations (however the translations require another
update now)
  • Loading branch information
Jays2Kings committed Sep 15, 2014
1 parent 60a054e commit c5f49cc
Show file tree
Hide file tree
Showing 20 changed files with 2,127 additions and 1,847 deletions.
23 changes: 11 additions & 12 deletions DS4Control/Control.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public bool Start(bool showlog = true)
x360Bus.Plugin(ind);
device.Report += this.On_Report;
TouchPadOn(ind, device);
LaunchProgram(ind);
string filename = Path.GetFileName(Global.getAProfile(ind));
ind++;
if (showlog)
Expand Down Expand Up @@ -187,7 +186,6 @@ public bool HotPlug()
if (!Global.getDinputOnly(Index))
x360Bus.Plugin(Index);
TouchPadOn(Index, device);
LaunchProgram(Index);
string filename = Path.GetFileName(Global.getAProfile(Index));
if (System.IO.File.Exists(Global.appdatapath + "\\Profiles\\" + filename))
{
Expand All @@ -208,13 +206,6 @@ public bool HotPlug()
return true;
}

public void LaunchProgram(int ind)
{
if (Global.getLaunchProgram(ind) != string.Empty)
{
System.Diagnostics.Process.Start(Global.getLaunchProgram(ind));
}
}
public void TouchPadOn(int ind, DS4Device device)
{
ITouchpadBehaviour tPad = touchPad[ind];
Expand Down Expand Up @@ -485,9 +476,9 @@ public string GetInputkeys(int ind)
return "nothing";
}

bool[] touchreleased = { true, true, true, true }, touchslid = { false, false, false, false };
byte[] oldtouchvalue = { 0, 0, 0, 0 };
int[] oldscrollvalue = { 0, 0, 0, 0 };
public bool[] touchreleased = { true, true, true, true }, touchslid = { false, false, false, false };
public byte[] oldtouchvalue = { 0, 0, 0, 0 };
public int[] oldscrollvalue = { 0, 0, 0, 0 };
protected virtual void CheckForHotkeys(int deviceID, DS4State cState, DS4State pState)
{
DS4Device d = DS4Controllers[deviceID];
Expand Down Expand Up @@ -531,6 +522,14 @@ protected virtual void CheckForHotkeys(int deviceID, DS4State cState, DS4State p
touchreleased[deviceID] = true;
}

public virtual void StartTPOff(int deviceID)
{
oldtouchvalue[deviceID] = Global.getTouchSensitivity(deviceID);
oldscrollvalue[deviceID] = Global.getScrollSensitivity(deviceID);
Global.setTouchSensitivity(deviceID, 0);
Global.setScrollSensitivity(deviceID, 0);
}

public virtual string TouchpadSlide(int ind)
{
DS4State cState = CurrentState[ind];
Expand Down
21 changes: 11 additions & 10 deletions DS4Control/DS4LightBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,15 @@ public static void updateLightBar(DS4Device device, int deviceNum, DS4State cSta
else
color = new DS4Color { red = 0, green = 0, blue = 0 };
}
Color dsc = Color.FromArgb(color.red, color.green, color.blue);
if (Global.getAProfile(deviceNum).ToLower().Contains("distance"))
bool distanceprofile = (Global.getAProfile(deviceNum).ToLower().Contains("distance") || Global.tempprofilename[deviceNum].ToLower().Contains("distance"));
if (distanceprofile && !defualtLight)
{ //Thing I did for Distance
float rumble = device.LeftHeavySlowRumble / 2.55f;
if (device.LeftHeavySlowRumble > 50)
color = getTransitionedColor(color, rumble);
byte max= Math.Max(color.red, Math.Max(color.green, color.blue));
if (device.LeftHeavySlowRumble > 100)
color = getTransitionedColor(new DS4Color { green = max, red = max }, rumble, new DS4Color { red = 255 });
else
color = getTransitionedColor(color, device.LeftHeavySlowRumble, getTransitionedColor(new DS4Color { green = max, red = max }, 39.6078f, new DS4Color { red = 255 }));
}
DS4HapticState haptics = new DS4HapticState
{
Expand All @@ -158,7 +161,7 @@ public static void updateLightBar(DS4Device device, int deviceNum, DS4State cSta
haptics.LightBarFlashDurationOn = BatteryIndicatorDurations[level, 0];
haptics.LightBarFlashDurationOff = BatteryIndicatorDurations[level, 1];
}
else if (Global.getAProfile(deviceNum).ToLower().Contains("distance") && device.LeftHeavySlowRumble > 155) //also part of Distance
else if (distanceprofile && device.LeftHeavySlowRumble > 155) //also part of Distance
{
haptics.LightBarFlashDurationOff = haptics.LightBarFlashDurationOn = (byte)((-device.LeftHeavySlowRumble + 265));
haptics.LightBarExplicitlyOff = true;
Expand Down Expand Up @@ -237,10 +240,8 @@ public static DS4Color HuetoRGB(float hue, byte sat)
return new DS4Color { red = 255, green = 0, blue = 0 };
}

public static DS4Color getTransitionedColor(DS4Color c1, double ratio)
{//;
//Color cs = Color.FromArgb(c1.red, c1.green, c1.blue);
DS4Color c2 = new DS4Color { red = 255, green = 0, blue = 0 };
public static DS4Color getTransitionedColor(DS4Color c1, double ratio, DS4Color c2)
{
c1.red = applyRatio(c1.red, c2.red, ratio);
c1.green = applyRatio(c1.green, c2.green, ratio);
c1.blue = applyRatio(c1.blue, c2.blue, ratio);
Expand All @@ -254,7 +255,7 @@ private static byte applyRatio(byte b1, byte b2, double r)
else if (r < 0)
r = 0;
uint ratio = (uint)r;
if (b1 > b2)
if (b1 > b2)// b2 == 255)
{
ratio = 100 - (uint)r;
}
Expand Down
62 changes: 47 additions & 15 deletions DS4Control/ScpUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public class Global
protected static Int32 m_IdleTimeout = 600000;
static string exepath = Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName;
public static string appdatapath;
public static string[] tempprofilename = new string[5] { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty };

public static void SaveWhere(string path)
{
Expand Down Expand Up @@ -239,6 +240,14 @@ public static bool getDinputOnly(int device)
{
return m_Config.dinputOnly[device];
}
public static void setStartTouchpadOff(int device, bool off)
{
m_Config.startTouchpadOff[device] = off;
}
public static bool getStartTouchpadOff(int device)
{
return m_Config.startTouchpadOff[device];
}
public static void setUseExclusiveMode(bool exclusive)
{
m_Config.useExclusiveMode = exclusive;
Expand Down Expand Up @@ -593,17 +602,21 @@ public static bool Load()
{
return m_Config.Load();
}
public static void LoadProfile(int device, System.Windows.Forms.Control[] buttons, System.Windows.Forms.Control[] shiftbuttons)
public static void LoadProfile(int device, System.Windows.Forms.Control[] buttons, System.Windows.Forms.Control[] shiftbuttons, bool launchprogram, Control control)
{
m_Config.LoadProfile(device, buttons, shiftbuttons);
m_Config.LoadProfile(device, buttons, shiftbuttons, launchprogram, control);
tempprofilename[device] = string.Empty;
}
public static void LoadProfile(int device)
public static void LoadProfile(int device, bool launchprogram, Control control)
{
m_Config.LoadProfile(device, null, null);
m_Config.LoadProfile(device, null, null, launchprogram, control);
tempprofilename[device] = string.Empty;

}
public static void LoadTempProfile(int device, string name)
public static void LoadTempProfile(int device, string name, bool launchprogram, Control control)
{
m_Config.LoadProfile(device, null, null, appdatapath + @"\Profiles\" + name + ".xml");
m_Config.LoadProfile(device, null, null, launchprogram, control, appdatapath + @"\Profiles\" + name + ".xml");
tempprofilename[device] = name;
}
public static bool Save()
{
Expand Down Expand Up @@ -695,8 +708,10 @@ public class BackingStore
protected XmlDocument m_Xdoc = new XmlDocument();
//fifth value used to for options, not fifth controller
public int[] buttonMouseSensitivity = { 25, 25, 25, 25, 25 };

public Boolean[] touchpadJitterCompensation = {true, true, true, true, true};

public bool[] flushHIDQueue = { true, true, true, true, true };
public int[] idleDisconnectTimeout = { 0, 0, 0, 0, 0 };
public Boolean[] touchpadJitterCompensation = { true, true, true, true, true };
public Boolean[] lowerRCOn = { false, false, false, false, false };
public Boolean[] ledAsBattery = { false, false, false, false, false };
public Boolean[] flashLedLowBattery = { false, false, false, false, false };
Expand All @@ -710,7 +725,7 @@ public class BackingStore
public bool[] doubleTap = { false, false, false, false, false };
public int[] scrollSensitivity = { 0, 0, 0, 0, 0 };
public double[] rainbow = { 0, 0, 0, 0, 0 };
public int[] flashAt = { 30, 30, 30, 30, 30 };
public int[] flashAt = { 0, 0, 0, 0, 0 };
public int[] shiftModifier = { 0, 0, 0, 0, 0 };
public bool[] mouseAccel = { true, true, true, true, true };
public Byte[][] m_LowLeds = new Byte[][]
Expand Down Expand Up @@ -755,11 +770,9 @@ public class BackingStore
};
public bool[] shiftColorOn = { false, false, false, false, false };
public int[] chargingType = { 0, 0, 0, 0, 0 };
public bool[] flushHIDQueue = { true, true, true, true, true };
public int[] idleDisconnectTimeout = { 0, 0, 0, 0, 0 };
public string[] launchProgram = { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty };
public bool[] dinputOnly = { false, false, false, false, false };

public bool[] startTouchpadOff = { false, false, false, false, false };
public Boolean useExclusiveMode = false;
public Int32 formWidth = 782;
public Int32 formHeight = 550;
Expand Down Expand Up @@ -916,6 +929,7 @@ public Boolean SaveProfile(int device, String propath, System.Windows.Forms.Cont
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 NodeControl = m_Xdoc.CreateNode(XmlNodeType.Element, "Control", null);

XmlNode Key = m_Xdoc.CreateNode(XmlNodeType.Element, "Key", null);
Expand Down Expand Up @@ -1179,7 +1193,7 @@ private X360Controls getX360ControlsByName(string key)
return X360Controls.Unbound;
}

public Boolean LoadProfile(int device, System.Windows.Forms.Control[] buttons, System.Windows.Forms.Control[] shiftbuttons, string propath = "")
public Boolean LoadProfile(int device, System.Windows.Forms.Control[] buttons, System.Windows.Forms.Control[] shiftbuttons, bool launchprogram, Control control, string propath = "")
{
Boolean Loaded = true;
Dictionary<DS4Controls, DS4KeyType> customMapKeyTypes = new Dictionary<DS4Controls, DS4KeyType>();
Expand Down Expand Up @@ -1348,10 +1362,28 @@ public Boolean LoadProfile(int device, System.Windows.Forms.Control[] buttons, S
catch { missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/ShiftModifier"); Int32.TryParse(Item.InnerText, out shiftModifier[device]); }
catch { shiftModifier[device] = 0; missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/LaunchProgram"); launchProgram[device] = Item.InnerText; }
try
{
Item = m_Xdoc.SelectSingleNode("/ScpControl/LaunchProgram");
launchProgram[device] = Item.InnerText;
if (launchprogram == true && launchProgram[device] != string.Empty) System.Diagnostics.Process.Start(launchProgram[device]);
}
catch { launchProgram[device] = string.Empty; missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/DinputOnly"); Boolean.TryParse(Item.InnerText, out dinputOnly[device]); }
try
{
Item = m_Xdoc.SelectSingleNode("/ScpControl/DinputOnly");
Boolean.TryParse(Item.InnerText, out dinputOnly[device]);
if (dinputOnly[device] == true) control.x360Bus.Unplug(device);
else control.x360Bus.Plugin(device);
}
catch { missingSetting = true; }
try
{
Item = m_Xdoc.SelectSingleNode("/ScpControl/StartTouchpadOff");
Boolean.TryParse(Item.InnerText, out startTouchpadOff[device]);
if (startTouchpadOff[device] == true) control.StartTPOff(device);
}
catch { startTouchpadOff[device] = false; missingSetting = true; }
DS4KeyType keyType;
UInt16 wvk;
if (buttons == null)
Expand Down
3 changes: 3 additions & 0 deletions DS4Tool/DS4Tool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@
<EmbeddedResource Include="Options.fr-FR.resx">
<DependentUpon>Options.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Options.fr.resx">
<DependentUpon>Options.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Options.resx">
<DependentUpon>Options.cs</DependentUpon>
</EmbeddedResource>
Expand Down
Loading

0 comments on commit c5f49cc

Please sign in to comment.