Some small changes to the mapping routine

This commit is contained in:
Travis Nickles 2017-04-07 17:13:19 -07:00
parent f050df5f81
commit a1f103c483
2 changed files with 25 additions and 11 deletions

View File

@ -164,9 +164,9 @@ namespace DS4Windows
//distanceprofile = (ProfilePath[deviceNum].ToLower().Contains("distance") || tempprofilename[deviceNum].ToLower().Contains("distance")); //distanceprofile = (ProfilePath[deviceNum].ToLower().Contains("distance") || tempprofilename[deviceNum].ToLower().Contains("distance"));
if (distanceprofile && !defualtLight) if (distanceprofile && !defualtLight)
{ //Thing I did for Distance { //Thing I did for Distance
float rumble = device.LeftHeavySlowRumble / 2.55f; float rumble = device.getLeftHeavySlowRumble() / 2.55f;
byte max = Max(color.red, Max(color.green, color.blue)); byte max = Max(color.red, Max(color.green, color.blue));
if (device.LeftHeavySlowRumble > 100) if (device.getLeftHeavySlowRumble() > 100)
color = getTransitionedColor(new DS4Color(max, max, 0), new DS4Color(255, 0, 0), rumble); color = getTransitionedColor(new DS4Color(max, max, 0), new DS4Color(255, 0, 0), rumble);
else else
color = getTransitionedColor(color, getTransitionedColor(new DS4Color(max, max, 0), new DS4Color(255, 0, 0), 39.6078f), device.getLeftHeavySlowRumble()); color = getTransitionedColor(color, getTransitionedColor(new DS4Color(max, max, 0), new DS4Color(255, 0, 0), 39.6078f), device.getLeftHeavySlowRumble());

View File

@ -687,6 +687,7 @@ namespace DS4Windows
{ {
switch (trigger) switch (trigger)
{ {
case 0: return false;
case 1: return getBoolMapping(device, DS4Controls.Cross, cState, eState, tp); case 1: return getBoolMapping(device, DS4Controls.Cross, cState, eState, tp);
case 2: return getBoolMapping(device, DS4Controls.Circle, cState, eState, tp); case 2: return getBoolMapping(device, DS4Controls.Circle, cState, eState, tp);
case 3: return getBoolMapping(device, DS4Controls.Square, cState, eState, tp); case 3: return getBoolMapping(device, DS4Controls.Square, cState, eState, tp);
@ -792,7 +793,6 @@ namespace DS4Windows
cState.CopyTo(MappedState); cState.CopyTo(MappedState);
Dictionary<DS4Controls, DS4Controls> tempControlDict = new Dictionary<DS4Controls, DS4Controls>(); Dictionary<DS4Controls, DS4Controls> tempControlDict = new Dictionary<DS4Controls, DS4Controls>();
//Dictionary<DS4Controls, DS4Controls> tempAxesControlDict = new Dictionary<DS4Controls, DS4Controls>();
DS4Controls usingExtra = DS4Controls.None; DS4Controls usingExtra = DS4Controls.None;
foreach (DS4ControlSettings dcs in getDS4CSettings(device)) foreach (DS4ControlSettings dcs in getDS4CSettings(device))
{ {
@ -811,6 +811,7 @@ namespace DS4Windows
actionType = dcs.actionType; actionType = dcs.actionType;
keyType = dcs.keyType; keyType = dcs.keyType;
} }
if (action != null) if (action != null)
{ {
if (actionType == DS4ControlSettings.ActionType.Macro) if (actionType == DS4ControlSettings.ActionType.Macro)
@ -991,8 +992,9 @@ namespace DS4Windows
else else
p = dcs.extras; p = dcs.extras;
string[] extraS = p.Split(','); string[] extraS = p.Split(',');
int[] extras = new int[extraS.Length]; int extrasSLen = extraS.Length;
for (int i = 0; i < extraS.Length; i++) int[] extras = new int[extrasSLen];
for (int i = 0; i < extrasSLen; i++)
{ {
int b; int b;
if (int.TryParse(extraS[i], out b)) if (int.TryParse(extraS[i], out b))
@ -1188,8 +1190,11 @@ namespace DS4Windows
} }
} }
if (MouseDeltaX != 0 || MouseDeltaY != 0)
{
InputMethods.MoveCursorBy(MouseDeltaX, MouseDeltaY); InputMethods.MoveCursorBy(MouseDeltaX, MouseDeltaY);
} }
}
private static bool IfAxisIsNotModified(int device, bool shift, DS4Controls dc) private static bool IfAxisIsNotModified(int device, bool shift, DS4Controls dc)
{ {
@ -1200,6 +1205,8 @@ namespace DS4Windows
/* TODO: This method is slow sauce. Find ways to speed up action execution */ /* TODO: This method is slow sauce. Find ways to speed up action execution */
try try
{ {
int actionDoneCount = actionDone.Count;
int totalActionCount = GetActions().Count;
List<string> profileActions = getProfileActions(device); List<string> profileActions = getProfileActions(device);
foreach (string actionname in profileActions) foreach (string actionname in profileActions)
{ {
@ -1208,11 +1215,18 @@ namespace DS4Windows
//int index = GetActionIndexOf(actionname); //int index = GetActionIndexOf(actionname);
SpecialAction action = GetProfileAction(device, actionname); SpecialAction action = GetProfileAction(device, actionname);
int index = GetProfileActionIndexOf(device, actionname); int index = GetProfileActionIndexOf(device, actionname);
int actionDoneCount = actionDone.Count;
if (actionDoneCount < index + 1) if (actionDoneCount < index + 1)
{
actionDone.Add(new ActionState()); actionDone.Add(new ActionState());
else if (actionDoneCount > GetActions().Count) actionDoneCount++;
}
else if (actionDoneCount > totalActionCount)
{
actionDone.RemoveAt(actionDoneCount - 1); actionDone.RemoveAt(actionDoneCount - 1);
actionDoneCount--;
}
double time = 0.0; double time = 0.0;
//If a key or button is assigned to the trigger, a key special action is used like //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 //a quick tap to use and hold to use the regular custom button/key
@ -1399,7 +1413,7 @@ namespace DS4Windows
else if (triggeractivated && action.typeID == SpecialAction.ActionTypeId.DisconnectBT) else if (triggeractivated && action.typeID == SpecialAction.ActionTypeId.DisconnectBT)
{ {
DS4Device d = ctrl.DS4Controllers[device]; DS4Device d = ctrl.DS4Controllers[device];
if (!d.Charging) if (!d.isCharging())
{ {
ConnectionType deviceConn = d.ConnectionType; ConnectionType deviceConn = d.ConnectionType;
if (deviceConn == ConnectionType.BT) if (deviceConn == ConnectionType.BT)
@ -1417,7 +1431,7 @@ namespace DS4Windows
else if (dcs.actionType == DS4ControlSettings.ActionType.Macro) else if (dcs.actionType == DS4ControlSettings.ActionType.Macro)
{ {
int[] keys = (int[])dcs.action; int[] keys = (int[])dcs.action;
for (int i = 0; i < keys.Length; i++) for (int i = 0, keysLen = keys.Length; i < keysLen; i++)
InputMethods.performKeyRelease((ushort)keys[i]); InputMethods.performKeyRelease((ushort)keys[i]);
} }
} }
@ -1616,7 +1630,7 @@ namespace DS4Windows
else if (dcs.actionType == DS4ControlSettings.ActionType.Macro) else if (dcs.actionType == DS4ControlSettings.ActionType.Macro)
{ {
int[] keys = (int[])dcs.action; int[] keys = (int[])dcs.action;
for (int i = 0; i < keys.Length; i++) for (int i = 0, keysLen=keys.Length; i < keysLen; i++)
InputMethods.performKeyRelease((ushort)keys[i]); InputMethods.performKeyRelease((ushort)keys[i]);
} }
} }