diff --git a/DS4Windows/DS4Control/ControlSerivce.cs b/DS4Windows/DS4Control/ControlSerivce.cs
index 6554bc6..28759a7 100644
--- a/DS4Windows/DS4Control/ControlSerivce.cs
+++ b/DS4Windows/DS4Control/ControlSerivce.cs
@@ -479,13 +479,13 @@ namespace DS4Windows
L2Sens[ind] != 0 || R2Sens[ind] != 0) //if a curve or deadzone is in place
cState = Mapping.SetCurveAndDeadzone(ind, cState);
if (!recordingMacro && (!string.IsNullOrEmpty(tempprofilename[ind]) ||
- getHasCustomKeysorButtons(ind) || getHasShiftCustomKeysorButtons(ind) || ProfileActions[ind].Count > 0))
+ HasCustomAction(ind) || HasCustomExtras(ind) || ProfileActions[ind].Count > 0))
{
Mapping.MapCustom(ind, cState, MappedState[ind], ExposedState[ind], touchPad[ind], this);
cState = MappedState[ind];
}
- if (getHasCustomExtras(ind))
- DoExtras(ind);
+ //if (HasCustomExtras(ind))
+ // DoExtras(ind);
// Update the GUI/whatever.
DS4LightBar.updateLightBar(device, ind, cState, ExposedState[ind], touchPad[ind]);
@@ -534,7 +534,7 @@ namespace DS4Windows
}
}
- private void DoExtras(int ind)
+ /* private void DoExtras(int ind)
{
DS4State cState = CurrentState[ind];
DS4StateExposed eState = ExposedState[ind];
@@ -589,8 +589,8 @@ namespace DS4Windows
setRumble(0, 0, ind);
held[ind] = false;
}
- }
-
+ }*/
+
public void EasterTime(int ind)
diff --git a/DS4Windows/DS4Control/DS4LightBar.cs b/DS4Windows/DS4Control/DS4LightBar.cs
index 5157578..98483a3 100644
--- a/DS4Windows/DS4Control/DS4LightBar.cs
+++ b/DS4Windows/DS4Control/DS4LightBar.cs
@@ -34,11 +34,7 @@ namespace DS4Windows
DS4Color color;
if (!defualtLight && !forcelight[deviceNum])
{
- if (ShiftColorOn[deviceNum] && ShiftModifier[deviceNum] > 0 && shiftMod(device, deviceNum, cState, eState, tp))
- {
- color = ShiftColor[deviceNum];
- }
- else if (UseCustomLed[deviceNum])
+ if (UseCustomLed[deviceNum])
{
if (LedAsBatteryIndicator[deviceNum])
{
@@ -140,9 +136,7 @@ namespace DS4Windows
color = HuetoRGB((float)counters[deviceNum] % 360, 255);
break;
case 3:
- if (!(ShiftColorOn[deviceNum] && ShiftModifier[deviceNum] > 0 && shiftMod(device, deviceNum, cState, eState, tp)) &&
- !UseCustomLed[deviceNum])
- color = ChargingColor[deviceNum];
+ color = ChargingColor[deviceNum];
break;
default:
break;
@@ -214,42 +208,7 @@ namespace DS4Windows
}
public static bool defualtLight = false, shuttingdown = false;
-
- public static bool shiftMod(DS4Device device, int deviceNum, DS4State cState, DS4StateExposed eState, Mouse tp)
- {
- bool shift;
- switch (ShiftModifier[deviceNum])
- {
- case 1: shift = Mapping.getBoolMapping(deviceNum, DS4Controls.Cross, cState, eState, tp); break;
- case 2: shift = Mapping.getBoolMapping(deviceNum, DS4Controls.Circle, cState, eState, tp); break;
- case 3: shift = Mapping.getBoolMapping(deviceNum, DS4Controls.Square, cState, eState, tp); break;
- case 4: shift = Mapping.getBoolMapping(deviceNum, DS4Controls.Triangle, cState, eState, tp); break;
- case 5: shift = Mapping.getBoolMapping(deviceNum, DS4Controls.Options, cState, eState, tp); break;
- case 6: shift = Mapping.getBoolMapping(deviceNum, DS4Controls.Share, cState, eState, tp); break;
- case 7: shift = Mapping.getBoolMapping(deviceNum, DS4Controls.DpadUp, cState, eState, tp); break;
- case 8: shift = Mapping.getBoolMapping(deviceNum, DS4Controls.DpadDown, cState, eState, tp); break;
- case 9: shift = Mapping.getBoolMapping(deviceNum, DS4Controls.DpadLeft, cState, eState, tp); break;
- case 10: shift = Mapping.getBoolMapping(deviceNum, DS4Controls.DpadRight, cState, eState, tp); break;
- case 11: shift = Mapping.getBoolMapping(deviceNum, DS4Controls.PS, cState, eState, tp); break;
- case 12: shift = Mapping.getBoolMapping(deviceNum, DS4Controls.L1, cState, eState, tp); break;
- case 13: shift = Mapping.getBoolMapping(deviceNum, DS4Controls.R1, cState, eState, tp); break;
- case 14: shift = Mapping.getBoolMapping(deviceNum, DS4Controls.L2, cState, eState, tp); break;
- case 15: shift = Mapping.getBoolMapping(deviceNum, DS4Controls.R2, cState, eState, tp); break;
- case 16: shift = Mapping.getBoolMapping(deviceNum, DS4Controls.L3, cState, eState, tp); break;
- case 17: shift = Mapping.getBoolMapping(deviceNum, DS4Controls.R3, cState, eState, tp); break;
- case 18: shift = Mapping.getBoolMapping(deviceNum, DS4Controls.TouchLeft, cState, eState, tp); break;
- case 19: shift = Mapping.getBoolMapping(deviceNum, DS4Controls.TouchUpper, cState, eState, tp); break;
- case 20: shift = Mapping.getBoolMapping(deviceNum, DS4Controls.TouchMulti, cState, eState, tp); break;
- case 21: shift = Mapping.getBoolMapping(deviceNum, DS4Controls.TouchRight, cState, eState, tp); break;
- case 22: shift = Mapping.getBoolMapping(deviceNum, DS4Controls.GyroZNeg, cState, eState, tp); break;
- case 23: shift = Mapping.getBoolMapping(deviceNum, DS4Controls.GyroZPos, cState, eState, tp); break;
- case 24: shift = Mapping.getBoolMapping(deviceNum, DS4Controls.GyroXPos, cState, eState, tp); break;
- case 25: shift = Mapping.getBoolMapping(deviceNum, DS4Controls.GyroXNeg, cState, eState, tp); break;
- case 26: shift = device.getCurrentState().Touch1; break;
- default: shift = false; break;
- }
- return shift;
- }
+
public static DS4Color HuetoRGB(float hue, byte sat)
{
byte C = sat;
diff --git a/DS4Windows/DS4Control/Mapping.cs b/DS4Windows/DS4Control/Mapping.cs
index ee9d05a..98c2889 100644
--- a/DS4Windows/DS4Control/Mapping.cs
+++ b/DS4Windows/DS4Control/Mapping.cs
@@ -483,12 +483,99 @@ namespace DS4Windows
return dState;
}
+ private static bool ShiftTrigger(int trigger, int device, DS4State cState, DS4StateExposed eState, Mouse tp)
+ {
+ switch (trigger)
+ {
+ case 1: return getBoolMapping(device, DS4Controls.Cross, cState, eState, tp);
+ case 2: return getBoolMapping(device, DS4Controls.Circle, cState, eState, tp);
+ case 3: return getBoolMapping(device, DS4Controls.Square, cState, eState, tp);
+ case 4: return getBoolMapping(device, DS4Controls.Triangle, cState, eState, tp);
+ case 5: return getBoolMapping(device, DS4Controls.Options, cState, eState, tp);
+ case 6: return getBoolMapping(device, DS4Controls.Share, cState, eState, tp);
+ case 7: return getBoolMapping(device, DS4Controls.DpadUp, cState, eState, tp);
+ case 8: return getBoolMapping(device, DS4Controls.DpadDown, cState, eState, tp);
+ case 9: return getBoolMapping(device, DS4Controls.DpadLeft, cState, eState, tp);
+ case 10: return getBoolMapping(device, DS4Controls.DpadRight, cState, eState, tp);
+ case 11: return getBoolMapping(device, DS4Controls.PS, cState, eState, tp);
+ case 12: return getBoolMapping(device, DS4Controls.L1, cState, eState, tp);
+ case 13: return getBoolMapping(device, DS4Controls.R1, cState, eState, tp);
+ case 14: return getBoolMapping(device, DS4Controls.L2, cState, eState, tp);
+ case 15: return getBoolMapping(device, DS4Controls.R2, cState, eState, tp);
+ case 16: return getBoolMapping(device, DS4Controls.L3, cState, eState, tp);
+ case 17: return getBoolMapping(device, DS4Controls.R3, cState, eState, tp);
+ case 18: return getBoolMapping(device, DS4Controls.TouchLeft, cState, eState, tp);
+ case 19: return getBoolMapping(device, DS4Controls.TouchUpper, cState, eState, tp);
+ case 20: return getBoolMapping(device, DS4Controls.TouchMulti, cState, eState, tp);
+ case 21: return getBoolMapping(device, DS4Controls.TouchRight, cState, eState, tp);
+ case 22: return getBoolMapping(device, DS4Controls.GyroZNeg, cState, eState, tp);
+ case 23: return getBoolMapping(device, DS4Controls.GyroZPos, cState, eState, tp);
+ case 24: return getBoolMapping(device, DS4Controls.GyroXPos, cState, eState, tp);
+ case 25: return getBoolMapping(device, DS4Controls.GyroXNeg, cState, eState, tp);
+ case 26: return cState.Touch1;
+ default: return false;
+ }
+ }
+ private static X360Controls getX360ControlsByName(string key)
+ {
+ X360Controls x3c;
+ if (Enum.TryParse(key, true, out x3c))
+ return x3c;
+ 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;
+
+ 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 "Mouse Up": return X360Controls.MouseUp;
+ case "Mouse Down": return X360Controls.MouseDown;
+ case "Mouse Left": return X360Controls.MouseLeft;
+ case "Mouse Right": return X360Controls.MouseRight;
+ case "Unbound": return X360Controls.Unbound;
+
+ }
+ return X360Controls.Unbound;
+ }
+
///
/// Map DS4 Buttons/Axes to other DS4 Buttons/Axes (largely the same as Xinput ones) and to keyboard and mouse buttons.
///
+ static bool[] held = new bool[4];
+ static int[] oldmouse = new int[4] { -1, -1, -1, -1 };
public static void MapCustom(int device, DS4State cState, DS4State MappedState, DS4StateExposed eState, Mouse tp, ControlService ctrl)
{
- bool shift;
MappedState.LX = 127;
MappedState.LY = 127;
@@ -498,98 +585,12 @@ namespace DS4Windows
int MouseDeltaY = 0;
SyntheticState deviceState = Mapping.deviceState[device];
- if (GetActions().Count > 0 && (ProfileActions[device].Count > 0 ||
- !string.IsNullOrEmpty(tempprofilename[device])))
+ if (GetActions().Count > 0 && (ProfileActions[device].Count > 0 || !string.IsNullOrEmpty(tempprofilename[device])))
MapCustomAction(device, cState, MappedState, eState, tp, ctrl);
if (ctrl.DS4Controllers[device] == null) return;
- switch (ShiftModifier[device])
- {
- case 1: shift = getBoolMapping(device, DS4Controls.Cross, cState, eState, tp); break;
- case 2: shift = getBoolMapping(device, DS4Controls.Circle, cState, eState, tp); break;
- case 3: shift = getBoolMapping(device, DS4Controls.Square, cState, eState, tp); break;
- case 4: shift = getBoolMapping(device, DS4Controls.Triangle, cState, eState, tp); break;
- case 5: shift = getBoolMapping(device, DS4Controls.Options, cState, eState, tp); break;
- case 6: shift = getBoolMapping(device, DS4Controls.Share, cState, eState, tp); break;
- case 7: shift = getBoolMapping(device, DS4Controls.DpadUp, cState, eState, tp); break;
- case 8: shift = getBoolMapping(device, DS4Controls.DpadDown, cState, eState, tp); break;
- case 9: shift = getBoolMapping(device, DS4Controls.DpadLeft, cState, eState, tp); break;
- case 10: shift = getBoolMapping(device, DS4Controls.DpadRight, cState, eState, tp); break;
- case 11: shift = getBoolMapping(device, DS4Controls.PS, cState, eState, tp); break;
- case 12: shift = getBoolMapping(device, DS4Controls.L1, cState, eState, tp); break;
- case 13: shift = getBoolMapping(device, DS4Controls.R1, cState, eState, tp); break;
- case 14: shift = getBoolMapping(device, DS4Controls.L2, cState, eState, tp); break;
- case 15: shift = getBoolMapping(device, DS4Controls.R2, cState, eState, tp); break;
- case 16: shift = getBoolMapping(device, DS4Controls.L3, cState, eState, tp); break;
- case 17: shift = getBoolMapping(device, DS4Controls.R3, cState, eState, tp); break;
- case 18: shift = getBoolMapping(device, DS4Controls.TouchLeft, cState, eState, tp); break;
- case 19: shift = getBoolMapping(device, DS4Controls.TouchUpper, cState, eState, tp); break;
- case 20: shift = getBoolMapping(device, DS4Controls.TouchMulti, cState, eState, tp); break;
- case 21: shift = getBoolMapping(device, DS4Controls.TouchRight, cState, eState, tp); break;
- case 22: shift = getBoolMapping(device, DS4Controls.GyroZNeg, cState, eState, tp); break;
- case 23: shift = getBoolMapping(device, DS4Controls.GyroZPos, cState, eState, tp); break;
- case 24: shift = getBoolMapping(device, DS4Controls.GyroXPos, cState, eState, tp); break;
- case 25: shift = getBoolMapping(device, DS4Controls.GyroXNeg, cState, eState, tp); break;
- case 26: shift = cState.Touch1; break;
- default: shift = false; break;
- }
- cState.CopyTo(MappedState);
- if (shift)
- MapShiftCustom(device, cState, MappedState, eState, tp);
- foreach (KeyValuePair customKey in getCustomMacros(device))
- {
- if (shift == false ||
- (getShiftCustomMacro(device, customKey.Key) == "0" &&
- getShiftCustomKey(device, customKey.Key) == 0 &&
- getShiftCustomButton(device, customKey.Key) == X360Controls.None))
- {
- DS4KeyType keyType = getCustomKeyType(device, customKey.Key);
- if (getBoolMapping(device, customKey.Key, cState, eState, tp))
- {
- resetToDefaultValue(customKey.Key, MappedState);
- PlayMacro(device, macroControl, customKey.Value, customKey.Key, keyType);
- }
- else if (!getBoolMapping(device, customKey.Key, cState, eState, tp))
- {
- EndMacro(device, macroControl, customKey.Value, customKey.Key);
- }
- }
- }
- foreach (KeyValuePair customKey in getCustomKeys(device))
- {
- if (shift == false ||
- (getShiftCustomMacro(device, customKey.Key) == "0" &&
- getShiftCustomKey(device, customKey.Key) == 0 &&
- getShiftCustomButton(device, customKey.Key) == X360Controls.None))
- {
- DS4KeyType keyType = getCustomKeyType(device, customKey.Key);
- if (getBoolMapping(device, customKey.Key, cState, eState, tp))
- {
- resetToDefaultValue(customKey.Key, MappedState);
- SyntheticState.KeyPresses kp;
- if (!deviceState.keyPresses.TryGetValue(customKey.Value, out kp))
- deviceState.keyPresses[customKey.Value] = kp = new SyntheticState.KeyPresses();
- if (keyType.HasFlag(DS4KeyType.ScanCode))
- kp.current.scanCodeCount++;
- else
- kp.current.vkCount++;
- if (keyType.HasFlag(DS4KeyType.Toggle))
- {
- if (!pressedonce[customKey.Value])
- {
- kp.current.toggle = !kp.current.toggle;
- pressedonce[customKey.Value] = true;
- }
- kp.current.toggleCount++;
- }
- kp.current.repeatCount++;
- }
- else
- pressedonce[customKey.Value] = false;
- }
- }
- //Dictionary customButtons = getCustomButtons(device);
- //foreach (KeyValuePair customButton in customButtons)
+ cState.CopyTo(MappedState);
+
List Cross = new List();
List Circle = new List();
List Square = new List();
@@ -615,140 +616,245 @@ namespace DS4Windows
List RXP = new List();
List RYN = new List();
List RYP = new List();
- foreach (KeyValuePair customButton in getCustomButtons(device))
+ DS4Controls usingExtra = DS4Controls.None;
+ foreach (DS4ControlSettings dcs in getDS4CSettings(device))
{
- if (shift == false ||
- (getShiftCustomMacro(device, customButton.Key) == "0" &&
- getShiftCustomKey(device, customButton.Key) == 0 &&
- getShiftCustomButton(device, customButton.Key) == X360Controls.None))
+ object action = null;
+ DS4ControlSettings.ActionType actionType = 0;
+ DS4KeyType keyType = DS4KeyType.None;
+ if (dcs.shiftAction != null && ShiftTrigger(dcs.shiftTrigger, device, cState, eState, tp))
{
- DS4KeyType keyType = getCustomKeyType(device, customButton.Key);
- int keyvalue = 0;
- switch (customButton.Value)
+ action = dcs.shiftAction;
+ actionType = dcs.shiftActionType;
+ keyType = dcs.shiftKeyType;
+ }
+ else if (dcs.action != null)
+ {
+ action = dcs.action;
+ actionType = dcs.actionType;
+ keyType = dcs.keyType;
+ }
+ if (action != null)
+ {
+ if (actionType == DS4ControlSettings.ActionType.Macro)
{
- case X360Controls.LeftMouse: keyvalue = 256; break;
- case X360Controls.RightMouse: keyvalue = 257; break;
- case X360Controls.MiddleMouse: keyvalue = 258; break;
- case X360Controls.FourthMouse: keyvalue = 259; break;
- case X360Controls.FifthMouse: keyvalue = 260; break;
- }
- if (keyType.HasFlag(DS4KeyType.Toggle))
- {
- if (getBoolMapping(device, customButton.Key, cState, eState, tp))
+ if (getBoolMapping(device, dcs.control, cState, eState, tp))
{
- resetToDefaultValue(customButton.Key, MappedState);
- if (!pressedonce[keyvalue])
+ resetToDefaultValue(dcs.control, MappedState);
+ PlayMacro(device, macroControl, string.Join("/", (int[])action), dcs.control, keyType);
+ }
+ else if (!getBoolMapping(device, dcs.control, cState, eState, tp))
+ {
+ EndMacro(device, macroControl, string.Join("/", (int[])action), dcs.control);
+ }
+ }
+ else if (actionType == DS4ControlSettings.ActionType.Key)
+ {
+ ushort value = ushort.Parse(action.ToString());
+ if (getBoolMapping(device, dcs.control, cState, eState, tp))
+ {
+ resetToDefaultValue(dcs.control, MappedState);
+ SyntheticState.KeyPresses kp;
+ if (!deviceState.keyPresses.TryGetValue(value, out kp))
+ deviceState.keyPresses[value] = kp = new SyntheticState.KeyPresses();
+ if (keyType.HasFlag(DS4KeyType.ScanCode))
+ kp.current.scanCodeCount++;
+ else
+ kp.current.vkCount++;
+ if (keyType.HasFlag(DS4KeyType.Toggle))
{
- deviceState.currentClicks.toggle = !deviceState.currentClicks.toggle;
- pressedonce[keyvalue] = true;
+ if (!pressedonce[value])
+ {
+ kp.current.toggle = !kp.current.toggle;
+ pressedonce[value] = true;
+ }
+ kp.current.toggleCount++;
}
- deviceState.currentClicks.toggleCount++;
+ kp.current.repeatCount++;
}
else
- {
- pressedonce[keyvalue] = false;
- }
+ pressedonce[value] = false;
}
- resetToDefaultValue(customButton.Key, MappedState); // erase default mappings for things that are remapped
- bool isAnalog = customButton.Key.ToString().Contains("LX") ||
- customButton.Key.ToString().Contains("RX") ||
- customButton.Key.ToString().Contains("LY") ||
- customButton.Key.ToString().Contains("LY") ||
- customButton.Key.ToString().Contains("R2") ||
- customButton.Key.ToString().Contains("L2") ||
- customButton.Key.ToString().Contains("Gyro");
- switch (customButton.Value)
+ else if (actionType == DS4ControlSettings.ActionType.Button)
{
- case X360Controls.A: Cross.Add(customButton.Key); break;
- case X360Controls.B: Circle.Add(customButton.Key); break;
- case X360Controls.X: Square.Add(customButton.Key); break;
- case X360Controls.Y: Triangle.Add(customButton.Key); break;
- case X360Controls.LB: L1.Add(customButton.Key); break;
- case X360Controls.LS: L3.Add(customButton.Key); break;
- case X360Controls.RB: R1.Add(customButton.Key); break;
- case X360Controls.RS: R3.Add(customButton.Key); break;
- case X360Controls.DpadUp: DpadUp.Add(customButton.Key); break;
- case X360Controls.DpadDown: DpadDown.Add(customButton.Key); break;
- case X360Controls.DpadLeft: DpadLeft.Add(customButton.Key); break;
- case X360Controls.DpadRight: DpadRight.Add(customButton.Key); break;
- case X360Controls.Start: Options.Add(customButton.Key); break;
- case X360Controls.Guide: PS.Add(customButton.Key); break;
- case X360Controls.Back: Share.Add(customButton.Key); break;
- case X360Controls.LXNeg: LXN.Add(customButton.Key); break;
- case X360Controls.LYNeg: LYN.Add(customButton.Key); break;
- case X360Controls.RXNeg: RXN.Add(customButton.Key); break;
- case X360Controls.RYNeg: RYN.Add(customButton.Key); break;
- case X360Controls.LXPos: LXP.Add(customButton.Key); break;
- case X360Controls.LYPos: LYP.Add(customButton.Key); break;
- case X360Controls.RXPos: RXP.Add(customButton.Key); break;
- case X360Controls.RYPos: RYP.Add(customButton.Key); break;
- case X360Controls.LT: L2.Add(customButton.Key); break;
- case X360Controls.RT: R2.Add(customButton.Key); break;
- case X360Controls.LeftMouse:
- if (getBoolMapping(device, customButton.Key, cState, eState, tp))
- deviceState.currentClicks.leftCount++;
- break;
- case X360Controls.RightMouse:
- if (getBoolMapping(device, customButton.Key, cState, eState, tp))
- deviceState.currentClicks.rightCount++;
- break;
- case X360Controls.MiddleMouse:
- if (getBoolMapping(device, customButton.Key, cState, eState, tp))
- deviceState.currentClicks.middleCount++;
- break;
- case X360Controls.FourthMouse:
- if (getBoolMapping(device, customButton.Key, cState, eState, tp))
- deviceState.currentClicks.fourthCount++;
- break;
- case X360Controls.FifthMouse:
- if (getBoolMapping(device, customButton.Key, cState, eState, tp))
- deviceState.currentClicks.fifthCount++;
- break;
- case X360Controls.WUP:
- if (getBoolMapping(device, customButton.Key, cState, eState, tp))
- if (isAnalog)
- getMouseWheelMapping(device, customButton.Key, cState, eState, tp, false);
- else
- deviceState.currentClicks.wUpCount++;
- break;
- case X360Controls.WDOWN:
- if (getBoolMapping(device, customButton.Key, cState, eState, tp))
- if (isAnalog)
- getMouseWheelMapping(device, customButton.Key, cState, eState, tp, true);
- else
- deviceState.currentClicks.wDownCount++;
- break;
- case X360Controls.MouseUp:
- if (MouseDeltaY == 0)
+ int keyvalue = 0;
+ bool isAnalog = dcs.control.ToString().Contains("LX") ||
+ dcs.control.ToString().Contains("RX") ||
+ dcs.control.ToString().Contains("LY") ||
+ dcs.control.ToString().Contains("LY") ||
+ dcs.control.ToString().Contains("R2") ||
+ dcs.control.ToString().Contains("L2") ||
+ dcs.control.ToString().Contains("Gyro");
+ switch (getX360ControlsByName(action.ToString()))
+ {
+ case X360Controls.A: Cross.Add(dcs.control); break;
+ case X360Controls.B: Circle.Add(dcs.control); break;
+ case X360Controls.X: Square.Add(dcs.control); break;
+ case X360Controls.Y: Triangle.Add(dcs.control); break;
+ case X360Controls.LB: L1.Add(dcs.control); break;
+ case X360Controls.LS: L3.Add(dcs.control); break;
+ case X360Controls.RB: R1.Add(dcs.control); break;
+ case X360Controls.RS: R3.Add(dcs.control); break;
+ case X360Controls.DpadUp: DpadUp.Add(dcs.control); break;
+ case X360Controls.DpadDown: DpadDown.Add(dcs.control); break;
+ case X360Controls.DpadLeft: DpadLeft.Add(dcs.control); break;
+ case X360Controls.DpadRight: DpadRight.Add(dcs.control); break;
+ case X360Controls.Start: Options.Add(dcs.control); break;
+ case X360Controls.Guide: PS.Add(dcs.control); break;
+ case X360Controls.Back: Share.Add(dcs.control); break;
+ case X360Controls.LXNeg: LXN.Add(dcs.control); break;
+ case X360Controls.LYNeg: LYN.Add(dcs.control); break;
+ case X360Controls.RXNeg: RXN.Add(dcs.control); break;
+ case X360Controls.RYNeg: RYN.Add(dcs.control); break;
+ case X360Controls.LXPos: LXP.Add(dcs.control); break;
+ case X360Controls.LYPos: LYP.Add(dcs.control); break;
+ case X360Controls.RXPos: RXP.Add(dcs.control); break;
+ case X360Controls.RYPos: RYP.Add(dcs.control); break;
+ case X360Controls.LT: L2.Add(dcs.control); break;
+ case X360Controls.RT: R2.Add(dcs.control); break;
+ case X360Controls.LeftMouse:
+ keyvalue = 256;
+ if (getBoolMapping(device, dcs.control, cState, eState, tp))
+ deviceState.currentClicks.leftCount++;
+ break;
+ case X360Controls.RightMouse:
+ keyvalue = 257;
+ if (getBoolMapping(device, dcs.control, cState, eState, tp))
+ deviceState.currentClicks.rightCount++;
+ break;
+ case X360Controls.MiddleMouse:
+ keyvalue = 258;
+ if (getBoolMapping(device, dcs.control, cState, eState, tp))
+ deviceState.currentClicks.middleCount++;
+ break;
+ case X360Controls.FourthMouse:
+ keyvalue = 259;
+ if (getBoolMapping(device, dcs.control, cState, eState, tp))
+ deviceState.currentClicks.fourthCount++;
+ break;
+ case X360Controls.FifthMouse:
+ keyvalue = 260;
+ if (getBoolMapping(device, dcs.control, cState, eState, tp))
+ deviceState.currentClicks.fifthCount++;
+ break;
+ case X360Controls.WUP:
+ if (getBoolMapping(device, dcs.control, cState, eState, tp))
+ if (isAnalog)
+ getMouseWheelMapping(device, dcs.control, cState, eState, tp, false);
+ else
+ deviceState.currentClicks.wUpCount++;
+ break;
+ case X360Controls.WDOWN:
+ if (getBoolMapping(device, dcs.control, cState, eState, tp))
+ if (isAnalog)
+ getMouseWheelMapping(device, dcs.control, cState, eState, tp, true);
+ else
+ deviceState.currentClicks.wDownCount++;
+ break;
+ case X360Controls.MouseUp:
+ if (MouseDeltaY == 0)
+ {
+ MouseDeltaY = getMouseMapping(device, dcs.control, cState, eState, 0);
+ MouseDeltaY = -Math.Abs((MouseDeltaY == -2147483648 ? 0 : MouseDeltaY));
+ }
+ break;
+ case X360Controls.MouseDown:
+ if (MouseDeltaY == 0)
+ {
+ MouseDeltaY = getMouseMapping(device, dcs.control, cState, eState, 1);
+ MouseDeltaY = Math.Abs((MouseDeltaY == -2147483648 ? 0 : MouseDeltaY));
+ }
+ break;
+ case X360Controls.MouseLeft:
+ if (MouseDeltaX == 0)
+ {
+ MouseDeltaX = getMouseMapping(device, dcs.control, cState, eState, 2);
+ MouseDeltaX = -Math.Abs((MouseDeltaX == -2147483648 ? 0 : MouseDeltaX));
+ }
+ break;
+ case X360Controls.MouseRight:
+ if (MouseDeltaX == 0)
+ {
+ MouseDeltaX = getMouseMapping(device, dcs.control, cState, eState, 3);
+ MouseDeltaX = Math.Abs((MouseDeltaX == -2147483648 ? 0 : MouseDeltaX));
+ }
+ break;
+ }
+ if (keyType.HasFlag(DS4KeyType.Toggle))
+ {
+ if (getBoolMapping(device, dcs.control, cState, eState, tp))
{
- MouseDeltaY = getMouseMapping(device, customButton.Key, cState, eState, 0);
- MouseDeltaY = -Math.Abs((MouseDeltaY == -2147483648 ? 0 : MouseDeltaY));
+ resetToDefaultValue(dcs.control, MappedState);
+ if (!pressedonce[keyvalue])
+ {
+ deviceState.currentClicks.toggle = !deviceState.currentClicks.toggle;
+ pressedonce[keyvalue] = true;
+ }
+ deviceState.currentClicks.toggleCount++;
}
- break;
- case X360Controls.MouseDown:
- if (MouseDeltaY == 0)
+ else
{
- MouseDeltaY = getMouseMapping(device, customButton.Key, cState, eState, 1);
- MouseDeltaY = Math.Abs((MouseDeltaY == -2147483648 ? 0 : MouseDeltaY));
+ pressedonce[keyvalue] = false;
}
- break;
- case X360Controls.MouseLeft:
- if (MouseDeltaX == 0)
- {
- MouseDeltaX = getMouseMapping(device, customButton.Key, cState, eState, 2);
- MouseDeltaX = -Math.Abs((MouseDeltaX == -2147483648 ? 0 : MouseDeltaX));
- }
- break;
- case X360Controls.MouseRight:
- if (MouseDeltaX == 0)
- {
- MouseDeltaX = getMouseMapping(device, customButton.Key, cState, eState, 3);
- MouseDeltaX = Math.Abs((MouseDeltaX == -2147483648 ? 0 : MouseDeltaX));
- }
- break;
+ }
+ resetToDefaultValue(dcs.control, MappedState); // erase default mappings for things that are remapped
}
}
- }
+
+ if (usingExtra == DS4Controls.None || usingExtra == dcs.control)
+ {
+ bool shiftE = dcs.shiftExtras != "0,0,0,0,0,0,0,0" && dcs.shiftExtras != "" && ShiftTrigger(dcs.shiftTrigger, device, cState, eState, tp);
+ bool regE = dcs.extras != "0,0,0,0,0,0,0,0" && dcs.extras != "";
+ if ((regE || shiftE) && getBoolMapping(device, dcs.control, cState, eState, tp))
+ {
+ usingExtra = dcs.control;
+ string p;
+ if (shiftE)
+ p = dcs.shiftExtras;
+ else
+ p = dcs.extras;
+ string[] extraS = p.Split(',');
+ int[] extras = new int[extraS.Length];
+ for (int i = 0; i < extraS.Length; i++)
+ {
+ int b;
+ if (int.TryParse(extraS[i], out b))
+ extras[i] = b;
+ }
+ held[device] = true;
+ try
+ {
+ if (!(extras[0] == extras[1] && extras[1] == 0))
+ ctrl.setRumble((byte)extras[0], (byte)extras[1], device);
+ if (extras[2] == 1)
+ {
+ DS4Color color = new DS4Color { red = (byte)extras[3], green = (byte)extras[4], blue = (byte)extras[5] };
+ DS4LightBar.forcedColor[device] = color;
+ DS4LightBar.forcedFlash[device] = (byte)extras[6];
+ DS4LightBar.forcelight[device] = true;
+ }
+ if (extras[7] == 1)
+ {
+ if (oldmouse[device] == -1)
+ oldmouse[device] = ButtonMouseSensitivity[device];
+ ButtonMouseSensitivity[device] = extras[8];
+ }
+ }
+ catch { }
+ }
+ else if ((regE || shiftE) && held[device])
+ {
+ DS4LightBar.forcelight[device] = false;
+ DS4LightBar.forcedFlash[device] = 0;
+ ButtonMouseSensitivity[device] = oldmouse[device];
+ oldmouse[device] = -1;
+ ctrl.setRumble(0, 0, device);
+ held[device] = false;
+ usingExtra = DS4Controls.None;
+ }
+ }
+ }
+
if (macroControl[00]) MappedState.Cross = true;
if (macroControl[01]) MappedState.Circle = true;
if (macroControl[02]) MappedState.Square = true;
@@ -825,24 +931,31 @@ namespace DS4Windows
foreach (DS4Controls dc in PS)
if (getBoolMapping(device, dc, cState, eState, tp))
MappedState.PS = true;
-
- if (getCustomButton(device, DS4Controls.LXNeg) == X360Controls.None)
+ if (IfAxisIsNotModified(device, ShiftTrigger(GetDS4STrigger(device, DS4Controls.LXNeg.ToString()), device, cState, eState, tp), DS4Controls.LXNeg))
LXN.Add(DS4Controls.LXNeg);
- if (getCustomButton(device, DS4Controls.LXPos) == X360Controls.None)
+
+ if (IfAxisIsNotModified(device, ShiftTrigger(GetDS4STrigger(device, DS4Controls.LXPos.ToString()), device, cState, eState, tp), DS4Controls.LXPos))
LXP.Add(DS4Controls.LXPos);
- if (getCustomButton(device, DS4Controls.LYNeg) == X360Controls.None)
+
+ if (IfAxisIsNotModified(device, ShiftTrigger(GetDS4STrigger(device, DS4Controls.LYNeg.ToString()), device, cState, eState, tp), DS4Controls.LYNeg))
LYN.Add(DS4Controls.LYNeg);
- if (getCustomButton(device, DS4Controls.LYPos) == X360Controls.None)
+
+ if (IfAxisIsNotModified(device, ShiftTrigger(GetDS4STrigger(device, DS4Controls.LYPos.ToString()), device, cState, eState, tp), DS4Controls.LYPos))
LYP.Add(DS4Controls.LYPos);
- if (getCustomButton(device, DS4Controls.RXNeg) == X360Controls.None)
+
+ if (IfAxisIsNotModified(device, ShiftTrigger(GetDS4STrigger(device, DS4Controls.RXNeg.ToString()), device, cState, eState, tp), DS4Controls.RXNeg))
RXN.Add(DS4Controls.RXNeg);
- if (getCustomButton(device, DS4Controls.RXPos) == X360Controls.None)
+
+ if (IfAxisIsNotModified(device, ShiftTrigger(GetDS4STrigger(device, DS4Controls.RXPos.ToString()), device, cState, eState, tp), DS4Controls.RXPos))
RXP.Add(DS4Controls.RXPos);
- if (getCustomButton(device, DS4Controls.RYNeg) == X360Controls.None)
+
+ if (IfAxisIsNotModified(device, ShiftTrigger(GetDS4STrigger(device, DS4Controls.RYNeg.ToString()), device, cState, eState, tp), DS4Controls.RYNeg))
RYN.Add(DS4Controls.RYNeg);
- if (getCustomButton(device, DS4Controls.RYPos) == X360Controls.None)
+
+ if (IfAxisIsNotModified(device, ShiftTrigger(GetDS4STrigger(device, DS4Controls.RYPos.ToString()), device, cState, eState, tp), DS4Controls.RYPos))
RYP.Add(DS4Controls.RYPos);
- if ((shift && MappedState.LX == 127) || !shift)
+
+ if (Math.Abs(MappedState.LX - 127) < 10)
if (LXN.Count > 0 || LXP.Count > 0)
{
foreach (DS4Controls dc in LXP)
@@ -854,7 +967,7 @@ namespace DS4Windows
}
else
MappedState.LX = cState.LX;
- if ((shift && MappedState.LY == 127) || !shift)
+ if (Math.Abs(MappedState.LY - 127) < 10)
if (LYN.Count > 0 || LYP.Count > 0)
{
foreach (DS4Controls dc in LYN)
@@ -866,7 +979,7 @@ namespace DS4Windows
}
else
MappedState.LY = cState.LY;
- if ((shift && MappedState.RX == 127) || !shift)
+ if (Math.Abs(MappedState.RX - 127) < 10)
if (RXN.Count > 0 || RXP.Count > 0)
{
foreach (DS4Controls dc in RXN)
@@ -878,7 +991,7 @@ namespace DS4Windows
}
else
MappedState.RX = cState.RX;
- if ((shift && MappedState.RY == 127) || !shift)
+ if (Math.Abs(MappedState.RY - 127) < 10)
if (RYN.Count > 0 || RYP.Count > 0)
{
foreach (DS4Controls dc in RYN)
@@ -893,692 +1006,366 @@ namespace DS4Windows
InputMethods.MoveCursorBy(MouseDeltaX, MouseDeltaY);
}
- public static void MapShiftCustom(int device, DS4State cState, DS4State MappedState, DS4StateExposed eState, Mouse tp)
+ private static bool IfAxisIsNotModified(int device, bool shift, DS4Controls dc)
{
- //cState.CopyTo(MappedState);
- SyntheticState deviceState = Mapping.deviceState[device];
- foreach (KeyValuePair customKey in getShiftCustomMacros(device)) //with delays
- {
- DS4KeyType keyType = getShiftCustomKeyType(device, customKey.Key);
- if (getBoolMapping(device, customKey.Key, cState, eState, tp))
- {
- resetToDefaultValue(customKey.Key, MappedState);
- PlayMacro(device, macroControl, customKey.Value, customKey.Key, keyType);
- }
- else if (!getBoolMapping(device, customKey.Key, cState, eState, tp))
- {
- EndMacro(device, macroControl, customKey.Value, customKey.Key);
- }
- }
- foreach (KeyValuePair customKey in getShiftCustomKeys(device))
- {
- DS4KeyType keyType = getShiftCustomKeyType(device, customKey.Key);
- if (getBoolMapping(device, customKey.Key, cState, eState, tp))
- {
- resetToDefaultValue(customKey.Key, MappedState);
- SyntheticState.KeyPresses kp;
- if (!deviceState.keyPresses.TryGetValue(customKey.Value, out kp))
- deviceState.keyPresses[customKey.Value] = kp = new SyntheticState.KeyPresses();
- if (keyType.HasFlag(DS4KeyType.ScanCode))
- kp.current.scanCodeCount++;
- else
- kp.current.vkCount++;
- if (keyType.HasFlag(DS4KeyType.Toggle))
- {
- if (!pressedonce[customKey.Value])
- {
- kp.current.toggle = !kp.current.toggle;
- pressedonce[customKey.Value] = true;
- }
- kp.current.toggleCount++;
- }
- kp.current.repeatCount++;
- }
- else
- pressedonce[customKey.Value] = false;
- }
-
- MappedState.LX = 127;
- MappedState.LY = 127;
- MappedState.RX = 127;
- MappedState.RY = 127;
- int MouseDeltaX = 0;
- int MouseDeltaY = 0;
-
- Dictionary customButtons = getShiftCustomButtons(device);
- //foreach (KeyValuePair customButton in customButtons)
- // resetToDefaultValue(customButton.Key, MappedState); // erase default mappings for things that are remapped
-
- List Cross = new List();
- List Circle = new List();
- List Square = new List();
- List Triangle = new List();
- List Options = new List();
- List Share = new List();
- List DpadUp = new List();
- List DpadDown = new List();
- List DpadLeft = new List();
- List DpadRight = new List();
- List PS = new List();
- List L1 = new List();
- List R1 = new List();
- List L2 = new List();
- List R2 = new List();
- List L3 = new List();
- List R3 = new List();
- List LXN = new List();
- List LXP = new List();
- List LYN = new List();
- List LYP = new List();
- List RXN = new List();
- List RXP = new List();
- List RYN = new List();
- List RYP = new List();
- foreach (KeyValuePair customButton in customButtons)
- {
- resetToDefaultValue(customButton.Key, MappedState); // erase default mappings for things that are remapped
- DS4KeyType keyType = getShiftCustomKeyType(device, customButton.Key);
- int keyvalue = 0;
- switch (customButton.Value)
- {
- case X360Controls.LeftMouse: keyvalue = 256; break;
- case X360Controls.RightMouse: keyvalue = 257; break;
- case X360Controls.MiddleMouse: keyvalue = 258; break;
- case X360Controls.FourthMouse: keyvalue = 259; break;
- case X360Controls.FifthMouse: keyvalue = 260; break;
- }
- if (keyType.HasFlag(DS4KeyType.Toggle))
- {
- if (getBoolMapping(device, customButton.Key, cState, eState, tp))
- {
- if (!pressedonce[keyvalue])
- {
- deviceState.currentClicks.toggle = !deviceState.currentClicks.toggle;
- pressedonce[keyvalue] = true;
- }
- deviceState.currentClicks.toggleCount++;
- }
- else
- {
- pressedonce[keyvalue] = false;
- }
- }
- switch (customButton.Value)
- {
- case X360Controls.A: Cross.Add(customButton.Key); break;
- case X360Controls.B: Circle.Add(customButton.Key); break;
- case X360Controls.X: Square.Add(customButton.Key); break;
- case X360Controls.Y: Triangle.Add(customButton.Key); break;
- case X360Controls.LB: L1.Add(customButton.Key); break;
- case X360Controls.LS: L3.Add(customButton.Key); break;
- case X360Controls.RB: R1.Add(customButton.Key); break;
- case X360Controls.RS: R3.Add(customButton.Key); break;
- case X360Controls.DpadUp: DpadUp.Add(customButton.Key); break;
- case X360Controls.DpadDown: DpadDown.Add(customButton.Key); break;
- case X360Controls.DpadLeft: DpadLeft.Add(customButton.Key); break;
- case X360Controls.DpadRight: DpadRight.Add(customButton.Key); break;
- case X360Controls.Start: Options.Add(customButton.Key); break;
- case X360Controls.Guide: PS.Add(customButton.Key); break;
- case X360Controls.Back: Share.Add(customButton.Key); break;
- case X360Controls.LXNeg: LXN.Add(customButton.Key); break;
- case X360Controls.LYNeg: LYN.Add(customButton.Key); break;
- case X360Controls.RXNeg: RXN.Add(customButton.Key); break;
- case X360Controls.RYNeg: RYN.Add(customButton.Key); break;
- case X360Controls.LXPos: LXP.Add(customButton.Key); break;
- case X360Controls.LYPos: LYP.Add(customButton.Key); break;
- case X360Controls.RXPos: RXP.Add(customButton.Key); break;
- case X360Controls.RYPos: RYP.Add(customButton.Key); break;
- case X360Controls.LT: L2.Add(customButton.Key); break;
- case X360Controls.RT: R2.Add(customButton.Key); break;
- case X360Controls.LeftMouse:
- if (getBoolMapping(device, customButton.Key, cState, eState, tp))
- deviceState.currentClicks.leftCount++;
- break;
- case X360Controls.RightMouse:
- if (getBoolMapping(device, customButton.Key, cState, eState, tp))
- deviceState.currentClicks.rightCount++;
- break;
- case X360Controls.MiddleMouse:
- if (getBoolMapping(device, customButton.Key, cState, eState, tp))
- deviceState.currentClicks.middleCount++;
- break;
- case X360Controls.FourthMouse:
- if (getBoolMapping(device, customButton.Key, cState, eState, tp))
- deviceState.currentClicks.fourthCount++;
- break;
- case X360Controls.FifthMouse:
- if (getBoolMapping(device, customButton.Key, cState, eState, tp))
- deviceState.currentClicks.fifthCount++;
- break;
- case X360Controls.WUP:
- if (getBoolMapping(device, customButton.Key, cState, eState, tp))
- deviceState.currentClicks.wUpCount++;
- break;
- case X360Controls.WDOWN:
- if (getBoolMapping(device, customButton.Key, cState, eState, tp))
- deviceState.currentClicks.wDownCount++;
- break;
- case X360Controls.MouseUp:
- if (MouseDeltaY == 0)
- {
- MouseDeltaY = getMouseMapping(device, customButton.Key, cState, eState, 0);
- MouseDeltaY = -Math.Abs((MouseDeltaY == -2147483648 ? 0 : MouseDeltaY));
- }
- break;
- case X360Controls.MouseDown:
- if (MouseDeltaY == 0)
- {
- MouseDeltaY = getMouseMapping(device, customButton.Key, cState, eState, 1);
- MouseDeltaY = Math.Abs((MouseDeltaY == -2147483648 ? 0 : MouseDeltaY));
- }
- break;
- case X360Controls.MouseLeft:
- if (MouseDeltaX == 0)
- {
- MouseDeltaX = getMouseMapping(device, customButton.Key, cState, eState, 2);
- MouseDeltaX = -Math.Abs((MouseDeltaX == -2147483648 ? 0 : MouseDeltaX));
- }
- break;
- case X360Controls.MouseRight:
- if (MouseDeltaX == 0)
- {
- MouseDeltaX = getMouseMapping(device, customButton.Key, cState, eState, 3);
- MouseDeltaX = Math.Abs((MouseDeltaX == -2147483648 ? 0 : MouseDeltaX));
- }
- break;
- }
- }
- if (macroControl[0]) MappedState.Cross = true;
- if (macroControl[1]) MappedState.Circle = true;
- if (macroControl[2]) MappedState.Square = true;
- if (macroControl[3]) MappedState.Triangle = true;
- if (macroControl[4]) MappedState.Options = true;
- if (macroControl[5]) MappedState.Share = true;
- if (macroControl[6]) MappedState.DpadUp = true;
- if (macroControl[7]) MappedState.DpadDown = true;
- if (macroControl[8]) MappedState.DpadLeft = true;
- if (macroControl[9]) MappedState.DpadRight = true;
- if (macroControl[10]) MappedState.PS = true;
- if (macroControl[11]) MappedState.L1 = true;
- if (macroControl[12]) MappedState.R1 = true;
- if (macroControl[13]) MappedState.L2 = 255;
- if (macroControl[14]) MappedState.R2 = 255;
- if (macroControl[15]) MappedState.L3 = true;
- if (macroControl[16]) MappedState.R3 = true;
- if (macroControl[17]) MappedState.LX = 255;
- if (macroControl[18]) MappedState.LX = 0;
- if (macroControl[19]) MappedState.LY = 255;
- if (macroControl[20]) MappedState.LY = 0;
- if (macroControl[21]) MappedState.RX = 255;
- if (macroControl[22]) MappedState.RX = 0;
- if (macroControl[23]) MappedState.RY = 255;
- if (macroControl[24]) MappedState.RY = 0;
- foreach (DS4Controls dc in Cross)
- if (getBoolMapping(device, dc, cState, eState, tp))
- MappedState.Cross = true;
- foreach (DS4Controls dc in Circle)
- if (getBoolMapping(device, dc, cState, eState, tp))
- MappedState.Circle = true;
- foreach (DS4Controls dc in Square)
- if (getBoolMapping(device, dc, cState, eState, tp))
- MappedState.Square = true;
- foreach (DS4Controls dc in Triangle)
- if (getBoolMapping(device, dc, cState, eState, tp))
- MappedState.Triangle = true;
- foreach (DS4Controls dc in L1)
- if (getBoolMapping(device, dc, cState, eState, tp))
- MappedState.L1 = true;
- foreach (DS4Controls dc in L2)
- if (getByteMapping(device, dc, cState, eState, tp) != 0)
- MappedState.L2 = getByteMapping(device, dc, cState, eState, tp);
- foreach (DS4Controls dc in L3)
- if (getBoolMapping(device, dc, cState, eState, tp))
- MappedState.L3 = true;
- foreach (DS4Controls dc in R1)
- if (getBoolMapping(device, dc, cState, eState, tp))
- MappedState.R1 = true;
- foreach (DS4Controls dc in R2)
- if (getByteMapping(device, dc, cState, eState, tp) != 0)
- MappedState.R2 = getByteMapping(device, dc, cState, eState, tp);
- foreach (DS4Controls dc in R3)
- if (getBoolMapping(device, dc, cState, eState, tp))
- MappedState.R3 = true;
- foreach (DS4Controls dc in DpadUp)
- if (getBoolMapping(device, dc, cState, eState, tp))
- MappedState.DpadUp = true;
- foreach (DS4Controls dc in DpadRight)
- if (getBoolMapping(device, dc, cState, eState, tp))
- MappedState.DpadRight = true;
- foreach (DS4Controls dc in DpadLeft)
- if (getBoolMapping(device, dc, cState, eState, tp))
- MappedState.DpadLeft = true;
- foreach (DS4Controls dc in DpadDown)
- if (getBoolMapping(device, dc, cState, eState, tp))
- MappedState.DpadDown = true;
- foreach (DS4Controls dc in Options)
- if (getBoolMapping(device, dc, cState, eState, tp))
- MappedState.Options = true;
- foreach (DS4Controls dc in Share)
- if (getBoolMapping(device, dc, cState, eState, tp))
- MappedState.Share = true;
- foreach (DS4Controls dc in PS)
- if (getBoolMapping(device, dc, cState, eState, tp))
- MappedState.PS = true;
-
- if (getShiftCustomButton(device, DS4Controls.LXNeg) == X360Controls.None)
- LXN.Add(DS4Controls.LXNeg);
- if (getShiftCustomButton(device, DS4Controls.LXPos) == X360Controls.None)
- LXP.Add(DS4Controls.LXPos);
- if (getShiftCustomButton(device, DS4Controls.LYNeg) == X360Controls.None)
- LYN.Add(DS4Controls.LYNeg);
- if (getShiftCustomButton(device, DS4Controls.LYPos) == X360Controls.None)
- LYP.Add(DS4Controls.LYPos);
- if (getShiftCustomButton(device, DS4Controls.RXNeg) == X360Controls.None)
- RXN.Add(DS4Controls.RXNeg);
- if (getShiftCustomButton(device, DS4Controls.RXPos) == X360Controls.None)
- RXP.Add(DS4Controls.RXPos);
- if (getShiftCustomButton(device, DS4Controls.RYNeg) == X360Controls.None)
- RYN.Add(DS4Controls.RYNeg);
- if (getShiftCustomButton(device, DS4Controls.RYPos) == X360Controls.None)
- RYP.Add(DS4Controls.RYPos);
- if (LXN.Count > 0 || LXP.Count > 0)
- {
- foreach (DS4Controls dc in LXP)
- if (Math.Abs(127 - getXYAxisMapping(device, dc, cState, eState, tp, true)) > 5)
- MappedState.LX = getXYAxisMapping(device, dc, cState, eState, tp, true);
- foreach (DS4Controls dc in LXN)
- if (Math.Abs(127 - getXYAxisMapping(device, dc, cState, eState, tp)) > 5)
- MappedState.LX = getXYAxisMapping(device, dc, cState, eState, tp);
- }
- else
- MappedState.LX = cState.LX;
- if (LYN.Count > 0 || LYP.Count > 0)
- {
- foreach (DS4Controls dc in LYN)
- if (Math.Abs(127 - getXYAxisMapping(device, dc, cState, eState, tp)) > 5)
- MappedState.LY = getXYAxisMapping(device, dc, cState, eState, tp);
- foreach (DS4Controls dc in LYP)
- if (Math.Abs(127 - getXYAxisMapping(device, dc, cState, eState, tp, true)) > 5)
- MappedState.LY = getXYAxisMapping(device, dc, cState, eState, tp, true);
- }
- else
- MappedState.LY = cState.LY;
- if (RXN.Count > 0 || RXP.Count > 0)
- {
- foreach (DS4Controls dc in RXN)
- {
- if (Math.Abs(127 - getXYAxisMapping(device, dc, cState, eState, tp)) > 5)
- {
- MappedState.RX = getXYAxisMapping(device, dc, cState, eState, tp);
- }
- }
- foreach (DS4Controls dc in RXP)
- if (Math.Abs(127 - getXYAxisMapping(device, dc, cState, eState, tp, true)) > 5)
- MappedState.RX = getXYAxisMapping(device, dc, cState, eState, tp, true);
- }
- else
- MappedState.RX = cState.RX;
- if (RYN.Count > 0 || RYP.Count > 0)
- {
- foreach (DS4Controls dc in RYN)
- if (Math.Abs(127 - getXYAxisMapping(device, dc, cState, eState, tp)) > 5)
- MappedState.RY = getXYAxisMapping(device, dc, cState, eState, tp);
- foreach (DS4Controls dc in RYP)
- if (Math.Abs(127 - getXYAxisMapping(device, dc, cState, eState, tp, true)) > 5)
- MappedState.RY = getXYAxisMapping(device, dc, cState, eState, tp, true);
- }
- else
- MappedState.RY = cState.RY;
- InputMethods.MoveCursorBy(MouseDeltaX, MouseDeltaY);
+ return shift ? GetDS4Action(device, DS4Controls.LXNeg.ToString(), true) == null : GetDS4Action(device, DS4Controls.LXNeg.ToString(), false) == null;
}
-
public static async void MapCustomAction(int device, DS4State cState, DS4State MappedState, DS4StateExposed eState, Mouse tp, ControlService ctrl)
{
- foreach (string actionname in ProfileActions[device])
- {
- //DS4KeyType keyType = getShiftCustomKeyType(device, customKey.Key);
- SpecialAction action = GetAction(actionname);
- int index = GetActionIndexOf(actionname);
- 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
- bool triggerToBeTapped = action.type == "Key" && action.trigger.Count == 1 &&
- (getCustomMacro(device, action.trigger[0]) != "0" ||
- getCustomKey(device, action.trigger[0]) != 0 ||
- getCustomButton(device, action.trigger[0]) != X360Controls.None);
- if (!(action.name == "null" || index < 0))
+ try {
+ foreach (string actionname in ProfileActions[device])
{
- bool triggeractivated = true;
- if (action.delayTime > 0)
+ //DS4KeyType keyType = getShiftCustomKeyType(device, customKey.Key);
+ SpecialAction action = GetAction(actionname);
+ int index = GetActionIndexOf(actionname);
+ 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
+ bool triggerToBeTapped = action.type == "Key" && action.trigger.Count == 1 &&
+ GetDS4Action(device, action.trigger[0].ToString(), false) == null;
+ if (!(action.name == "null" || index < 0))
{
- triggeractivated = false;
- bool subtriggeractivated = true;
- foreach (DS4Controls dc in action.trigger)
+ bool triggeractivated = true;
+ if (action.delayTime > 0)
{
- if (!getBoolMapping(device, dc, cState, eState, tp))
- {
- subtriggeractivated = false;
- break;
- }
- }
- if (subtriggeractivated)
- {
- time = action.delayTime;
- nowAction[device] = DateTime.UtcNow;
- if (nowAction[device] >= oldnowAction[device] + TimeSpan.FromSeconds(time))
- triggeractivated = true;
- }
- else if (nowAction[device] < DateTime.UtcNow - TimeSpan.FromMilliseconds(100))
- oldnowAction[device] = DateTime.UtcNow;
- }
- else if (triggerToBeTapped && oldnowKeyAct[device] == DateTime.MinValue)
- {
- triggeractivated = false;
- bool subtriggeractivated = true;
- foreach (DS4Controls dc in action.trigger)
- {
- if (!getBoolMapping(device, dc, cState, eState, tp))
- {
- subtriggeractivated = false;
- break;
- }
- }
- if (subtriggeractivated)
- {
- oldnowKeyAct[device] = DateTime.UtcNow;
- }
- }
- else if (triggerToBeTapped && oldnowKeyAct[device] != DateTime.MinValue)
- {
- triggeractivated = false;
- bool subtriggeractivated = true;
- foreach (DS4Controls dc in action.trigger)
- {
- if (!getBoolMapping(device, dc, cState, eState, tp))
- {
- subtriggeractivated = false;
- break;
- }
- }
- DateTime now = DateTime.UtcNow;
- if (!subtriggeractivated && now <= oldnowKeyAct[device] + TimeSpan.FromMilliseconds(250))
- {
- await Task.Delay(3); //if the button is assigned to the same key use a delay so the key down is the last action, not key up
- triggeractivated = true;
- oldnowKeyAct[device] = DateTime.MinValue;
- }
- else if (!subtriggeractivated)
- oldnowKeyAct[device] = DateTime.MinValue;
- }
- else
- foreach (DS4Controls dc in action.trigger)
- {
- if (!getBoolMapping(device, dc, cState, eState, tp))
- {
- triggeractivated = false;
- break;
- }
- }
-
- bool utriggeractivated = true;
- if (action.type == "Key" && action.uTrigger.Count > 0)
- {
- foreach (DS4Controls dc in action.uTrigger)
- {
- if (!getBoolMapping(device, dc, cState, eState, tp))
- {
- utriggeractivated = false;
- break;
- }
- }
- if (action.pressRelease) utriggeractivated = !utriggeractivated;
- }
-
- if (triggeractivated && action.type == "Program")
- {
- if (!actionDone[device, index])
- {
- actionDone[device, index] = true;
- if (!string.IsNullOrEmpty(action.extra))
- Process.Start(action.details, action.extra);
- else
- Process.Start(action.details);
- }
- }
- else if (triggeractivated && action.type == "Profile")
- {
- if (!actionDone[device, index] && string.IsNullOrEmpty(tempprofilename[device]))
- {
- actionDone[device, index] = true;
- untriggeraction[device] = action;
- untriggerindex[device] = index;
+ triggeractivated = false;
+ bool subtriggeractivated = true;
foreach (DS4Controls dc in action.trigger)
{
- InputMethods.performKeyRelease(getCustomKey(0, dc));
- string[] skeys = getCustomMacro(0, dc).Split('/');
- ushort[] keys = new ushort[skeys.Length];
- for (int i = 0; i < keys.Length; i++)
+ if (!getBoolMapping(device, dc, cState, eState, tp))
{
- keys[i] = ushort.Parse(skeys[i]);
- InputMethods.performKeyRelease(keys[i]);
+ subtriggeractivated = false;
+ break;
}
}
- LoadTempProfile(device, action.details, true, ctrl);
- return;
+ if (subtriggeractivated)
+ {
+ time = action.delayTime;
+ nowAction[device] = DateTime.UtcNow;
+ if (nowAction[device] >= oldnowAction[device] + TimeSpan.FromSeconds(time))
+ triggeractivated = true;
+ }
+ else if (nowAction[device] < DateTime.UtcNow - TimeSpan.FromMilliseconds(100))
+ oldnowAction[device] = DateTime.UtcNow;
}
- }
- else if (triggeractivated && action.type == "Macro")
- {
- if (!actionDone[device, index])
+ else if (triggerToBeTapped && oldnowKeyAct[device] == DateTime.MinValue)
{
- DS4KeyType keyType = action.keyType;
- actionDone[device, index] = true;
+ triggeractivated = false;
+ bool subtriggeractivated = true;
foreach (DS4Controls dc in action.trigger)
- resetToDefaultValue(dc, MappedState);
- PlayMacro(device, macroControl, String.Join("/", action.macro), DS4Controls.None, keyType);
+ {
+ if (!getBoolMapping(device, dc, cState, eState, tp))
+ {
+ subtriggeractivated = false;
+ break;
+ }
+ }
+ if (subtriggeractivated)
+ {
+ oldnowKeyAct[device] = DateTime.UtcNow;
+ }
+ }
+ else if (triggerToBeTapped && oldnowKeyAct[device] != DateTime.MinValue)
+ {
+ triggeractivated = false;
+ bool subtriggeractivated = true;
+ foreach (DS4Controls dc in action.trigger)
+ {
+ if (!getBoolMapping(device, dc, cState, eState, tp))
+ {
+ subtriggeractivated = false;
+ break;
+ }
+ }
+ DateTime now = DateTime.UtcNow;
+ if (!subtriggeractivated && now <= oldnowKeyAct[device] + TimeSpan.FromMilliseconds(250))
+ {
+ await Task.Delay(3); //if the button is assigned to the same key use a delay so the key down is the last action, not key up
+ triggeractivated = true;
+ oldnowKeyAct[device] = DateTime.MinValue;
+ }
+ else if (!subtriggeractivated)
+ oldnowKeyAct[device] = DateTime.MinValue;
}
else
- EndMacro(device, macroControl, String.Join("/", action.macro), DS4Controls.None);
- }
- else if (triggeractivated && action.type == "Key")
- {
- if (action.uTrigger.Count == 0 || (action.uTrigger.Count > 0 && untriggerindex[device] == -1 && !actionDone[device, index]))
- {
- actionDone[device, index] = true;
- untriggerindex[device] = index;
- ushort key;
- ushort.TryParse(action.details, out key);
- if (action.uTrigger.Count == 0)
- {
- SyntheticState.KeyPresses kp;
- if (!deviceState[device].keyPresses.TryGetValue(key, out kp))
- deviceState[device].keyPresses[key] = kp = new SyntheticState.KeyPresses();
- if (action.keyType.HasFlag(DS4KeyType.ScanCode))
- kp.current.scanCodeCount++;
- else
- kp.current.vkCount++;
- kp.current.repeatCount++;
- }
- else if (action.keyType.HasFlag(DS4KeyType.ScanCode))
- InputMethods.performSCKeyPress(key);
- else
- InputMethods.performKeyPress(key);
- }
- }
- else if (action.uTrigger.Count > 0 && utriggeractivated && action.type == "Key")
- {
- if (untriggerindex[device] > -1 && !actionDone[device, index])
- {
- actionDone[device, index] = true;
- untriggerindex[device] = -1;
- ushort key;
- ushort.TryParse(action.details, out key);
- if (action.keyType.HasFlag(DS4KeyType.ScanCode))
- InputMethods.performSCKeyRelease(key);
- else
- InputMethods.performKeyRelease(key);
- }
- }
- else if (triggeractivated && action.type == "DisconnectBT")
- {
- DS4Device d = ctrl.DS4Controllers[device];
- if (!d.Charging)
- {
- d.DisconnectBT();
foreach (DS4Controls dc in action.trigger)
{
- InputMethods.performKeyRelease(getCustomKey(0, dc));
- string[] skeys = getCustomMacro(0, dc).Split('/');
- ushort[] keys = new ushort[skeys.Length];
- for (int i = 0; i < keys.Length; i++)
+ if (!getBoolMapping(device, dc, cState, eState, tp))
{
- keys[i] = ushort.Parse(skeys[i]);
- InputMethods.performKeyRelease(keys[i]);
+ triggeractivated = false;
+ break;
}
}
- return;
- }
- }
- else if (triggeractivated && action.type == "BatteryCheck")
- {
- string[] dets = action.details.Split(',');
- if (bool.Parse(dets[1]) && !actionDone[device, index])
+
+ bool utriggeractivated = true;
+ if (action.type == "Key" && action.uTrigger.Count > 0)
{
- Log.LogToTray("Controller " + (device + 1) + ": " +
- ctrl.getDS4Battery(device), true);
- }
- if (bool.Parse(dets[2]))
- {
- DS4Device d = ctrl.DS4Controllers[device];
- if (!actionDone[device, index])
+ foreach (DS4Controls dc in action.uTrigger)
{
- lastColor[device] = d.LightBarColor;
- DS4LightBar.forcelight[device] = true;
- }
- DS4Color empty = new DS4Color(byte.Parse(dets[3]), byte.Parse(dets[4]), byte.Parse(dets[5]));
- DS4Color full = new DS4Color(byte.Parse(dets[6]), byte.Parse(dets[7]), byte.Parse(dets[8]));
- DS4Color trans = getTransitionedColor(empty, full, d.Battery);
- if (fadetimer[device] < 100)
- DS4LightBar.forcedColor[device] = getTransitionedColor(lastColor[device], trans, fadetimer[device] += 2);
- }
- actionDone[device, index] = true;
- }
- else if (!triggeractivated && action.type == "BatteryCheck")
- {
- if (actionDone[device, index])
- {
- fadetimer[device] = 0;
- /*if (prevFadetimer[device] == fadetimer[device])
- {
- prevFadetimer[device] = 0;
- fadetimer[device] = 0;
- }
- else
- prevFadetimer[device] = fadetimer[device];*/
- DS4LightBar.forcelight[device] = false;
- actionDone[device, index] = false;
- }
- }
- else if (action.type == "XboxGameDVR")
- {
- if (getCustomButton(device, action.trigger[0]) != X360Controls.Unbound)
- getCustomButtons(device)[action.trigger[0]] = X360Controls.Unbound;
- if (getCustomMacro(device, action.trigger[0]) != "0")
- getCustomMacros(device).Remove(action.trigger[0]);
- if (getCustomKey(device, action.trigger[0]) != 0)
- getCustomMacros(device).Remove(action.trigger[0]);
- string[] dets = action.details.Split(',');
- DS4Device d = ctrl.DS4Controllers[device];
- //cus
- if (getBoolMapping(device, action.trigger[0], cState, eState, tp) && !getBoolMapping(device, action.trigger[0], d.getPreviousState(), eState, tp))
- {//pressed down
- pastTime = DateTime.UtcNow;
- if (DateTime.UtcNow <= (firstTap + TimeSpan.FromMilliseconds(150)))
- {
- tappedOnce = false;
- secondtouchbegin = true;
- }
- else
- firstTouch = true;
- }
- else if (!getBoolMapping(device, action.trigger[0], cState, eState, tp) && getBoolMapping(device, action.trigger[0], d.getPreviousState(), eState, tp))
- {//released
- if (secondtouchbegin)
- {
- firstTouch = false;
- secondtouchbegin = false;
- }
- else if (firstTouch)
- {
- firstTouch = false;
- if (DateTime.UtcNow <= (pastTime + TimeSpan.FromMilliseconds(200)) && !tappedOnce)
+ if (!getBoolMapping(device, dc, cState, eState, tp))
{
- tappedOnce = true;
- firstTap = DateTime.UtcNow;
- TimeofEnd = DateTime.UtcNow;
+ utriggeractivated = false;
+ break;
}
}
+ if (action.pressRelease) utriggeractivated = !utriggeractivated;
}
- int type = 0;
- string macro = "";
- if (tappedOnce) //single tap
+ if (triggeractivated && action.type == "Program")
{
- if (int.TryParse(dets[0], out type))
+ if (!actionDone[device, index])
{
- switch (type)
+ actionDone[device, index] = true;
+ if (!string.IsNullOrEmpty(action.extra))
+ Process.Start(action.details, action.extra);
+ else
+ Process.Start(action.details);
+ }
+ }
+ else if (triggeractivated && action.type == "Profile")
+ {
+ if (!actionDone[device, index] && string.IsNullOrEmpty(tempprofilename[device]))
+ {
+ actionDone[device, index] = true;
+ untriggeraction[device] = action;
+ untriggerindex[device] = index;
+ foreach (DS4Controls dc in action.trigger)
{
- case 0: macro = "91/71/71/91"; break;
- case 1: macro = "91/164/82/82/164/91"; break;
- case 2: macro = "91/164/44/44/164/91"; break;
- case 3: macro = dets[3] + "/" + dets[3]; break;
- case 4: macro = "91/164/71/71/164/91"; break;
+ DS4ControlSettings dcs = getDS4CSetting(device, dc.ToString());
+ if (dcs.action != null)
+ {
+ if (dcs.actionType == DS4ControlSettings.ActionType.Key)
+ InputMethods.performKeyRelease(ushort.Parse(action.ToString()));
+ else if (dcs.actionType == DS4ControlSettings.ActionType.Macro)
+ {
+ int[] keys = (int[])dcs.action;
+ for (int i = 0; i < keys.Length; i++)
+ InputMethods.performKeyRelease((ushort)keys[i]);
+ }
+ }
+ }
+ LoadTempProfile(device, action.details, true, ctrl);
+ return;
+ }
+ }
+ else if (triggeractivated && action.type == "Macro")
+ {
+ if (!actionDone[device, index])
+ {
+ DS4KeyType keyType = action.keyType;
+ actionDone[device, index] = true;
+ foreach (DS4Controls dc in action.trigger)
+ resetToDefaultValue(dc, MappedState);
+ PlayMacro(device, macroControl, String.Join("/", action.macro), DS4Controls.None, keyType);
+ }
+ else
+ EndMacro(device, macroControl, String.Join("/", action.macro), DS4Controls.None);
+ }
+ else if (triggeractivated && action.type == "Key")
+ {
+ if (action.uTrigger.Count == 0 || (action.uTrigger.Count > 0 && untriggerindex[device] == -1 && !actionDone[device, index]))
+ {
+ actionDone[device, index] = true;
+ untriggerindex[device] = index;
+ ushort key;
+ ushort.TryParse(action.details, out key);
+ if (action.uTrigger.Count == 0)
+ {
+ SyntheticState.KeyPresses kp;
+ if (!deviceState[device].keyPresses.TryGetValue(key, out kp))
+ deviceState[device].keyPresses[key] = kp = new SyntheticState.KeyPresses();
+ if (action.keyType.HasFlag(DS4KeyType.ScanCode))
+ kp.current.scanCodeCount++;
+ else
+ kp.current.vkCount++;
+ kp.current.repeatCount++;
+ }
+ else if (action.keyType.HasFlag(DS4KeyType.ScanCode))
+ InputMethods.performSCKeyPress(key);
+ else
+ InputMethods.performKeyPress(key);
+ }
+ }
+ else if (action.uTrigger.Count > 0 && utriggeractivated && action.type == "Key")
+ {
+ if (untriggerindex[device] > -1 && !actionDone[device, index])
+ {
+ actionDone[device, index] = true;
+ untriggerindex[device] = -1;
+ ushort key;
+ ushort.TryParse(action.details, out key);
+ if (action.keyType.HasFlag(DS4KeyType.ScanCode))
+ InputMethods.performSCKeyRelease(key);
+ else
+ InputMethods.performKeyRelease(key);
+ }
+ }
+ else if (triggeractivated && action.type == "DisconnectBT")
+ {
+ DS4Device d = ctrl.DS4Controllers[device];
+ if (!d.Charging)
+ {
+ d.DisconnectBT();
+ foreach (DS4Controls dc in action.trigger)
+ {
+ DS4ControlSettings dcs = getDS4CSetting(device, dc.ToString());
+ if (dcs.action != null)
+ {
+ if (dcs.actionType == DS4ControlSettings.ActionType.Key)
+ InputMethods.performKeyRelease((ushort)dcs.action);
+ else if (dcs.actionType == DS4ControlSettings.ActionType.Macro)
+ {
+ int[] keys = (int[])dcs.action;
+ for (int i = 0; i < keys.Length; i++)
+ InputMethods.performKeyRelease((ushort)keys[i]);
+ }
+ }
+ }
+ return;
+ }
+ }
+ else if (triggeractivated && action.type == "BatteryCheck")
+ {
+ string[] dets = action.details.Split(',');
+ if (bool.Parse(dets[1]) && !actionDone[device, index])
+ {
+ Log.LogToTray("Controller " + (device + 1) + ": " +
+ ctrl.getDS4Battery(device), true);
+ }
+ if (bool.Parse(dets[2]))
+ {
+ DS4Device d = ctrl.DS4Controllers[device];
+ if (!actionDone[device, index])
+ {
+ lastColor[device] = d.LightBarColor;
+ DS4LightBar.forcelight[device] = true;
+ }
+ DS4Color empty = new DS4Color(byte.Parse(dets[3]), byte.Parse(dets[4]), byte.Parse(dets[5]));
+ DS4Color full = new DS4Color(byte.Parse(dets[6]), byte.Parse(dets[7]), byte.Parse(dets[8]));
+ DS4Color trans = getTransitionedColor(empty, full, d.Battery);
+ if (fadetimer[device] < 100)
+ DS4LightBar.forcedColor[device] = getTransitionedColor(lastColor[device], trans, fadetimer[device] += 2);
+ }
+ actionDone[device, index] = true;
+ }
+ else if (!triggeractivated && action.type == "BatteryCheck")
+ {
+ if (actionDone[device, index])
+ {
+ fadetimer[device] = 0;
+ /*if (prevFadetimer[device] == fadetimer[device])
+ {
+ prevFadetimer[device] = 0;
+ fadetimer[device] = 0;
+ }
+ else
+ prevFadetimer[device] = fadetimer[device];*/
+ DS4LightBar.forcelight[device] = false;
+ actionDone[device, index] = false;
+ }
+ }
+ else if (action.type == "XboxGameDVR")
+ {
+ /*if (getCustomButton(device, action.trigger[0]) != X360Controls.Unbound)
+ getCustomButtons(device)[action.trigger[0]] = X360Controls.Unbound;
+ if (getCustomMacro(device, action.trigger[0]) != "0")
+ getCustomMacros(device).Remove(action.trigger[0]);
+ if (getCustomKey(device, action.trigger[0]) != 0)
+ getCustomMacros(device).Remove(action.trigger[0]);*/
+ string[] dets = action.details.Split(',');
+ DS4Device d = ctrl.DS4Controllers[device];
+ //cus
+ if (getBoolMapping(device, action.trigger[0], cState, eState, tp) && !getBoolMapping(device, action.trigger[0], d.getPreviousState(), eState, tp))
+ {//pressed down
+ pastTime = DateTime.UtcNow;
+ if (DateTime.UtcNow <= (firstTap + TimeSpan.FromMilliseconds(150)))
+ {
+ tappedOnce = false;
+ secondtouchbegin = true;
+ }
+ else
+ firstTouch = true;
+ }
+ else if (!getBoolMapping(device, action.trigger[0], cState, eState, tp) && getBoolMapping(device, action.trigger[0], d.getPreviousState(), eState, tp))
+ {//released
+ if (secondtouchbegin)
+ {
+ firstTouch = false;
+ secondtouchbegin = false;
+ }
+ else if (firstTouch)
+ {
+ firstTouch = false;
+ if (DateTime.UtcNow <= (pastTime + TimeSpan.FromMilliseconds(200)) && !tappedOnce)
+ {
+ tappedOnce = true;
+ firstTap = DateTime.UtcNow;
+ TimeofEnd = DateTime.UtcNow;
+ }
}
}
- if ((DateTime.UtcNow - TimeofEnd) > TimeSpan.FromMilliseconds(150))
+
+ int type = 0;
+ string macro = "";
+ if (tappedOnce) //single tap
{
+ if (int.TryParse(dets[0], out type))
+ {
+ switch (type)
+ {
+ case 0: macro = "91/71/71/91"; break;
+ case 1: macro = "91/164/82/82/164/91"; break;
+ case 2: macro = "91/164/44/44/164/91"; break;
+ case 3: macro = dets[3] + "/" + dets[3]; break;
+ case 4: macro = "91/164/71/71/164/91"; break;
+ }
+ }
+ if ((DateTime.UtcNow - TimeofEnd) > TimeSpan.FromMilliseconds(150))
+ {
+ 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))
+ {
+ switch (type)
+ {
+ case 0: macro = "91/71/71/91"; break;
+ case 1: macro = "91/164/82/82/164/91"; break;
+ case 2: macro = "91/164/44/44/164/91"; break;
+ case 3: macro = dets[3] + "/" + dets[3]; break;
+ case 4: macro = "91/164/71/71/164/91"; break;
+ }
+ }
PlayMacro(device, macroControl, macro, DS4Controls.None, DS4KeyType.None);
- tappedOnce = false;
+ firstTouch = 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))
+ else if (secondtouchbegin) //if double tap
{
- switch (type)
+ if (int.TryParse(dets[2], out type))
{
- case 0: macro = "91/71/71/91"; break;
- case 1: macro = "91/164/82/82/164/91"; break;
- case 2: macro = "91/164/44/44/164/91"; break;
- case 3: macro = dets[3] + "/" + dets[3]; break;
- case 4: macro = "91/164/71/71/164/91"; break;
+ switch (type)
+ {
+ case 0: macro = "91/71/71/91"; break;
+ case 1: macro = "91/164/82/82/164/91"; break;
+ case 2: macro = "91/164/44/44/164/91"; break;
+ case 3: macro = dets[3] + "/" + dets[3]; break;
+ case 4: macro = "91/164/71/71/164/91"; break;
+ }
}
+ PlayMacro(device, macroControl, macro, DS4Controls.None, DS4KeyType.None);
+ secondtouchbegin = false;
}
- PlayMacro(device, macroControl, macro, DS4Controls.None, DS4KeyType.None);
- firstTouch = false;
- }
- else if (secondtouchbegin) //if double tap
- {
- if (int.TryParse(dets[2], out type))
- {
- switch (type)
- {
- case 0: macro = "91/71/71/91"; break;
- case 1: macro = "91/164/82/82/164/91"; break;
- case 2: macro = "91/164/44/44/164/91"; break;
- case 3: macro = dets[3] + "/" + dets[3]; break;
- case 4: macro = "91/164/71/71/164/91"; break;
- }
- }
- PlayMacro(device, macroControl, macro, DS4Controls.None, DS4KeyType.None);
- secondtouchbegin = false;
}
+ else
+ actionDone[device, index] = false;
}
- else
- actionDone[device, index] = false;
}
}
+ catch { return; }
if (untriggeraction[device] != null)
{
@@ -1603,13 +1390,17 @@ namespace DS4Windows
foreach (DS4Controls dc in action.uTrigger)
{
actionDone[device, index] = true;
- InputMethods.performKeyRelease(getCustomKey(0, dc));
- string[] skeys = getCustomMacro(0, dc).Split('/');
- ushort[] keys = new ushort[skeys.Length];
- for (int i = 0; i < keys.Length; i++)
+ DS4ControlSettings dcs = getDS4CSetting(device, dc.ToString());
+ if (dcs.action != null)
{
- keys[i] = ushort.Parse(skeys[i]);
- InputMethods.performKeyRelease(keys[i]);
+ if (dcs.actionType == DS4ControlSettings.ActionType.Key)
+ InputMethods.performKeyRelease((ushort)dcs.action);
+ else if (dcs.actionType == DS4ControlSettings.ActionType.Macro)
+ {
+ int[] keys = (int[])dcs.action;
+ for (int i = 0; i < keys.Length; i++)
+ InputMethods.performKeyRelease((ushort)keys[i]);
+ }
}
}
untriggeraction[device] = null;
diff --git a/DS4Windows/DS4Control/Mouse.cs b/DS4Windows/DS4Control/Mouse.cs
index 2f444cf..bd90856 100644
--- a/DS4Windows/DS4Control/Mouse.cs
+++ b/DS4Windows/DS4Control/Mouse.cs
@@ -174,30 +174,18 @@ namespace DS4Windows
public bool dragging, dragging2;
private void synthesizeMouseButtons()
{
- if (Global.getCustomButton(deviceNum, DS4Controls.TouchLeft) == X360Controls.None &&
- Global.getCustomMacro(deviceNum, DS4Controls.TouchLeft) == "0" &&
- Global.getCustomKey(deviceNum, DS4Controls.TouchLeft) == 0 &&
- leftDown)
+ if (Global.GetDS4Action(deviceNum, DS4Controls.TouchLeft.ToString(), false) == null && leftDown)
{
Mapping.MapClick(deviceNum, Mapping.Click.Left);
dragging2 = true;
}
else
dragging2 = false;
- if (Global.getCustomButton(deviceNum, DS4Controls.TouchUpper) == X360Controls.None &&
- Global.getCustomMacro(deviceNum, DS4Controls.TouchUpper) == "0" &&
- Global.getCustomKey(deviceNum, DS4Controls.TouchUpper) == 0 &&
- upperDown)
+ if (Global.GetDS4Action(deviceNum, DS4Controls.TouchUpper.ToString(), false) == null && upperDown)
Mapping.MapClick(deviceNum, Mapping.Click.Middle);
- if (Global.getCustomButton(deviceNum, DS4Controls.TouchRight) == X360Controls.None &&
- Global.getCustomMacro(deviceNum, DS4Controls.TouchRight) == "0" &&
- Global.getCustomKey(deviceNum, DS4Controls.TouchRight) == 0 &&
- rightDown)
+ if (Global.GetDS4Action(deviceNum, DS4Controls.TouchRight.ToString(), false) == null && rightDown)
Mapping.MapClick(deviceNum, Mapping.Click.Left);
- if (Global.getCustomButton(deviceNum, DS4Controls.TouchMulti) == X360Controls.None &&
- Global.getCustomMacro(deviceNum, DS4Controls.TouchMulti) == "0" &&
- Global.getCustomKey(deviceNum, DS4Controls.TouchMulti) == 0 &&
- multiDown)
+ if (Global.GetDS4Action(deviceNum, DS4Controls.TouchMulti.ToString(), false) == null && multiDown)
Mapping.MapClick(deviceNum, Mapping.Click.Right);
if (!Global.UseTPforControls[deviceNum])
{
diff --git a/DS4Windows/DS4Control/ScpUtil.cs b/DS4Windows/DS4Control/ScpUtil.cs
index 1ebab20..801e593 100644
--- a/DS4Windows/DS4Control/ScpUtil.cs
+++ b/DS4Windows/DS4Control/ScpUtil.cs
@@ -16,6 +16,72 @@ namespace DS4Windows
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, GyroXPos, GyroXNeg, GyroZPos, GyroZNeg, SwipeLeft, SwipeRight, SwipeUp, SwipeDown };
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, MouseUp, MouseDown, MouseLeft, MouseRight, Unbound };
+ public class DS4ControlSettings
+ {
+ public DS4Controls control;
+ public string extras = "0,0,0,0,0,0,0,0";
+ public DS4KeyType keyType = DS4KeyType.None;
+ public enum ActionType : byte { Default, Key, Button, Macro };
+ public ActionType actionType = ActionType.Default;
+ public object action = null;
+ public ActionType shiftActionType = ActionType.Default;
+ public object shiftAction = null;
+ public int shiftTrigger = 0;
+ public string shiftExtras = "0,0,0,0,0,0,0,0";
+ public DS4KeyType shiftKeyType = DS4KeyType.None;
+
+ public DS4ControlSettings(DS4Controls ctrl)
+ {
+ control = ctrl;
+ }
+
+ public void Reset()
+ {
+ extras = "0,0,0,0,0,0,0,0";
+ keyType = DS4KeyType.None;
+ actionType = ActionType.Default;
+ action = null;
+ shiftActionType = ActionType.Default;
+ shiftAction = null;
+ shiftTrigger = 0;
+ shiftExtras = "0,0,0,0,0,0,0,0";
+ shiftKeyType = DS4KeyType.None;
+ }
+
+ internal void UpdateSettings(bool shift, object act, string exts, DS4KeyType kt, int trigger = 0)
+ {
+ if (!shift)
+ {
+ if (act is int || act is ushort)
+ actionType = ActionType.Key;
+ else if (act is string || act is X360Controls)
+ actionType = ActionType.Button;
+ else if (act is int[])
+ actionType = ActionType.Macro;
+ else
+ actionType = ActionType.Default;
+ action = act;
+ extras = exts;
+ keyType = kt;
+ }
+ else
+ {
+ if (act is int || act is ushort)
+ shiftActionType = ActionType.Key;
+ else if (act is string || act is X360Controls)
+ shiftActionType = ActionType.Button;
+ else if (act is int[])
+ shiftActionType = ActionType.Macro;
+ else
+ shiftActionType = ActionType.Default;
+ shiftAction = act;
+ shiftExtras = exts;
+ shiftKeyType = kt;
+ shiftTrigger = trigger;
+ }
+ }
+ }
+
public class DebugEventArgs : EventArgs
{
protected DateTime m_Time = DateTime.Now;
@@ -225,8 +291,6 @@ namespace DS4Windows
public static bool[] UseCustomLed => m_Config.useCustomLeds;
public static DS4Color[] FlashColor => m_Config.m_FlashLeds;
- public static DS4Color[] ShiftColor => m_Config.m_ShiftLeds;
- public static bool[] ShiftColorOn => m_Config.shiftColorOn;
public static byte[] TapSensitivity => m_Config.tapSensitivity;
public static bool[] DoubleTap => m_Config.doubleTap;
public static int[] ScrollSensitivity => m_Config.scrollSensitivity;
@@ -248,10 +312,27 @@ namespace DS4Windows
public static double[] LSSens => m_Config.LSSens;
public static double[] RSSens => m_Config.RSSens;
public static bool[] MouseAccel => m_Config.mouseAccel;
- public static int[] ShiftModifier => m_Config.shiftModifier;
public static string[] LaunchProgram => m_Config.launchProgram;
public static string[] ProfilePath => m_Config.profilePath;
public static List[] ProfileActions => m_Config.profileActions;
+
+ public static void UpdateDS4CSetting (int deviceNum, string buttonName, bool shift, object action, string exts, DS4KeyType kt, int trigger = 0)
+ {
+ m_Config.UpdateDS4CSetting(deviceNum, buttonName, shift, action, exts, kt, trigger);
+ }
+ public static void UpdateDS4Extra(int deviceNum, string buttonName, bool shift, string exts)
+ {
+ m_Config.UpdateDS4CExtra(deviceNum, buttonName, shift, exts);
+ }
+
+ public static object GetDS4Action(int deviceNum, string buttonName, bool shift) => m_Config.GetDS4Action(deviceNum, buttonName, shift);
+ public static DS4KeyType GetDS4KeyType(int deviceNum, string buttonName, bool shift) => m_Config.GetDS4KeyType(deviceNum, buttonName, shift);
+ public static string GetDS4Extra(int deviceNum, string buttonName, bool shift) => m_Config.GetDS4Extra(deviceNum, buttonName, shift);
+ public static int GetDS4STrigger(int deviceNum, string buttonName) => m_Config.GetDS4STrigger(deviceNum, buttonName);
+ public static List getDS4CSettings(int device) => m_Config.ds4settings[device];
+ public static DS4ControlSettings getDS4CSetting(int deviceNum, string control) => m_Config.getDS4CSetting(deviceNum, control);
+ public static bool HasCustomAction(int deviceNum) => m_Config.HasCustomActions(deviceNum);
+ public static bool HasCustomExtras(int deviceNum) => m_Config.HasCustomExtras(deviceNum);
public static void SaveAction(string name, string controls, int mode, string details, bool edit, string extras = "")
{
@@ -284,7 +365,7 @@ namespace DS4Windows
}
- public static X360Controls getCustomButton(int device, DS4Controls controlName) => m_Config.GetCustomButton(device, controlName);
+ /*public static X360Controls getCustomButton(int device, DS4Controls controlName) => m_Config.GetCustomButton(device, controlName);
public static ushort getCustomKey(int device, DS4Controls controlName) => m_Config.GetCustomKey(device, controlName);
@@ -316,33 +397,29 @@ namespace DS4Windows
public static Dictionary getShiftCustomKeys(int device) => m_Config.shiftCustomMapKeys[device];
public static Dictionary getShiftCustomMacros(int device) => m_Config.shiftCustomMapMacros[device];
public static Dictionary getShiftCustomExtras(int device) => m_Config.shiftCustomMapExtras[device];
- public static Dictionary getShiftCustomKeyTypes(int device) => m_Config.shiftCustomMapKeyTypes[device];
+ public static Dictionary getShiftCustomKeyTypes(int device) => m_Config.shiftCustomMapKeyTypes[device]; */
public static bool Load() => m_Config.Load();
- public static void LoadProfile(int device, System.Windows.Forms.Control[] buttons, System.Windows.Forms.Control[] shiftbuttons, bool launchprogram, ControlService control)
- {
- m_Config.LoadProfile(device, buttons, shiftbuttons, launchprogram, control);
- tempprofilename[device] = string.Empty;
- }
public static void LoadProfile(int device, bool launchprogram, ControlService control)
{
- m_Config.LoadProfile(device, null, null, launchprogram, control);
+ m_Config.LoadProfile(device, launchprogram, control);
tempprofilename[device] = string.Empty;
-
}
+
public static void LoadTempProfile(int device, string name, bool launchprogram, ControlService control)
{
- m_Config.LoadProfile(device, null, null, launchprogram, control, appdatapath + @"\Profiles\" + name + ".xml");
+ m_Config.LoadProfile(device, launchprogram, control, appdatapath + @"\Profiles\" + name + ".xml");
tempprofilename[device] = name;
}
+
public static bool Save()
{
return m_Config.Save();
}
- public static void SaveProfile(int device, string propath, System.Windows.Forms.Control[] buttons, System.Windows.Forms.Control[] shiftbuttons)
+ public static void SaveProfile(int device, string propath)
{
- m_Config.SaveProfile(device, propath, buttons, shiftbuttons);
+ m_Config.SaveProfile(device, propath);
}
private static byte applyRatio(byte b1, byte b2, double r)
@@ -442,7 +519,6 @@ namespace DS4Windows
public int[] scrollSensitivity = { 0, 0, 0, 0, 0 };
public double[] rainbow = { 0, 0, 0, 0, 0 };
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 DS4Color[] m_LowLeds = new DS4Color[]
{
@@ -468,14 +544,6 @@ namespace DS4Windows
new DS4Color(Color.Black),
new DS4Color(Color.Black)
};
- public DS4Color[] m_ShiftLeds = new DS4Color[]
- {
- new DS4Color(Color.Black),
- new DS4Color(Color.Black),
- new DS4Color(Color.Black),
- new DS4Color(Color.Black),
- new DS4Color(Color.Black)
- };
public DS4Color[] m_FlashLeds = new DS4Color[]
{
new DS4Color(Color.Black),
@@ -492,7 +560,6 @@ namespace DS4Windows
new DS4Color(Color.Black),
new DS4Color(Color.Black)
};
- public bool[] shiftColorOn = { false, false, false, false, false };
public int[] chargingType = { 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 };
@@ -516,7 +583,8 @@ namespace DS4Windows
public int firstXinputPort = 1;
public bool closeMini = false;
public List actions = new List();
- public Dictionary[] customMapKeyTypes = { null, null, null, null, null };
+ public List[] ds4settings = { new List(), new List(), new List(), new List(), new List() };
+ /*public Dictionary[] customMapKeyTypes = { null, null, null, null, null };
public Dictionary[] customMapKeys = { null, null, null, null, null };
public Dictionary[] customMapMacros = { null, null, null, null, null };
public Dictionary[] customMapButtons = { null, null, null, null, null };
@@ -526,8 +594,8 @@ namespace DS4Windows
public Dictionary[] shiftCustomMapKeys = { null, null, null, null, null };
public Dictionary[] shiftCustomMapMacros = { null, null, null, null, null };
public Dictionary[] shiftCustomMapButtons = { null, null, null, null, null };
- public Dictionary[] shiftCustomMapExtras = { null, null, null, null, null };
- public List[] profileActions = { null, null, null, null, null };
+ public Dictionary[] shiftCustomMapExtras = { null, null, null, null, null };*/
+ public List[] profileActions = { null, null, null, null, null };
public bool downloadLang = true;
public bool flashWhenLate = true;
public int flashWhenLateAt = 10;
@@ -538,7 +606,10 @@ namespace DS4Windows
{
for (int i = 0; i < 5; i++)
{
- customMapKeyTypes[i] = new Dictionary();
+ foreach (DS4Controls dc in Enum.GetValues(typeof(DS4Controls)))
+ if (dc != DS4Controls.None)
+ ds4settings[i].Add(new DS4ControlSettings(dc));
+ /*customMapKeyTypes[i] = new Dictionary();
customMapKeys[i] = new Dictionary();
customMapMacros[i] = new Dictionary();
customMapButtons[i] = new Dictionary();
@@ -548,13 +619,13 @@ namespace DS4Windows
shiftCustomMapKeys[i] = new Dictionary();
shiftCustomMapMacros[i] = new Dictionary();
shiftCustomMapButtons[i] = new Dictionary();
- shiftCustomMapExtras[i] = new Dictionary();
+ shiftCustomMapExtras[i] = new Dictionary();*/
profileActions[i] = new List();
profileActions[i].Add("Disconnect Controller");
}
}
- public X360Controls GetCustomButton(int device, DS4Controls controlName)
+ /*public X360Controls GetCustomButton(int device, DS4Controls controlName)
{
if (customMapButtons[device].ContainsKey(controlName))
return customMapButtons[device][controlName];
@@ -622,12 +693,12 @@ namespace DS4Windows
else return 0;
}
catch { return 0; }
- }
+ }*/
- public Boolean SaveProfile(int device, String propath, System.Windows.Forms.Control[] buttons, System.Windows.Forms.Control[] shiftbuttons)
+ public bool SaveProfile(int device, string propath)
{
- Boolean Saved = true;
- String path = Global.appdatapath + @"\Profiles\" + Path.GetFileNameWithoutExtension(propath) + ".xml";
+ bool Saved = true;
+ string path = Global.appdatapath + @"\Profiles\" + Path.GetFileNameWithoutExtension(propath) + ".xml";
try
{
XmlNode Node;
@@ -635,10 +706,10 @@ namespace DS4Windows
XmlNode xmlShiftControls = m_Xdoc.SelectSingleNode("/DS4Windows/ShiftControl");
m_Xdoc.RemoveAll();
- Node = m_Xdoc.CreateXmlDeclaration("1.0", "utf-8", String.Empty);
+ Node = m_Xdoc.CreateXmlDeclaration("1.0", "utf-8", string.Empty);
m_Xdoc.AppendChild(Node);
- Node = m_Xdoc.CreateComment(String.Format(" DS4Windows Configuration Data. {0} ", DateTime.Now));
+ Node = m_Xdoc.CreateComment(string.Format(" DS4Windows Configuration Data. {0} ", DateTime.Now));
m_Xdoc.AppendChild(Node);
Node = m_Xdoc.CreateWhitespace("\r\n");
@@ -649,7 +720,7 @@ namespace DS4Windows
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 xmlColor = m_Xdoc.CreateNode(XmlNodeType.Element, "Color", null);
- xmlColor.InnerText = m_Leds[device].red.ToString() + "," + m_Leds[device].green.ToString() + "," + m_Leds[device].blue.ToString();
+ xmlColor.InnerText = m_Leds[device].red.ToString() + "," + m_Leds[device].green.ToString() + "," + m_Leds[device].blue.ToString();
Node.AppendChild(xmlColor);
XmlNode xmlRumbleBoost = m_Xdoc.CreateNode(XmlNodeType.Element, "RumbleBoost", null); xmlRumbleBoost.InnerText = rumble[device].ToString(); Node.AppendChild(xmlRumbleBoost);
XmlNode xmlLedAsBatteryIndicator = m_Xdoc.CreateNode(XmlNodeType.Element, "ledAsBatteryIndicator", null); xmlLedAsBatteryIndicator.InnerText = ledAsBattery[device].ToString(); Node.AppendChild(xmlLedAsBatteryIndicator);
@@ -662,10 +733,6 @@ namespace DS4Windows
XmlNode xmlChargingColor = m_Xdoc.CreateNode(XmlNodeType.Element, "ChargingColor", null);
xmlChargingColor.InnerText = m_ChargingLeds[device].red.ToString() + "," + m_ChargingLeds[device].green.ToString() + "," + m_ChargingLeds[device].blue.ToString();
Node.AppendChild(xmlChargingColor);
- XmlNode xmlShiftColor = m_Xdoc.CreateNode(XmlNodeType.Element, "ShiftColor", null);
- xmlShiftColor.InnerText = m_ShiftLeds[device].red.ToString() + "," + m_ShiftLeds[device].green.ToString() + "," + m_ShiftLeds[device].blue.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].red.ToString() + "," + m_FlashLeds[device].green.ToString() + "," + m_FlashLeds[device].blue.ToString();
Node.AppendChild(xmlFlashColor);
@@ -689,7 +756,7 @@ namespace DS4Windows
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 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);
@@ -701,101 +768,168 @@ namespace DS4Windows
XmlNode xmlLSC = m_Xdoc.CreateNode(XmlNodeType.Element, "LSCurve", null); xmlLSC.InnerText = lsCurve[device].ToString(); Node.AppendChild(xmlLSC);
XmlNode xmlRSC = m_Xdoc.CreateNode(XmlNodeType.Element, "RSCurve", null); xmlRSC.InnerText = rsCurve[device].ToString(); Node.AppendChild(xmlRSC);
XmlNode xmlProfileActions = m_Xdoc.CreateNode(XmlNodeType.Element, "ProfileActions", null); xmlProfileActions.InnerText = string.Join("/", profileActions[device]); Node.AppendChild(xmlProfileActions);
- XmlNode NodeControl = m_Xdoc.CreateNode(XmlNodeType.Element, "Control", null);
+ XmlNode NodeControl = m_Xdoc.CreateNode(XmlNodeType.Element, "Control", null);
XmlNode Key = m_Xdoc.CreateNode(XmlNodeType.Element, "Key", null);
XmlNode Macro = m_Xdoc.CreateNode(XmlNodeType.Element, "Macro", null);
XmlNode KeyType = m_Xdoc.CreateNode(XmlNodeType.Element, "KeyType", null);
XmlNode Button = m_Xdoc.CreateNode(XmlNodeType.Element, "Button", null);
XmlNode Extras = m_Xdoc.CreateNode(XmlNodeType.Element, "Extras", null);
- if (buttons != null)
+
+ XmlNode NodeShiftControl = m_Xdoc.CreateNode(XmlNodeType.Element, "ShiftControl", null);
+
+ XmlNode ShiftKey = m_Xdoc.CreateNode(XmlNodeType.Element, "Key", null);
+ XmlNode ShiftMacro = m_Xdoc.CreateNode(XmlNodeType.Element, "Macro", null);
+ XmlNode ShiftKeyType = m_Xdoc.CreateNode(XmlNodeType.Element, "KeyType", null);
+ XmlNode ShiftButton = m_Xdoc.CreateNode(XmlNodeType.Element, "Button", null);
+ XmlNode ShiftExtras = m_Xdoc.CreateNode(XmlNodeType.Element, "Extras", null);
+
+ foreach (DS4ControlSettings dcs in ds4settings[device])
{
- foreach (var button in buttons)
+ if (dcs.action != null)
{
- // Save even if string (for xbox controller buttons)
- if (button.Tag != null)
+ XmlNode buttonNode;
+ string keyType = string.Empty;
+
+ if (dcs.action is string)
+ if (dcs.action.ToString() == "Unbound")
+ keyType += DS4KeyType.Unbound;
+ if (dcs.keyType.HasFlag(DS4KeyType.HoldMacro))
+ keyType += DS4KeyType.HoldMacro;
+ if (dcs.keyType.HasFlag(DS4KeyType.Macro))
+ keyType += DS4KeyType.Macro;
+ if (dcs.keyType.HasFlag(DS4KeyType.Toggle))
+ keyType += DS4KeyType.Toggle;
+ if (dcs.keyType.HasFlag(DS4KeyType.ScanCode))
+ keyType += DS4KeyType.ScanCode;
+ if (keyType != string.Empty)
{
- XmlNode buttonNode;
- string keyType = String.Empty;
+ buttonNode = m_Xdoc.CreateNode(XmlNodeType.Element, dcs.control.ToString(), null);
+ buttonNode.InnerText = keyType;
+ KeyType.AppendChild(buttonNode);
+ }
- if (button.Tag is KeyValuePair)
- if (((KeyValuePair)button.Tag).Key == "Unbound")
- keyType += DS4KeyType.Unbound;
-
- if (button.Font.Strikeout)
- keyType += DS4KeyType.HoldMacro;
- if (button.Font.Underline)
- keyType += DS4KeyType.Macro;
- if (button.Font.Italic)
- keyType += DS4KeyType.Toggle;
- if (button.Font.Bold)
- keyType += DS4KeyType.ScanCode;
- if (keyType != String.Empty)
- {
- buttonNode = m_Xdoc.CreateNode(XmlNodeType.Element, button.Name, null);
- buttonNode.InnerText = keyType;
- KeyType.AppendChild(buttonNode);
- }
-
- string[] extras;
- buttonNode = m_Xdoc.CreateNode(XmlNodeType.Element, button.Name, null);
- if (button.Tag is KeyValuePair, string> || button.Tag is KeyValuePair || button.Tag is KeyValuePair)
- {
- KeyValuePair tag = (KeyValuePair)button.Tag;
- int[] ii = tag.Key;
- buttonNode.InnerText = string.Join("/", ii);
- Macro.AppendChild(buttonNode);
- extras = tag.Value.Split(',');
- }
- else if (button.Tag is KeyValuePair || button.Tag is KeyValuePair || button.Tag is KeyValuePair)
- {
- KeyValuePair tag = (KeyValuePair)button.Tag;
- buttonNode.InnerText = tag.Key.ToString();
- Key.AppendChild(buttonNode);
- extras = tag.Value.Split(',');
- }
- else if (button.Tag is KeyValuePair)
- {
- KeyValuePair tag = (KeyValuePair)button.Tag;
- buttonNode.InnerText = tag.Key;
- Button.AppendChild(buttonNode);
- extras = tag.Value.Split(',');
- }
- else
- {
- KeyValuePair