Skip to content

Commit

Permalink
Version 1.4.5
Browse files Browse the repository at this point in the history
Added support for the New DS4 USB Adapater (Thanks to boganhobo and
Chamilsaan)
Implemented teokp's amazing fix for hide ds4 not working on the
anniversary update of Windows 10: when a controller fails to enter
exclusive mode, DS4Windows will ask for admin privilages to fix the
issue.
Now (near)unlimited Special Actions can be made from the previous limit
of 50
Special Action Xbox Game DVR is now no longer limited to Windows 10,
renamed multi action button: Assign a macro to single tap, double tap,
and holding down a button
Added option for White DS4Windows Icon in the notification tray (While
not merged from, thanks to tehmantra)
Added option to temporarily turn off DS4Windows when using a certain
program (togglable in the Auto Profiles Tab) (Same case as above but
thanks to dedChar to bring to light)
Fixed Options crashes in certain locales where decimal points are
repesented with commas, such as German (Thanks to kiliansch)
Added/Updated translations for many languauges, now including Japanese,
Slovenian, Hungarian, Greek, Finnish, Czech, Indonesian, and Ukrainian
  • Loading branch information
Jays2Kings committed Sep 22, 2016
1 parent a06d776 commit 1bfc69e
Show file tree
Hide file tree
Showing 156 changed files with 35,421 additions and 7,981 deletions.
85 changes: 57 additions & 28 deletions DS4Windows/DS4Control/Mapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ public void SavePrevious(bool performClear)
}
}
}

public class ActionState
{
public bool[] dev = new bool[4];
}

public static SyntheticState globalState = new SyntheticState();
public static SyntheticState[] deviceState = { new SyntheticState(), new SyntheticState(), new SyntheticState(), new SyntheticState() };

Expand All @@ -65,7 +71,9 @@ public void SavePrevious(bool performClear)
public static int[] fadetimer = { 0, 0, 0, 0 };
public static int[] prevFadetimer = { 0, 0, 0, 0 };
public static DS4Color[] lastColor = new DS4Color[4];
public static bool[,] actionDone = new bool[4, 50];
public static List<ActionState> actionDone = new List<ActionState>();
//public static List<bool>[] actionDone = { new List<bool>(), new List<bool>(), new List<bool>(), new List<bool>() };
//public static bool[,] actionDone = new bool[4, 50];
public static SpecialAction[] untriggeraction = new SpecialAction[4];
public static DateTime[] nowAction = { DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue };
public static DateTime[] oldnowAction = { DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue };
Expand Down Expand Up @@ -1018,6 +1026,10 @@ public static async void MapCustomAction(int device, DS4State cState, DS4State M
//DS4KeyType keyType = getShiftCustomKeyType(device, customKey.Key);
SpecialAction action = GetAction(actionname);
int index = GetActionIndexOf(actionname);
if (actionDone.Count < index + 1)
actionDone.Add(new ActionState());
else if (actionDone.Count > GetActions().Count())
actionDone.RemoveAt(actionDone.Count - 1);
double time;
//If a key or button is assigned to the trigger, a key special action is used like
//a quick tap to use and hold to use the regular custom button/key
Expand Down Expand Up @@ -1113,9 +1125,9 @@ public static async void MapCustomAction(int device, DS4State cState, DS4State M

if (triggeractivated && action.type == "Program")
{
if (!actionDone[device, index])
if (!actionDone[index].dev[device])
{
actionDone[device, index] = true;
actionDone[index].dev[device] = true;
if (!string.IsNullOrEmpty(action.extra))
Process.Start(action.details, action.extra);
else
Expand All @@ -1124,9 +1136,9 @@ public static async void MapCustomAction(int device, DS4State cState, DS4State M
}
else if (triggeractivated && action.type == "Profile")
{
if (!actionDone[device, index] && string.IsNullOrEmpty(tempprofilename[device]))
if (!actionDone[index].dev[device] && string.IsNullOrEmpty(tempprofilename[device]))
{
actionDone[device, index] = true;
actionDone[index].dev[device] = true;
untriggeraction[device] = action;
untriggerindex[device] = index;
foreach (DS4Controls dc in action.trigger)
Expand All @@ -1150,10 +1162,10 @@ public static async void MapCustomAction(int device, DS4State cState, DS4State M
}
else if (triggeractivated && action.type == "Macro")
{
if (!actionDone[device, index])
if (!actionDone[index].dev[device])
{
DS4KeyType keyType = action.keyType;
actionDone[device, index] = true;
actionDone[index].dev[device] = true;
foreach (DS4Controls dc in action.trigger)
resetToDefaultValue(dc, MappedState);
PlayMacro(device, macroControl, String.Join("/", action.macro), DS4Controls.None, keyType);
Expand All @@ -1163,9 +1175,9 @@ public static async void MapCustomAction(int device, DS4State cState, DS4State M
}
else if (triggeractivated && action.type == "Key")
{
if (action.uTrigger.Count == 0 || (action.uTrigger.Count > 0 && untriggerindex[device] == -1 && !actionDone[device, index]))
if (action.uTrigger.Count == 0 || (action.uTrigger.Count > 0 && untriggerindex[device] == -1 && !actionDone[index].dev[device]))
{
actionDone[device, index] = true;
actionDone[index].dev[device] = true;
untriggerindex[device] = index;
ushort key;
ushort.TryParse(action.details, out key);
Expand All @@ -1188,9 +1200,9 @@ public static async void MapCustomAction(int device, DS4State cState, DS4State M
}
else if (action.uTrigger.Count > 0 && utriggeractivated && action.type == "Key")
{
if (untriggerindex[device] > -1 && !actionDone[device, index])
if (untriggerindex[device] > -1 && !actionDone[index].dev[device])
{
actionDone[device, index] = true;
actionDone[index].dev[device] = true;
untriggerindex[device] = -1;
ushort key;
ushort.TryParse(action.details, out key);
Expand Down Expand Up @@ -1226,16 +1238,18 @@ public static async void MapCustomAction(int device, DS4State cState, DS4State M
}
else if (triggeractivated && action.type == "BatteryCheck")
{
string[] dets = action.details.Split(',');
if (bool.Parse(dets[1]) && !actionDone[device, index])
string[] dets = action.details.Split('|');
if (dets.Length == 1)
dets = action.details.Split(',');
if (bool.Parse(dets[1]) && !actionDone[index].dev[device])
{
Log.LogToTray("Controller " + (device + 1) + ": " +
ctrl.getDS4Battery(device), true);
}
if (bool.Parse(dets[2]))
{
DS4Device d = ctrl.DS4Controllers[device];
if (!actionDone[device, index])
if (!actionDone[index].dev[device])
{
lastColor[device] = d.LightBarColor;
DS4LightBar.forcelight[device] = true;
Expand All @@ -1246,11 +1260,11 @@ public static async void MapCustomAction(int device, DS4State cState, DS4State M
if (fadetimer[device] < 100)
DS4LightBar.forcedColor[device] = getTransitionedColor(lastColor[device], trans, fadetimer[device] += 2);
}
actionDone[device, index] = true;
actionDone[index].dev[device] = true;
}
else if (!triggeractivated && action.type == "BatteryCheck")
{
if (actionDone[device, index])
if (actionDone[index].dev[device])
{
fadetimer[device] = 0;
/*if (prevFadetimer[device] == fadetimer[device])
Expand All @@ -1261,10 +1275,10 @@ public static async void MapCustomAction(int device, DS4State cState, DS4State M
else
prevFadetimer[device] = fadetimer[device];*/
DS4LightBar.forcelight[device] = false;
actionDone[device, index] = false;
actionDone[index].dev[device] = false;
}
}
else if (action.type == "XboxGameDVR")
else if (action.type == "XboxGameDVR" || action.type == "MultiAction")
{
/*if (getCustomButton(device, action.trigger[0]) != X360Controls.Unbound)
getCustomButtons(device)[action.trigger[0]] = X360Controls.Unbound;
Expand Down Expand Up @@ -1309,7 +1323,11 @@ public static async void MapCustomAction(int device, DS4State cState, DS4State M
string macro = "";
if (tappedOnce) //single tap
{
if (int.TryParse(dets[0], out type))
if (action.type == "MultiAction")
{
macro = dets[0];
}
else if (int.TryParse(dets[0], out type))
{
switch (type)
{
Expand All @@ -1322,14 +1340,19 @@ public static async void MapCustomAction(int device, DS4State cState, DS4State M
}
if ((DateTime.UtcNow - TimeofEnd) > TimeSpan.FromMilliseconds(150))
{
PlayMacro(device, macroControl, macro, DS4Controls.None, DS4KeyType.None);
if (macro != "")
PlayMacro(device, macroControl, macro, DS4Controls.None, DS4KeyType.None);
tappedOnce = false;
}
//if it fails the method resets, and tries again with a new tester value (gives tap a delay so tap and hold can work)
}
else if (firstTouch && (DateTime.UtcNow - pastTime) > TimeSpan.FromMilliseconds(1000)) //helddown
{
if (int.TryParse(dets[1], out type))
if (action.type == "MultiAction")
{
macro = dets[1];
}
else if (int.TryParse(dets[1], out type))
{
switch (type)
{
Expand All @@ -1340,12 +1363,17 @@ public static async void MapCustomAction(int device, DS4State cState, DS4State M
case 4: macro = "91/164/71/71/164/91"; break;
}
}
PlayMacro(device, macroControl, macro, DS4Controls.None, DS4KeyType.None);
if (macro != "")
PlayMacro(device, macroControl, macro, DS4Controls.None, DS4KeyType.None);
firstTouch = false;
}
else if (secondtouchbegin) //if double tap
{
if (int.TryParse(dets[2], out type))
if (action.type == "MultiAction")
{
macro = dets[2];
}
else if (int.TryParse(dets[2], out type))
{
switch (type)
{
Expand All @@ -1356,12 +1384,13 @@ public static async void MapCustomAction(int device, DS4State cState, DS4State M
case 4: macro = "91/164/71/71/164/91"; break;
}
}
PlayMacro(device, macroControl, macro, DS4Controls.None, DS4KeyType.None);
if (macro != "")
PlayMacro(device, macroControl, macro, DS4Controls.None, DS4KeyType.None);
secondtouchbegin = false;
}
}
else
actionDone[device, index] = false;
actionDone[index].dev[device] = false;
}
}
}
Expand All @@ -1383,13 +1412,13 @@ public static async void MapCustomAction(int device, DS4State cState, DS4State M

if (utriggeractivated && action.type == "Profile")
{
if ((action.controls == action.ucontrols && !actionDone[device, index]) || //if trigger and end trigger are the same
if ((action.controls == action.ucontrols && !actionDone[index].dev[device]) || //if trigger and end trigger are the same
action.controls != action.ucontrols)
if (!string.IsNullOrEmpty(tempprofilename[device]))
{
foreach (DS4Controls dc in action.uTrigger)
{
actionDone[device, index] = true;
actionDone[index].dev[device] = true;
DS4ControlSettings dcs = getDS4CSetting(device, dc.ToString());
if (dcs.action != null)
{
Expand All @@ -1408,7 +1437,7 @@ public static async void MapCustomAction(int device, DS4State cState, DS4State M
}
}
else
actionDone[device, index] = false;
actionDone[index].dev[device] = false;
}
}

Expand Down
Loading

0 comments on commit 1bfc69e

Please sign in to comment.