mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-12-24 15:41:49 +01:00
Invoke log methods async
This commit is contained in:
parent
ad9f707cda
commit
e63001e3ab
@ -24,6 +24,7 @@ namespace DS4Windows
|
||||
{
|
||||
public string[] arguements;
|
||||
delegate void LogDebugDelegate(DateTime Time, String Data, bool warning);
|
||||
delegate void NotificationDelegate(object sender, DebugEventArgs args);
|
||||
protected Label[] Pads, Batteries;
|
||||
protected ComboBox[] cbs;
|
||||
protected Button[] ebns;
|
||||
@ -324,6 +325,7 @@ namespace DS4Windows
|
||||
cBUpdateTime.SelectedIndex = 0;
|
||||
nUDUpdateTime.Value = checkwhen;
|
||||
}
|
||||
|
||||
Uri url = new Uri("http://23.236.26.40/ds4windows/files/builds/newest.txt"); //Sorry other devs, gonna have to find your own server
|
||||
|
||||
|
||||
@ -381,7 +383,6 @@ namespace DS4Windows
|
||||
|
||||
UpdateTheUpdater();
|
||||
|
||||
|
||||
this.StartWindowsCheckBox.CheckedChanged += new System.EventHandler(this.StartWindowsCheckBox_CheckedChanged);
|
||||
}
|
||||
|
||||
@ -508,39 +509,52 @@ namespace DS4Windows
|
||||
lbTest.Visible = true;
|
||||
lbTest.Text = ((int)(Program.rootHub.ExposedState[0].AccelX * 2) / 2f).ToString();
|
||||
}
|
||||
|
||||
void Hotkeys(object sender, EventArgs e)
|
||||
{
|
||||
if (SwipeProfiles)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
string slide = Program.rootHub.TouchpadSlide(i);
|
||||
if (slide == "left")
|
||||
{
|
||||
if (cbs[i].SelectedIndex <= 0)
|
||||
cbs[i].SelectedIndex = cbs[i].Items.Count - 2;
|
||||
else
|
||||
cbs[i].SelectedIndex--;
|
||||
|
||||
}
|
||||
else if (slide == "right")
|
||||
{
|
||||
if (cbs[i].SelectedIndex == cbs[i].Items.Count - 2)
|
||||
cbs[i].SelectedIndex = 0;
|
||||
else
|
||||
cbs[i].SelectedIndex++;
|
||||
}
|
||||
|
||||
if (slide.Contains("t"))
|
||||
ShowNotification(this, Properties.Resources.UsingProfile.Replace("*number*", (i + 1).ToString()).Replace("*Profile name*", cbs[i].Text));
|
||||
}
|
||||
}
|
||||
|
||||
//Check for process for auto profiles
|
||||
if (tempProfileProgram == "null")
|
||||
{
|
||||
for (int i = 0; i < programpaths.Count; i++)
|
||||
{
|
||||
string name = programpaths[i].ToLower().Replace('/', '\\');
|
||||
if (name == GetTopWindowName().ToLower().Replace('/', '\\'))
|
||||
{
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
if (proprofiles[j][i] != "(none)" && proprofiles[j][i] != Properties.Resources.noneProfile)
|
||||
{
|
||||
LoadTempProfile(j, proprofiles[j][i], true, Program.rootHub); //j is controller index, i is filename
|
||||
if (LaunchProgram[j] != string.Empty) Process.Start(LaunchProgram[j]);
|
||||
}
|
||||
}
|
||||
|
||||
if (turnOffTempProfiles[i])
|
||||
{
|
||||
turnOffTemp = true;
|
||||
@ -551,10 +565,12 @@ namespace DS4Windows
|
||||
btnStartStop.Text = Properties.Resources.StartText;
|
||||
}
|
||||
}
|
||||
|
||||
tempProfileProgram = name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tempProfileProgram != GetTopWindowName().ToLower().Replace('/', '\\'))
|
||||
@ -562,6 +578,7 @@ namespace DS4Windows
|
||||
tempProfileProgram = "null";
|
||||
for (int j = 0; j < 4; j++)
|
||||
LoadProfile(j, false, Program.rootHub);
|
||||
|
||||
if (turnOffTemp)
|
||||
{
|
||||
turnOffTemp = false;
|
||||
@ -573,6 +590,7 @@ namespace DS4Windows
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bat != null && bat.HasExited && runningBat)
|
||||
{
|
||||
Process.Start("explorer.exe");
|
||||
@ -767,6 +785,7 @@ namespace DS4Windows
|
||||
WP.Dock = DockStyle.Fill;
|
||||
tabAutoProfiles.Controls.Add(WP);
|
||||
}
|
||||
|
||||
protected void LogDebug(DateTime Time, String Data, bool warning)
|
||||
{
|
||||
if (lvDebug.InvokeRequired)
|
||||
@ -774,7 +793,9 @@ namespace DS4Windows
|
||||
LogDebugDelegate d = new LogDebugDelegate(LogDebug);
|
||||
try
|
||||
{
|
||||
this.Invoke(d, new Object[] { Time, Data, warning });
|
||||
// Make sure to invoke method asynchronously instead of waiting for result
|
||||
this.BeginInvoke(d, new object[] { Time, Data, warning });
|
||||
//this.Invoke(d, new object[] { Time, Data, warning });
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
@ -790,6 +811,19 @@ namespace DS4Windows
|
||||
}
|
||||
|
||||
protected void ShowNotification(object sender, DebugEventArgs args)
|
||||
{
|
||||
if (this.InvokeRequired)
|
||||
{
|
||||
NotificationDelegate d = new NotificationDelegate(ShowNotification);
|
||||
|
||||
try
|
||||
{
|
||||
// Make sure to invoke method asynchronously instead of waiting for result
|
||||
this.BeginInvoke(d, new object[] { sender, args });
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Form.ActiveForm != this && (Notifications == 2 || (Notifications == 1 && args.Warning) || sender != null))
|
||||
{
|
||||
@ -798,6 +832,7 @@ namespace DS4Windows
|
||||
notifyIcon1.ShowBalloonTip(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void ShowNotification(object sender, string text)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user