diff --git a/DS4Windows/DS4Control/ControlSerivce.cs b/DS4Windows/DS4Control/ControlSerivce.cs index 7ee380e..6388312 100644 --- a/DS4Windows/DS4Control/ControlSerivce.cs +++ b/DS4Windows/DS4Control/ControlSerivce.cs @@ -604,9 +604,6 @@ namespace DS4Windows cState = MappedState[ind]; } - //if (HasCustomExtras(ind)) - // DoExtras(ind); - // Update the GUI/whatever. DS4LightBar.updateLightBar(device, ind, cState, ExposedState[ind], touchPad[ind]); @@ -653,63 +650,6 @@ namespace DS4Windows DS4LightBar.forcedFlash[ind] = 0; } } - - /* private void DoExtras(int ind) - { - DS4State cState = CurrentState[ind]; - DS4StateExposed eState = ExposedState[ind]; - Mouse tp = touchPad[ind]; - DS4Controls helddown = DS4Controls.None; - foreach (KeyValuePair p in getCustomExtras(ind)) - { - if (Mapping.getBoolMapping(ind, p.Key, cState, eState, tp)) - { - helddown = p.Key; - break; - } - } - if (helddown != DS4Controls.None) - { - string p = getCustomExtras(ind)[helddown]; - 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[ind] = true; - try - { - if (!(extras[0] == extras[1] && extras[1] == 0)) - setRumble((byte)extras[0], (byte)extras[1], ind); - if (extras[2] == 1) - { - DS4Color color = new DS4Color { red = (byte)extras[3], green = (byte)extras[4], blue = (byte)extras[5] }; - DS4LightBar.forcedColor[ind] = color; - DS4LightBar.forcedFlash[ind] = (byte)extras[6]; - DS4LightBar.forcelight[ind] = true; - } - if (extras[7] == 1) - { - if (oldmouse[ind] == -1) - oldmouse[ind] = ButtonMouseSensitivity[ind]; - ButtonMouseSensitivity[ind] = extras[8]; - } - } - catch { } - } - else if (held[ind]) - { - DS4LightBar.forcelight[ind] = false; - DS4LightBar.forcedFlash[ind] = 0; - ButtonMouseSensitivity[ind] = oldmouse[ind]; - oldmouse[ind] = -1; - setRumble(0, 0, ind); - held[ind] = false; - } - }*/ public void EasterTime(int ind) { diff --git a/DS4Windows/DS4Control/Mapping.cs b/DS4Windows/DS4Control/Mapping.cs index 30af654..f90dcf3 100644 --- a/DS4Windows/DS4Control/Mapping.cs +++ b/DS4Windows/DS4Control/Mapping.cs @@ -38,6 +38,7 @@ namespace DS4Windows previousClicks = currentClicks; if (performClear) currentClicks.leftCount = currentClicks.middleCount = currentClicks.rightCount = currentClicks.fourthCount = currentClicks.fifthCount = currentClicks.wUpCount = currentClicks.wDownCount = currentClicks.toggleCount = 0; + //foreach (KeyPresses kp in keyPresses.Values) Dictionary.ValueCollection keyValues = keyPresses.Values; for (int i = 0, kpCount = keyValues.Count; i < kpCount; i++) diff --git a/DS4Windows/DS4Forms/RecordBox.cs b/DS4Windows/DS4Forms/RecordBox.cs index 3866eff..25861b8 100644 --- a/DS4Windows/DS4Forms/RecordBox.cs +++ b/DS4Windows/DS4Forms/RecordBox.cs @@ -86,7 +86,6 @@ namespace DS4Windows void AddtoDS4List() { - dcs.Add(DS4Controls.Cross); dcs.Add(DS4Controls.Cross); dcs.Add(DS4Controls.Circle); dcs.Add(DS4Controls.Square); @@ -121,7 +120,9 @@ namespace DS4Windows else macros.Add(value); } + bool[] pTP = new bool[4]; + void ds4_Tick(object sender, EventArgs e) { if (Program.rootHub.DS4Controllers[0] != null) @@ -147,17 +148,25 @@ namespace DS4Windows pTP[0] = tP.leftDown; pTP[1] = tP.rightDown; } - foreach (DS4Controls dc in dcs) + + //foreach (DS4Controls dc in dcs) + for (int controlIndex = 0, dcsLen = dcs.Count; controlIndex < dcsLen; controlIndex++) + { + DS4Controls dc = dcs[controlIndex]; if (Mapping.getBoolMapping(0, dc, cState, null, null)) { int value = DS4ControltoInt(dc); int count = 0; - foreach (int i in macros) + int macroLen = macros.Count; + //foreach (int i in macros) + for (int macroIndex = 0; macroIndex < macroLen; macroIndex++) { + int i = macros[macroIndex]; if (i == value) count++; } - if (macros.Count == 0) + + if (macroLen == 0) { AddMacroValue(value); lVMacros.Items.Add(DS4ControltoX360(dc), 0); @@ -179,22 +188,28 @@ namespace DS4Windows AddMacroValue(value); lVMacros.Items.Add(DS4ControltoX360(dc), 0); } + lVMacros.Items[lVMacros.Items.Count - 1].EnsureVisible(); } else if (!Mapping.getBoolMapping(0, dc, cState, null, null)) { - if (macros.Count != 0) + int macroLen = macros.Count; + if (macroLen != 0) { int value = DS4ControltoInt(dc); int count = 0; - foreach (int i in macros) + //foreach (int i in macros) + for (int macroIndex = 0; macroIndex < macroLen; macroIndex++) { + int i = macros[macroIndex]; if (i == value) count++; } + /*for (int i = macros.Count - 1; i >= 0; i--) if (macros.Count == 261) count++;*/ + if (count % 2 == 1) { if (cBRecordDelays.Checked) @@ -204,12 +219,14 @@ namespace DS4Windows sw.Reset(); sw.Start(); } + AddMacroValue(value); lVMacros.Items.Add(DS4ControltoX360(dc), 1); lVMacros.Items[lVMacros.Items.Count - 1].EnsureVisible(); } } } + } } } } @@ -279,8 +296,10 @@ namespace DS4Windows } return "None"; } + bool recordAfter = false; int recordAfterInt = 0; + private void btnRecord_Click(object sender, EventArgs e) { if (btnRecord.Text != Properties.Resources.StopText) diff --git a/DS4Windows/DS4Library/DS4Device.cs b/DS4Windows/DS4Library/DS4Device.cs index 3942cae..f0aa31a 100644 --- a/DS4Windows/DS4Library/DS4Device.cs +++ b/DS4Windows/DS4Library/DS4Device.cs @@ -29,12 +29,14 @@ namespace DS4Windows green = c.G; blue = c.B; } + public DS4Color(byte r, byte g, byte b) { red = r; green = g; blue = b; } + public override bool Equals(object obj) { if (obj is DS4Color) @@ -45,6 +47,7 @@ namespace DS4Windows else return false; } + public Color ToColor => Color.FromArgb(red, green, blue); public Color ToColorA { @@ -84,6 +87,7 @@ namespace DS4Windows } catch { return false; } } + public override string ToString() => $"Red: {red} Green: {green} Blue: {blue}"; } @@ -100,10 +104,12 @@ namespace DS4Windows public byte LightBarFlashDurationOn, LightBarFlashDurationOff; public byte RumbleMotorStrengthLeftHeavySlow, RumbleMotorStrengthRightLightFast; public bool RumbleMotorsExplicitlyOff; + public bool IsLightBarSet() { return LightBarExplicitlyOff || LightBarColor.red != 0 || LightBarColor.green != 0 || LightBarColor.blue != 0; } + public bool IsRumbleSet() { return RumbleMotorsExplicitlyOff || RumbleMotorStrengthLeftHeavySlow != 0 || RumbleMotorStrengthRightLightFast != 0; @@ -869,6 +875,7 @@ namespace DS4Windows } private DS4HapticState testRumble = new DS4HapticState(); + public void setRumble(byte rightLightFastMotor, byte leftHeavySlowMotor) { testRumble.RumbleMotorStrengthRightLightFast = rightLightFastMotor;