Skip to content
This repository has been archived by the owner on Jan 1, 2024. It is now read-only.

Commit

Permalink
Some minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryochan7 committed Apr 22, 2017
1 parent a11e4c9 commit 52c5fde
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 66 deletions.
60 changes: 0 additions & 60 deletions DS4Windows/DS4Control/ControlSerivce.cs
Original file line number Diff line number Diff line change
Expand Up @@ -604,9 +604,6 @@ protected virtual void On_Report(object sender, EventArgs e)
cState = MappedState[ind];
}

//if (HasCustomExtras(ind))
// DoExtras(ind);

// Update the GUI/whatever.
DS4LightBar.updateLightBar(device, ind, cState, ExposedState[ind], touchPad[ind]);

Expand Down Expand Up @@ -653,63 +650,6 @@ public void LagFlashWarning(int ind, bool on)
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<DS4Controls, string> 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)
{
Expand Down
1 change: 1 addition & 0 deletions DS4Windows/DS4Control/Mapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public void SavePrevious(bool performClear)
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<ushort, KeyPresses>.ValueCollection keyValues = keyPresses.Values;
for (int i = 0, kpCount = keyValues.Count; i < kpCount; i++)
Expand Down
31 changes: 25 additions & 6 deletions DS4Windows/DS4Forms/RecordBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ public RecordBox(SpecActions op, int button = -1)

void AddtoDS4List()
{
dcs.Add(DS4Controls.Cross);
dcs.Add(DS4Controls.Cross);
dcs.Add(DS4Controls.Circle);
dcs.Add(DS4Controls.Square);
Expand Down Expand Up @@ -121,7 +120,9 @@ void AddMacroValue(int value)
else
macros.Add(value);
}

bool[] pTP = new bool[4];

void ds4_Tick(object sender, EventArgs e)
{
if (Program.rootHub.DS4Controllers[0] != null)
Expand All @@ -147,17 +148,25 @@ void ds4_Tick(object sender, EventArgs e)
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);
Expand All @@ -179,22 +188,28 @@ void ds4_Tick(object sender, EventArgs e)
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)
Expand All @@ -204,12 +219,14 @@ void ds4_Tick(object sender, EventArgs e)
sw.Reset();
sw.Start();
}

AddMacroValue(value);
lVMacros.Items.Add(DS4ControltoX360(dc), 1);
lVMacros.Items[lVMacros.Items.Count - 1].EnsureVisible();
}
}
}
}
}
}
}
Expand Down Expand Up @@ -279,8 +296,10 @@ public static string DS4ControltoX360(DS4Controls ctrl)
}
return "None";
}

bool recordAfter = false;
int recordAfterInt = 0;

private void btnRecord_Click(object sender, EventArgs e)
{
if (btnRecord.Text != Properties.Resources.StopText)
Expand Down
7 changes: 7 additions & 0 deletions DS4Windows/DS4Library/DS4Device.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ public DS4Color(System.Drawing.Color c)
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)
Expand All @@ -45,6 +47,7 @@ public override bool Equals(object obj)
else
return false;
}

public Color ToColor => Color.FromArgb(red, green, blue);
public Color ToColorA
{
Expand Down Expand Up @@ -84,6 +87,7 @@ public static bool TryParse(string value, ref DS4Color ds4color)
}
catch { return false; }
}

public override string ToString() => $"Red: {red} Green: {green} Blue: {blue}";
}

Expand All @@ -100,10 +104,12 @@ public struct DS4HapticState
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;
Expand Down Expand Up @@ -869,6 +875,7 @@ public bool DisconnectDongle(bool remove = false)
}

private DS4HapticState testRumble = new DS4HapticState();

public void setRumble(byte rightLightFastMotor, byte leftHeavySlowMotor)
{
testRumble.RumbleMotorStrengthRightLightFast = rightLightFastMotor;
Expand Down

0 comments on commit 52c5fde

Please sign in to comment.