Minor enhancements. Update changelog link. Add sleep period to reEnableDevice method.

This commit is contained in:
Travis Nickles 2017-03-29 07:26:07 -07:00
parent 96090fc857
commit a2fb603d72
6 changed files with 983 additions and 554 deletions

View File

@ -214,13 +214,13 @@ namespace DS4Windows
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 + ")");
@ -418,7 +418,7 @@ namespace DS4Windows
{
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)
@ -434,10 +434,13 @@ namespace DS4Windows
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)
{
@ -456,14 +459,23 @@ namespace DS4Windows
{
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]);

View File

@ -1718,7 +1718,7 @@ namespace DS4Windows
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
@ -1752,9 +1752,9 @@ namespace DS4Windows
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;

View File

@ -40,6 +40,7 @@
this.tPHotkeys = new System.Windows.Forms.TabPage();
this.lbHotkeys = new System.Windows.Forms.Label();
this.tPCredits = new System.Windows.Forms.TabPage();
this.linkTeokp = new System.Windows.Forms.LinkLabel();
this.linkKiliansch = new System.Windows.Forms.LinkLabel();
this.linkChamilsaan = new System.Windows.Forms.LinkLabel();
this.linkBoganhobo = new System.Windows.Forms.LinkLabel();
@ -85,7 +86,6 @@
this.lbTranslators = new System.Windows.Forms.Label();
this.linkSourceCode = new System.Windows.Forms.LinkLabel();
this.lbLinkText = new System.Windows.Forms.Label();
this.linkTeokp = new System.Windows.Forms.LinkLabel();
this.tCAbout.SuspendLayout();
this.tPHotkeys.SuspendLayout();
this.tPCredits.SuspendLayout();
@ -177,6 +177,13 @@
this.tPCredits.Name = "tPCredits";
this.tPCredits.UseVisualStyleBackColor = true;
//
// linkTeokp
//
resources.ApplyResources(this.linkTeokp, "linkTeokp");
this.linkTeokp.Name = "linkTeokp";
this.linkTeokp.TabStop = true;
this.linkTeokp.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkTeokp_LinkClicked);
//
// linkKiliansch
//
resources.ApplyResources(this.linkKiliansch, "linkKiliansch");
@ -448,13 +455,6 @@
resources.ApplyResources(this.lbLinkText, "lbLinkText");
this.lbLinkText.Name = "lbLinkText";
//
// linkTeokp
//
resources.ApplyResources(this.linkTeokp, "linkTeokp");
this.linkTeokp.Name = "linkTeokp";
this.linkTeokp.TabStop = true;
this.linkTeokp.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkTeokp_LinkClicked);
//
// Hotkeys
//
resources.ApplyResources(this, "$this");

View File

@ -77,7 +77,7 @@ namespace DS4Windows
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)

File diff suppressed because it is too large Load Diff

View File

@ -188,6 +188,9 @@ namespace DS4Windows
{
throw new Exception("Error disabling device, error code = " + Marshal.GetLastWin32Error());
}
System.Threading.Thread.Sleep(50);
propChangeParams.stateChange = NativeMethods.DICS_ENABLE;
success = NativeMethods.SetupDiSetClassInstallParams(deviceInfoSet, ref deviceInfoData, ref propChangeParams, Marshal.SizeOf(propChangeParams));
if (!success)