diff --git a/DS4Windows/DS4Control/ControlService.cs b/DS4Windows/DS4Control/ControlService.cs index bf2f265..75b7cf0 100644 --- a/DS4Windows/DS4Control/ControlService.cs +++ b/DS4Windows/DS4Control/ControlService.cs @@ -8,12 +8,10 @@ using System.Threading.Tasks; using static DS4Windows.Global; using System.Threading; using System.Diagnostics; -using Microsoft.Win32; using Nefarius.ViGEm.Client; using Nefarius.ViGEm.Client.Targets; using Nefarius.ViGEm.Client.Targets.Xbox360; - namespace DS4Windows { public class ControlService @@ -305,94 +303,6 @@ namespace DS4Windows } } - public void ScanPurgeHidGuard() - { - RegistryKey tempkey = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\HidGuardian\Parameters\Whitelist"); - string[] subkeys = null; - if (tempkey != null) - { - subkeys = tempkey.GetSubKeyNames(); - } - else - { - subkeys = new string[0]; - } - - bool processExists = false; - for (int ind = 0, arlen = subkeys.Length; ind < arlen; ind++) - { - processExists = true; - try - { - Process.GetProcessById(Convert.ToInt32(subkeys[ind])); - } - catch { processExists = false; } - - if (!processExists) - { - try - { - Registry.LocalMachine.DeleteSubKey(@"SYSTEM\CurrentControlSet\Services\HidGuardian\Parameters\Whitelist\" + subkeys[ind]); - } - catch { } - } - } - } - - public void CreateHidGuardKey() - { - try - { - Registry.LocalMachine.CreateSubKey(@"SYSTEM\CurrentControlSet\Services\HidGuardian\Parameters\Whitelist\" + System.Diagnostics.Process.GetCurrentProcess().Id); - } - catch { } - } - - public void removeHidGuardKey() - { - try - { - Registry.LocalMachine.DeleteSubKey(@"SYSTEM\CurrentControlSet\Services\HidGuardian\Parameters\Whitelist\" + System.Diagnostics.Process.GetCurrentProcess().Id); - } - catch { } - } - - public bool PlugXInputController(int index) - { - int xinputIndex = x360Bus.FirstController + index; - LogDebug("Plugging in X360 Controller #" + xinputIndex); - bool xinputResult = x360Bus.Plugin(index); - if (xinputResult) - { - useDInputOnly[index] = false; - LogDebug("X360 Controller # " + xinputIndex + " connected"); - } - else - { - useDInputOnly[index] = true; - LogDebug("X360 Controller # " + xinputIndex + " failed. Using DInput only mode"); - } - - return xinputResult; - } - - public bool UnplugXInputController(int index) - { - bool unplugResult = x360Bus.Unplug(index); - int xinputIndex = x360Bus.FirstController + index; - if (unplugResult) - { - useDInputOnly[index] = true; - LogDebug("X360 Controller # " + xinputIndex + " unplugged"); - } - else - { - LogDebug("X360 Controller # " + xinputIndex + " failed to unplug"); - } - - return unplugResult; - } - private void startViGEm() { tempThread = new Thread(() => { try { vigemTestClient = new ViGEmClient(); } catch { } }); diff --git a/DS4Windows/DS4Control/UdpServer.cs b/DS4Windows/DS4Control/UdpServer.cs index a979715..76ad2aa 100644 --- a/DS4Windows/DS4Control/UdpServer.cs +++ b/DS4Windows/DS4Control/UdpServer.cs @@ -5,6 +5,7 @@ using System.Net; using System.Net.NetworkInformation; using System.Net.Sockets; using System.ComponentModel; +using System.Threading; namespace DS4Windows { @@ -71,6 +72,7 @@ namespace DS4Windows private byte[] recvBuffer = new byte[1024]; private SocketAsyncEventArgs[] argsList; private int listInd = 0; + private ReaderWriterLockSlim poolLock = new ReaderWriterLockSlim(); public delegate void GetPadDetail(int padIdx, ref DualShockPadMeta meta); @@ -83,6 +85,7 @@ namespace DS4Windows for (int num = 0; num <= 19; num++) { SocketAsyncEventArgs args = new SocketAsyncEventArgs(); + args.SetBuffer(new byte[100], 0, 100); argsList[num] = args; } } @@ -182,10 +185,16 @@ namespace DS4Windows FinishPacket(packetData); //try { udpSock.SendTo(packetData, clientEP); } - SocketAsyncEventArgs args = argsList[listInd]; + int temp = 0; + poolLock.EnterWriteLock(); + temp = listInd; listInd = ++listInd % 20; + SocketAsyncEventArgs args = argsList[temp]; + poolLock.ExitWriteLock(); + args.RemoteEndPoint = clientEP; - args.SetBuffer(packetData, 0, packetData.Length); + Array.Copy(packetData, args.Buffer, packetData.Length); + //args.SetBuffer(packetData, 0, packetData.Length); try { udpSock.SendToAsync(args); } @@ -642,10 +651,15 @@ namespace DS4Windows foreach (var cl in clientsList) { //try { udpSock.SendTo(outputData, cl); } - SocketAsyncEventArgs args = argsList[listInd]; + int temp = 0; + poolLock.EnterWriteLock(); + temp = listInd; listInd = ++listInd % 20; + SocketAsyncEventArgs args = argsList[temp]; + poolLock.ExitWriteLock(); + args.RemoteEndPoint = cl; - args.SetBuffer(outputData, 0, outputData.Length); + Array.Copy(outputData, args.Buffer, outputData.Length); try { udpSock.SendToAsync(args); } diff --git a/DS4Windows/DS4Forms/DS4Form.Designer.cs b/DS4Windows/DS4Forms/DS4Form.Designer.cs index 607920c..dcfd142 100644 --- a/DS4Windows/DS4Forms/DS4Form.Designer.cs +++ b/DS4Windows/DS4Forms/DS4Form.Designer.cs @@ -165,9 +165,6 @@ this.linkUninstall = new System.Windows.Forms.LinkLabel(); this.linkSetup = new System.Windows.Forms.LinkLabel(); this.lLBUpdate = new System.Windows.Forms.LinkLabel(); - this.hidGuardWhiteList = new System.Windows.Forms.LinkLabel(); - this.clrHidGuardWlistLinkLabel = new System.Windows.Forms.LinkLabel(); - this.hidGuardRegLinkLabel = new System.Windows.Forms.LinkLabel(); this.tabLog = new System.Windows.Forms.TabPage(); this.panel3 = new System.Windows.Forms.Panel(); this.exportLogTxtBtn = new System.Windows.Forms.Button(); @@ -735,7 +732,6 @@ this.lBProfiles.BorderStyle = System.Windows.Forms.BorderStyle.None; this.lBProfiles.ContextMenuStrip = this.cMProfile; resources.ApplyResources(this.lBProfiles, "lBProfiles"); - this.lBProfiles.FormattingEnabled = true; this.lBProfiles.Name = "lBProfiles"; this.lBProfiles.SelectedIndexChanged += new System.EventHandler(this.lBProfiles_SelectedIndexChanged); this.lBProfiles.KeyDown += new System.Windows.Forms.KeyEventHandler(this.lBProfiles_KeyDown); @@ -1272,9 +1268,6 @@ this.flowLayoutPanel1.Controls.Add(this.linkUninstall); this.flowLayoutPanel1.Controls.Add(this.linkSetup); this.flowLayoutPanel1.Controls.Add(this.lLBUpdate); - this.flowLayoutPanel1.Controls.Add(this.hidGuardWhiteList); - this.flowLayoutPanel1.Controls.Add(this.clrHidGuardWlistLinkLabel); - this.flowLayoutPanel1.Controls.Add(this.hidGuardRegLinkLabel); resources.ApplyResources(this.flowLayoutPanel1, "flowLayoutPanel1"); this.flowLayoutPanel1.ForeColor = System.Drawing.SystemColors.ControlText; this.flowLayoutPanel1.Name = "flowLayoutPanel1"; @@ -1314,27 +1307,6 @@ this.lLBUpdate.TabStop = true; this.lLBUpdate.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lLBUpdate_LinkClicked); // - // hidGuardWhiteList - // - resources.ApplyResources(this.hidGuardWhiteList, "hidGuardWhiteList"); - this.hidGuardWhiteList.Name = "hidGuardWhiteList"; - this.hidGuardWhiteList.TabStop = true; - this.hidGuardWhiteList.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.HidGuardWhiteList_LinkClicked); - // - // clrHidGuardWlistLinkLabel - // - resources.ApplyResources(this.clrHidGuardWlistLinkLabel, "clrHidGuardWlistLinkLabel"); - this.clrHidGuardWlistLinkLabel.Name = "clrHidGuardWlistLinkLabel"; - this.clrHidGuardWlistLinkLabel.TabStop = true; - this.clrHidGuardWlistLinkLabel.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.ClrHidGuardWlistLinkLabel_LinkClicked); - // - // hidGuardRegLinkLabel - // - resources.ApplyResources(this.hidGuardRegLinkLabel, "hidGuardRegLinkLabel"); - this.hidGuardRegLinkLabel.Name = "hidGuardRegLinkLabel"; - this.hidGuardRegLinkLabel.TabStop = true; - this.hidGuardRegLinkLabel.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.HidGuardRegLinkLabel_LinkClicked); - // // tabLog // this.tabLog.Controls.Add(this.lvDebug); @@ -1395,7 +1367,6 @@ // // DS4Form // - this.AllowDrop = true; resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; this.BackColor = System.Drawing.SystemColors.Window; @@ -1586,9 +1557,6 @@ private System.Windows.Forms.Button exportLogTxtBtn; private System.Windows.Forms.Button btnClear; private DS4Forms.LanguagePackComboBox languagePackComboBox1; - private System.Windows.Forms.LinkLabel hidGuardWhiteList; - private System.Windows.Forms.LinkLabel clrHidGuardWlistLinkLabel; - private System.Windows.Forms.LinkLabel hidGuardRegLinkLabel; private System.Windows.Forms.ToolStripMenuItem openProgramFolderToolStripMenuItem; private System.Windows.Forms.ToolStripSeparator toolStripSeparator4; private System.Windows.Forms.ToolStripMenuItem disconToolStripMenuItem; diff --git a/DS4Windows/DS4Forms/DS4Form.cs b/DS4Windows/DS4Forms/DS4Form.cs index 1ec5bae..56e24da 100644 --- a/DS4Windows/DS4Forms/DS4Form.cs +++ b/DS4Windows/DS4Forms/DS4Form.cs @@ -52,7 +52,6 @@ namespace DS4Windows Options opt; private bool optPop; public Size oldsize; - public bool mAllowVisible; bool contextclose; bool turnOffTemp; bool runningBat; @@ -235,13 +234,11 @@ namespace DS4Windows break; } - if (!(startMinimizedCheckBox.Checked || mini)) + if (startMinimizedCheckBox.Checked || mini) { - mAllowVisible = true; - Show(); + WindowState = FormWindowState.Minimized; } - Form_Resize(null, null); RefreshProfiles(); /*opt = new Options(this); opt.Icon = this.Icon; @@ -324,9 +321,6 @@ namespace DS4Windows uacPictureBox.Visible = true; new ToolTip().SetToolTip(uacPictureBox, Properties.Resources.UACTask); runStartTaskRadio.Enabled = false; - hidGuardWhiteList.Visible = false; - clrHidGuardWlistLinkLabel.Visible = false; - hidGuardRegLinkLabel.Visible = false; } else { @@ -395,13 +389,14 @@ namespace DS4Windows else { if (hoverTextDict.TryGetValue(control, out tempst)) - control.MouseEnter += Items_MouseHover; + control.MouseHover += Items_MouseHover; else control.MouseHover += ClearLastMessage; } } instance = this; + Form_Resize(null, null); if (btnStartStop.Enabled && start) TaskRunner.Delay(50).ContinueWith((t) => this.BeginInvoke((System.Action)(() => BtnStartStop_Clicked()))); } @@ -503,17 +498,6 @@ namespace DS4Windows } } - protected override void SetVisibleCore(bool value) - { - if (!mAllowVisible) - { - value = false; - if (!IsHandleCreated) CreateHandle(); - } - - base.SetVisibleCore(value); - } - public static string GetTopWindowName() { IntPtr hWnd = GetForegroundWindow(); @@ -1594,7 +1578,6 @@ Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question private void editMenu_Click(object sender, EventArgs e) { - mAllowVisible = true; Show(); WindowState = FormWindowState.Normal; ToolStripMenuItem em = (ToolStripMenuItem)sender; @@ -1744,7 +1727,6 @@ Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question private void openToolStripMenuItem_Click(object sender, EventArgs e) { - mAllowVisible = true; Show(); Focus(); WindowState = FormWindowState.Normal; @@ -2140,9 +2122,9 @@ Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question } bool tempBool = false; - protected void ScpForm_Closing(object sender, FormClosingEventArgs e) + private void ScpForm_Closing(object sender, FormClosingEventArgs e) { - if (opt != null && opt.Visible) + if (optPop) { opt.Close(); e.Cancel = true; @@ -2522,41 +2504,6 @@ Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question } } - private void HidGuardWhiteList_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) - { - try - { - RegistryKey key = Registry.LocalMachine.CreateSubKey(@"SYSTEM\CurrentControlSet\Services\HidGuardian\Parameters"); - key.SetValue("AffectedDevices", Program.rootHub.affectedDevs.ToArray(), RegistryValueKind.MultiString); - AppLogger.LogToGui("Wrote HidGuardian Device List to Registry", false); - } - catch { } - } - - private void ClrHidGuardWlistLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) - { - try - { - Registry.LocalMachine.DeleteSubKeyTree(@"SYSTEM\CurrentControlSet\Services\HidGuardian\Parameters\Whitelist"); - AppLogger.LogToGui("Cleared HidGuardian Whitelist", false); - Program.rootHub.CreateHidGuardKey(); - } - catch { } - } - - private void HidGuardRegLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) - { - try - { - RegistryKey key = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Applets\Regedit"); - key.SetValue("LastKey", @"Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HidGuardian\Parameters", RegistryValueKind.String); - Process temp = new Process(); - temp.StartInfo.FileName = "regedit"; - temp.Start(); - } - catch { } - } - private void OpenProgramFolderToolStripMenuItem_Click(object sender, EventArgs e) { Process temp = new Process(); @@ -2602,13 +2549,18 @@ Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question if (!state) { Program.rootHub.ChangeMotionEventStatus(state); - await TaskRunner.Delay(100); - Program.rootHub.ChangeUDPStatus(state); + await TaskRunner.Delay(100).ContinueWith((t) => + { + Program.rootHub.ChangeUDPStatus(state); + }); } else { Program.rootHub.ChangeUDPStatus(state); - Program.rootHub.ChangeMotionEventStatus(state); + await TaskRunner.Delay(100).ContinueWith((t) => + { + Program.rootHub.ChangeMotionEventStatus(state); + }); } nUDUdpPortNum.Enabled = state; diff --git a/DS4Windows/DS4Forms/DS4Form.resx b/DS4Windows/DS4Forms/DS4Form.resx index a184f38..02b5bb8 100644 --- a/DS4Windows/DS4Forms/DS4Form.resx +++ b/DS4Windows/DS4Forms/DS4Form.resx @@ -445,10 +445,10 @@ NoControl - 754, 89 + 748, 89 - 139, 22 + 145, 22 50 @@ -472,7 +472,7 @@ NoControl - 352, 34 + 348, 34 39, 20 @@ -574,7 +574,7 @@ NoControl - 714, 89 + 708, 89 34, 22 @@ -604,7 +604,7 @@ NoControl - 714, 117 + 708, 117 34, 22 @@ -703,7 +703,7 @@ None - 597, 33 + 591, 33 111, 21 @@ -730,7 +730,7 @@ NoControl - 714, 61 + 708, 61 34, 22 @@ -757,7 +757,7 @@ None - 597, 61 + 591, 61 111, 21 @@ -781,7 +781,7 @@ None - 597, 89 + 591, 89 111, 21 @@ -808,7 +808,7 @@ NoControl - 714, 33 + 708, 33 34, 22 @@ -835,7 +835,7 @@ None - 597, 117 + 591, 117 111, 21 @@ -868,7 +868,7 @@ NoControl - 598, 7 + 592, 7 109, 15 @@ -940,7 +940,7 @@ NoControl - 348, 7 + 344, 7 47, 15 @@ -976,7 +976,7 @@ NoControl - 443, 7 + 437, 7 51, 15 @@ -1012,7 +1012,7 @@ NoControl - 449, 36 + 443, 36 39, 15 @@ -1048,7 +1048,7 @@ NoControl - 449, 64 + 443, 64 39, 15 @@ -1084,7 +1084,7 @@ NoControl - 449, 92 + 443, 92 39, 15 @@ -1120,7 +1120,7 @@ NoControl - 449, 120 + 443, 120 39, 15 @@ -1150,7 +1150,7 @@ NoControl - 352, 62 + 348, 62 39, 20 @@ -1180,7 +1180,7 @@ NoControl - 352, 90 + 348, 90 39, 20 @@ -1210,7 +1210,7 @@ NoControl - 352, 118 + 348, 118 39, 20 @@ -1243,10 +1243,10 @@ NoControl - 754, 33 + 748, 33 - 139, 22 + 145, 22 50 @@ -1273,10 +1273,10 @@ NoControl - 754, 61 + 748, 61 - 139, 22 + 145, 22 51 @@ -1303,10 +1303,10 @@ NoControl - 754, 117 + 748, 117 - 139, 22 + 145, 22 52 @@ -1336,7 +1336,7 @@ NoControl - 520, 0 + 514, 0 67, 30 @@ -1375,7 +1375,7 @@ NoControl - 546, 37 + 540, 37 15, 14 @@ -1408,7 +1408,7 @@ NoControl - 546, 65 + 540, 65 15, 14 @@ -1441,7 +1441,7 @@ NoControl - 546, 93 + 540, 93 15, 14 @@ -1474,7 +1474,7 @@ NoControl - 546, 121 + 540, 121 15, 14 @@ -1522,7 +1522,7 @@ 0 - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="bnLight3" Row="3" RowSpan="1" Column="6" ColumnSpan="1" /><Control Name="pBStatus1" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="lbPad1" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbPad2" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="bnEditC3" Row="3" RowSpan="1" Column="5" ColumnSpan="1" /><Control Name="bnEditC4" Row="4" RowSpan="1" Column="5" ColumnSpan="1" /><Control Name="lbPad3" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbPad4" Row="4" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="cBController1" Row="1" RowSpan="1" Column="4" ColumnSpan="1" /><Control Name="bnEditC2" Row="2" RowSpan="1" Column="5" ColumnSpan="1" /><Control Name="cBController2" Row="2" RowSpan="1" Column="4" ColumnSpan="1" /><Control Name="cBController3" Row="3" RowSpan="1" Column="4" ColumnSpan="1" /><Control Name="bnEditC1" Row="1" RowSpan="1" Column="5" ColumnSpan="1" /><Control Name="cBController4" Row="4" RowSpan="1" Column="4" ColumnSpan="1" /><Control Name="lbSelectedProfile" Row="0" RowSpan="1" Column="4" ColumnSpan="1" /><Control Name="lbID" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbStatus" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="lbBattery" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="lbBatt1" Row="1" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="lbBatt2" Row="2" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="lbBatt3" Row="3" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="lbBatt4" Row="4" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="pBStatus2" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="pBStatus3" Row="3" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="pBStatus4" Row="4" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="bnLight1" Row="1" RowSpan="1" Column="6" ColumnSpan="1" /><Control Name="bnLight2" Row="2" RowSpan="1" Column="6" ColumnSpan="1" /><Control Name="bnLight4" Row="4" RowSpan="1" Column="6" ColumnSpan="1" /><Control Name="lbLinkProfile" Row="0" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="linkCB1" Row="1" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="linkCB2" Row="2" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="linkCB3" Row="3" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="linkCB4" Row="4" RowSpan="1" Column="3" ColumnSpan="1" /></Controls><Columns Styles="Percent,62.29144,Percent,20.02225,Percent,17.68632,Absolute,80,AutoSize,0,AutoSize,0,Absolute,144" /><Rows Styles="AutoSize,0,Percent,25,Percent,25,Percent,25,Percent,25" /></TableLayoutSettings> + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="bnLight3" Row="3" RowSpan="1" Column="6" ColumnSpan="1" /><Control Name="pBStatus1" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="lbPad1" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbPad2" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="bnEditC3" Row="3" RowSpan="1" Column="5" ColumnSpan="1" /><Control Name="bnEditC4" Row="4" RowSpan="1" Column="5" ColumnSpan="1" /><Control Name="lbPad3" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbPad4" Row="4" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="cBController1" Row="1" RowSpan="1" Column="4" ColumnSpan="1" /><Control Name="bnEditC2" Row="2" RowSpan="1" Column="5" ColumnSpan="1" /><Control Name="cBController2" Row="2" RowSpan="1" Column="4" ColumnSpan="1" /><Control Name="cBController3" Row="3" RowSpan="1" Column="4" ColumnSpan="1" /><Control Name="bnEditC1" Row="1" RowSpan="1" Column="5" ColumnSpan="1" /><Control Name="cBController4" Row="4" RowSpan="1" Column="4" ColumnSpan="1" /><Control Name="lbSelectedProfile" Row="0" RowSpan="1" Column="4" ColumnSpan="1" /><Control Name="lbID" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lbStatus" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="lbBattery" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="lbBatt1" Row="1" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="lbBatt2" Row="2" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="lbBatt3" Row="3" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="lbBatt4" Row="4" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="pBStatus2" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="pBStatus3" Row="3" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="pBStatus4" Row="4" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="bnLight1" Row="1" RowSpan="1" Column="6" ColumnSpan="1" /><Control Name="bnLight2" Row="2" RowSpan="1" Column="6" ColumnSpan="1" /><Control Name="bnLight4" Row="4" RowSpan="1" Column="6" ColumnSpan="1" /><Control Name="lbLinkProfile" Row="0" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="linkCB1" Row="1" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="linkCB2" Row="2" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="linkCB3" Row="3" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="linkCB4" Row="4" RowSpan="1" Column="3" ColumnSpan="1" /></Controls><Columns Styles="Percent,62.29144,Percent,20.02225,Percent,17.68632,Absolute,80,AutoSize,0,AutoSize,0,Absolute,150" /><Rows Styles="AutoSize,0,Percent,25,Percent,25,Percent,25,Percent,25" /></TableLayoutSettings> Fill @@ -2814,6 +2814,9 @@ True + + NoControl + 118, 2 @@ -2841,6 +2844,9 @@ True + + NoControl + 3, 1 @@ -2929,7 +2935,7 @@ languagePackComboBox1 - DS4Windows.DS4Forms.LanguagePackComboBox, DS4Windows, Version=1.5.13.0, Culture=neutral, PublicKeyToken=null + DS4Windows.DS4Forms.LanguagePackComboBox, DS4Windows, Version=1.5.15.0, Culture=neutral, PublicKeyToken=null fLPSettings @@ -3093,96 +3099,6 @@ 4 - - True - - - NoControl - - - 7, 69 - - - 150, 13 - - - 53 - - - Write HidGuardian Device List - - - hidGuardWhiteList - - - System.Windows.Forms.LinkLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - flowLayoutPanel1 - - - 5 - - - True - - - NoControl - - - 7, 82 - - - 141, 13 - - - 54 - - - Clear HidGuardian Whitelists - - - clrHidGuardWlistLinkLabel - - - System.Windows.Forms.LinkLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - flowLayoutPanel1 - - - 6 - - - True - - - NoControl - - - 7, 95 - - - 106, 13 - - - 55 - - - HidGuardian Regedit - - - hidGuardRegLinkLabel - - - System.Windows.Forms.LinkLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - flowLayoutPanel1 - - - 7 - TopDown @@ -3193,7 +3109,7 @@ 4, 4, 4, 4 - 204, 158 + 164, 112 56 @@ -3736,7 +3652,7 @@ advColorDialog - DS4Windows.AdvancedColorDialog, DS4Windows, Version=1.5.13.0, Culture=neutral, PublicKeyToken=null + DS4Windows.AdvancedColorDialog, DS4Windows, Version=1.5.15.0, Culture=neutral, PublicKeyToken=null DS4Form diff --git a/DS4Windows/DS4Forms/Hotkeys.cs b/DS4Windows/DS4Forms/Hotkeys.cs index 579ce6d..977f74a 100644 --- a/DS4Windows/DS4Forms/Hotkeys.cs +++ b/DS4Windows/DS4Forms/Hotkeys.cs @@ -2,7 +2,6 @@ using System.Windows.Forms; using System.Reflection; -using System.Threading; using System.Diagnostics; using System.Drawing; @@ -13,15 +12,6 @@ namespace DS4Windows public Hotkeys() { InitializeComponent(); - string s = Thread.CurrentThread.CurrentUICulture.ToString().Split('-')[0]; - - Control[] ctrls = tLPTranslators.Controls.Find("lb" + s, true); - if (ctrls.Length > 0) - { - ((Label)ctrls[0]).ForeColor = Color.DarkGreen; - int ind = tLPTranslators.Controls.IndexOf(ctrls[0]) + 1; - ((Label)tLPTranslators.Controls[ind]).ForeColor = Color.DarkGreen; - } FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location); string version = fvi.FileVersion; diff --git a/DS4Windows/DS4Library/DS4Device.cs b/DS4Windows/DS4Library/DS4Device.cs index f8732c8..aba9179 100644 --- a/DS4Windows/DS4Library/DS4Device.cs +++ b/DS4Windows/DS4Library/DS4Device.cs @@ -106,7 +106,8 @@ namespace DS4Windows public bool IsRumbleSet() { - return RumbleMotorsExplicitlyOff || RumbleMotorStrengthLeftHeavySlow != 0 || RumbleMotorStrengthRightLightFast != 0; + const byte zero = 0; + return RumbleMotorsExplicitlyOff || RumbleMotorStrengthLeftHeavySlow != zero || RumbleMotorStrengthRightLightFast != zero; } } @@ -740,6 +741,7 @@ namespace DS4Windows CRC32_POS_3 = BT_INPUT_REPORT_CRC32_POS + 3; int crcpos = BT_INPUT_REPORT_CRC32_POS; int crcoffset = 0; + long latencySum = 0; while (!exitInputThread) { @@ -748,14 +750,16 @@ namespace DS4Windows if (tempLatencyCount >= 20) { - latencyQueue.Dequeue(); + latencySum -= latencyQueue.Dequeue(); tempLatencyCount--; } + latencySum += this.lastTimeElapsed; latencyQueue.Enqueue(this.lastTimeElapsed); tempLatencyCount++; - Latency = latencyQueue.Average(); + //Latency = latencyQueue.Average(); + Latency = latencySum / tempLatencyCount; if (conType == ConnectionType.BT) { diff --git a/DS4Windows/DS4Library/DS4Devices.cs b/DS4Windows/DS4Library/DS4Devices.cs index 2636744..0193032 100644 --- a/DS4Windows/DS4Library/DS4Devices.cs +++ b/DS4Windows/DS4Library/DS4Devices.cs @@ -104,7 +104,7 @@ namespace DS4Windows startInfo.Arguments = "re-enabledevice " + devicePathToInstanceId(hDevice.DevicePath); Process child = Process.Start(startInfo); - if (!child.WaitForExit(15000)) + if (!child.WaitForExit(30000)) { child.Kill(); } diff --git a/DS4Windows/DS4Library/DS4Sixaxis.cs b/DS4Windows/DS4Library/DS4Sixaxis.cs index 8da297e..b082fd9 100644 --- a/DS4Windows/DS4Library/DS4Sixaxis.cs +++ b/DS4Windows/DS4Library/DS4Sixaxis.cs @@ -189,7 +189,11 @@ namespace DS4Windows calibrationData[5].sensNumer = 2 * SixAxis.ACC_RES_PER_G; calibrationData[5].sensDenom = accelRange; - calibrationDone = true; + // Check that denom will not be zero. + calibrationDone = calibrationData[0].sensDenom != 0 && + calibrationData[1].sensDenom != 0 && + calibrationData[2].sensDenom != 0 && + accelRange != 0; } private void applyCalibs(ref int yaw, ref int pitch, ref int roll, diff --git a/DS4Windows/DS4Windows.csproj b/DS4Windows/DS4Windows.csproj index 7745867..19f3d1d 100644 --- a/DS4Windows/DS4Windows.csproj +++ b/DS4Windows/DS4Windows.csproj @@ -87,7 +87,7 @@ none x64 false - prompt + none MinimumRecommendedRules.ruleset WIN64 On @@ -113,7 +113,7 @@ none x86 false - prompt + none MinimumRecommendedRules.ruleset true 6 diff --git a/DS4Windows/HidLibrary/HidDevices.cs b/DS4Windows/HidLibrary/HidDevices.cs index c847c86..00125eb 100644 --- a/DS4Windows/HidLibrary/HidDevices.cs +++ b/DS4Windows/HidLibrary/HidDevices.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; using System.Runtime.InteropServices; @@ -55,7 +54,8 @@ namespace DS4Windows for (int j = 0; !found && j < devInfoLen; j++) { VidPidInfo tempInfo = devInfo[j]; - if (tempDev.Attributes.VendorId == tempInfo.vid && + if (tempDev.Capabilities.Usage == 0x05 && + tempDev.Attributes.VendorId == tempInfo.vid && tempDev.Attributes.ProductId == tempInfo.pid) { found = true; diff --git a/DS4Windows/Program.cs b/DS4Windows/Program.cs index 39416bb..06406da 100644 --- a/DS4Windows/Program.cs +++ b/DS4Windows/Program.cs @@ -100,13 +100,10 @@ namespace DS4Windows //if (mutex.WaitOne(TimeSpan.Zero, true)) //{ createControlService(); - rootHub.ScanPurgeHidGuard(); - rootHub.CreateHidGuardKey(); //rootHub = new ControlService(); Application.EnableVisualStyles(); ds4form = new DS4Form(args); - Application.Run(ds4form); - rootHub.removeHidGuardKey(); + Application.Run(); //mutex.ReleaseMutex(); //} @@ -160,14 +157,14 @@ namespace DS4Windows /// /// private delegate void SetFormVisableDelegate(Form frm); - static private void ThreadFormVisable(Form frm) + private static void ThreadFormVisable(Form frm) { if (frm is DS4Form) { // display the form and bring to foreground. - frm.WindowState = FormWindowState.Normal; - frm.Focus(); - frm.Activate(); + DS4Form temp = (DS4Form)frm; + temp.Show(); + temp.WindowState = FormWindowState.Normal; } } } diff --git a/DS4Windows/Properties/AssemblyInfo.cs b/DS4Windows/Properties/AssemblyInfo.cs index f7f67b8..a5b21be 100644 --- a/DS4Windows/Properties/AssemblyInfo.cs +++ b/DS4Windows/Properties/AssemblyInfo.cs @@ -33,7 +33,7 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.5.14")] -[assembly: AssemblyFileVersion("1.5.14")] +[assembly: AssemblyVersion("1.5.17")] +[assembly: AssemblyFileVersion("1.5.17")] [assembly: NeutralResourcesLanguage("en")] diff --git a/README.md b/README.md index 843ab1b..12b88a9 100644 --- a/README.md +++ b/README.md @@ -34,9 +34,9 @@ If your DS4 is not detected by DS4Windows and the lightbar continues to flash yellow, there is a chance that Exclusive Mode has permanently disabled your DS4 in Windows. The easiest way to test if this has happened is for you to plug in the controller into a different USB port and see if it -works then. Although this problem mainly affected versions of -DS4Windows prior to 1.4.109 when using some applications, other mapping -programs can cause the same problem to occur. +works then. Although this problem mainly affected older versions of +DS4Windows (text written after version 1.5.15) for various reasons, +other mapping programs can cause the same problem to occur. If you suspect that your DS4 has been disabled, open the Device Manager (Control Panel\Hardware and Sound\Device Manager) and look for devices listed @@ -59,13 +59,3 @@ be made during code review to try to tweak the changes in order to improve application performance. However, there is a chance that a pull request will be rejected if no reasonable solution can be found to incorporate code changes. -## Tip Jar - -If you would like to send some coin my way, here are some means by -which to do so. - -**Bitcoin:** 1DnMJwjdd7JRfHJap2mmTmADYm38SzR2z9 -**Dogecoin:** D9fhbXp9bCHEhuS8vX1BmVu6t7Y2nVNUCK -**Litecoin:** La5mniW7SFMH2RhqDgUty3RwkBSYbjbnJ6 -**Monero:** 49RvRMiMewaeez1Y2auxHmfMaAUYfhUpBem4ohzRJd9b5acPcxzh1icjnhZfjnYd1S7NQ57reQ7cP1swGre3rpfzUgJhEB7 -**PayPal:** https://paypal.me/ryochan7 diff --git a/TODO.md b/TODO.md index 463d615..03146a9 100644 --- a/TODO.md +++ b/TODO.md @@ -1,7 +1,7 @@ # TODO * Look into adding periodic rumble updates when data does not change -* Look into newer version of HidGuardian +* ~~Look into newer version of HidGuardian~~ * Look into distributing profile properties around various objects rather than using a lot of getters to obtain properties each poll. It will complicate the architecture a little bit but hopefully