Skip to content

Commit

Permalink
Option to only use Dinput, turn off X360 input and only use the DS4's…
Browse files Browse the repository at this point in the history
… native input: useful for games that can use the ds4 as is without 360 input needed, but still want to use the lightbar and touchpad.

Added custom color when flashing, just click on the "Flash at" text
lightbar turns off fully when going into sleep mode
PS+touchpad also disables scrolling now
Update to french translations
Fixes to text
  • Loading branch information
Jays2Kings committed Aug 23, 2014
1 parent af09299 commit f82a85c
Show file tree
Hide file tree
Showing 17 changed files with 13,219 additions and 5,250 deletions.
12 changes: 9 additions & 3 deletions DS4Control/Control.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace DS4Control
{
public class Control
{
X360Device x360Bus;
public X360Device x360Bus;
public DS4Device[] DS4Controllers = new DS4Device[4];
//TPadModeSwitcher[] modeSwitcher = new TPadModeSwitcher[4];
Mouse[] touchPad = new Mouse[4];
Expand Down Expand Up @@ -80,7 +80,8 @@ public bool Start(bool showlog = true)
touchPad[ind] = new Mouse(ind, device);
DS4Color color = Global.loadColor(ind);
device.LightBarColor = color;
x360Bus.Plugin(ind);
if (!Global.getDinputOnly(ind))
x360Bus.Plugin(ind);
device.Report += this.On_Report;
TouchPadOn(ind, device);
LaunchProgram(ind);
Expand Down Expand Up @@ -183,7 +184,8 @@ public bool HotPlug()
touchPad[Index] = new Mouse(Index, device);
device.LightBarColor = Global.loadColor(Index);
device.Report += this.On_Report;
x360Bus.Plugin(Index);
if (!Global.getDinputOnly(Index))
x360Bus.Plugin(Index);
TouchPadOn(Index, device);
LaunchProgram(Index);
string filename = Path.GetFileName(Global.getAProfile(Index));
Expand Down Expand Up @@ -485,6 +487,7 @@ public string GetInputkeys(int ind)

bool[] touchreleased = { true, true, true, true }, touchslid = { false, false, false, false };
byte[] oldtouchvalue = { 0, 0, 0, 0 };
int[] oldscrollvalue = { 0, 0, 0, 0 };
protected virtual void CheckForHotkeys(int deviceID, DS4State cState, DS4State pState)
{
DS4Device d = DS4Controllers[deviceID];
Expand All @@ -508,14 +511,17 @@ protected virtual void CheckForHotkeys(int deviceID, DS4State cState, DS4State p
if (Global.getTouchSensitivity(deviceID) > 0 && touchreleased[deviceID])
{
oldtouchvalue[deviceID] = Global.getTouchSensitivity(deviceID);
oldscrollvalue[deviceID] = Global.getScrollSensitivity(deviceID);
Global.setTouchSensitivity(deviceID, 0);
Global.setScrollSensitivity(deviceID, 0);
LogDebug(Global.getTouchSensitivity(deviceID) > 0 ? Properties.Resources.TouchpadMovementOn : Properties.Resources.TouchpadMovementOff);
Log.LogToTray(Global.getTouchSensitivity(deviceID) > 0 ? Properties.Resources.TouchpadMovementOn : Properties.Resources.TouchpadMovementOff);
touchreleased[deviceID] = false;
}
else if (touchreleased[deviceID])
{
Global.setTouchSensitivity(deviceID, oldtouchvalue[deviceID]);
Global.setScrollSensitivity(deviceID, oldscrollvalue[deviceID]);
LogDebug(Global.getTouchSensitivity(deviceID) > 0 ? Properties.Resources.TouchpadMovementOn : Properties.Resources.TouchpadMovementOff);
Log.LogToTray(Global.getTouchSensitivity(deviceID) > 0 ? Properties.Resources.TouchpadMovementOn : Properties.Resources.TouchpadMovementOff);
touchreleased[deviceID] = false;
Expand Down
17 changes: 13 additions & 4 deletions DS4Control/DS4LightBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ public static void updateLightBar(DS4Device device, int deviceNum, DS4State cSta
color = Global.loadColor(deviceNum);
}


if (device.Battery <= Global.getFlashAt(deviceNum) && !defualtLight && !device.Charging)
{
if (!(Global.loadFlashColor(deviceNum).red == 0 &&
Global.loadFlashColor(deviceNum).green == 0 &&
Global.loadFlashColor(deviceNum).blue == 0))
color = Global.loadFlashColor(deviceNum);
}

if (Global.getIdleDisconnectTimeout(deviceNum) > 0 && Global.getLedAsBatteryIndicator(deviceNum) && (!device.Charging || device.Battery >= 100))
{//Fade lightbar by idle time
TimeSpan timeratio = new TimeSpan(DateTime.UtcNow.Ticks - device.lastActive.Ticks);
Expand Down Expand Up @@ -131,13 +140,14 @@ public static void updateLightBar(DS4Device device, int deviceNum, DS4State cSta
if (device.Battery <= Global.getFlashAt(deviceNum) && !defualtLight && !device.Charging)
{
int level = device.Battery / 10;
if (level >= 10)
level = 0; // all values of ~0% or >~100% are rendered the same
//if (level >= 10)
//level = 0; // all values of ~0% or >~100% are rendered the same
haptics.LightBarFlashDurationOn = BatteryIndicatorDurations[level, 0];
haptics.LightBarFlashDurationOff = BatteryIndicatorDurations[level, 1];
}
else
{
//haptics.LightBarFlashDurationOff = haptics.LightBarFlashDurationOn = 1;
haptics.LightBarFlashDurationOff = haptics.LightBarFlashDurationOn = 0;
haptics.LightBarExplicitlyOff = true;
}
Expand All @@ -147,13 +157,12 @@ public static void updateLightBar(DS4Device device, int deviceNum, DS4State cSta
haptics.LightBarExplicitlyOff = true;
}
device.pushHapticState(haptics);

}
public static bool defualtLight = false, shuttingdown = false;

public static bool shiftMod(DS4Device device, int deviceNum, DS4State cState, DS4StateExposed eState)
{
bool shift;;
bool shift;
switch (Global.getShiftModifier(deviceNum))
{
case 1: shift = Mapping.getBoolMapping(DS4Controls.Cross, cState, eState); break;
Expand Down
53 changes: 51 additions & 2 deletions DS4Control/ScpUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,15 @@ public static int getChargingType(int device)
return m_Config.chargingType[device];

}


public static void setDinputOnly(int device, bool dinput)
{
m_Config.dinputOnly[device] = dinput;
}
public static bool getDinputOnly(int device)
{
return m_Config.dinputOnly[device];
}
public static void setUseExclusiveMode(bool exclusive)
{
m_Config.useExclusiveMode = exclusive;
Expand Down Expand Up @@ -340,6 +348,20 @@ public static bool getShiftColorOn(int device)
{
return m_Config.shiftColorOn[device];
}
public static void saveFlashColor(int device, byte red, byte green, byte blue)
{
m_Config.m_FlashLeds[device][0] = red;
m_Config.m_FlashLeds[device][1] = green;
m_Config.m_FlashLeds[device][2] = blue;
}
public static DS4Color loadFlashColor(int device)
{
DS4Color color = new DS4Color();
color.red = m_Config.m_FlashLeds[device][0];
color.green = m_Config.m_FlashLeds[device][1];
color.blue = m_Config.m_FlashLeds[device][2];
return color;
}
public static void setTapSensitivity(int device, byte sen)
{
m_Config.tapSensitivity[device] = sen;
Expand Down Expand Up @@ -723,11 +745,20 @@ public class BackingStore
new Byte[] {0,0,0},
new Byte[] {0,0,0}
};
public Byte[][] m_FlashLeds = new Byte[][]
{
new Byte[] {0,0,0},
new Byte[] {0,0,0},
new Byte[] {0,0,0},
new Byte[] {0,0,0},
new Byte[] {0,0,0}
};
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 Boolean useExclusiveMode = false;
public Int32 formWidth = 782;
Expand Down Expand Up @@ -864,6 +895,9 @@ public Boolean SaveProfile(int device, String propath, System.Windows.Forms.Cont
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);
Expand All @@ -880,7 +914,8 @@ public Boolean SaveProfile(int device, String propath, System.Windows.Forms.Cont
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 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 NodeControl = m_Xdoc.CreateNode(XmlNodeType.Element, "Control", null);

XmlNode Key = m_Xdoc.CreateNode(XmlNodeType.Element, "Key", null);
Expand Down Expand Up @@ -1269,6 +1304,18 @@ public Boolean LoadProfile(int device, System.Windows.Forms.Control[] buttons, S
catch { m_ShiftLeds[device] = m_Leds[device]; missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/ShiftColorOn"); Boolean.TryParse(Item.InnerText, out shiftColorOn[device]); }
catch { shiftColorOn[device] = false; missingSetting = true; }
try
{
Item = m_Xdoc.SelectSingleNode("/ScpControl/FlashColor");
string[] colors;
if (!string.IsNullOrEmpty(Item.InnerText))
colors = Item.InnerText.Split(',');
else
colors = new string[0];
for (int i = 0; i < colors.Length; i++)
m_FlashLeds[device][i] = byte.Parse(colors[i]);
}
catch { missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/touchpadJitterCompensation"); Boolean.TryParse(Item.InnerText, out touchpadJitterCompensation[device]); }
catch { missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/lowerRCOn"); Boolean.TryParse(Item.InnerText, out lowerRCOn[device]); }
Expand Down Expand Up @@ -1303,6 +1350,8 @@ public Boolean LoadProfile(int device, System.Windows.Forms.Control[] buttons, S
catch { shiftModifier[device] = 0; missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/LaunchProgram"); launchProgram[device] = Item.InnerText; }
catch { launchProgram[device] = string.Empty; missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/ScpControl/DinputOnly"); Boolean.TryParse(Item.InnerText, out dinputOnly[device]); }
catch { 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 @@ -167,6 +167,9 @@
<EmbeddedResource Include="Hotkeys.resx">
<DependentUpon>Hotkeys.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="KBM360.fr-FR.resx">
<DependentUpon>KBM360.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="KBM360.resx">
<DependentUpon>KBM360.cs</DependentUpon>
</EmbeddedResource>
Expand Down
Loading

0 comments on commit f82a85c

Please sign in to comment.