From 02a59ede0cb05ca1519e4695990dfc86a52698c5 Mon Sep 17 00:00:00 2001 From: Lesueur Benjamin Date: Fri, 26 Nov 2021 16:30:53 +0100 Subject: [PATCH] misc cleanup --- ControllerHelper/Controller.cs | 4 ---- ControllerHelper/ControllerHelper.cs | 4 ---- ControllerHelper/ControllerHelper.csproj | 4 +++- ControllerHelper/MouseHook.cs | 1 - ControllerHelper/PipeClient.cs | 1 - ControllerHelper/ProfileManager.cs | 1 - ControllerHelper/ServiceManager.cs | 10 ++-------- ControllerHelper/Utils.cs | 6 +----- ControllerService/ControllerService.cs | 9 +++++---- ControllerService/ControllerService.csproj | 8 ++++++-- ControllerService/PipeServer.cs | 2 +- ControllerService/XInputController.cs | 2 +- 12 files changed, 19 insertions(+), 33 deletions(-) diff --git a/ControllerHelper/Controller.cs b/ControllerHelper/Controller.cs index 156d8fb29..e7e725789 100644 --- a/ControllerHelper/Controller.cs +++ b/ControllerHelper/Controller.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace ControllerHelper { diff --git a/ControllerHelper/ControllerHelper.cs b/ControllerHelper/ControllerHelper.cs index abb065afc..b0da4c209 100644 --- a/ControllerHelper/ControllerHelper.cs +++ b/ControllerHelper/ControllerHelper.cs @@ -1,13 +1,9 @@ using ControllerService; -using Microsoft.Extensions.Logging; using Microsoft.Win32; -using Serilog; using Serilog.Core; -using Serilog.Events; using System; using System.Collections.Generic; using System.Diagnostics; -using System.Drawing; using System.Globalization; using System.IO; using System.Reflection; diff --git a/ControllerHelper/ControllerHelper.csproj b/ControllerHelper/ControllerHelper.csproj index fcbf27f6c..070fc46ed 100644 --- a/ControllerHelper/ControllerHelper.csproj +++ b/ControllerHelper/ControllerHelper.csproj @@ -25,7 +25,9 @@ - + + true + diff --git a/ControllerHelper/MouseHook.cs b/ControllerHelper/MouseHook.cs index 151f9b58b..9e027f9af 100644 --- a/ControllerHelper/MouseHook.cs +++ b/ControllerHelper/MouseHook.cs @@ -3,7 +3,6 @@ using Serilog.Core; using System; using System.Collections.Generic; -using System.Numerics; using System.Threading; using System.Timers; using System.Windows.Forms; diff --git a/ControllerHelper/PipeClient.cs b/ControllerHelper/PipeClient.cs index ed0612fa3..8cefd83d1 100644 --- a/ControllerHelper/PipeClient.cs +++ b/ControllerHelper/PipeClient.cs @@ -1,7 +1,6 @@ using ControllerService; using NamedPipeWrapper; using Serilog.Core; -using SharpDX.XInput; using System; using System.Collections.Concurrent; using System.Timers; diff --git a/ControllerHelper/ProfileManager.cs b/ControllerHelper/ProfileManager.cs index fe8756d40..623e38194 100644 --- a/ControllerHelper/ProfileManager.cs +++ b/ControllerHelper/ProfileManager.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Text.Json; using System.Text.Json.Serialization; using static ControllerService.Utils; diff --git a/ControllerHelper/ServiceManager.cs b/ControllerHelper/ServiceManager.cs index 577759ef4..9b94d229d 100644 --- a/ControllerHelper/ServiceManager.cs +++ b/ControllerHelper/ServiceManager.cs @@ -1,14 +1,8 @@ using Serilog.Core; using System; -using System.Collections; -using System.Collections.Generic; using System.Diagnostics; -using System.Linq; using System.ServiceProcess; -using System.Text; -using System.Threading.Tasks; using System.Timers; -using System.Windows.Forms; using Timer = System.Timers.Timer; namespace ControllerHelper @@ -71,7 +65,7 @@ private void MonitorHelper(object sender, ElapsedEventArgs e) controller.Refresh(); status = controller.Status; } - catch(Exception) + catch (Exception) { status = 0; } @@ -82,7 +76,7 @@ private void MonitorHelper(object sender, ElapsedEventArgs e) { controller.WaitForStatus(nextStatus, TimeSpan.FromSeconds(5)); } - catch(Exception ex) + catch (Exception ex) { nextStatus = status; logger.Error("{0} set to {1}", name, ex.Message); diff --git a/ControllerHelper/Utils.cs b/ControllerHelper/Utils.cs index 61596fbb1..2950aaee4 100644 --- a/ControllerHelper/Utils.cs +++ b/ControllerHelper/Utils.cs @@ -1,15 +1,11 @@ using Microsoft.Toolkit.Uwp.Notifications; using System; -using System.Collections.Generic; using System.Diagnostics; -using System.Linq; using System.Management; using System.Net; using System.Runtime.InteropServices; using System.Security.Principal; using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; namespace ControllerHelper { @@ -67,7 +63,7 @@ public static string GetPathToApp(Process process) return ""; } - + public static bool IsTextAValidIPAddress(string text) { IPAddress test; diff --git a/ControllerService/ControllerService.cs b/ControllerService/ControllerService.cs index c1cc37335..dfdfef33d 100644 --- a/ControllerService/ControllerService.cs +++ b/ControllerService/ControllerService.cs @@ -167,7 +167,7 @@ internal void UpdateProfile(Dictionary args) public void UpdateSettings(Dictionary args) { - foreach(KeyValuePair pair in args) + foreach (KeyValuePair pair in args) { string name = pair.Key; string property = pair.Value; @@ -241,7 +241,7 @@ private void ApplySetting(string name, object prev_value, object value) PhysicalController.SetVibrationStrength((int)value); break; case "DSUEnabled": - switch((bool)value) + switch ((bool)value) { case true: DSUServer.Start(); break; case false: DSUServer.Stop(); break; @@ -279,7 +279,8 @@ public Task StartAsync(CancellationToken cancellationToken) PipeServer.Start(); // send notification - PipeServer.SendMessage(new PipeMessage { + PipeServer.SendMessage(new PipeMessage + { Code = PipeCode.SERVER_TOAST, args = new Dictionary { @@ -330,7 +331,7 @@ public Dictionary GetSettings() { Dictionary settings = new Dictionary(); - foreach(SettingsProperty s in Properties.Settings.Default.Properties) + foreach (SettingsProperty s in Properties.Settings.Default.Properties) settings.Add(s.Name, Properties.Settings.Default[s.Name].ToString()); settings.Add("gyrometer", $"{PhysicalController.gyrometer.sensor != null}"); diff --git a/ControllerService/ControllerService.csproj b/ControllerService/ControllerService.csproj index cab0e81b0..b00ae399f 100644 --- a/ControllerService/ControllerService.csproj +++ b/ControllerService/ControllerService.csproj @@ -60,8 +60,12 @@ - - + + true + + + true + diff --git a/ControllerService/PipeServer.cs b/ControllerService/PipeServer.cs index 13618f96b..0d1b6698a 100644 --- a/ControllerService/PipeServer.cs +++ b/ControllerService/PipeServer.cs @@ -134,7 +134,7 @@ private void OnClientDisconnected(NamedPipeConnection { connected = false; logger.LogInformation("Client {0} disconnected", connection.Id); - + service.PhysicalController.touch.OnMouseUp(-1, -1, 1048576 /* MouseButtons.Left */); } diff --git a/ControllerService/XInputController.cs b/ControllerService/XInputController.cs index 26584c045..2b42bcc0f 100644 --- a/ControllerService/XInputController.cs +++ b/ControllerService/XInputController.cs @@ -125,7 +125,7 @@ public void SetVirtualController(IVirtualGamepad _controller) vcontroller = _controller; vcontroller.AutoSubmitReport = false; - switch(vcontroller.GetType().FullName) + switch (vcontroller.GetType().FullName) { case "Nefarius.ViGEm.Client.Targets.DualShock4Controller": UpdateTimer.Elapsed += DS4_UpdateReport;