From a7f4dec009cfe53062d99fd714079e67589023b3 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Thu, 26 Oct 2017 01:37:21 -0500 Subject: [PATCH] Parse extras before launching actions Related to issue #133. --- DS4Windows/DS4Control/Mapping.cs | 116 +++++++++++++++---------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/DS4Windows/DS4Control/Mapping.cs b/DS4Windows/DS4Control/Mapping.cs index 5cb74c5..4cbe2be 100644 --- a/DS4Windows/DS4Control/Mapping.cs +++ b/DS4Windows/DS4Control/Mapping.cs @@ -1131,6 +1131,64 @@ namespace DS4Windows keyType = dcs.keyType; } + if (usingExtra == DS4Controls.None || usingExtra == dcs.control) + { + bool shiftE = !string.IsNullOrEmpty(dcs.shiftExtras) && dcs.shiftExtras != "0,0,0,0,0,0,0,0" && ShiftTrigger2(dcs.shiftTrigger, device, cState, eState, tp, fieldMapping); + bool regE = !string.IsNullOrEmpty(dcs.extras) && dcs.extras != "0,0,0,0,0,0,0,0"; + if ((regE || shiftE) && getBoolActionMapping2(device, dcs.control, cState, eState, tp, fieldMapping)) + { + usingExtra = dcs.control; + string p; + if (shiftE) + p = dcs.shiftExtras; + else + p = dcs.extras; + + string[] extraS = p.Split(','); + int extrasSLen = extraS.Length; + int[] extras = new int[extrasSLen]; + for (int i = 0; i < extrasSLen; 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 (action != null) { if (actionType == DS4ControlSettings.ActionType.Macro) @@ -1355,64 +1413,6 @@ namespace DS4Windows resetToDefaultValue2(dcs.control, MappedState, outputfieldMapping); } } - - if (usingExtra == DS4Controls.None || usingExtra == dcs.control) - { - bool shiftE = !string.IsNullOrEmpty(dcs.shiftExtras) && dcs.shiftExtras != "0,0,0,0,0,0,0,0" && ShiftTrigger2(dcs.shiftTrigger, device, cState, eState, tp, fieldMapping); - bool regE = !string.IsNullOrEmpty(dcs.extras) && dcs.extras != "0,0,0,0,0,0,0,0"; - if ((regE || shiftE) && getBoolActionMapping2(device, dcs.control, cState, eState, tp, fieldMapping)) - { - usingExtra = dcs.control; - string p; - if (shiftE) - p = dcs.shiftExtras; - else - p = dcs.extras; - - string[] extraS = p.Split(','); - int extrasSLen = extraS.Length; - int[] extras = new int[extrasSLen]; - for (int i = 0; i < extrasSLen; 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; - } - } } outputfieldMapping.populateState(MappedState);