Merge branch 'jay' into vigem-udpserver

# Conflicts:
#	DS4Windows/DS4Control/ControlService.cs
This commit is contained in:
Travis Nickles 2018-11-30 14:51:55 -06:00
commit dac9d1ba52
15 changed files with 102 additions and 357 deletions

View File

@ -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 { } });

View File

@ -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);
}

View File

@ -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;

View File

@ -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;

View File

@ -445,10 +445,10 @@
<value>NoControl</value>
</data>
<data name="bnLight3.Location" type="System.Drawing.Point, System.Drawing">
<value>754, 89</value>
<value>748, 89</value>
</data>
<data name="bnLight3.Size" type="System.Drawing.Size, System.Drawing">
<value>139, 22</value>
<value>145, 22</value>
</data>
<data name="bnLight3.TabIndex" type="System.Int32, mscorlib">
<value>50</value>
@ -472,7 +472,7 @@
<value>NoControl</value>
</data>
<data name="pBStatus1.Location" type="System.Drawing.Point, System.Drawing">
<value>352, 34</value>
<value>348, 34</value>
</data>
<data name="pBStatus1.Size" type="System.Drawing.Size, System.Drawing">
<value>39, 20</value>
@ -574,7 +574,7 @@
<value>NoControl</value>
</data>
<data name="bnEditC3.Location" type="System.Drawing.Point, System.Drawing">
<value>714, 89</value>
<value>708, 89</value>
</data>
<data name="bnEditC3.Size" type="System.Drawing.Size, System.Drawing">
<value>34, 22</value>
@ -604,7 +604,7 @@
<value>NoControl</value>
</data>
<data name="bnEditC4.Location" type="System.Drawing.Point, System.Drawing">
<value>714, 117</value>
<value>708, 117</value>
</data>
<data name="bnEditC4.Size" type="System.Drawing.Size, System.Drawing">
<value>34, 22</value>
@ -703,7 +703,7 @@
<value>None</value>
</data>
<data name="cBController1.Location" type="System.Drawing.Point, System.Drawing">
<value>597, 33</value>
<value>591, 33</value>
</data>
<data name="cBController1.Size" type="System.Drawing.Size, System.Drawing">
<value>111, 21</value>
@ -730,7 +730,7 @@
<value>NoControl</value>
</data>
<data name="bnEditC2.Location" type="System.Drawing.Point, System.Drawing">
<value>714, 61</value>
<value>708, 61</value>
</data>
<data name="bnEditC2.Size" type="System.Drawing.Size, System.Drawing">
<value>34, 22</value>
@ -757,7 +757,7 @@
<value>None</value>
</data>
<data name="cBController2.Location" type="System.Drawing.Point, System.Drawing">
<value>597, 61</value>
<value>591, 61</value>
</data>
<data name="cBController2.Size" type="System.Drawing.Size, System.Drawing">
<value>111, 21</value>
@ -781,7 +781,7 @@
<value>None</value>
</data>
<data name="cBController3.Location" type="System.Drawing.Point, System.Drawing">
<value>597, 89</value>
<value>591, 89</value>
</data>
<data name="cBController3.Size" type="System.Drawing.Size, System.Drawing">
<value>111, 21</value>
@ -808,7 +808,7 @@
<value>NoControl</value>
</data>
<data name="bnEditC1.Location" type="System.Drawing.Point, System.Drawing">
<value>714, 33</value>
<value>708, 33</value>
</data>
<data name="bnEditC1.Size" type="System.Drawing.Size, System.Drawing">
<value>34, 22</value>
@ -835,7 +835,7 @@
<value>None</value>
</data>
<data name="cBController4.Location" type="System.Drawing.Point, System.Drawing">
<value>597, 117</value>
<value>591, 117</value>
</data>
<data name="cBController4.Size" type="System.Drawing.Size, System.Drawing">
<value>111, 21</value>
@ -868,7 +868,7 @@
<value>NoControl</value>
</data>
<data name="lbSelectedProfile.Location" type="System.Drawing.Point, System.Drawing">
<value>598, 7</value>
<value>592, 7</value>
</data>
<data name="lbSelectedProfile.Size" type="System.Drawing.Size, System.Drawing">
<value>109, 15</value>
@ -940,7 +940,7 @@
<value>NoControl</value>
</data>
<data name="lbStatus.Location" type="System.Drawing.Point, System.Drawing">
<value>348, 7</value>
<value>344, 7</value>
</data>
<data name="lbStatus.Size" type="System.Drawing.Size, System.Drawing">
<value>47, 15</value>
@ -976,7 +976,7 @@
<value>NoControl</value>
</data>
<data name="lbBattery.Location" type="System.Drawing.Point, System.Drawing">
<value>443, 7</value>
<value>437, 7</value>
</data>
<data name="lbBattery.Size" type="System.Drawing.Size, System.Drawing">
<value>51, 15</value>
@ -1012,7 +1012,7 @@
<value>NoControl</value>
</data>
<data name="lbBatt1.Location" type="System.Drawing.Point, System.Drawing">
<value>449, 36</value>
<value>443, 36</value>
</data>
<data name="lbBatt1.Size" type="System.Drawing.Size, System.Drawing">
<value>39, 15</value>
@ -1048,7 +1048,7 @@
<value>NoControl</value>
</data>
<data name="lbBatt2.Location" type="System.Drawing.Point, System.Drawing">
<value>449, 64</value>
<value>443, 64</value>
</data>
<data name="lbBatt2.Size" type="System.Drawing.Size, System.Drawing">
<value>39, 15</value>
@ -1084,7 +1084,7 @@
<value>NoControl</value>
</data>
<data name="lbBatt3.Location" type="System.Drawing.Point, System.Drawing">
<value>449, 92</value>
<value>443, 92</value>
</data>
<data name="lbBatt3.Size" type="System.Drawing.Size, System.Drawing">
<value>39, 15</value>
@ -1120,7 +1120,7 @@
<value>NoControl</value>
</data>
<data name="lbBatt4.Location" type="System.Drawing.Point, System.Drawing">
<value>449, 120</value>
<value>443, 120</value>
</data>
<data name="lbBatt4.Size" type="System.Drawing.Size, System.Drawing">
<value>39, 15</value>
@ -1150,7 +1150,7 @@
<value>NoControl</value>
</data>
<data name="pBStatus2.Location" type="System.Drawing.Point, System.Drawing">
<value>352, 62</value>
<value>348, 62</value>
</data>
<data name="pBStatus2.Size" type="System.Drawing.Size, System.Drawing">
<value>39, 20</value>
@ -1180,7 +1180,7 @@
<value>NoControl</value>
</data>
<data name="pBStatus3.Location" type="System.Drawing.Point, System.Drawing">
<value>352, 90</value>
<value>348, 90</value>
</data>
<data name="pBStatus3.Size" type="System.Drawing.Size, System.Drawing">
<value>39, 20</value>
@ -1210,7 +1210,7 @@
<value>NoControl</value>
</data>
<data name="pBStatus4.Location" type="System.Drawing.Point, System.Drawing">
<value>352, 118</value>
<value>348, 118</value>
</data>
<data name="pBStatus4.Size" type="System.Drawing.Size, System.Drawing">
<value>39, 20</value>
@ -1243,10 +1243,10 @@
<value>NoControl</value>
</data>
<data name="bnLight1.Location" type="System.Drawing.Point, System.Drawing">
<value>754, 33</value>
<value>748, 33</value>
</data>
<data name="bnLight1.Size" type="System.Drawing.Size, System.Drawing">
<value>139, 22</value>
<value>145, 22</value>
</data>
<data name="bnLight1.TabIndex" type="System.Int32, mscorlib">
<value>50</value>
@ -1273,10 +1273,10 @@
<value>NoControl</value>
</data>
<data name="bnLight2.Location" type="System.Drawing.Point, System.Drawing">
<value>754, 61</value>
<value>748, 61</value>
</data>
<data name="bnLight2.Size" type="System.Drawing.Size, System.Drawing">
<value>139, 22</value>
<value>145, 22</value>
</data>
<data name="bnLight2.TabIndex" type="System.Int32, mscorlib">
<value>51</value>
@ -1303,10 +1303,10 @@
<value>NoControl</value>
</data>
<data name="bnLight4.Location" type="System.Drawing.Point, System.Drawing">
<value>754, 117</value>
<value>748, 117</value>
</data>
<data name="bnLight4.Size" type="System.Drawing.Size, System.Drawing">
<value>139, 22</value>
<value>145, 22</value>
</data>
<data name="bnLight4.TabIndex" type="System.Int32, mscorlib">
<value>52</value>
@ -1336,7 +1336,7 @@
<value>NoControl</value>
</data>
<data name="lbLinkProfile.Location" type="System.Drawing.Point, System.Drawing">
<value>520, 0</value>
<value>514, 0</value>
</data>
<data name="lbLinkProfile.Size" type="System.Drawing.Size, System.Drawing">
<value>67, 30</value>
@ -1375,7 +1375,7 @@
<value>NoControl</value>
</data>
<data name="linkCB1.Location" type="System.Drawing.Point, System.Drawing">
<value>546, 37</value>
<value>540, 37</value>
</data>
<data name="linkCB1.Size" type="System.Drawing.Size, System.Drawing">
<value>15, 14</value>
@ -1408,7 +1408,7 @@
<value>NoControl</value>
</data>
<data name="linkCB2.Location" type="System.Drawing.Point, System.Drawing">
<value>546, 65</value>
<value>540, 65</value>
</data>
<data name="linkCB2.Size" type="System.Drawing.Size, System.Drawing">
<value>15, 14</value>
@ -1441,7 +1441,7 @@
<value>NoControl</value>
</data>
<data name="linkCB3.Location" type="System.Drawing.Point, System.Drawing">
<value>546, 93</value>
<value>540, 93</value>
</data>
<data name="linkCB3.Size" type="System.Drawing.Size, System.Drawing">
<value>15, 14</value>
@ -1474,7 +1474,7 @@
<value>NoControl</value>
</data>
<data name="linkCB4.Location" type="System.Drawing.Point, System.Drawing">
<value>546, 121</value>
<value>540, 121</value>
</data>
<data name="linkCB4.Size" type="System.Drawing.Size, System.Drawing">
<value>15, 14</value>
@ -1522,7 +1522,7 @@
<value>0</value>
</data>
<data name="tLPControllers.LayoutSettings" type="System.Windows.Forms.TableLayoutSettings, System.Windows.Forms">
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="bnLight3" Row="3" RowSpan="1" Column="6" ColumnSpan="1" /&gt;&lt;Control Name="pBStatus1" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="lbPad1" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="lbPad2" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="bnEditC3" Row="3" RowSpan="1" Column="5" ColumnSpan="1" /&gt;&lt;Control Name="bnEditC4" Row="4" RowSpan="1" Column="5" ColumnSpan="1" /&gt;&lt;Control Name="lbPad3" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="lbPad4" Row="4" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="cBController1" Row="1" RowSpan="1" Column="4" ColumnSpan="1" /&gt;&lt;Control Name="bnEditC2" Row="2" RowSpan="1" Column="5" ColumnSpan="1" /&gt;&lt;Control Name="cBController2" Row="2" RowSpan="1" Column="4" ColumnSpan="1" /&gt;&lt;Control Name="cBController3" Row="3" RowSpan="1" Column="4" ColumnSpan="1" /&gt;&lt;Control Name="bnEditC1" Row="1" RowSpan="1" Column="5" ColumnSpan="1" /&gt;&lt;Control Name="cBController4" Row="4" RowSpan="1" Column="4" ColumnSpan="1" /&gt;&lt;Control Name="lbSelectedProfile" Row="0" RowSpan="1" Column="4" ColumnSpan="1" /&gt;&lt;Control Name="lbID" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="lbStatus" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="lbBattery" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /&gt;&lt;Control Name="lbBatt1" Row="1" RowSpan="1" Column="2" ColumnSpan="1" /&gt;&lt;Control Name="lbBatt2" Row="2" RowSpan="1" Column="2" ColumnSpan="1" /&gt;&lt;Control Name="lbBatt3" Row="3" RowSpan="1" Column="2" ColumnSpan="1" /&gt;&lt;Control Name="lbBatt4" Row="4" RowSpan="1" Column="2" ColumnSpan="1" /&gt;&lt;Control Name="pBStatus2" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="pBStatus3" Row="3" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="pBStatus4" Row="4" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="bnLight1" Row="1" RowSpan="1" Column="6" ColumnSpan="1" /&gt;&lt;Control Name="bnLight2" Row="2" RowSpan="1" Column="6" ColumnSpan="1" /&gt;&lt;Control Name="bnLight4" Row="4" RowSpan="1" Column="6" ColumnSpan="1" /&gt;&lt;Control Name="lbLinkProfile" Row="0" RowSpan="1" Column="3" ColumnSpan="1" /&gt;&lt;Control Name="linkCB1" Row="1" RowSpan="1" Column="3" ColumnSpan="1" /&gt;&lt;Control Name="linkCB2" Row="2" RowSpan="1" Column="3" ColumnSpan="1" /&gt;&lt;Control Name="linkCB3" Row="3" RowSpan="1" Column="3" ColumnSpan="1" /&gt;&lt;Control Name="linkCB4" Row="4" RowSpan="1" Column="3" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="Percent,62.29144,Percent,20.02225,Percent,17.68632,Absolute,80,AutoSize,0,AutoSize,0,Absolute,144" /&gt;&lt;Rows Styles="AutoSize,0,Percent,25,Percent,25,Percent,25,Percent,25" /&gt;&lt;/TableLayoutSettings&gt;</value>
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="bnLight3" Row="3" RowSpan="1" Column="6" ColumnSpan="1" /&gt;&lt;Control Name="pBStatus1" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="lbPad1" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="lbPad2" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="bnEditC3" Row="3" RowSpan="1" Column="5" ColumnSpan="1" /&gt;&lt;Control Name="bnEditC4" Row="4" RowSpan="1" Column="5" ColumnSpan="1" /&gt;&lt;Control Name="lbPad3" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="lbPad4" Row="4" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="cBController1" Row="1" RowSpan="1" Column="4" ColumnSpan="1" /&gt;&lt;Control Name="bnEditC2" Row="2" RowSpan="1" Column="5" ColumnSpan="1" /&gt;&lt;Control Name="cBController2" Row="2" RowSpan="1" Column="4" ColumnSpan="1" /&gt;&lt;Control Name="cBController3" Row="3" RowSpan="1" Column="4" ColumnSpan="1" /&gt;&lt;Control Name="bnEditC1" Row="1" RowSpan="1" Column="5" ColumnSpan="1" /&gt;&lt;Control Name="cBController4" Row="4" RowSpan="1" Column="4" ColumnSpan="1" /&gt;&lt;Control Name="lbSelectedProfile" Row="0" RowSpan="1" Column="4" ColumnSpan="1" /&gt;&lt;Control Name="lbID" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="lbStatus" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="lbBattery" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /&gt;&lt;Control Name="lbBatt1" Row="1" RowSpan="1" Column="2" ColumnSpan="1" /&gt;&lt;Control Name="lbBatt2" Row="2" RowSpan="1" Column="2" ColumnSpan="1" /&gt;&lt;Control Name="lbBatt3" Row="3" RowSpan="1" Column="2" ColumnSpan="1" /&gt;&lt;Control Name="lbBatt4" Row="4" RowSpan="1" Column="2" ColumnSpan="1" /&gt;&lt;Control Name="pBStatus2" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="pBStatus3" Row="3" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="pBStatus4" Row="4" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="bnLight1" Row="1" RowSpan="1" Column="6" ColumnSpan="1" /&gt;&lt;Control Name="bnLight2" Row="2" RowSpan="1" Column="6" ColumnSpan="1" /&gt;&lt;Control Name="bnLight4" Row="4" RowSpan="1" Column="6" ColumnSpan="1" /&gt;&lt;Control Name="lbLinkProfile" Row="0" RowSpan="1" Column="3" ColumnSpan="1" /&gt;&lt;Control Name="linkCB1" Row="1" RowSpan="1" Column="3" ColumnSpan="1" /&gt;&lt;Control Name="linkCB2" Row="2" RowSpan="1" Column="3" ColumnSpan="1" /&gt;&lt;Control Name="linkCB3" Row="3" RowSpan="1" Column="3" ColumnSpan="1" /&gt;&lt;Control Name="linkCB4" Row="4" RowSpan="1" Column="3" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="Percent,62.29144,Percent,20.02225,Percent,17.68632,Absolute,80,AutoSize,0,AutoSize,0,Absolute,150" /&gt;&lt;Rows Styles="AutoSize,0,Percent,25,Percent,25,Percent,25,Percent,25" /&gt;&lt;/TableLayoutSettings&gt;</value>
</data>
<data name="lbNoControllers.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
@ -2814,6 +2814,9 @@
<data name="label2.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="label2.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="label2.Location" type="System.Drawing.Point, System.Drawing">
<value>118, 2</value>
</data>
@ -2841,6 +2844,9 @@
<data name="ckUdpServ.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="ckUdpServ.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="ckUdpServ.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 1</value>
</data>
@ -2929,7 +2935,7 @@
<value>languagePackComboBox1</value>
</data>
<data name="&gt;&gt;languagePackComboBox1.Type" xml:space="preserve">
<value>DS4Windows.DS4Forms.LanguagePackComboBox, DS4Windows, Version=1.5.13.0, Culture=neutral, PublicKeyToken=null</value>
<value>DS4Windows.DS4Forms.LanguagePackComboBox, DS4Windows, Version=1.5.15.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;languagePackComboBox1.Parent" xml:space="preserve">
<value>fLPSettings</value>
@ -3093,96 +3099,6 @@
<data name="&gt;&gt;lLBUpdate.ZOrder" xml:space="preserve">
<value>4</value>
</data>
<data name="hidGuardWhiteList.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="hidGuardWhiteList.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="hidGuardWhiteList.Location" type="System.Drawing.Point, System.Drawing">
<value>7, 69</value>
</data>
<data name="hidGuardWhiteList.Size" type="System.Drawing.Size, System.Drawing">
<value>150, 13</value>
</data>
<data name="hidGuardWhiteList.TabIndex" type="System.Int32, mscorlib">
<value>53</value>
</data>
<data name="hidGuardWhiteList.Text" xml:space="preserve">
<value>Write HidGuardian Device List</value>
</data>
<data name="&gt;&gt;hidGuardWhiteList.Name" xml:space="preserve">
<value>hidGuardWhiteList</value>
</data>
<data name="&gt;&gt;hidGuardWhiteList.Type" xml:space="preserve">
<value>System.Windows.Forms.LinkLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;hidGuardWhiteList.Parent" xml:space="preserve">
<value>flowLayoutPanel1</value>
</data>
<data name="&gt;&gt;hidGuardWhiteList.ZOrder" xml:space="preserve">
<value>5</value>
</data>
<data name="clrHidGuardWlistLinkLabel.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="clrHidGuardWlistLinkLabel.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="clrHidGuardWlistLinkLabel.Location" type="System.Drawing.Point, System.Drawing">
<value>7, 82</value>
</data>
<data name="clrHidGuardWlistLinkLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>141, 13</value>
</data>
<data name="clrHidGuardWlistLinkLabel.TabIndex" type="System.Int32, mscorlib">
<value>54</value>
</data>
<data name="clrHidGuardWlistLinkLabel.Text" xml:space="preserve">
<value>Clear HidGuardian Whitelists</value>
</data>
<data name="&gt;&gt;clrHidGuardWlistLinkLabel.Name" xml:space="preserve">
<value>clrHidGuardWlistLinkLabel</value>
</data>
<data name="&gt;&gt;clrHidGuardWlistLinkLabel.Type" xml:space="preserve">
<value>System.Windows.Forms.LinkLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;clrHidGuardWlistLinkLabel.Parent" xml:space="preserve">
<value>flowLayoutPanel1</value>
</data>
<data name="&gt;&gt;clrHidGuardWlistLinkLabel.ZOrder" xml:space="preserve">
<value>6</value>
</data>
<data name="hidGuardRegLinkLabel.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="hidGuardRegLinkLabel.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="hidGuardRegLinkLabel.Location" type="System.Drawing.Point, System.Drawing">
<value>7, 95</value>
</data>
<data name="hidGuardRegLinkLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>106, 13</value>
</data>
<data name="hidGuardRegLinkLabel.TabIndex" type="System.Int32, mscorlib">
<value>55</value>
</data>
<data name="hidGuardRegLinkLabel.Text" xml:space="preserve">
<value>HidGuardian Regedit</value>
</data>
<data name="&gt;&gt;hidGuardRegLinkLabel.Name" xml:space="preserve">
<value>hidGuardRegLinkLabel</value>
</data>
<data name="&gt;&gt;hidGuardRegLinkLabel.Type" xml:space="preserve">
<value>System.Windows.Forms.LinkLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;hidGuardRegLinkLabel.Parent" xml:space="preserve">
<value>flowLayoutPanel1</value>
</data>
<data name="&gt;&gt;hidGuardRegLinkLabel.ZOrder" xml:space="preserve">
<value>7</value>
</data>
<data name="flowLayoutPanel1.FlowDirection" type="System.Windows.Forms.FlowDirection, System.Windows.Forms">
<value>TopDown</value>
</data>
@ -3193,7 +3109,7 @@
<value>4, 4, 4, 4</value>
</data>
<data name="flowLayoutPanel1.Size" type="System.Drawing.Size, System.Drawing">
<value>204, 158</value>
<value>164, 112</value>
</data>
<data name="flowLayoutPanel1.TabIndex" type="System.Int32, mscorlib">
<value>56</value>
@ -3736,7 +3652,7 @@
<value>advColorDialog</value>
</data>
<data name="&gt;&gt;advColorDialog.Type" xml:space="preserve">
<value>DS4Windows.AdvancedColorDialog, DS4Windows, Version=1.5.13.0, Culture=neutral, PublicKeyToken=null</value>
<value>DS4Windows.AdvancedColorDialog, DS4Windows, Version=1.5.15.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>DS4Form</value>

View File

@ -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;

View File

@ -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)
{

View File

@ -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();
}

View File

@ -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,

View File

@ -87,7 +87,7 @@
<DebugType>none</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<ErrorReport>none</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<DefineConstants>WIN64</DefineConstants>
<GenerateSerializationAssemblies>On</GenerateSerializationAssemblies>
@ -113,7 +113,7 @@
<DebugType>none</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<ErrorReport>none</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
<LangVersion>6</LangVersion>

View File

@ -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;

View File

@ -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
/// </summary>
/// <param name="frm"></param>
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;
}
}
}

View File

@ -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")]

View File

@ -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

View File

@ -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