mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2025-01-25 22:41:16 +01:00
Change thread affinity of DS4Device objects
Drastically improves performance. Might be able to remove the need for the separate input thread later.
This commit is contained in:
parent
150476d6aa
commit
6190ddff9b
@ -107,7 +107,7 @@ namespace DS4Windows
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Start(bool showlog = true)
|
public bool Start(object tempui, bool showlog = true)
|
||||||
{
|
{
|
||||||
if (x360Bus.Open() && x360Bus.Start())
|
if (x360Bus.Open() && x360Bus.Start())
|
||||||
{
|
{
|
||||||
@ -141,7 +141,7 @@ namespace DS4Windows
|
|||||||
task.Start();
|
task.Start();
|
||||||
|
|
||||||
DS4Controllers[i] = device;
|
DS4Controllers[i] = device;
|
||||||
device.setUiContext(SynchronizationContext.Current);
|
device.setUiContext(tempui as SynchronizationContext);
|
||||||
device.Removal += this.On_DS4Removal;
|
device.Removal += this.On_DS4Removal;
|
||||||
device.Removal += DS4Devices.On_Removal;
|
device.Removal += DS4Devices.On_Removal;
|
||||||
device.SyncChange += this.On_SyncChange;
|
device.SyncChange += this.On_SyncChange;
|
||||||
|
@ -16,6 +16,7 @@ using Microsoft.Win32.TaskScheduler;
|
|||||||
using System.Security.Principal;
|
using System.Security.Principal;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
|
using TaskRunner = System.Threading.Tasks.Task;
|
||||||
using static DS4Windows.Global;
|
using static DS4Windows.Global;
|
||||||
|
|
||||||
namespace DS4Windows
|
namespace DS4Windows
|
||||||
@ -416,7 +417,7 @@ namespace DS4Windows
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
System.Threading.Tasks.Task.Run(() => { UpdateTheUpdater(); });
|
TaskRunner.Run(() => { UpdateTheUpdater(); });
|
||||||
|
|
||||||
this.StartWindowsCheckBox.CheckedChanged += new EventHandler(this.StartWindowsCheckBox_CheckedChanged);
|
this.StartWindowsCheckBox.CheckedChanged += new EventHandler(this.StartWindowsCheckBox_CheckedChanged);
|
||||||
new ToolTip().SetToolTip(StartWindowsCheckBox, Properties.Resources.RunAtStartup);
|
new ToolTip().SetToolTip(StartWindowsCheckBox, Properties.Resources.RunAtStartup);
|
||||||
@ -465,14 +466,11 @@ namespace DS4Windows
|
|||||||
|
|
||||||
private void blankControllerTab()
|
private void blankControllerTab()
|
||||||
{
|
{
|
||||||
bool nocontrollers = true;
|
for (int Index = 0, PadsLen = Pads.Length;
|
||||||
for (Int32 Index = 0, PadsLen = Pads.Length; Index < PadsLen; Index++)
|
Index < PadsLen; Index++)
|
||||||
{
|
{
|
||||||
// Make sure a controller exists
|
|
||||||
if (Index < ControlService.DS4_CONTROLLER_COUNT)
|
if (Index < ControlService.DS4_CONTROLLER_COUNT)
|
||||||
{
|
{
|
||||||
Pads[Index].Text = "";
|
|
||||||
|
|
||||||
statPB[Index].Visible = false; toolTip1.SetToolTip(statPB[Index], "");
|
statPB[Index].Visible = false; toolTip1.SetToolTip(statPB[Index], "");
|
||||||
Batteries[Index].Text = Properties.Resources.NA;
|
Batteries[Index].Text = Properties.Resources.NA;
|
||||||
Pads[Index].Text = Properties.Resources.Disconnected;
|
Pads[Index].Text = Properties.Resources.Disconnected;
|
||||||
@ -480,8 +478,8 @@ namespace DS4Windows
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lbNoControllers.Visible = nocontrollers;
|
lbNoControllers.Visible = true;
|
||||||
tLPControllers.Visible = !nocontrollers;
|
tLPControllers.Visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateTheUpdater()
|
private void UpdateTheUpdater()
|
||||||
@ -946,11 +944,18 @@ namespace DS4Windows
|
|||||||
btnStartStop_Clicked();
|
btnStartStop_Clicked();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void btnStartStop_Clicked(bool log = true)
|
private void serviceStartup(bool log)
|
||||||
{
|
{
|
||||||
if (btnStartStop.Text == Properties.Resources.StartText)
|
var uiContext = SynchronizationContext.Current;
|
||||||
|
TaskRunner.Run(() =>
|
||||||
|
{
|
||||||
|
Program.rootHub.Start(uiContext, log);
|
||||||
|
this.Invoke((System.Action)(() => { serviceStartupFinish(); }));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void serviceStartupFinish()
|
||||||
{
|
{
|
||||||
Program.rootHub.Start(log);
|
|
||||||
if (SwipeProfiles && !hotkeysTimer.Enabled)
|
if (SwipeProfiles && !hotkeysTimer.Enabled)
|
||||||
{
|
{
|
||||||
hotkeysTimer.Start();
|
hotkeysTimer.Start();
|
||||||
@ -963,10 +968,18 @@ namespace DS4Windows
|
|||||||
|
|
||||||
btnStartStop.Text = Properties.Resources.StopText;
|
btnStartStop.Text = Properties.Resources.StopText;
|
||||||
}
|
}
|
||||||
else if (btnStartStop.Text == Properties.Resources.StopText)
|
|
||||||
|
private void serviceShutdown(bool log)
|
||||||
|
{
|
||||||
|
TaskRunner.Run(() =>
|
||||||
{
|
{
|
||||||
blankControllerTab();
|
|
||||||
Program.rootHub.Stop(log);
|
Program.rootHub.Stop(log);
|
||||||
|
this.Invoke((System.Action)(() => { serviceShutdownFinish(); }));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void serviceShutdownFinish()
|
||||||
|
{
|
||||||
hotkeysTimer.Stop();
|
hotkeysTimer.Stop();
|
||||||
autoProfilesTimer.Stop();
|
autoProfilesTimer.Stop();
|
||||||
btnStartStop.Text = Properties.Resources.StartText;
|
btnStartStop.Text = Properties.Resources.StartText;
|
||||||
@ -974,6 +987,18 @@ namespace DS4Windows
|
|||||||
populateFullNotifyText();
|
populateFullNotifyText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void btnStartStop_Clicked(bool log = true)
|
||||||
|
{
|
||||||
|
if (btnStartStop.Text == Properties.Resources.StartText)
|
||||||
|
{
|
||||||
|
serviceStartup(log);
|
||||||
|
}
|
||||||
|
else if (btnStartStop.Text == Properties.Resources.StopText)
|
||||||
|
{
|
||||||
|
blankControllerTab();
|
||||||
|
serviceShutdown(log);
|
||||||
|
}
|
||||||
|
|
||||||
startToolStripMenuItem.Text = btnStartStop.Text;
|
startToolStripMenuItem.Text = btnStartStop.Text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1004,7 +1029,7 @@ namespace DS4Windows
|
|||||||
if (!inHotPlug)
|
if (!inHotPlug)
|
||||||
{
|
{
|
||||||
inHotPlug = true;
|
inHotPlug = true;
|
||||||
System.Threading.Tasks.Task.Run(() => { InnerHotplug2(uiContext); });
|
TaskRunner.Run(() => { InnerHotplug2(uiContext); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1032,7 +1057,7 @@ namespace DS4Windows
|
|||||||
while (loopHotplug == true)
|
while (loopHotplug == true)
|
||||||
{
|
{
|
||||||
Program.rootHub.HotPlug(uiContext);
|
Program.rootHub.HotPlug(uiContext);
|
||||||
//Tasks.Task.Run(() => { Program.rootHub.HotPlug(uiContext); });
|
//TaskRunner.Run(() => { Program.rootHub.HotPlug(uiContext); });
|
||||||
lock (hotplugCounterLock)
|
lock (hotplugCounterLock)
|
||||||
{
|
{
|
||||||
hotplugCounter--;
|
hotplugCounter--;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user