From 10194996129ed2b0bf395de0c670b4166e835738 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Sat, 29 Sep 2018 04:42:22 -0500 Subject: [PATCH] Resolve name collision with Log class and Diagnostics namespace Makes app snappier --- DS4Windows/DS4Control/ControlService.cs | 28 ++++++++++++------------- DS4Windows/DS4Control/Log.cs | 2 +- DS4Windows/DS4Control/Mapping.cs | 2 +- DS4Windows/DS4Control/ScpUtil.cs | 14 ++++++------- DS4Windows/DS4Forms/DS4Form.cs | 10 ++++----- DS4Windows/DS4Library/DS4Device.cs | 8 +++---- 6 files changed, 32 insertions(+), 32 deletions(-) diff --git a/DS4Windows/DS4Control/ControlService.cs b/DS4Windows/DS4Control/ControlService.cs index bf12f13..933b78f 100644 --- a/DS4Windows/DS4Control/ControlService.cs +++ b/DS4Windows/DS4Control/ControlService.cs @@ -198,7 +198,7 @@ namespace DS4Windows 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); - Log.LogToTray(errMsg, true, true); + AppLogger.LogToTray(errMsg, true, true); } udpChangeStatus = false; @@ -211,7 +211,7 @@ namespace DS4Windows udpChangeStatus = true; _udpServer.Stop(); _udpServer = null; - Log.LogToGui("Closed UDP server", false); + AppLogger.LogToGui("Closed UDP server", false); udpChangeStatus = false; }); } @@ -276,7 +276,7 @@ namespace DS4Windows 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); - Log.LogToTray(errMsg, true, true); + AppLogger.LogToTray(errMsg, true, true); } changingUDPPort = false; @@ -289,7 +289,7 @@ namespace DS4Windows string message = Properties.Resources.CouldNotOpenDS4.Replace("*Mac address*", device.getMacAddress()) + " " + Properties.Resources.QuitOtherPrograms; LogDebug(message, true); - Log.LogToTray(message, true); + AppLogger.LogToTray(message, true); } } @@ -490,13 +490,13 @@ namespace DS4Windows { string prolog = Properties.Resources.UsingProfile.Replace("*number*", (i + 1).ToString()).Replace("*Profile name*", ProfilePath[i]); LogDebug(prolog); - Log.LogToTray(prolog); + AppLogger.LogToTray(prolog); } else { string prolog = Properties.Resources.NotUsingProfile.Replace("*number*", (i + 1).ToString()); LogDebug(prolog); - Log.LogToTray(prolog); + AppLogger.LogToTray(prolog); } } @@ -507,7 +507,7 @@ namespace DS4Windows catch (Exception e) { LogDebug(e.Message); - Log.LogToTray(e.Message); + AppLogger.LogToTray(e.Message); } running = true; @@ -527,7 +527,7 @@ namespace DS4Windows 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); - Log.LogToTray(errMsg, true, true); + AppLogger.LogToTray(errMsg, true, true); } } } @@ -535,7 +535,7 @@ namespace DS4Windows { string logMessage = "Could not connect to Scp Virtual Bus Driver. Please check the status of the System device in Device Manager"; LogDebug(logMessage); - Log.LogToTray(logMessage); + AppLogger.LogToTray(logMessage); } runHotPlug = true; @@ -719,13 +719,13 @@ namespace DS4Windows { string prolog = Properties.Resources.UsingProfile.Replace("*number*", (Index + 1).ToString()).Replace("*Profile name*", ProfilePath[Index]); LogDebug(prolog); - Log.LogToTray(prolog); + AppLogger.LogToTray(prolog); } else { string prolog = Properties.Resources.NotUsingProfile.Replace("*number*", (Index + 1).ToString()); LogDebug(prolog); - Log.LogToTray(prolog); + AppLogger.LogToTray(prolog); } break; @@ -1028,7 +1028,7 @@ namespace DS4Windows } LogDebug(removed); - Log.LogToTray(removed); + AppLogger.LogToTray(removed); /*Stopwatch sw = new Stopwatch(); sw.Start(); while (sw.ElapsedMilliseconds < XINPUT_UNPLUG_SETTLE_TIME) @@ -1291,7 +1291,7 @@ namespace DS4Windows getTouchSensitivity()[deviceID] = 0; getScrollSensitivity()[deviceID] = 0; LogDebug(Properties.Resources.TouchpadMovementOff); - Log.LogToTray(Properties.Resources.TouchpadMovementOff); + AppLogger.LogToTray(Properties.Resources.TouchpadMovementOff); touchreleased[deviceID] = false; } else if (touchreleased[deviceID]) @@ -1299,7 +1299,7 @@ namespace DS4Windows getTouchSensitivity()[deviceID] = oldtouchvalue[deviceID]; getScrollSensitivity()[deviceID] = oldscrollvalue[deviceID]; LogDebug(Properties.Resources.TouchpadMovementOn); - Log.LogToTray(Properties.Resources.TouchpadMovementOn); + AppLogger.LogToTray(Properties.Resources.TouchpadMovementOn); touchreleased[deviceID] = false; } } diff --git a/DS4Windows/DS4Control/Log.cs b/DS4Windows/DS4Control/Log.cs index 1eef330..a2d8815 100644 --- a/DS4Windows/DS4Control/Log.cs +++ b/DS4Windows/DS4Control/Log.cs @@ -2,7 +2,7 @@ namespace DS4Windows { - public class Log + public class AppLogger { public static event EventHandler TrayIconLog; public static event EventHandler GuiLog; diff --git a/DS4Windows/DS4Control/Mapping.cs b/DS4Windows/DS4Control/Mapping.cs index 2fe70c0..c7614c5 100644 --- a/DS4Windows/DS4Control/Mapping.cs +++ b/DS4Windows/DS4Control/Mapping.cs @@ -1940,7 +1940,7 @@ namespace DS4Windows dets = action.details.Split(','); if (bool.Parse(dets[1]) && !actionDone[index].dev[device]) { - Log.LogToTray("Controller " + (device + 1) + ": " + + AppLogger.LogToTray("Controller " + (device + 1) + ": " + ctrl.getDS4Battery(device), true); } if (bool.Parse(dets[2])) diff --git a/DS4Windows/DS4Control/ScpUtil.cs b/DS4Windows/DS4Control/ScpUtil.cs index 604c8c2..b968a33 100644 --- a/DS4Windows/DS4Control/ScpUtil.cs +++ b/DS4Windows/DS4Control/ScpUtil.cs @@ -2900,12 +2900,12 @@ namespace DS4Windows if (xinputResult) { dinputOnly[device] = false; - Log.LogToGui("X360 Controller # " + xinputIndex + " connected", false); + AppLogger.LogToGui("X360 Controller # " + xinputIndex + " connected", false); } else { dinputOnly[device] = true; - Log.LogToGui("X360 Controller # " + xinputIndex + " failed. Using DInput only mode", true); + AppLogger.LogToGui("X360 Controller # " + xinputIndex + " failed. Using DInput only mode", true); } } else if (xinputStatus && !xinputPlug) @@ -2915,11 +2915,11 @@ namespace DS4Windows if (xinputResult) { dinputOnly[device] = true; - Log.LogToGui("X360 Controller # " + xinputIndex + " unplugged", false); + AppLogger.LogToGui("X360 Controller # " + xinputIndex + " unplugged", false); } else { - Log.LogToGui("X360 Controller # " + xinputIndex + " failed to unplug", true); + AppLogger.LogToGui("X360 Controller # " + xinputIndex + " failed to unplug", true); } } @@ -3355,7 +3355,7 @@ namespace DS4Windows m_Xdoc.AppendChild(Node); try { m_Xdoc.Save(m_linkedProfiles); } - catch (UnauthorizedAccessException) { Log.LogToGui("Unauthorized Access - Save failed to path: " + m_linkedProfiles, false); saved = false; } + catch (UnauthorizedAccessException) { AppLogger.LogToGui("Unauthorized Access - Save failed to path: " + m_linkedProfiles, false); saved = false; } return saved; } @@ -3386,7 +3386,7 @@ namespace DS4Windows } else { - Log.LogToGui("LinkedProfiles.xml can't be found.", false); + AppLogger.LogToGui("LinkedProfiles.xml can't be found.", false); loaded = false; } @@ -3424,7 +3424,7 @@ namespace DS4Windows } try { linkedXdoc.Save(m_linkedProfiles); } - catch (UnauthorizedAccessException) { Log.LogToGui("Unauthorized Access - Save failed to path: " + m_linkedProfiles, false); saved = false; } + catch (UnauthorizedAccessException) { AppLogger.LogToGui("Unauthorized Access - Save failed to path: " + m_linkedProfiles, false); saved = false; } } else { diff --git a/DS4Windows/DS4Forms/DS4Form.cs b/DS4Windows/DS4Forms/DS4Form.cs index 21f57cf..68e5189 100644 --- a/DS4Windows/DS4Forms/DS4Form.cs +++ b/DS4Windows/DS4Forms/DS4Form.cs @@ -149,8 +149,8 @@ namespace DS4Windows Program.rootHub.Debug += On_Debug; - Log.GuiLog += On_Debug; - Log.TrayIconLog += ShowNotification; + AppLogger.GuiLog += On_Debug; + AppLogger.TrayIconLog += ShowNotification; Directory.CreateDirectory(appdatapath); if (!Save()) //if can't write to file @@ -252,7 +252,7 @@ namespace DS4Windows FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location); string version = fvi.FileVersion; - Log.LogToGui("DS4Windows version " + version, false); + AppLogger.LogToGui("DS4Windows version " + version, false); LoadP(); LoadLinkedProfiles(); @@ -2493,7 +2493,7 @@ Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question { RegistryKey key = Registry.LocalMachine.CreateSubKey(@"SYSTEM\CurrentControlSet\Services\HidGuardian\Parameters"); key.SetValue("AffectedDevices", Program.rootHub.affectedDevs.ToArray(), RegistryValueKind.MultiString); - Log.LogToGui("Wrote HidGuardian Device List to Registry", false); + AppLogger.LogToGui("Wrote HidGuardian Device List to Registry", false); } catch { } } @@ -2503,7 +2503,7 @@ Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question try { Registry.LocalMachine.DeleteSubKeyTree(@"SYSTEM\CurrentControlSet\Services\HidGuardian\Parameters\Whitelist"); - Log.LogToGui("Cleared HidGuardian Whitelist", false); + AppLogger.LogToGui("Cleared HidGuardian Whitelist", false); Program.rootHub.CreateHidGuardKey(); } catch { } diff --git a/DS4Windows/DS4Library/DS4Device.cs b/DS4Windows/DS4Library/DS4Device.cs index 4a58fc8..bc603a1 100644 --- a/DS4Windows/DS4Library/DS4Device.cs +++ b/DS4Windows/DS4Library/DS4Device.cs @@ -503,7 +503,7 @@ namespace DS4Windows bool validCrc = recvCrc32 == calcCrc32; if (!validCrc && tries >= 5) { - Log.LogToGui("Gyro Calibration Failed", true); + AppLogger.LogToGui("Gyro Calibration Failed", true); continue; } else if (validCrc) @@ -786,7 +786,7 @@ namespace DS4Windows { if (res == HidDevice.ReadStatus.WaitTimedOut) { - Log.LogToGui(Mac.ToString() + " disconnected due to timeout", true); + AppLogger.LogToGui(Mac.ToString() + " disconnected due to timeout", true); } else { @@ -814,7 +814,7 @@ namespace DS4Windows { if (res == HidDevice.ReadStatus.WaitTimedOut) { - Log.LogToGui(Mac.ToString() + " disconnected due to timeout", true); + AppLogger.LogToGui(Mac.ToString() + " disconnected due to timeout", true); } else { @@ -1051,7 +1051,7 @@ namespace DS4Windows if (shouldDisconnect) { - Log.LogToGui(Mac.ToString() + " disconnecting due to idle disconnect", false); + AppLogger.LogToGui(Mac.ToString() + " disconnecting due to idle disconnect", false); if (conType == ConnectionType.BT) {