Skip to content

Commit

Permalink
Minor enhancements. Update changelog link. Add sleep period to reEnab…
Browse files Browse the repository at this point in the history
…leDevice method.
  • Loading branch information
Ryochan7 authored and SiliconExarch committed May 1, 2017
1 parent 7503640 commit b3d7573
Show file tree
Hide file tree
Showing 6 changed files with 890 additions and 461 deletions.
24 changes: 18 additions & 6 deletions DS4Windows/DS4Control/ControlSerivce.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,13 @@ public bool HotPlug()
continue;
if (((Func<bool>)delegate
{
for (Int32 Index = 0; Index < DS4Controllers.Length; Index++)
for (Int32 Index = 0, arlength = DS4Controllers.Length; Index < arlength; Index++)
if (DS4Controllers[Index] != null && DS4Controllers[Index].MacAddress == device.MacAddress)
return true;
return false;
})())
continue;
for (Int32 Index = 0; Index < DS4Controllers.Length; Index++)
for (Int32 Index = 0, arlength = DS4Controllers.Length; Index < arlength; Index++)
if (DS4Controllers[Index] == null)
{
LogDebug(Properties.Resources.FoundController + device.MacAddress + " (" + device.ConnectionType + ")");
Expand Down Expand Up @@ -418,7 +418,7 @@ protected virtual void On_DS4Removal(object sender, EventArgs e)
{
DS4Device device = (DS4Device)sender;
int ind = -1;
for (int i = 0; i < DS4Controllers.Length; i++)
for (int i = 0, arlength = DS4Controllers.Length; ind == -1 && i < arlength; i++)
if (DS4Controllers[i] != null && device.MacAddress == DS4Controllers[i].MacAddress)
ind = i;
if (ind != -1)
Expand All @@ -434,10 +434,13 @@ protected virtual void On_DS4Removal(object sender, EventArgs e)
System.Threading.Thread.Sleep(XINPUT_UNPLUG_SETTLE_TIME);
DS4Controllers[ind] = null;
touchPad[ind] = null;
lag[ind] = false;
inWarnMonitor[ind] = false;
ControllerStatusChanged(this);
}
}
public bool[] lag = { false, false, false, false };
public bool[] inWarnMonitor = { false, false, false, false };
//Called every time the new input report has arrived
protected virtual void On_Report(object sender, EventArgs e)
{
Expand All @@ -456,14 +459,23 @@ protected virtual void On_Report(object sender, EventArgs e)
{
LogDebug(device.error);
}
if (DateTime.UtcNow - device.firstActive > TimeSpan.FromSeconds(5))

if (inWarnMonitor[ind])
{
int flashWhenLateAt = getFlashWhenLateAt();
if (device.Latency >= flashWhenLateAt && !lag[ind])
if (!lag[ind] && device.Latency >= flashWhenLateAt)
LagFlashWarning(ind, true);
else if (device.Latency < flashWhenLateAt && lag[ind])
else if (lag[ind] && device.Latency < flashWhenLateAt)
LagFlashWarning(ind, false);
}
else
{
if (DateTime.UtcNow - device.firstActive > TimeSpan.FromSeconds(5))
{
inWarnMonitor[ind] = true;
}
}

device.getExposedState(ExposedState[ind], CurrentState[ind]);
DS4State cState = CurrentState[ind];
device.getPreviousState(PreviousState[ind]);
Expand Down
6 changes: 3 additions & 3 deletions DS4Windows/DS4Control/Mapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1718,7 +1718,7 @@ private static async void PlayMacro(int device, bool[] macrocontrol, string macr
keydown[i] = false;
}
}
for (ushort i = 0; i < keydown.Length; i++)
for (int i = 0, arlength = keydown.Length; i < arlength; i++)
{
if (keydown[i])
if (i == 256) InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_LEFTUP); //anything above 255 is not a keyvalue
Expand Down Expand Up @@ -1752,9 +1752,9 @@ private static async void PlayMacro(int device, bool[] macrocontrol, string macr
else if (i == 284) macroControl[23] = false;
else if (i == 285) macroControl[24] = false;
else if (keyType.HasFlag(DS4KeyType.ScanCode))
InputMethods.performSCKeyRelease(i);
InputMethods.performSCKeyRelease((ushort)i);
else
InputMethods.performKeyRelease(i);
InputMethods.performKeyRelease((ushort)i);
}
DS4LightBar.forcedFlash[device] = 0;
DS4LightBar.forcelight[device] = false;
Expand Down
16 changes: 8 additions & 8 deletions DS4Windows/DS4Forms/Hotkeys.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion DS4Windows/DS4Forms/Hotkeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private void linkJhebbel_LinkClicked(object sender, LinkLabelLinkClickedEventArg

private void lLChangelog_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Process.Start("https://docs.google.com/document/d/1l4xcgVQkGUskc5CQ0p069yW22Cd5WAH_yE3Fz2hXo0E/edit?usp=sharing");
Process.Start("https://docs.google.com/document/d/1CovpH08fbPSXrC6TmEprzgPwCe0tTjQ_HTFfDotpmxk/edit?usp=sharing");
}

private void linkDonate_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
Expand Down
Loading

0 comments on commit b3d7573

Please sign in to comment.