Merge remote-tracking branch 'upstream/jay' into jay

This commit is contained in:
mika-n 2018-12-04 00:54:20 +02:00
commit 3ab55d102e
4 changed files with 20 additions and 32 deletions

View File

@ -181,9 +181,9 @@ namespace DS4Windows
{ {
if (state && _udpServer == null) if (state && _udpServer == null)
{ {
udpChangeStatus = true;
TestQueueBus(() => TestQueueBus(() =>
{ {
udpChangeStatus = true;
_udpServer = new UdpServer(GetPadDetailForIdx); _udpServer = new UdpServer(GetPadDetailForIdx);
var UDP_SERVER_PORT = Global.getUDPServerPortNum(); var UDP_SERVER_PORT = Global.getUDPServerPortNum();
@ -315,7 +315,7 @@ namespace DS4Windows
ChangeUDPStatus(true); ChangeUDPStatus(true);
while (udpChangeStatus == true) while (udpChangeStatus == true)
{ {
Task.Delay(100); Thread.SpinWait(500);
} }
} }
@ -426,25 +426,6 @@ namespace DS4Windows
} }
running = true; running = true;
if (_udpServer != null)
{
//var UDP_SERVER_PORT = 26760;
var UDP_SERVER_PORT = Global.getUDPServerPortNum();
try
{
_udpServer.Start(UDP_SERVER_PORT);
LogDebug("UDP server listening on port " + UDP_SERVER_PORT);
}
catch (System.Net.Sockets.SocketException ex)
{
var errMsg = String.Format("Couldn't start UDP server on port {0}, outside applications won't be able to access pad data ({1})", UDP_SERVER_PORT, ex.SocketErrorCode);
LogDebug(errMsg, true);
AppLogger.LogToTray(errMsg, true, true);
}
}
} }
else else
{ {

View File

@ -85,6 +85,7 @@ namespace DS4Windows
for (int num = 0; num <= 19; num++) for (int num = 0; num <= 19; num++)
{ {
SocketAsyncEventArgs args = new SocketAsyncEventArgs(); SocketAsyncEventArgs args = new SocketAsyncEventArgs();
args.SetBuffer(new byte[100], 0, 100);
argsList[num] = args; argsList[num] = args;
} }
} }
@ -186,13 +187,14 @@ namespace DS4Windows
//try { udpSock.SendTo(packetData, clientEP); } //try { udpSock.SendTo(packetData, clientEP); }
int temp = 0; int temp = 0;
poolLock.EnterWriteLock(); poolLock.EnterWriteLock();
listInd = ++listInd % 20;
temp = listInd; temp = listInd;
listInd = ++listInd % 20;
SocketAsyncEventArgs args = argsList[temp];
poolLock.ExitWriteLock(); poolLock.ExitWriteLock();
SocketAsyncEventArgs args = argsList[temp];
args.RemoteEndPoint = clientEP; args.RemoteEndPoint = clientEP;
args.SetBuffer(packetData, 0, packetData.Length); Array.Copy(packetData, args.Buffer, packetData.Length);
//args.SetBuffer(packetData, 0, packetData.Length);
try { try {
udpSock.SendToAsync(args); udpSock.SendToAsync(args);
} }
@ -651,13 +653,13 @@ namespace DS4Windows
//try { udpSock.SendTo(outputData, cl); } //try { udpSock.SendTo(outputData, cl); }
int temp = 0; int temp = 0;
poolLock.EnterWriteLock(); poolLock.EnterWriteLock();
listInd = ++listInd % 20;
temp = listInd; temp = listInd;
listInd = ++listInd % 20;
SocketAsyncEventArgs args = argsList[temp];
poolLock.ExitWriteLock(); poolLock.ExitWriteLock();
SocketAsyncEventArgs args = argsList[temp];
args.RemoteEndPoint = cl; args.RemoteEndPoint = cl;
args.SetBuffer(outputData, 0, outputData.Length); Array.Copy(outputData, args.Buffer, outputData.Length);
try { try {
udpSock.SendToAsync(args); udpSock.SendToAsync(args);
} }

View File

@ -2549,13 +2549,18 @@ Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question
if (!state) if (!state)
{ {
Program.rootHub.ChangeMotionEventStatus(state); Program.rootHub.ChangeMotionEventStatus(state);
await TaskRunner.Delay(100); await TaskRunner.Delay(100).ContinueWith((t) =>
Program.rootHub.ChangeUDPStatus(state); {
Program.rootHub.ChangeUDPStatus(state);
});
} }
else else
{ {
Program.rootHub.ChangeUDPStatus(state); Program.rootHub.ChangeUDPStatus(state);
Program.rootHub.ChangeMotionEventStatus(state); await TaskRunner.Delay(100).ContinueWith((t) =>
{
Program.rootHub.ChangeMotionEventStatus(state);
});
} }
nUDUdpPortNum.Enabled = state; nUDUdpPortNum.Enabled = state;

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 // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.5.16")] [assembly: AssemblyVersion("1.5.17")]
[assembly: AssemblyFileVersion("1.5.16")] [assembly: AssemblyFileVersion("1.5.17")]
[assembly: NeutralResourcesLanguage("en")] [assembly: NeutralResourcesLanguage("en")]