From 942d7587e22d9cd8f0423dfa6e9b53797aa5a574 Mon Sep 17 00:00:00 2001 From: Lesueur Benjamin Date: Sat, 12 Aug 2023 19:00:12 +0200 Subject: [PATCH] remove unused usings and fix formatting --- HandheldCompanion/Actions/MouseActions.cs | 1 - HandheldCompanion/App.xaml.cs | 1 - HandheldCompanion/AssemblyInfo.cs | 8 +- .../Controllers/GordonController.cs | 2 +- HandheldCompanion/Controllers/IController.cs | 18 +- .../Controllers/NeptuneController.cs | 3 +- .../Controllers/XInputController.cs | 31 +- .../Controls/Layout/LayoutTemplate.xaml.cs | 42 ++- .../Controls/Mapping/AxisMapping.xaml.cs | 18 +- .../Controls/Mapping/ButtonMapping.xaml.cs | 29 +- .../Controls/Mapping/TriggerMapping.xaml.cs | 8 +- HandheldCompanion/Controls/ProcessEx.xaml.cs | 50 ++-- .../Devices/AOKZOE/AOKZOEA1Pro.cs | 8 +- HandheldCompanion/Devices/ASUS/ROGAlly.cs | 50 ++-- .../Devices/AYANEO/AYANEO2021.cs | 1 - .../Devices/Ayn/AynLokiMax6600U.cs | 4 +- .../Devices/Ayn/AynLokiMax6800U.cs | 4 +- .../Devices/Ayn/AynLokiMiniPro.cs | 4 +- HandheldCompanion/Devices/Ayn/AynLokiZero.cs | 4 +- HandheldCompanion/Devices/DefaultDevice.cs | 6 +- HandheldCompanion/Devices/GPD/GPDWin3.cs | 1 - HandheldCompanion/Devices/GPD/GPDWinMax2.cs | 1 - HandheldCompanion/Devices/IDevice.cs | 233 ++++++++------- .../Devices/OneXPlayer/OneXPlayer2-7840U.cs | 8 +- .../Devices/OneXPlayer/OneXPlayerMiniPro.cs | 4 +- HandheldCompanion/Devices/Valve/SteamDeck.cs | 1 - .../Managers/ControllerManager.cs | 112 +++---- HandheldCompanion/Managers/DeviceManager.cs | 6 +- .../Managers/GamepadFocusManager.cs | 18 +- HandheldCompanion/Managers/HotkeysManager.cs | 89 +++--- HandheldCompanion/Managers/LayoutManager.cs | 22 +- HandheldCompanion/Managers/OSDManager.cs | 280 +++++++++--------- .../Managers/PerformanceManager.cs | 24 +- HandheldCompanion/Managers/PlatformManager.cs | 47 ++- HandheldCompanion/Managers/ProcessManager.cs | 22 +- HandheldCompanion/Managers/ProfileManager.cs | 24 +- HandheldCompanion/Managers/SensorsManager.cs | 4 +- HandheldCompanion/Managers/SettingsManager.cs | 90 +++--- HandheldCompanion/Managers/SystemManager.cs | 112 +++---- HandheldCompanion/Managers/TaskManager.cs | 1 - HandheldCompanion/Managers/UpdateManager.cs | 1 - HandheldCompanion/Misc/DeviceHelper.cs | 1 - HandheldCompanion/Misc/Layout.cs | 8 +- HandheldCompanion/Misc/MotherboardInfo.cs | 9 +- HandheldCompanion/Misc/PnPUtil.cs | 4 +- HandheldCompanion/Misc/Profile.cs | 2 +- HandheldCompanion/Misc/WinAPI.cs | 2 - HandheldCompanion/Platforms/GOGGalaxy.cs | 1 - HandheldCompanion/Platforms/HWiNFO.cs | 244 +++++++-------- HandheldCompanion/Platforms/RTSS.cs | 5 +- HandheldCompanion/Platforms/SteamPlatform.cs | 4 +- HandheldCompanion/Platforms/UbisoftConnect.cs | 1 - HandheldCompanion/Sensors/IMUAccelerometer.cs | 13 +- HandheldCompanion/Sensors/IMUGyrometer.cs | 22 +- HandheldCompanion/Sensors/IMUSensor.cs | 1 - HandheldCompanion/Sensors/SerialUSBIMU.cs | 88 +++--- .../Simulators/KeyboardSimulator.cs | 3 +- HandheldCompanion/Utils/WPFUtils.cs | 1 - HandheldCompanion/Utils/XInputPlusUtils.cs | 9 +- .../Views/Classes/GamepadWindow.cs | 4 +- .../Views/Classes/OverlayWindow.cs | 8 +- .../Views/Pages/ControllerPage.xaml.cs | 5 +- .../Views/Pages/Layout/ILayoutPage.cs | 4 +- .../Views/Pages/LayoutPage.xaml.cs | 38 ++- .../Views/Pages/OverlayPage.xaml.cs | 10 +- .../Pages/Profiles/SettingsMode0.xaml.cs | 20 +- .../Pages/Profiles/SettingsMode1.xaml.cs | 2 +- .../Views/Pages/ProfilesPage.xaml.cs | 24 +- .../Views/Pages/SettingsPage.xaml.cs | 196 ++++++------ .../QuickPages/QuickProfilesPage.xaml.cs | 40 +-- HandheldCompanion/Views/SplashScreen.xaml.cs | 12 - .../Views/Windows/MainWindow.xaml.cs | 2 +- .../Views/Windows/OverlayModel.xaml.cs | 2 +- .../Views/Windows/OverlayQuickTools.xaml.cs | 73 +++-- .../Views/Windows/OverlayTrackpad.xaml.cs | 138 ++++----- HandheldCompanion/XInputPlus/XInputPlus.cs | 17 +- .../models/ModelToyController.cs | 2 +- hidapi.net/HidDevice.cs | 2 +- steam-hidapi.net/Hid/HidEnums.cs | 190 ++++++------ 79 files changed, 1251 insertions(+), 1348 deletions(-) diff --git a/HandheldCompanion/Actions/MouseActions.cs b/HandheldCompanion/Actions/MouseActions.cs index f04b22814..5a70b27e3 100644 --- a/HandheldCompanion/Actions/MouseActions.cs +++ b/HandheldCompanion/Actions/MouseActions.cs @@ -1,5 +1,4 @@ using HandheldCompanion.Inputs; -using HandheldCompanion.Misc; using HandheldCompanion.Simulators; using System; using System.ComponentModel; diff --git a/HandheldCompanion/App.xaml.cs b/HandheldCompanion/App.xaml.cs index 06e38c0b7..769501ac4 100644 --- a/HandheldCompanion/App.xaml.cs +++ b/HandheldCompanion/App.xaml.cs @@ -6,7 +6,6 @@ using System.Windows; using HandheldCompanion.Managers; using HandheldCompanion.Utils; -using HandheldCompanion.Managers; using HandheldCompanion.Views; using static HandheldCompanion.WinAPI; diff --git a/HandheldCompanion/AssemblyInfo.cs b/HandheldCompanion/AssemblyInfo.cs index 4a05c7d47..4f943deb8 100644 --- a/HandheldCompanion/AssemblyInfo.cs +++ b/HandheldCompanion/AssemblyInfo.cs @@ -2,9 +2,9 @@ [assembly: ThemeInfo( ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) + //(used if a resource is not found in the page, + // or application resource dictionaries) ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) )] \ No newline at end of file diff --git a/HandheldCompanion/Controllers/GordonController.cs b/HandheldCompanion/Controllers/GordonController.cs index 05fe1f6a2..690a8c116 100644 --- a/HandheldCompanion/Controllers/GordonController.cs +++ b/HandheldCompanion/Controllers/GordonController.cs @@ -81,7 +81,7 @@ public override void UpdateInputs(long ticks) Inputs.ButtonState[ButtonFlags.B2] = input.State.ButtonState[GordonControllerButton.BtnB]; Inputs.ButtonState[ButtonFlags.B3] = input.State.ButtonState[GordonControllerButton.BtnX]; Inputs.ButtonState[ButtonFlags.B4] = input.State.ButtonState[GordonControllerButton.BtnY]; - + Inputs.ButtonState[ButtonFlags.DPadUp] = input.State.ButtonState[GordonControllerButton.BtnDpadUp]; Inputs.ButtonState[ButtonFlags.DPadDown] = input.State.ButtonState[GordonControllerButton.BtnDpadDown]; Inputs.ButtonState[ButtonFlags.DPadLeft] = input.State.ButtonState[GordonControllerButton.BtnDpadLeft]; diff --git a/HandheldCompanion/Controllers/IController.cs b/HandheldCompanion/Controllers/IController.cs index 47d19a831..4ab17eee8 100644 --- a/HandheldCompanion/Controllers/IController.cs +++ b/HandheldCompanion/Controllers/IController.cs @@ -88,31 +88,35 @@ public abstract class IController // todo: make this a custom control ! protected Border ui_border = new() - { CornerRadius = new CornerRadius(4, 4, 4, 4), Padding = new Thickness(15, 12, 12, 12) }; + { CornerRadius = new CornerRadius(4, 4, 4, 4), Padding = new Thickness(15, 12, 12, 12) }; protected Button ui_button_hide = new() { - Width = 100, FontSize = 14, VerticalAlignment = VerticalAlignment.Center, + Width = 100, + FontSize = 14, + VerticalAlignment = VerticalAlignment.Center, Style = Application.Current.FindResource("AccentButtonStyle") as Style }; protected Button ui_button_hook = new() { - Width = 100, FontSize = 14, VerticalAlignment = VerticalAlignment.Center, + Width = 100, + FontSize = 14, + VerticalAlignment = VerticalAlignment.Center, Style = Application.Current.FindResource("AccentButtonStyle") as Style }; protected SimpleStackPanel ui_dock_buttons = new() - { Spacing = 6, Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Right }; + { Spacing = 6, Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Right }; protected DockPanel ui_dock_content = new() { HorizontalAlignment = HorizontalAlignment.Left }; protected Grid ui_grid = new(); protected FontIcon ui_icon = new() - { Glyph = "\uE7FC", Height = 40, HorizontalAlignment = HorizontalAlignment.Center }; + { Glyph = "\uE7FC", Height = 40, HorizontalAlignment = HorizontalAlignment.Center }; protected TextBlock ui_name = new() - { VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(12, 0, 0, 0) }; + { VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(12, 0, 0, 0) }; protected int UserIndex; protected double VibrationStrength = 1.0d; @@ -330,7 +334,7 @@ public void Hide(bool powerCycle = true) // get HidHideDevice HidHideDevice hideDevice = HidHide.GetHidHideDevice(Details.baseContainerDeviceInstanceId); if (hideDevice is not null) - foreach(HidHideSubDevice subDevice in hideDevice.Devices) + foreach (HidHideSubDevice subDevice in hideDevice.Devices) HidHide.HidePath(subDevice.DeviceInstancePath); HidHide.HidePath(Details.deviceInstanceId); diff --git a/HandheldCompanion/Controllers/NeptuneController.cs b/HandheldCompanion/Controllers/NeptuneController.cs index 08debbdd2..4f7e61e6b 100644 --- a/HandheldCompanion/Controllers/NeptuneController.cs +++ b/HandheldCompanion/Controllers/NeptuneController.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Threading; using System.Threading.Tasks; using HandheldCompanion.Managers; using steam_hidapi.net; @@ -108,7 +107,7 @@ public override void UpdateInputs(long ticks) Inputs.ButtonState[ButtonFlags.L2Full] = L2 > Gamepad.TriggerThreshold * 8; Inputs.ButtonState[ButtonFlags.R2Full] = R2 > Gamepad.TriggerThreshold * 8; - + Inputs.AxisState[AxisFlags.L2] = (short)L2; Inputs.AxisState[AxisFlags.R2] = (short)R2; diff --git a/HandheldCompanion/Controllers/XInputController.cs b/HandheldCompanion/Controllers/XInputController.cs index 57dcc5738..d81d92c73 100644 --- a/HandheldCompanion/Controllers/XInputController.cs +++ b/HandheldCompanion/Controllers/XInputController.cs @@ -1,6 +1,5 @@ using System; using System.Runtime.InteropServices; -using System.Threading.Tasks; using System.Windows.Media; using HandheldCompanion.Inputs; using HandheldCompanion.Managers; @@ -239,25 +238,32 @@ public override string GetGlyph(AxisLayoutFlags axis) [StructLayout(LayoutKind.Explicit)] protected struct XInputGamepad { - [MarshalAs(UnmanagedType.I2)] [FieldOffset(0)] + [MarshalAs(UnmanagedType.I2)] + [FieldOffset(0)] public short wButtons; - [MarshalAs(UnmanagedType.I1)] [FieldOffset(2)] + [MarshalAs(UnmanagedType.I1)] + [FieldOffset(2)] public byte bLeftTrigger; - [MarshalAs(UnmanagedType.I1)] [FieldOffset(3)] + [MarshalAs(UnmanagedType.I1)] + [FieldOffset(3)] public byte bRightTrigger; - [MarshalAs(UnmanagedType.I2)] [FieldOffset(4)] + [MarshalAs(UnmanagedType.I2)] + [FieldOffset(4)] public short sThumbLX; - [MarshalAs(UnmanagedType.I2)] [FieldOffset(6)] + [MarshalAs(UnmanagedType.I2)] + [FieldOffset(6)] public short sThumbLY; - [MarshalAs(UnmanagedType.I2)] [FieldOffset(8)] + [MarshalAs(UnmanagedType.I2)] + [FieldOffset(8)] public short sThumbRX; - [MarshalAs(UnmanagedType.I2)] [FieldOffset(10)] + [MarshalAs(UnmanagedType.I2)] + [FieldOffset(10)] public short sThumbRY; } @@ -272,13 +278,16 @@ protected struct XInputVibration [StructLayout(LayoutKind.Explicit)] protected struct XInputCapabilities { - [MarshalAs(UnmanagedType.I1)] [FieldOffset(0)] + [MarshalAs(UnmanagedType.I1)] + [FieldOffset(0)] private readonly byte Type; - [MarshalAs(UnmanagedType.I1)] [FieldOffset(1)] + [MarshalAs(UnmanagedType.I1)] + [FieldOffset(1)] public byte SubType; - [MarshalAs(UnmanagedType.I2)] [FieldOffset(2)] + [MarshalAs(UnmanagedType.I2)] + [FieldOffset(2)] public short Flags; [FieldOffset(4)] public XInputGamepad Gamepad; diff --git a/HandheldCompanion/Controls/Layout/LayoutTemplate.xaml.cs b/HandheldCompanion/Controls/Layout/LayoutTemplate.xaml.cs index 3a18aab83..220925d82 100644 --- a/HandheldCompanion/Controls/Layout/LayoutTemplate.xaml.cs +++ b/HandheldCompanion/Controls/Layout/LayoutTemplate.xaml.cs @@ -2,11 +2,9 @@ using System.Collections.Generic; using System.Windows; using System.Windows.Controls; -using HandheldCompanion; using HandheldCompanion.Actions; using GregsStack.InputSimulatorStandard.Native; -using HandheldCompanion.Actions; using HandheldCompanion.Controllers; using Newtonsoft.Json; using HandheldCompanion.Inputs; @@ -69,8 +67,8 @@ private LayoutTemplate(string name, string description, string author, bool isIn switch (Name) { case "Desktop": - { - Layout.AxisLayout = new SortedDictionary + { + Layout.AxisLayout = new SortedDictionary { { AxisLayoutFlags.LeftStick, @@ -90,7 +88,7 @@ private LayoutTemplate(string name, string description, string author, bool isIn } }; - Layout.ButtonLayout = new() + Layout.ButtonLayout = new() { { ButtonFlags.B1, new List() { new KeyboardActions { Key = VirtualKeyCode.RETURN } } }, { ButtonFlags.B2, new List() { new KeyboardActions { Key = VirtualKeyCode.ESCAPE } } }, @@ -114,21 +112,21 @@ private LayoutTemplate(string name, string description, string author, bool isIn { ButtonFlags.LeftPadClick, new List() { new MouseActions { MouseType = MouseActionsType.RightButton } } }, { ButtonFlags.RightPadClick, new List() { new MouseActions { MouseType = MouseActionsType.LeftButton } } } }; - } + } break; case "Gamepad (Nintendo)": - { - Layout.ButtonLayout[ButtonFlags.B1] = new List() { new ButtonActions { Button = ButtonFlags.B2 } }; - Layout.ButtonLayout[ButtonFlags.B2] = new List() { new ButtonActions { Button = ButtonFlags.B1 } }; - Layout.ButtonLayout[ButtonFlags.B3] = new List() { new ButtonActions { Button = ButtonFlags.B4 } }; - Layout.ButtonLayout[ButtonFlags.B4] = new List() { new ButtonActions { Button = ButtonFlags.B3 } }; - } + { + Layout.ButtonLayout[ButtonFlags.B1] = new List() { new ButtonActions { Button = ButtonFlags.B2 } }; + Layout.ButtonLayout[ButtonFlags.B2] = new List() { new ButtonActions { Button = ButtonFlags.B1 } }; + Layout.ButtonLayout[ButtonFlags.B3] = new List() { new ButtonActions { Button = ButtonFlags.B4 } }; + Layout.ButtonLayout[ButtonFlags.B4] = new List() { new ButtonActions { Button = ButtonFlags.B3 } }; + } break; case "Keyboard (WASD) and Mouse": - { - Layout.AxisLayout = new SortedDictionary + { + Layout.AxisLayout = new SortedDictionary { { AxisLayoutFlags.RightStick, @@ -140,7 +138,7 @@ private LayoutTemplate(string name, string description, string author, bool isIn } }; - Layout.ButtonLayout = new() + Layout.ButtonLayout = new() { { ButtonFlags.B1, new List() { new KeyboardActions { Key = VirtualKeyCode.SPACE } } }, { ButtonFlags.B2, new List() { new KeyboardActions { Key = VirtualKeyCode.VK_E } } }, @@ -176,19 +174,19 @@ private LayoutTemplate(string name, string description, string author, bool isIn { ButtonFlags.RightPadClick, new List() { new MouseActions { MouseType = MouseActionsType.LeftButton } } } }; - } + } break; case "Gamepad with Mouse Trackpad": - { - Layout.AxisLayout[AxisLayoutFlags.RightPad] = new MouseActions { MouseType = MouseActionsType.Move }; - } + { + Layout.AxisLayout[AxisLayoutFlags.RightPad] = new MouseActions { MouseType = MouseActionsType.Move }; + } break; case "Gamepad with Joystick Trackpad": - { - Layout.AxisLayout[AxisLayoutFlags.RightPad] = new AxisActions { Axis = AxisLayoutFlags.RightStick }; - } + { + Layout.AxisLayout[AxisLayoutFlags.RightPad] = new AxisActions { Axis = AxisLayoutFlags.RightStick }; + } break; } } diff --git a/HandheldCompanion/Controls/Mapping/AxisMapping.xaml.cs b/HandheldCompanion/Controls/Mapping/AxisMapping.xaml.cs index 7e7110228..aee715286 100644 --- a/HandheldCompanion/Controls/Mapping/AxisMapping.xaml.cs +++ b/HandheldCompanion/Controls/Mapping/AxisMapping.xaml.cs @@ -130,7 +130,7 @@ private void Action_SelectionChanged(object sender, SelectionChangedEventArgs e) // create a label, store MouseActionsType as Tag and Label as controller specific string var buttonLabel = new Label - { Tag = mouseType, Content = EnumUtils.GetDescriptionFromEnumValue(mouseType) }; + { Tag = mouseType, Content = EnumUtils.GetDescriptionFromEnumValue(mouseType) }; TargetComboBox.Items.Add(buttonLabel); if (mouseType.Equals(((MouseActions)Actions).MouseType)) @@ -163,17 +163,17 @@ private void Target_SelectionChanged(object sender, SelectionChangedEventArgs e) switch (Actions.ActionType) { case ActionType.Joystick: - { - var buttonLabel = TargetComboBox.SelectedItem as Label; - ((AxisActions)Actions).Axis = (AxisLayoutFlags)buttonLabel.Tag; - } + { + var buttonLabel = TargetComboBox.SelectedItem as Label; + ((AxisActions)Actions).Axis = (AxisLayoutFlags)buttonLabel.Tag; + } break; case ActionType.Mouse: - { - var buttonLabel = TargetComboBox.SelectedItem as Label; - ((MouseActions)Actions).MouseType = (MouseActionsType)buttonLabel.Tag; - } + { + var buttonLabel = TargetComboBox.SelectedItem as Label; + ((MouseActions)Actions).MouseType = (MouseActionsType)buttonLabel.Tag; + } break; } diff --git a/HandheldCompanion/Controls/Mapping/ButtonMapping.xaml.cs b/HandheldCompanion/Controls/Mapping/ButtonMapping.xaml.cs index 76fc35a43..715ed1fc7 100644 --- a/HandheldCompanion/Controls/Mapping/ButtonMapping.xaml.cs +++ b/HandheldCompanion/Controls/Mapping/ButtonMapping.xaml.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Threading; using System.Windows; using System.Windows.Controls; using HandheldCompanion.Actions; @@ -8,10 +7,8 @@ using HandheldCompanion.Utils; using GregsStack.InputSimulatorStandard.Native; -using HandheldCompanion.Actions; using HandheldCompanion.Inputs; using HandheldCompanion.Managers; -using HandheldCompanion.Simulators; using Inkore.UI.WPF.Modern.Controls; namespace HandheldCompanion.Controls; @@ -161,7 +158,7 @@ private void Action_SelectionChanged(object sender, SelectionChangedEventArgs e) // create a label, store MouseActionsType as Tag and Label as controller specific string var buttonLabel = new Label - { Tag = mouseType, Content = EnumUtils.GetDescriptionFromEnumValue(mouseType) }; + { Tag = mouseType, Content = EnumUtils.GetDescriptionFromEnumValue(mouseType) }; TargetComboBox.Items.Add(buttonLabel); if (mouseType.Equals(((MouseActions)Actions).MouseType)) @@ -208,24 +205,24 @@ private void Target_SelectionChanged(object sender, SelectionChangedEventArgs e) switch (Actions.ActionType) { case ActionType.Button: - { - var buttonLabel = TargetComboBox.SelectedItem as Label; - ((ButtonActions)Actions).Button = (ButtonFlags)buttonLabel.Tag; - } + { + var buttonLabel = TargetComboBox.SelectedItem as Label; + ((ButtonActions)Actions).Button = (ButtonFlags)buttonLabel.Tag; + } break; case ActionType.Keyboard: - { - var buttonLabel = TargetComboBox.SelectedItem as Label; - ((KeyboardActions)Actions).Key = (VirtualKeyCode)buttonLabel.Tag; - } + { + var buttonLabel = TargetComboBox.SelectedItem as Label; + ((KeyboardActions)Actions).Key = (VirtualKeyCode)buttonLabel.Tag; + } break; case ActionType.Mouse: - { - var buttonLabel = TargetComboBox.SelectedItem as Label; - ((MouseActions)Actions).MouseType = (MouseActionsType)buttonLabel.Tag; - } + { + var buttonLabel = TargetComboBox.SelectedItem as Label; + ((MouseActions)Actions).MouseType = (MouseActionsType)buttonLabel.Tag; + } break; } diff --git a/HandheldCompanion/Controls/Mapping/TriggerMapping.xaml.cs b/HandheldCompanion/Controls/Mapping/TriggerMapping.xaml.cs index 17c6f376b..df7ffad74 100644 --- a/HandheldCompanion/Controls/Mapping/TriggerMapping.xaml.cs +++ b/HandheldCompanion/Controls/Mapping/TriggerMapping.xaml.cs @@ -120,10 +120,10 @@ private void Target_SelectionChanged(object sender, SelectionChangedEventArgs e) switch (Actions.ActionType) { case ActionType.Trigger: - { - var buttonLabel = TargetComboBox.SelectedItem as Label; - ((TriggerActions)Actions).Axis = (AxisLayoutFlags)buttonLabel.Tag; - } + { + var buttonLabel = TargetComboBox.SelectedItem as Label; + ((TriggerActions)Actions).Axis = (AxisLayoutFlags)buttonLabel.Tag; + } break; } diff --git a/HandheldCompanion/Controls/ProcessEx.xaml.cs b/HandheldCompanion/Controls/ProcessEx.xaml.cs index 1a1df1dcd..4529a446d 100644 --- a/HandheldCompanion/Controls/ProcessEx.xaml.cs +++ b/HandheldCompanion/Controls/ProcessEx.xaml.cs @@ -1,12 +1,10 @@ using System; -using System.ComponentModel; using System.Diagnostics; using System.Drawing; using System.IO; using System.Windows; using System.Windows.Controls; using System.Windows.Media; -using HandheldCompanion; using HandheldCompanion.Platforms; using HandheldCompanion.Utils; using HandheldCompanion.Managers; @@ -137,32 +135,32 @@ public void Refresh() switch (MainThread.ThreadState) { case ThreadState.Wait: - { - // monitor if the process main thread was suspended or resumed - if (MainThread.WaitReason != prevThreadWaitReason) { - prevThreadWaitReason = MainThread.WaitReason; - - switch (prevThreadWaitReason) + // monitor if the process main thread was suspended or resumed + if (MainThread.WaitReason != prevThreadWaitReason) { - case ThreadWaitReason.Suspended: - SuspendToggle.IsOn = true; - break; - - default: - SuspendToggle.IsOn = false; - break; + prevThreadWaitReason = MainThread.WaitReason; + + switch (prevThreadWaitReason) + { + case ThreadWaitReason.Suspended: + SuspendToggle.IsOn = true; + break; + + default: + SuspendToggle.IsOn = false; + break; + } } } - } break; case ThreadState.Terminated: - { - // dispose from MainThread - MainThread.Dispose(); - MainThread = null; - } + { + // dispose from MainThread + MainThread.Dispose(); + MainThread = null; + } break; } @@ -195,12 +193,12 @@ private void SuspendToggle_Toggled(object sender, RoutedEventArgs e) switch (SuspendToggle.IsOn) { case true: - { - if (prevThreadWaitReason == ThreadWaitReason.Suspended) - return; + { + if (prevThreadWaitReason == ThreadWaitReason.Suspended) + return; - ProcessManager.SuspendProcess(this); - } + ProcessManager.SuspendProcess(this); + } break; case false: ProcessManager.ResumeProcess(this); diff --git a/HandheldCompanion/Devices/AOKZOE/AOKZOEA1Pro.cs b/HandheldCompanion/Devices/AOKZOE/AOKZOEA1Pro.cs index 77174d4ba..fc03b1363 100644 --- a/HandheldCompanion/Devices/AOKZOE/AOKZOEA1Pro.cs +++ b/HandheldCompanion/Devices/AOKZOE/AOKZOEA1Pro.cs @@ -1,10 +1,4 @@ -using System.Collections.Generic; -using System.Numerics; - -using HandheldCompanion.Managers; -using WindowsInput.Events; - -namespace HandheldCompanion.Devices; +namespace HandheldCompanion.Devices; public class AOKZOEA1Pro : AOKZOEA1 { diff --git a/HandheldCompanion/Devices/ASUS/ROGAlly.cs b/HandheldCompanion/Devices/ASUS/ROGAlly.cs index 0932c9df8..8de33843c 100644 --- a/HandheldCompanion/Devices/ASUS/ROGAlly.cs +++ b/HandheldCompanion/Devices/ASUS/ROGAlly.cs @@ -151,7 +151,7 @@ public override bool IsReady() var pnpDevice = PnPDevice.GetDeviceByInterfaceId(_hidDevice.DevicePath); var device_parent = pnpDevice.GetProperty(DevicePropertyKey.Device_Parent); - + var pnpParent = PnPDevice.GetDeviceByInstanceId(device_parent); var parent_guid = pnpParent.GetProperty(DevicePropertyKey.Device_ClassGuid); var parent_instanceId = pnpParent.GetProperty(DevicePropertyKey.Device_InstanceId); @@ -161,10 +161,10 @@ public override bool IsReady() public override void SetKeyPressDelay(HIDmode controllerMode) { - switch(controllerMode) + switch (controllerMode) { case HIDmode.DualShock4Controller: - KeyPressDelay = 180; + KeyPressDelay = 180; break; default: KeyPressDelay = 20; @@ -202,27 +202,27 @@ private void InputReportReceiver_Received(HidDevice hidDevice, DeviceItemInputPa return; case 0: - { - // two empty packets in a row means back button was released - if (previousWasEmpty) - KeyRelease(ButtonFlags.OEM3); + { + // two empty packets in a row means back button was released + if (previousWasEmpty) + KeyRelease(ButtonFlags.OEM3); - previousWasEmpty = true; - } + previousWasEmpty = true; + } return; case 56: case 166: - { - // OEM1 and OEM2 key needs a key press delay based on emulated controller - Task.Factory.StartNew(async () => { - KeyPress(button); - await Task.Delay(KeyPressDelay); - KeyRelease(button); - }); - } - break; + // OEM1 and OEM2 key needs a key press delay based on emulated controller + Task.Factory.StartNew(async () => + { + KeyPress(button); + await Task.Delay(KeyPressDelay); + KeyRelease(button); + }); + } + break; case 165: case 167: @@ -234,14 +234,14 @@ private void InputReportReceiver_Received(HidDevice hidDevice, DeviceItemInputPa break; default: - { - Task.Factory.StartNew(async () => { - KeyPress(button); - await Task.Delay(20); - KeyRelease(button); - }); - } + Task.Factory.StartNew(async () => + { + KeyPress(button); + await Task.Delay(20); + KeyRelease(button); + }); + } break; } diff --git a/HandheldCompanion/Devices/AYANEO/AYANEO2021.cs b/HandheldCompanion/Devices/AYANEO/AYANEO2021.cs index ae5a5e08a..6feb5fab1 100644 --- a/HandheldCompanion/Devices/AYANEO/AYANEO2021.cs +++ b/HandheldCompanion/Devices/AYANEO/AYANEO2021.cs @@ -1,6 +1,5 @@ using HandheldCompanion.Inputs; using System.Collections.Generic; -using System.Numerics; using WindowsInput.Events; namespace HandheldCompanion.Devices; diff --git a/HandheldCompanion/Devices/Ayn/AynLokiMax6600U.cs b/HandheldCompanion/Devices/Ayn/AynLokiMax6600U.cs index 27846f096..e6211bd74 100644 --- a/HandheldCompanion/Devices/Ayn/AynLokiMax6600U.cs +++ b/HandheldCompanion/Devices/Ayn/AynLokiMax6600U.cs @@ -1,6 +1,4 @@ -using System.Numerics; - -namespace HandheldCompanion.Devices; +namespace HandheldCompanion.Devices; public class LokiMax6600U : AynLoki { diff --git a/HandheldCompanion/Devices/Ayn/AynLokiMax6800U.cs b/HandheldCompanion/Devices/Ayn/AynLokiMax6800U.cs index 67cdeb188..a8864d9a7 100644 --- a/HandheldCompanion/Devices/Ayn/AynLokiMax6800U.cs +++ b/HandheldCompanion/Devices/Ayn/AynLokiMax6800U.cs @@ -1,6 +1,4 @@ -using System.Numerics; - -namespace HandheldCompanion.Devices; +namespace HandheldCompanion.Devices; public class LokiMax6800U : AynLoki { diff --git a/HandheldCompanion/Devices/Ayn/AynLokiMiniPro.cs b/HandheldCompanion/Devices/Ayn/AynLokiMiniPro.cs index a29f25933..9f8c9563b 100644 --- a/HandheldCompanion/Devices/Ayn/AynLokiMiniPro.cs +++ b/HandheldCompanion/Devices/Ayn/AynLokiMiniPro.cs @@ -1,6 +1,4 @@ -using System.Numerics; - -namespace HandheldCompanion.Devices; +namespace HandheldCompanion.Devices; public class LokiMiniPro : AynLoki { diff --git a/HandheldCompanion/Devices/Ayn/AynLokiZero.cs b/HandheldCompanion/Devices/Ayn/AynLokiZero.cs index 688790f85..214454a36 100644 --- a/HandheldCompanion/Devices/Ayn/AynLokiZero.cs +++ b/HandheldCompanion/Devices/Ayn/AynLokiZero.cs @@ -1,6 +1,4 @@ -using System.Numerics; - -namespace HandheldCompanion.Devices; +namespace HandheldCompanion.Devices; public class LokiZero : AynLoki { diff --git a/HandheldCompanion/Devices/DefaultDevice.cs b/HandheldCompanion/Devices/DefaultDevice.cs index 33e6cde47..8a7929ea9 100644 --- a/HandheldCompanion/Devices/DefaultDevice.cs +++ b/HandheldCompanion/Devices/DefaultDevice.cs @@ -1,8 +1,4 @@ -using System.Collections.Generic; - -using WindowsInput.Events; - -namespace HandheldCompanion.Devices; +namespace HandheldCompanion.Devices; public class DefaultDevice : IDevice { diff --git a/HandheldCompanion/Devices/GPD/GPDWin3.cs b/HandheldCompanion/Devices/GPD/GPDWin3.cs index 3c70a0a3a..7a357932b 100644 --- a/HandheldCompanion/Devices/GPD/GPDWin3.cs +++ b/HandheldCompanion/Devices/GPD/GPDWin3.cs @@ -1,6 +1,5 @@ using HandheldCompanion.Inputs; using System.Collections.Generic; -using System.Numerics; using WindowsInput.Events; namespace HandheldCompanion.Devices; diff --git a/HandheldCompanion/Devices/GPD/GPDWinMax2.cs b/HandheldCompanion/Devices/GPD/GPDWinMax2.cs index 86bed9b0d..3fabc0b96 100644 --- a/HandheldCompanion/Devices/GPD/GPDWinMax2.cs +++ b/HandheldCompanion/Devices/GPD/GPDWinMax2.cs @@ -1,6 +1,5 @@ using HandheldCompanion.Inputs; using System.Collections.Generic; -using System.Numerics; using WindowsInput.Events; namespace HandheldCompanion.Devices; diff --git a/HandheldCompanion/Devices/IDevice.cs b/HandheldCompanion/Devices/IDevice.cs index 0c4dcc956..0bdf96117 100644 --- a/HandheldCompanion/Devices/IDevice.cs +++ b/HandheldCompanion/Devices/IDevice.cs @@ -9,7 +9,6 @@ using static HandheldCompanion.OneEuroFilter; using HandheldCompanion.Managers; using HandheldCompanion.Sensors; -using HandheldCompanion.Controllers; namespace HandheldCompanion.Devices; @@ -154,154 +153,154 @@ public static IDevice GetDefault() } break; case "AOKZOE": - { - switch (ProductName) { - case "AOKZOE A1 AR07": - device = new AOKZOEA1(); - break; - case "AOKZOE A1 Pro": - device = new AOKZOEA1Pro(); - break; + switch (ProductName) + { + case "AOKZOE A1 AR07": + device = new AOKZOEA1(); + break; + case "AOKZOE A1 Pro": + device = new AOKZOEA1Pro(); + break; } - } + } break; case "AYADEVICE": case "AYANEO": - { - switch (ProductName) { - case "AIR": - device = new AYANEOAIR(); - break; - case "AIR Pro": - device = new AYANEOAIRPro(); - break; - case "AIR Lite": - device = new AYANEOAIRLite(); - break; - case "AYA NEO FOUNDER": - case "AYANEO 2021": - device = new AYANEO2021(); - break; - case "AYANEO 2021 Pro": - case "AYANEO 2021 Pro Retro Power": - device = new AYANEO2021Pro(); - break; - case "NEXT Pro": - case "NEXT Advance": - case "NEXT": - device = new AYANEONEXT(); - break; - case "AYANEO 2": - case "GEEK": - device = new AYANEO2(); - break; - case "AB05-AMD": - device = new AYANEOAIRPlus(); - break; - case "AYANEO 2S": - case "GEEK 1S": - device = new AYANEO2S(); - break; + switch (ProductName) + { + case "AIR": + device = new AYANEOAIR(); + break; + case "AIR Pro": + device = new AYANEOAIRPro(); + break; + case "AIR Lite": + device = new AYANEOAIRLite(); + break; + case "AYA NEO FOUNDER": + case "AYANEO 2021": + device = new AYANEO2021(); + break; + case "AYANEO 2021 Pro": + case "AYANEO 2021 Pro Retro Power": + device = new AYANEO2021Pro(); + break; + case "NEXT Pro": + case "NEXT Advance": + case "NEXT": + device = new AYANEONEXT(); + break; + case "AYANEO 2": + case "GEEK": + device = new AYANEO2(); + break; + case "AB05-AMD": + device = new AYANEOAIRPlus(); + break; + case "AYANEO 2S": + case "GEEK 1S": + device = new AYANEO2S(); + break; + } } - } break; case "GPD": - { - switch (ProductName) { - case "WIN2": - device = new GPDWin2(); - break; - case "G1618-03": - device = new GPDWin3(); - break; - case "G1618-04": - device = new GPDWin4(); - break; - case "G1619-03": - device = new GPDWinMax2Intel(); - break; - case "G1619-04": - device = new GPDWinMax2AMD(); - break; + switch (ProductName) + { + case "WIN2": + device = new GPDWin2(); + break; + case "G1618-03": + device = new GPDWin3(); + break; + case "G1618-04": + device = new GPDWin4(); + break; + case "G1619-03": + device = new GPDWinMax2Intel(); + break; + case "G1619-04": + device = new GPDWinMax2AMD(); + break; + } } - } break; case "ONE-NETBOOK TECHNOLOGY CO., LTD.": case "ONE-NETBOOK": - { - switch (ProductName) { - case "ONE XPLAYER": - case "ONEXPLAYER Mini Pro": + switch (ProductName) { - switch (Version) - { - default: - case "V01": - device = new OneXPlayerMiniAMD(); - break; - case "1002-C": - device = new OneXPlayerMiniIntel(); - break; - case "V03": - device = new OneXPlayerMiniPro(); + case "ONE XPLAYER": + case "ONEXPLAYER Mini Pro": + { + switch (Version) + { + default: + case "V01": + device = new OneXPlayerMiniAMD(); + break; + case "1002-C": + device = new OneXPlayerMiniIntel(); + break; + case "V03": + device = new OneXPlayerMiniPro(); + break; + } break; - } - break; - } - case "ONEXPLAYER mini A07": - device = new OneXPlayerMiniAMD(); - break; - case "ONEXPLAYER 2 ARP23": - { - switch (Version) - { - default: - case "Ver.1.0": - device = new OneXPlayer2(); + } + case "ONEXPLAYER mini A07": + device = new OneXPlayerMiniAMD(); + break; + case "ONEXPLAYER 2 ARP23": + { + switch (Version) + { + default: + case "Ver.1.0": + device = new OneXPlayer2(); + break; + } break; - } - break; + } + case "ONEXPLAYER 2 PRO ARP23P EVA-01": + switch (Version) + { + default: + case "Version 1.0": + device = new OneXPlayer2_7840U(); + break; + } + break; } - case "ONEXPLAYER 2 PRO ARP23P EVA-01": - switch (Version) - { - default: - case "Version 1.0": - device = new OneXPlayer2_7840U(); - break; - } - break; } - } break; case "ASUSTEK COMPUTER INC.": - { - switch (ProductName) { - // Todo, figure out if theres a diff between Z1 and Z1 extreme versions - case "RC71L": - device = new ROGAlly(); - break; + switch (ProductName) + { + // Todo, figure out if theres a diff between Z1 and Z1 extreme versions + case "RC71L": + device = new ROGAlly(); + break; + } } - } break; case "VALVE": - { - switch (ProductName) { - case "Jupiter": - device = new SteamDeck(); - break; + switch (ProductName) + { + case "Jupiter": + device = new SteamDeck(); + break; + } } - } break; } diff --git a/HandheldCompanion/Devices/OneXPlayer/OneXPlayer2-7840U.cs b/HandheldCompanion/Devices/OneXPlayer/OneXPlayer2-7840U.cs index c2e35c48d..f3126450c 100644 --- a/HandheldCompanion/Devices/OneXPlayer/OneXPlayer2-7840U.cs +++ b/HandheldCompanion/Devices/OneXPlayer/OneXPlayer2-7840U.cs @@ -1,10 +1,4 @@ -using System.Collections.Generic; -using System.Numerics; -using HandheldCompanion.Inputs; -using HandheldCompanion.Managers; -using WindowsInput.Events; - -namespace HandheldCompanion.Devices; +namespace HandheldCompanion.Devices; public class OneXPlayer2_7840U : OneXPlayer2 { diff --git a/HandheldCompanion/Devices/OneXPlayer/OneXPlayerMiniPro.cs b/HandheldCompanion/Devices/OneXPlayer/OneXPlayerMiniPro.cs index 631be93a6..9d2290ba2 100644 --- a/HandheldCompanion/Devices/OneXPlayer/OneXPlayerMiniPro.cs +++ b/HandheldCompanion/Devices/OneXPlayer/OneXPlayerMiniPro.cs @@ -1,8 +1,6 @@ -using System.Collections.Generic; -using System.Numerics; +using System.Numerics; using HandheldCompanion.Inputs; using HandheldCompanion.Managers; -using WindowsInput.Events; namespace HandheldCompanion.Devices; diff --git a/HandheldCompanion/Devices/Valve/SteamDeck.cs b/HandheldCompanion/Devices/Valve/SteamDeck.cs index 1d54d1869..a1c9b5aad 100644 --- a/HandheldCompanion/Devices/Valve/SteamDeck.cs +++ b/HandheldCompanion/Devices/Valve/SteamDeck.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Numerics; using HandheldCompanion.Inputs; using HandheldCompanion.Managers; using WindowsInput.Events; diff --git a/HandheldCompanion/Managers/ControllerManager.cs b/HandheldCompanion/Managers/ControllerManager.cs index 840ab09b2..421809494 100644 --- a/HandheldCompanion/Managers/ControllerManager.cs +++ b/HandheldCompanion/Managers/ControllerManager.cs @@ -53,7 +53,7 @@ public static void Start() VirtualManager.ControllerSelected += VirtualManager_ControllerSelected; VirtualManager.Vibrated += VirtualManager_Vibrated; - + MainWindow.CurrentDevice.KeyPressed += CurrentDevice_KeyPressed; MainWindow.CurrentDevice.KeyReleased += CurrentDevice_KeyReleased; @@ -82,7 +82,7 @@ private static void GamepadFocusManager_LostFocus(Control control) { GamepadWindow gamepadWindow = (GamepadWindow)control; - switch(gamepadWindow.Title) + switch (gamepadWindow.Title) { case "QuickTools": focusedWindows &= ~FocusedWindow.Quicktools; @@ -150,7 +150,7 @@ private static void CheckControllerScenario() if (steamController.IsVirtualMuted()) ControllerMuted = true; } - } + } // either main window or quicktools are focused if (focusedWindows != FocusedWindow.None) @@ -197,17 +197,17 @@ private static void SettingsManager_SettingValueChanged(string name, object valu break; case "SteamControllerMute": - { - IController target = GetTargetController(); - if (target is null) - return; + { + IController target = GetTargetController(); + if (target is null) + return; - if (target is not SteamController) - return; + if (target is not SteamController) + return; - bool Muted = Convert.ToBoolean(value); - ((SteamController)target).SetVirtualMuted(Muted); - } + bool Muted = Convert.ToBoolean(value); + ((SteamController)target).SetVirtualMuted(Muted); + } break; } }); @@ -316,62 +316,62 @@ private static void HidDeviceArrived(PnPDetails details, DeviceEventArgs obj) { // SONY case 0x054C: - { - switch (ProductId) { - case 0x0268: // DualShock 3 - case 0x05C4: // DualShock 4 - case 0x09CC: // DualShock 4 (2nd Gen) - case 0x0CE6: // DualSense - controller = new DS4Controller(joystick, details); - break; + switch (ProductId) + { + case 0x0268: // DualShock 3 + case 0x05C4: // DualShock 4 + case 0x09CC: // DualShock 4 (2nd Gen) + case 0x0CE6: // DualSense + controller = new DS4Controller(joystick, details); + break; + } } - } break; // STEAM case 0x28DE: - { - switch (ProductId) { - // WIRED STEAM CONTROLLER - case 0x1102: - // MI == 0 is virtual keyboards - // MI == 1 is virtual mouse - // MI == 2 is controller proper - // No idea what's in case of more than one controller connected - if (details.GetMI() == 2) - controller = new GordonController(details); - break; - // WIRELESS STEAM CONTROLLER - case 0x1142: - // MI == 0 is virtual keyboards - // MI == 1-4 are 4 controllers - // TODO: The dongle registers 4 controller devices, regardless how many are - // actually connected. There is no easy way to check for connection without - // actually talking to each controller. Handle only the first for now. - if (details.GetMI() == 1) - controller = new GordonController(details); - break; - - // STEAM DECK - case 0x1205: - controller = new NeptuneController(details); - break; + switch (ProductId) + { + // WIRED STEAM CONTROLLER + case 0x1102: + // MI == 0 is virtual keyboards + // MI == 1 is virtual mouse + // MI == 2 is controller proper + // No idea what's in case of more than one controller connected + if (details.GetMI() == 2) + controller = new GordonController(details); + break; + // WIRELESS STEAM CONTROLLER + case 0x1142: + // MI == 0 is virtual keyboards + // MI == 1-4 are 4 controllers + // TODO: The dongle registers 4 controller devices, regardless how many are + // actually connected. There is no easy way to check for connection without + // actually talking to each controller. Handle only the first for now. + if (details.GetMI() == 1) + controller = new GordonController(details); + break; + + // STEAM DECK + case 0x1205: + controller = new NeptuneController(details); + break; + } } - } break; // NINTENDO case 0x057E: - { - switch (ProductId) { - // Nintendo Wireless Gamepad - case 0x2009: - break; + switch (ProductId) + { + // Nintendo Wireless Gamepad + case 0x2009: + break; + } } - } break; } @@ -632,7 +632,7 @@ private static void UpdateInputs(ControllerState controllerState) // pass to SensorsManager for sensors value reading SensorFamily sensorSelection = (SensorFamily)SettingsManager.GetInt("SensorSelection"); - switch(sensorSelection) + switch (sensorSelection) { case SensorFamily.Windows: case SensorFamily.SerialUSBIMU: @@ -673,7 +673,7 @@ internal static IController GetEmulatedController() private static bool IsHCVirtualController(XInputController controller) { - if(controller.IsVirtual() && virtualControllerCreated) + if (controller.IsVirtual() && virtualControllerCreated) { virtualControllerCreated = false; return true; diff --git a/HandheldCompanion/Managers/DeviceManager.cs b/HandheldCompanion/Managers/DeviceManager.cs index 12dc99dd5..fcda165c6 100644 --- a/HandheldCompanion/Managers/DeviceManager.cs +++ b/HandheldCompanion/Managers/DeviceManager.cs @@ -138,7 +138,7 @@ private static void RefreshXInput() devices = devices.OrderBy(device => device.Value).ToDictionary(x => x.Key, x => x.Value); foreach (var pair in devices) XUsbDevice_DeviceArrived(new DeviceEventArgs - { InterfaceGuid = DeviceInterfaceIds.XUsbDevice, SymLink = pair.Key }); + { InterfaceGuid = DeviceInterfaceIds.XUsbDevice, SymLink = pair.Key }); } private static void RefreshDInput() @@ -160,7 +160,7 @@ private static void RefreshDInput() devices = devices.OrderBy(device => device.Value).ToDictionary(x => x.Key, x => x.Value); foreach (var pair in devices) HidDevice_DeviceArrived(new DeviceEventArgs - { InterfaceGuid = DeviceInterfaceIds.HidDevice, SymLink = pair.Key }); + { InterfaceGuid = DeviceInterfaceIds.HidDevice, SymLink = pair.Key }); } private static PnPDetails FindDevice(string SymLink, bool Removed = false) @@ -393,7 +393,7 @@ private static bool IsGaming(Attributes attributes, Capabilities capabilities) { return ( ((attributes.VendorID == 0x28DE) && (attributes.ProductID == 0x1102)) || // STEAM CONTROLLER - // ((attributes.VendorID == 0x28DE) && (attributes.ProductID == 0x1106)) || // STEAM CONTROLLER BLUETOOTH + // ((attributes.VendorID == 0x28DE) && (attributes.ProductID == 0x1106)) || // STEAM CONTROLLER BLUETOOTH ((attributes.VendorID == 0x28DE) && (attributes.ProductID == 0x1142)) || // STEAM CONTROLLER WIRELESS ((attributes.VendorID == 0x28DE) && (attributes.ProductID == 0x1205)) || // STEAM DECK (0x05 == capabilities.UsagePage) || (0x01 == capabilities.UsagePage) && ((0x04 == capabilities.Usage) || (0x05 == capabilities.Usage))); diff --git a/HandheldCompanion/Managers/GamepadFocusManager.cs b/HandheldCompanion/Managers/GamepadFocusManager.cs index b4a875262..3b662f16b 100644 --- a/HandheldCompanion/Managers/GamepadFocusManager.cs +++ b/HandheldCompanion/Managers/GamepadFocusManager.cs @@ -59,7 +59,7 @@ public GamepadFocusManager(GamepadWindow gamepadWindow, Frame contentFrame) //_currentWindow.IsVisibleChanged += _currentWindow_IsVisibleChanged; - _currentWindow.GotGamepadWindowFocus += _currentWindow_GotGamepadWindowFocus; + _currentWindow.GotGamepadWindowFocus += _currentWindow_GotGamepadWindowFocus; _currentWindow.LostGamepadWindowFocus += _currentWindow_LostGamepadWindowFocus; _currentWindow.Activated += (sender, e) => _currentWindow_GotFocus(sender, null); @@ -69,7 +69,7 @@ public GamepadFocusManager(GamepadWindow gamepadWindow, Frame contentFrame) _gamepadFrame.Navigated += ContentFrame_Navigated; // start listening to inputs - switch(SettingsManager.GetBoolean("DesktopProfileOnStart")) + switch (SettingsManager.GetBoolean("DesktopProfileOnStart")) { case true: ControllerManager.InputsUpdated -= InputsUpdated; @@ -149,7 +149,7 @@ private void SettingsManager_SettingValueChanged(string name, object value) case "DesktopLayoutEnabled": { var value = SettingsManager.GetBoolean(name, true); - switch(value) + switch (value) { case true: ControllerManager.InputsUpdated -= InputsUpdated; @@ -263,7 +263,7 @@ public Control FocusedElement(GamepadWindow window) keyboardFocused = _currentWindow; } - if(keyboardFocused.Focusable) + if (keyboardFocused.Focusable) { Control controlFocused = (Control)keyboardFocused; @@ -369,7 +369,7 @@ private void InputsUpdated(ControllerState controllerState) { // lazy // todo: implement proper RoutedEvent call - switch (elementType) + switch (elementType) { case "Button": WPFUtils.SendKeyToControl(focusedElement, (int)VirtualKeyCode.RETURN); @@ -386,7 +386,7 @@ private void InputsUpdated(ControllerState controllerState) case "NavigationViewItem": { - switch(focusedElement.Name) + switch (focusedElement.Name) { // deprecated, used for ui:NavigationView.FooterMenuItem case "b_ServiceStart": @@ -465,7 +465,7 @@ private void InputsUpdated(ControllerState controllerState) case "ComboBox": { ComboBox comboBox = (ComboBox)focusedElement; - switch(comboBox.IsDropDownOpen) + switch (comboBox.IsDropDownOpen) { case true: comboBox.IsDropDownOpen = false; @@ -529,7 +529,7 @@ private void InputsUpdated(ControllerState controllerState) // navigation if (direction != WPFUtils.Direction.None) { - switch(elementType) + switch (elementType) { case "NavigationViewItem": { @@ -558,7 +558,7 @@ private void InputsUpdated(ControllerState controllerState) case "ComboBoxItem": { - switch(direction) + switch (direction) { case WPFUtils.Direction.Up: WPFUtils.SendKeyToControl(focusedElement, (int)VirtualKeyCode.UP); diff --git a/HandheldCompanion/Managers/HotkeysManager.cs b/HandheldCompanion/Managers/HotkeysManager.cs index 5a21d8acf..03b3077f2 100644 --- a/HandheldCompanion/Managers/HotkeysManager.cs +++ b/HandheldCompanion/Managers/HotkeysManager.cs @@ -3,11 +3,9 @@ using System.IO; using System.Linq; using System.Runtime.InteropServices; -using System.Threading; using System.Windows; using Windows.System; using HandheldCompanion.Controllers; -using HandheldCompanion.Managers; using HandheldCompanion.Utils; using GregsStack.InputSimulatorStandard.Native; using HandheldCompanion.Controls; @@ -18,7 +16,6 @@ using Newtonsoft.Json; using static HandheldCompanion.Managers.InputsHotkey; using static HandheldCompanion.Managers.InputsManager; -using System.Threading.Tasks; using HandheldCompanion.Misc; namespace HandheldCompanion.Managers; @@ -174,20 +171,20 @@ private static void PinOrUnpinHotkey(Hotkey hotkey) switch (hotkey.IsPinned) { case false: - { - var count = CountPinned(); - - if (count >= PIN_LIMIT) { - _ = Dialog.ShowAsync($"{Resources.SettingsPage_UpdateWarning}", - $"You can't pin more than {PIN_LIMIT} hotkeys", - ContentDialogButton.Primary, string.Empty, $"{Resources.ProfilesPage_OK}"); + var count = CountPinned(); - return; - } + if (count >= PIN_LIMIT) + { + _ = Dialog.ShowAsync($"{Resources.SettingsPage_UpdateWarning}", + $"You can't pin more than {PIN_LIMIT} hotkeys", + ContentDialogButton.Primary, string.Empty, $"{Resources.ProfilesPage_OK}"); - hotkey.IsPinned = true; - } + return; + } + + hotkey.IsPinned = true; + } break; case true: hotkey.IsPinned = false; @@ -327,62 +324,62 @@ public static void TriggerRaised(string listener, InputsChord input, InputsHotke { VirtualKeyCode.LCONTROL, VirtualKeyCode.LSHIFT, VirtualKeyCode.ESCAPE }); break; case "shortcutActionCenter": - { - var uri = new Uri("ms-actioncenter"); - var success = Launcher.LaunchUriAsync(uri); - } + { + var uri = new Uri("ms-actioncenter"); + var success = Launcher.LaunchUriAsync(uri); + } break; case "shortcutControlCenter": - { - var uri = new Uri( - "ms-actioncenter:controlcenter/&suppressAnimations=false&showFooter=true&allowPageNavigation=true"); - var success = Launcher.LaunchUriAsync(uri); - } + { + var uri = new Uri( + "ms-actioncenter:controlcenter/&suppressAnimations=false&showFooter=true&allowPageNavigation=true"); + var success = Launcher.LaunchUriAsync(uri); + } break; case "shortcutPrintScreen": KeyboardSimulator.KeyPress( new[] { VirtualKeyCode.LWIN, VirtualKeyCode.LSHIFT, VirtualKeyCode.VK_S }); break; case "suspendResumeTask": - { - var sProcess = ProcessManager.GetLastSuspendedProcess(); + { + var sProcess = ProcessManager.GetLastSuspendedProcess(); - if (sProcess is null || sProcess.Filter != ProcessEx.ProcessFilter.Allowed) - break; + if (sProcess is null || sProcess.Filter != ProcessEx.ProcessFilter.Allowed) + break; - if (sProcess.IsSuspended()) - ProcessManager.ResumeProcess(sProcess); - else - ProcessManager.SuspendProcess(fProcess); - } + if (sProcess.IsSuspended()) + ProcessManager.ResumeProcess(sProcess); + else + ProcessManager.SuspendProcess(fProcess); + } break; case "shortcutKillApp": if (fProcess is not null) fProcess.Process.Kill(); break; case "QuietModeToggled": - { - var value = !SettingsManager.GetBoolean(listener); - SettingsManager.SetProperty(listener, value); + { + var value = !SettingsManager.GetBoolean(listener); + SettingsManager.SetProperty(listener, value); - ToastManager.SendToast("Quiet mode", $"is now {(value ? "enabled" : "disabled")}"); - } + ToastManager.SendToast("Quiet mode", $"is now {(value ? "enabled" : "disabled")}"); + } break; case "OnScreenDisplayLevel": - { - var value = !SettingsManager.GetBoolean(listener); - SettingsManager.SetProperty(listener, value); - } + { + var value = !SettingsManager.GetBoolean(listener); + SettingsManager.SetProperty(listener, value); + } break; // temporary settings case "DesktopLayoutEnabled": - { - var value = !SettingsManager.GetBoolean(listener, true); - SettingsManager.SetProperty(listener, value, false, true); + { + var value = !SettingsManager.GetBoolean(listener, true); + SettingsManager.SetProperty(listener, value, false, true); - ToastManager.SendToast("Desktop layout", $"is now {(value ? "enabled" : "disabled")}"); - } + ToastManager.SendToast("Desktop layout", $"is now {(value ? "enabled" : "disabled")}"); + } break; default: diff --git a/HandheldCompanion/Managers/LayoutManager.cs b/HandheldCompanion/Managers/LayoutManager.cs index 5fbdc64b0..27d73535b 100644 --- a/HandheldCompanion/Managers/LayoutManager.cs +++ b/HandheldCompanion/Managers/LayoutManager.cs @@ -3,13 +3,9 @@ using System.IO; using System.Threading.Tasks; using System.Windows; -using HandheldCompanion; using HandheldCompanion.Actions; using HandheldCompanion.Controllers; - -using HandheldCompanion.Managers; using HandheldCompanion.Utils; -using HandheldCompanion.Actions; using HandheldCompanion.Controls; using HandheldCompanion.Managers.Desktop; using HandheldCompanion.Views; @@ -243,17 +239,17 @@ private static void SettingsManager_SettingValueChanged(string name, object valu switch (name) { case "DesktopLayoutEnabled": - { - switch (Convert.ToBoolean(value)) { - case true: - SetActiveLayout(desktopLayout); - break; - case false: - SetActiveLayout(profileLayout); - break; + switch (Convert.ToBoolean(value)) + { + case true: + SetActiveLayout(desktopLayout); + break; + case false: + SetActiveLayout(profileLayout); + break; + } } - } break; } } diff --git a/HandheldCompanion/Managers/OSDManager.cs b/HandheldCompanion/Managers/OSDManager.cs index f111eb19a..5263e238c 100644 --- a/HandheldCompanion/Managers/OSDManager.cs +++ b/HandheldCompanion/Managers/OSDManager.cs @@ -165,134 +165,134 @@ public static string Draw(int processId) break; case 1: - { - OverlayRow row1 = new(); - - OverlayEntry FPSentry = new(AppFlag, "C6"); - FPSentry.elements.Add(new SensorElement { - Value = PlatformManager.RTSS.GetFramerate(processId), - szUnit = "FPS" - }); - row1.entries.Add(FPSentry); + OverlayRow row1 = new(); - // add header to row1 - Content.Add(Header + row1); - } + OverlayEntry FPSentry = new(AppFlag, "C6"); + FPSentry.elements.Add(new SensorElement + { + Value = PlatformManager.RTSS.GetFramerate(processId), + szUnit = "FPS" + }); + row1.entries.Add(FPSentry); + + // add header to row1 + Content.Add(Header + row1); + } break; case 2: - { - OverlayRow row1 = new(); - - OverlayEntry BATTentry = new("BATT", "C5"); - if (PlatformManager.HWiNFO.MonitoredSensors.TryGetValue(SensorElementType.BatteryChargeLevel, - out sensor)) - BATTentry.elements.Add(sensor); - if (PlatformManager.HWiNFO.MonitoredSensors.TryGetValue(SensorElementType.BatteryRemainingCapacity, - out sensor)) - BATTentry.elements.Add(sensor); - row1.entries.Add(BATTentry); - - OverlayEntry GPUentry = new("GPU", "C1"); - if (PlatformManager.HWiNFO.MonitoredSensors.TryGetValue(SensorElementType.GPUUsage, out sensor)) - GPUentry.elements.Add(sensor); - if (PlatformManager.HWiNFO.MonitoredSensors.TryGetValue(SensorElementType.GPUPower, out sensor)) - GPUentry.elements.Add(sensor); - row1.entries.Add(GPUentry); - - OverlayEntry CPUentry = new("CPU", "C2"); - if (PlatformManager.HWiNFO.MonitoredSensors.TryGetValue(SensorElementType.CPUUsage, out sensor)) - CPUentry.elements.Add(sensor); - if (PlatformManager.HWiNFO.MonitoredSensors.TryGetValue(SensorElementType.CPUPower, out sensor)) - CPUentry.elements.Add(sensor); - row1.entries.Add(CPUentry); - - OverlayEntry RAMentry = new("RAM", "C3"); - if (PlatformManager.HWiNFO.MonitoredSensors.TryGetValue(SensorElementType.PhysicalMemoryUsage, - out sensor)) - RAMentry.elements.Add(sensor); - row1.entries.Add(RAMentry); - - OverlayEntry FPSentry = new(AppFlag, "C6"); - FPSentry.elements.Add(new SensorElement { - Value = PlatformManager.RTSS.GetFramerate(processId), - szUnit = "FPS" - }); - row1.entries.Add(FPSentry); + OverlayRow row1 = new(); + + OverlayEntry BATTentry = new("BATT", "C5"); + if (PlatformManager.HWiNFO.MonitoredSensors.TryGetValue(SensorElementType.BatteryChargeLevel, + out sensor)) + BATTentry.elements.Add(sensor); + if (PlatformManager.HWiNFO.MonitoredSensors.TryGetValue(SensorElementType.BatteryRemainingCapacity, + out sensor)) + BATTentry.elements.Add(sensor); + row1.entries.Add(BATTentry); + + OverlayEntry GPUentry = new("GPU", "C1"); + if (PlatformManager.HWiNFO.MonitoredSensors.TryGetValue(SensorElementType.GPUUsage, out sensor)) + GPUentry.elements.Add(sensor); + if (PlatformManager.HWiNFO.MonitoredSensors.TryGetValue(SensorElementType.GPUPower, out sensor)) + GPUentry.elements.Add(sensor); + row1.entries.Add(GPUentry); + + OverlayEntry CPUentry = new("CPU", "C2"); + if (PlatformManager.HWiNFO.MonitoredSensors.TryGetValue(SensorElementType.CPUUsage, out sensor)) + CPUentry.elements.Add(sensor); + if (PlatformManager.HWiNFO.MonitoredSensors.TryGetValue(SensorElementType.CPUPower, out sensor)) + CPUentry.elements.Add(sensor); + row1.entries.Add(CPUentry); + + OverlayEntry RAMentry = new("RAM", "C3"); + if (PlatformManager.HWiNFO.MonitoredSensors.TryGetValue(SensorElementType.PhysicalMemoryUsage, + out sensor)) + RAMentry.elements.Add(sensor); + row1.entries.Add(RAMentry); + + OverlayEntry FPSentry = new(AppFlag, "C6"); + FPSentry.elements.Add(new SensorElement + { + Value = PlatformManager.RTSS.GetFramerate(processId), + szUnit = "FPS" + }); + row1.entries.Add(FPSentry); - // add header to row1 - Content.Add(Header + row1); - } + // add header to row1 + Content.Add(Header + row1); + } break; case 3: - { - OverlayRow row1 = new(); - OverlayRow row2 = new(); - OverlayRow row3 = new(); - OverlayRow row4 = new(); - OverlayRow row5 = new(); - OverlayRow row6 = new(); - - OverlayEntry GPUentry = new("GPU", "C1", true); - if (PlatformManager.HWiNFO.MonitoredSensors.TryGetValue(SensorElementType.GPUUsage, out sensor)) - GPUentry.elements.Add(sensor); - if (PlatformManager.HWiNFO.MonitoredSensors.TryGetValue(SensorElementType.GPUPower, out sensor)) - GPUentry.elements.Add(sensor); - if (PlatformManager.HWiNFO.MonitoredSensors.TryGetValue(SensorElementType.GPUTemperature, out sensor)) - GPUentry.elements.Add(sensor); - row1.entries.Add(GPUentry); - - OverlayEntry CPUentry = new("CPU", "C2", true); - if (PlatformManager.HWiNFO.MonitoredSensors.TryGetValue(SensorElementType.CPUUsage, out sensor)) - CPUentry.elements.Add(sensor); - if (PlatformManager.HWiNFO.MonitoredSensors.TryGetValue(SensorElementType.CPUPower, out sensor)) - CPUentry.elements.Add(sensor); - if (PlatformManager.HWiNFO.MonitoredSensors.TryGetValue(SensorElementType.CPUTemperature, out sensor)) - CPUentry.elements.Add(sensor); - row2.entries.Add(CPUentry); - - OverlayEntry RAMentry = new("RAM", "C3", true); - if (PlatformManager.HWiNFO.MonitoredSensors.TryGetValue(SensorElementType.PhysicalMemoryUsage, - out sensor)) - RAMentry.elements.Add(sensor); - row3.entries.Add(RAMentry); - - OverlayEntry VRAMentry = new("VRAM", "C4", true); - if (PlatformManager.HWiNFO.MonitoredSensors.TryGetValue(SensorElementType.GPUMemoryUsage, out sensor)) - VRAMentry.elements.Add(sensor); - row4.entries.Add(VRAMentry); - - OverlayEntry BATTentry = new("BATT", "C5", true); - if (PlatformManager.HWiNFO.MonitoredSensors.TryGetValue(SensorElementType.BatteryChargeLevel, - out sensor)) - BATTentry.elements.Add(sensor); - if (PlatformManager.HWiNFO.MonitoredSensors.TryGetValue(SensorElementType.BatteryRemainingCapacity, - out sensor)) - BATTentry.elements.Add(sensor); - if (PlatformManager.HWiNFO.MonitoredSensors.TryGetValue(SensorElementType.BatteryRemainingTime, - out sensor)) - BATTentry.elements.Add(sensor); - row5.entries.Add(BATTentry); - - OverlayEntry FPSentry = new(AppFlag, "C6", true); - FPSentry.elements.Add(new SensorElement { - Value = PlatformManager.RTSS.GetFramerate(processId), - szUnit = "FPS" - }); - row6.entries.Add(FPSentry); - - // add header to row1 - Content.Add(Header + row1); - Content.Add(row2.ToString()); - Content.Add(row3.ToString()); - Content.Add(row4.ToString()); - Content.Add(row5.ToString()); - Content.Add(row6.ToString()); - } + OverlayRow row1 = new(); + OverlayRow row2 = new(); + OverlayRow row3 = new(); + OverlayRow row4 = new(); + OverlayRow row5 = new(); + OverlayRow row6 = new(); + + OverlayEntry GPUentry = new("GPU", "C1", true); + if (PlatformManager.HWiNFO.MonitoredSensors.TryGetValue(SensorElementType.GPUUsage, out sensor)) + GPUentry.elements.Add(sensor); + if (PlatformManager.HWiNFO.MonitoredSensors.TryGetValue(SensorElementType.GPUPower, out sensor)) + GPUentry.elements.Add(sensor); + if (PlatformManager.HWiNFO.MonitoredSensors.TryGetValue(SensorElementType.GPUTemperature, out sensor)) + GPUentry.elements.Add(sensor); + row1.entries.Add(GPUentry); + + OverlayEntry CPUentry = new("CPU", "C2", true); + if (PlatformManager.HWiNFO.MonitoredSensors.TryGetValue(SensorElementType.CPUUsage, out sensor)) + CPUentry.elements.Add(sensor); + if (PlatformManager.HWiNFO.MonitoredSensors.TryGetValue(SensorElementType.CPUPower, out sensor)) + CPUentry.elements.Add(sensor); + if (PlatformManager.HWiNFO.MonitoredSensors.TryGetValue(SensorElementType.CPUTemperature, out sensor)) + CPUentry.elements.Add(sensor); + row2.entries.Add(CPUentry); + + OverlayEntry RAMentry = new("RAM", "C3", true); + if (PlatformManager.HWiNFO.MonitoredSensors.TryGetValue(SensorElementType.PhysicalMemoryUsage, + out sensor)) + RAMentry.elements.Add(sensor); + row3.entries.Add(RAMentry); + + OverlayEntry VRAMentry = new("VRAM", "C4", true); + if (PlatformManager.HWiNFO.MonitoredSensors.TryGetValue(SensorElementType.GPUMemoryUsage, out sensor)) + VRAMentry.elements.Add(sensor); + row4.entries.Add(VRAMentry); + + OverlayEntry BATTentry = new("BATT", "C5", true); + if (PlatformManager.HWiNFO.MonitoredSensors.TryGetValue(SensorElementType.BatteryChargeLevel, + out sensor)) + BATTentry.elements.Add(sensor); + if (PlatformManager.HWiNFO.MonitoredSensors.TryGetValue(SensorElementType.BatteryRemainingCapacity, + out sensor)) + BATTentry.elements.Add(sensor); + if (PlatformManager.HWiNFO.MonitoredSensors.TryGetValue(SensorElementType.BatteryRemainingTime, + out sensor)) + BATTentry.elements.Add(sensor); + row5.entries.Add(BATTentry); + + OverlayEntry FPSentry = new(AppFlag, "C6", true); + FPSentry.elements.Add(new SensorElement + { + Value = PlatformManager.RTSS.GetFramerate(processId), + szUnit = "FPS" + }); + row6.entries.Add(FPSentry); + + // add header to row1 + Content.Add(Header + row1); + Content.Add(row2.ToString()); + Content.Add(row3.ToString()); + Content.Add(row4.ToString()); + Content.Add(row5.ToString()); + Content.Add(row6.ToString()); + } break; } @@ -320,39 +320,39 @@ private static void SettingsManager_SettingValueChanged(string name, object valu switch (name) { case "OnScreenDisplayLevel": - { - OverlayLevel = Convert.ToInt16(value); - - if (OverlayLevel != 0) - { - if (!RefreshTimer.IsRunning()) - RefreshTimer.Start(); - } - else { - RefreshTimer.Stop(); + OverlayLevel = Convert.ToInt16(value); - // clear UI on stop - foreach (var pair in OnScreenDisplay) + if (OverlayLevel != 0) + { + if (!RefreshTimer.IsRunning()) + RefreshTimer.Start(); + } + else { - var processOSD = pair.Value; - processOSD.Update(""); + RefreshTimer.Stop(); + + // clear UI on stop + foreach (var pair in OnScreenDisplay) + { + var processOSD = pair.Value; + processOSD.Update(""); + } } } - } break; case "OnScreenDisplayRefreshRate": - { - RefreshInterval = Convert.ToInt32(value); - - if (RefreshTimer.IsRunning()) { - RefreshTimer.Stop(); - RefreshTimer.SetPeriod(RefreshInterval); - RefreshTimer.Start(); + RefreshInterval = Convert.ToInt32(value); + + if (RefreshTimer.IsRunning()) + { + RefreshTimer.Stop(); + RefreshTimer.SetPeriod(RefreshInterval); + RefreshTimer.Start(); + } } - } break; } } diff --git a/HandheldCompanion/Managers/PerformanceManager.cs b/HandheldCompanion/Managers/PerformanceManager.cs index ca11feae1..fab59b715 100644 --- a/HandheldCompanion/Managers/PerformanceManager.cs +++ b/HandheldCompanion/Managers/PerformanceManager.cs @@ -119,16 +119,16 @@ private void SettingsManagerOnSettingValueChanged(string name, object value) switch (name) { case "ConfigurableTDPOverrideDown": - { - TDPMin = Convert.ToDouble(value); - AutoTDP = (TDPMax + TDPMin) / 2.0d; - } + { + TDPMin = Convert.ToDouble(value); + AutoTDP = (TDPMax + TDPMin) / 2.0d; + } break; case "ConfigurableTDPOverrideUp": - { - TDPMax = Convert.ToDouble(value); - AutoTDP = (TDPMax + TDPMin) / 2.0d; - } + { + TDPMax = Convert.ToDouble(value); + AutoTDP = (TDPMax + TDPMin) / 2.0d; + } break; } } @@ -697,7 +697,7 @@ public void RequestEPP(uint EPPOverrideValue) uint[] EPP = ReadPowerCfg(PowerSubGroup.SUB_PROCESSOR, PowerSetting.PERFEPP); if (EPP[0] == requestedEPP[0] && EPP[1] == requestedEPP[1]) return; - + LogManager.LogInformation("User requested EPP AC: {0}, DC: {1}", requestedEPP[0], requestedEPP[1]); // Set profile EPP @@ -946,9 +946,9 @@ private void Processor_MiscChanged(string misc, float value) switch (misc) { case "gfx_clk": - { - CurrentGfxClock = value; - } + { + CurrentGfxClock = value; + } break; } } diff --git a/HandheldCompanion/Managers/PlatformManager.cs b/HandheldCompanion/Managers/PlatformManager.cs index e1d3c7f60..c7085380e 100644 --- a/HandheldCompanion/Managers/PlatformManager.cs +++ b/HandheldCompanion/Managers/PlatformManager.cs @@ -2,9 +2,6 @@ using System.Diagnostics; using System.Timers; using System.Windows; -using HandheldCompanion; -using HandheldCompanion.Managers; -using HandheldCompanion.Platforms; using HandheldCompanion.Platforms; namespace HandheldCompanion.Managers; @@ -93,30 +90,30 @@ private static void SettingsManager_SettingValueChanged(string name, object valu switch (name) { case "OnScreenDisplayLevel": - { - var level = Convert.ToInt16(value); - - switch (level) { - case 0: - CurrentNeeds &= ~PlatformNeeds.OnScreenDisplay; - CurrentNeeds &= ~PlatformNeeds.OnScreenDisplayComplex; - break; - default: - case 1: - CurrentNeeds |= PlatformNeeds.OnScreenDisplay; - CurrentNeeds &= ~PlatformNeeds.OnScreenDisplayComplex; - break; - case 2: - case 3: - CurrentNeeds |= PlatformNeeds.OnScreenDisplay; - CurrentNeeds |= PlatformNeeds.OnScreenDisplayComplex; - break; + var level = Convert.ToInt16(value); + + switch (level) + { + case 0: + CurrentNeeds &= ~PlatformNeeds.OnScreenDisplay; + CurrentNeeds &= ~PlatformNeeds.OnScreenDisplayComplex; + break; + default: + case 1: + CurrentNeeds |= PlatformNeeds.OnScreenDisplay; + CurrentNeeds &= ~PlatformNeeds.OnScreenDisplayComplex; + break; + case 2: + case 3: + CurrentNeeds |= PlatformNeeds.OnScreenDisplay; + CurrentNeeds |= PlatformNeeds.OnScreenDisplayComplex; + break; + } + + UpdateTimer.Stop(); + UpdateTimer.Start(); } - - UpdateTimer.Stop(); - UpdateTimer.Start(); - } break; } }); diff --git a/HandheldCompanion/Managers/ProcessManager.cs b/HandheldCompanion/Managers/ProcessManager.cs index 3669dd824..8def9aa56 100644 --- a/HandheldCompanion/Managers/ProcessManager.cs +++ b/HandheldCompanion/Managers/ProcessManager.cs @@ -151,7 +151,7 @@ public static List GetProcesses(string executable) return Processes.Values.Where(a => a.Executable.Equals(executable, StringComparison.InvariantCultureIgnoreCase)) .ToList(); } - + private static void ForegroundCallback(object? sender, EventArgs e) { IntPtr hWnd = GetforegroundWindow(); @@ -299,18 +299,18 @@ private static ProcessFilter GetFilter(string exec, string path, string MainWind { // handheld companion case "handheldcompanion.exe": - { - /* if (!string.IsNullOrEmpty(MainWindowTitle)) { - switch (MainWindowTitle) + /* if (!string.IsNullOrEmpty(MainWindowTitle)) { - case "QuickTools": - return ProcessFilter.HandheldCompanion; - } - } */ - - return ProcessFilter.HandheldCompanion; - } + switch (MainWindowTitle) + { + case "QuickTools": + return ProcessFilter.HandheldCompanion; + } + } */ + + return ProcessFilter.HandheldCompanion; + } case "rw.exe": // Used to change TDP case "kx.exe": // Used to change TDP diff --git a/HandheldCompanion/Managers/ProfileManager.cs b/HandheldCompanion/Managers/ProfileManager.cs index 50241c704..e24361ad6 100644 --- a/HandheldCompanion/Managers/ProfileManager.cs +++ b/HandheldCompanion/Managers/ProfileManager.cs @@ -291,20 +291,20 @@ private static void ProcessProfile(string fileName) switch (version.ToString()) { case "0.15.0.4": - { - outputraw = CommonUtils.RegexReplace(outputraw, "Generic.Dictionary(.*)System.Private.CoreLib\"", - "Generic.SortedDictionary$1System.Collections\""); - jObject = JObject.Parse(outputraw); - jObject.Remove("MotionSensivityArray"); - outputraw = jObject.ToString(); - } + { + outputraw = CommonUtils.RegexReplace(outputraw, "Generic.Dictionary(.*)System.Private.CoreLib\"", + "Generic.SortedDictionary$1System.Collections\""); + jObject = JObject.Parse(outputraw); + jObject.Remove("MotionSensivityArray"); + outputraw = jObject.ToString(); + } break; case "0.16.0.5": - { - outputraw = outputraw.Replace( - "\"System.Collections.Generic.SortedDictionary`2[[HandheldCompanion.Inputs.ButtonFlags, HandheldCompanion],[System.Boolean, System.Private.CoreLib]], System.Collections\"", - "\"System.Collections.Concurrent.ConcurrentDictionary`2[[HandheldCompanion.Inputs.ButtonFlags, HandheldCompanion],[System.Boolean, System.Private.CoreLib]], System.Collections.Concurrent\""); - } + { + outputraw = outputraw.Replace( + "\"System.Collections.Generic.SortedDictionary`2[[HandheldCompanion.Inputs.ButtonFlags, HandheldCompanion],[System.Boolean, System.Private.CoreLib]], System.Collections\"", + "\"System.Collections.Concurrent.ConcurrentDictionary`2[[HandheldCompanion.Inputs.ButtonFlags, HandheldCompanion],[System.Boolean, System.Private.CoreLib]], System.Collections.Concurrent\""); + } break; } diff --git a/HandheldCompanion/Managers/SensorsManager.cs b/HandheldCompanion/Managers/SensorsManager.cs index 236208d06..97ee56026 100644 --- a/HandheldCompanion/Managers/SensorsManager.cs +++ b/HandheldCompanion/Managers/SensorsManager.cs @@ -4,8 +4,6 @@ using HandheldCompanion.Views; using Nefarius.Utilities.DeviceManagement.PnP; using System; -using System.Diagnostics; -using System.Numerics; using static HandheldCompanion.Utils.DeviceUtils; namespace HandheldCompanion.Managers @@ -52,7 +50,7 @@ private static void ControllerManager_ControllerUnplugged(IController Controller return; // restore default sensor - if (MainWindow.CurrentDevice.Capabilities.HasFlag(DeviceCapabilities.InternalSensor)) + if (MainWindow.CurrentDevice.Capabilities.HasFlag(DeviceCapabilities.InternalSensor)) SettingsManager.SetProperty("SensorSelection", 1); else if (MainWindow.CurrentDevice.Capabilities.HasFlag(DeviceCapabilities.ExternalSensor)) SettingsManager.SetProperty("SensorSelection", 2); diff --git a/HandheldCompanion/Managers/SettingsManager.cs b/HandheldCompanion/Managers/SettingsManager.cs index fe75806a9..2cdd85d8d 100644 --- a/HandheldCompanion/Managers/SettingsManager.cs +++ b/HandheldCompanion/Managers/SettingsManager.cs @@ -56,10 +56,10 @@ public static void Stop() public static void SetProperty(string name, object value, bool force = false, bool temporary = false) { var prevValue = GetProperty(name, temporary); - - if(prevValue is not null) + + if (prevValue is not null) { - switch(prevValue.GetType().Name) + switch (prevValue.GetType().Name) { case "StringCollection": if (prevValue.Equals(value) && !force) @@ -122,52 +122,52 @@ private static object GetProperty(string name, bool temporary = false) switch (name) { case "ConfigurableTDPOverrideDown": - { - var TDPoverride = GetBoolean("ConfigurableTDPOverride"); + { + var TDPoverride = GetBoolean("ConfigurableTDPOverride"); - var TDPvalue = Convert.ToDouble(Properties.Settings.Default["ConfigurableTDPOverrideDown"]); - return TDPoverride - ? Properties.Settings.Default["ConfigurableTDPOverrideDown"] - : MainWindow.CurrentDevice.cTDP[0]; - } + var TDPvalue = Convert.ToDouble(Properties.Settings.Default["ConfigurableTDPOverrideDown"]); + return TDPoverride + ? Properties.Settings.Default["ConfigurableTDPOverrideDown"] + : MainWindow.CurrentDevice.cTDP[0]; + } case "ConfigurableTDPOverrideUp": - { - var TDPoverride = GetBoolean("ConfigurableTDPOverride"); + { + var TDPoverride = GetBoolean("ConfigurableTDPOverride"); - var TDPvalue = Convert.ToDouble(Properties.Settings.Default["ConfigurableTDPOverrideUp"]); - return TDPoverride - ? Properties.Settings.Default["ConfigurableTDPOverrideUp"] - : MainWindow.CurrentDevice.cTDP[1]; - } + var TDPvalue = Convert.ToDouble(Properties.Settings.Default["ConfigurableTDPOverrideUp"]); + return TDPoverride + ? Properties.Settings.Default["ConfigurableTDPOverrideUp"] + : MainWindow.CurrentDevice.cTDP[1]; + } case "QuickToolsPerformanceTDPValue": - { - var TDPoverride = GetBoolean("QuickToolsPerformanceTDPEnabled"); + { + var TDPoverride = GetBoolean("QuickToolsPerformanceTDPEnabled"); - var TDPvalue = Convert.ToDouble(Properties.Settings.Default["QuickToolsPerformanceTDPValue"]); - return TDPvalue != 0 - ? Properties.Settings.Default["QuickToolsPerformanceTDPValue"] - : MainWindow.CurrentDevice.nTDP[(int)PowerType.Slow]; - } + var TDPvalue = Convert.ToDouble(Properties.Settings.Default["QuickToolsPerformanceTDPValue"]); + return TDPvalue != 0 + ? Properties.Settings.Default["QuickToolsPerformanceTDPValue"] + : MainWindow.CurrentDevice.nTDP[(int)PowerType.Slow]; + } case "QuickToolsPerformanceTDPBoostValue": - { - var TDPoverride = GetBoolean("QuickToolsPerformanceTDPEnabled"); + { + var TDPoverride = GetBoolean("QuickToolsPerformanceTDPEnabled"); - var TDPvalue = Convert.ToDouble(Properties.Settings.Default["QuickToolsPerformanceTDPBoostValue"]); - return TDPvalue != 0 - ? Properties.Settings.Default["QuickToolsPerformanceTDPBoostValue"] - : MainWindow.CurrentDevice.nTDP[(int)PowerType.Fast]; - } + var TDPvalue = Convert.ToDouble(Properties.Settings.Default["QuickToolsPerformanceTDPBoostValue"]); + return TDPvalue != 0 + ? Properties.Settings.Default["QuickToolsPerformanceTDPBoostValue"] + : MainWindow.CurrentDevice.nTDP[(int)PowerType.Fast]; + } case "QuickToolsPerformanceGPUValue": - { - var GPUoverride = GetBoolean("QuickToolsPerformanceGPUEnabled"); + { + var GPUoverride = GetBoolean("QuickToolsPerformanceGPUEnabled"); - var GPUvalue = Convert.ToDouble(Properties.Settings.Default["QuickToolsPerformanceGPUValue"]); - return GPUvalue; - } + var GPUvalue = Convert.ToDouble(Properties.Settings.Default["QuickToolsPerformanceGPUValue"]); + return GPUvalue; + } case "HasBrightnessSupport": return SystemManager.HasBrightnessSupport(); @@ -176,14 +176,14 @@ private static object GetProperty(string name, bool temporary = false) return SystemManager.HasVolumeSupport(); default: - { - if (temporary && Settings.TryGetValue(name, out var property)) - return property; - if (PropertyExists(name)) - return Properties.Settings.Default[name]; - - return false; - } + { + if (temporary && Settings.TryGetValue(name, out var property)) + return property; + if (PropertyExists(name)) + return Properties.Settings.Default[name]; + + return false; + } } } @@ -217,7 +217,7 @@ public static double GetDouble(string name, bool temporary = false) return Convert.ToDouble(GetProperty(name, temporary)); } - public static StringCollection GetStringCollection(string name, bool temporary = false) + public static StringCollection GetStringCollection(string name, bool temporary = false) { return (StringCollection)GetProperty(name, temporary); } diff --git a/HandheldCompanion/Managers/SystemManager.cs b/HandheldCompanion/Managers/SystemManager.cs index d3a13b128..fd941e75a 100644 --- a/HandheldCompanion/Managers/SystemManager.cs +++ b/HandheldCompanion/Managers/SystemManager.cs @@ -92,7 +92,7 @@ private static void ADLXTimer_Elapsed(object? sender, ElapsedEventArgs e) } catch { } } - + private static void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data) { VolumeNotification?.Invoke(data.MasterVolume * 100.0f); @@ -130,57 +130,57 @@ private static void SettingsManager_SettingValueChanged(string name, object valu switch (name) { case "NativeDisplayOrientation": - { - var nativeOrientation = (ScreenRotation.Rotations)Convert.ToInt32(value); + { + var nativeOrientation = (ScreenRotation.Rotations)Convert.ToInt32(value); - if (!IsInitialized) - return; + if (!IsInitialized) + return; - var oldOrientation = ScreenOrientation.rotation; - ScreenOrientation = new ScreenRotation(ScreenOrientation.rotationUnnormalized, nativeOrientation); + var oldOrientation = ScreenOrientation.rotation; + ScreenOrientation = new ScreenRotation(ScreenOrientation.rotationUnnormalized, nativeOrientation); - if (oldOrientation != ScreenOrientation.rotation) - // Though the real orientation didn't change, raise event because the interpretation of it changed - DisplayOrientationChanged?.Invoke(ScreenOrientation); - } + if (oldOrientation != ScreenOrientation.rotation) + // Though the real orientation didn't change, raise event because the interpretation of it changed + DisplayOrientationChanged?.Invoke(ScreenOrientation); + } break; case "QuietModeEnabled": - { - var enabled = Convert.ToBoolean(value); - var toggled = SettingsManager.GetBoolean("QuietModeToggled"); + { + var enabled = Convert.ToBoolean(value); + var toggled = SettingsManager.GetBoolean("QuietModeToggled"); - if (!enabled && toggled) - SettingsManager.SetProperty("QuietModeToggled", false); - } + if (!enabled && toggled) + SettingsManager.SetProperty("QuietModeToggled", false); + } break; case "QuietModeToggled": - { - var toggled = Convert.ToBoolean(value); + { + var toggled = Convert.ToBoolean(value); - // do not send command to device on startup if toggle is off - if (!SettingsManager.IsInitialized && !toggled) - return; + // do not send command to device on startup if toggle is off + if (!SettingsManager.IsInitialized && !toggled) + return; - MainWindow.CurrentDevice.SetFanControl(toggled); + MainWindow.CurrentDevice.SetFanControl(toggled); - if (!toggled) - return; + if (!toggled) + return; - var duty = SettingsManager.GetDouble("QuietModeDuty"); - MainWindow.CurrentDevice.SetFanDuty(duty); - } + var duty = SettingsManager.GetDouble("QuietModeDuty"); + MainWindow.CurrentDevice.SetFanDuty(duty); + } break; case "QuietModeDuty": - { - var enabled = SettingsManager.GetBoolean("QuietModeEnabled"); - var toggled = SettingsManager.GetBoolean("QuietModeToggled"); + { + var enabled = SettingsManager.GetBoolean("QuietModeEnabled"); + var toggled = SettingsManager.GetBoolean("QuietModeToggled"); - if (!enabled || !toggled) - return; + if (!enabled || !toggled) + return; - var duty = Convert.ToDouble(value); - MainWindow.CurrentDevice.SetFanDuty(duty); - } + var duty = Convert.ToDouble(value); + MainWindow.CurrentDevice.SetFanDuty(duty); + } break; } } @@ -190,32 +190,32 @@ private static void HotkeysManager_CommandExecuted(string listener) switch (listener) { case "increaseBrightness": - { - var stepRoundDn = (int)Math.Floor(GetBrightness() / 5.0d); - var brightness = stepRoundDn * 5 + 5; - SetBrightness(brightness); - } + { + var stepRoundDn = (int)Math.Floor(GetBrightness() / 5.0d); + var brightness = stepRoundDn * 5 + 5; + SetBrightness(brightness); + } break; case "decreaseBrightness": - { - var stepRoundUp = (int)Math.Ceiling(GetBrightness() / 5.0d); - var brightness = stepRoundUp * 5 - 5; - SetBrightness(brightness); - } + { + var stepRoundUp = (int)Math.Ceiling(GetBrightness() / 5.0d); + var brightness = stepRoundUp * 5 - 5; + SetBrightness(brightness); + } break; case "increaseVolume": - { - var stepRoundDn = (int)Math.Floor(Math.Round(GetVolume() / 5.0d, 2)); - var volume = stepRoundDn * 5 + 5; - SetVolume(volume); - } + { + var stepRoundDn = (int)Math.Floor(Math.Round(GetVolume() / 5.0d, 2)); + var volume = stepRoundDn * 5 + 5; + SetVolume(volume); + } break; case "decreaseVolume": - { - var stepRoundUp = (int)Math.Ceiling(Math.Round(GetVolume() / 5.0d, 2)); - var volume = stepRoundUp * 5 - 5; - SetVolume(volume); - } + { + var stepRoundUp = (int)Math.Ceiling(Math.Round(GetVolume() / 5.0d, 2)); + var volume = stepRoundUp * 5 - 5; + SetVolume(volume); + } break; } } diff --git a/HandheldCompanion/Managers/TaskManager.cs b/HandheldCompanion/Managers/TaskManager.cs index ae6dc0405..1831696a7 100644 --- a/HandheldCompanion/Managers/TaskManager.cs +++ b/HandheldCompanion/Managers/TaskManager.cs @@ -1,5 +1,4 @@ using System; -using HandheldCompanion.Managers; using Microsoft.Win32.TaskScheduler; namespace HandheldCompanion.Managers; diff --git a/HandheldCompanion/Managers/UpdateManager.cs b/HandheldCompanion/Managers/UpdateManager.cs index 3ea8ddab6..c45c32374 100644 --- a/HandheldCompanion/Managers/UpdateManager.cs +++ b/HandheldCompanion/Managers/UpdateManager.cs @@ -6,7 +6,6 @@ using System.Net; using System.Net.Cache; using System.Reflection; -using HandheldCompanion.Managers; using HandheldCompanion.Misc; using HandheldCompanion.Properties; using HandheldCompanion.Views; diff --git a/HandheldCompanion/Misc/DeviceHelper.cs b/HandheldCompanion/Misc/DeviceHelper.cs index 7d6e4bfbf..6c337e32e 100644 --- a/HandheldCompanion/Misc/DeviceHelper.cs +++ b/HandheldCompanion/Misc/DeviceHelper.cs @@ -6,7 +6,6 @@ using Microsoft.Win32.SafeHandles; using System.Security; using System.Runtime.ConstrainedExecution; -using System.Management; namespace HandheldCompanion { diff --git a/HandheldCompanion/Misc/Layout.cs b/HandheldCompanion/Misc/Layout.cs index cfe1cb5f9..fd5110165 100644 --- a/HandheldCompanion/Misc/Layout.cs +++ b/HandheldCompanion/Misc/Layout.cs @@ -29,10 +29,10 @@ public Layout(bool fill) : this() } ButtonLayout[ButtonFlags.OEM1] = new List() { new ButtonActions { Button = ButtonFlags.Special } }; - ButtonLayout[ButtonFlags.LeftPadClickUp] = new List() { new ButtonActions { Button = ButtonFlags.DPadUp }}; - ButtonLayout[ButtonFlags.LeftPadClickDown] = new List() { new ButtonActions { Button = ButtonFlags.DPadDown }}; - ButtonLayout[ButtonFlags.LeftPadClickLeft] = new List() { new ButtonActions { Button = ButtonFlags.DPadLeft }}; - ButtonLayout[ButtonFlags.LeftPadClickRight] = new List() { new ButtonActions { Button = ButtonFlags.DPadRight }}; + ButtonLayout[ButtonFlags.LeftPadClickUp] = new List() { new ButtonActions { Button = ButtonFlags.DPadUp } }; + ButtonLayout[ButtonFlags.LeftPadClickDown] = new List() { new ButtonActions { Button = ButtonFlags.DPadDown } }; + ButtonLayout[ButtonFlags.LeftPadClickLeft] = new List() { new ButtonActions { Button = ButtonFlags.DPadLeft } }; + ButtonLayout[ButtonFlags.LeftPadClickRight] = new List() { new ButtonActions { Button = ButtonFlags.DPadRight } }; // generic axis mapping foreach (AxisLayoutFlags axis in Enum.GetValues(typeof(AxisLayoutFlags))) diff --git a/HandheldCompanion/Misc/MotherboardInfo.cs b/HandheldCompanion/Misc/MotherboardInfo.cs index ba0aae847..7084de75e 100644 --- a/HandheldCompanion/Misc/MotherboardInfo.cs +++ b/HandheldCompanion/Misc/MotherboardInfo.cs @@ -1,8 +1,5 @@ -using HandheldCompanion.Managers; -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Management; -using System.Windows.Documents; namespace HandheldCompanion; @@ -181,7 +178,7 @@ public static string PrimaryBusType public static string Processor { get - { + { foreach (ManagementObject queryObj in processerSearcher.Get()) { var query = queryObj["Name"]; @@ -189,7 +186,7 @@ public static string Processor if (query is not null) return query.ToString().TrimEnd(); } - + return string.Empty; } } diff --git a/HandheldCompanion/Misc/PnPUtil.cs b/HandheldCompanion/Misc/PnPUtil.cs index b45716dc4..214040046 100644 --- a/HandheldCompanion/Misc/PnPUtil.cs +++ b/HandheldCompanion/Misc/PnPUtil.cs @@ -7,7 +7,7 @@ public class PnPUtilResult { public int ExitCode; public string StandardOutput; - + public PnPUtilResult(int exitCode, string output) { ExitCode = exitCode; @@ -27,7 +27,7 @@ public static bool RestartDevice(string InstanceId) var pnpResult = StartPnPUtil($"/restart-device \"{InstanceId}\""); return ValidateChangeDeviceStatusResult(InstanceId, pnpResult); } - public static bool EnableDevice(string InstanceId) + public static bool EnableDevice(string InstanceId) { var pnpResult = StartPnPUtil($"/enable-device \"{InstanceId}\""); return ValidateChangeDeviceStatusResult(InstanceId, pnpResult); diff --git a/HandheldCompanion/Misc/Profile.cs b/HandheldCompanion/Misc/Profile.cs index c30522003..b68008133 100644 --- a/HandheldCompanion/Misc/Profile.cs +++ b/HandheldCompanion/Misc/Profile.cs @@ -92,7 +92,7 @@ public Profile(string path) : this() public Layout Layout { get; set; } = new(); public bool Whitelisted { get; set; } // if true, can see through the HidHide cloak - + public XInputPlusMethod XInputPlus { get; set; } // if true, deploy xinput1_3.dll public float GyrometerMultiplier { get; set; } = 1.0f; // gyroscope multiplicator (remove me) diff --git a/HandheldCompanion/Misc/WinAPI.cs b/HandheldCompanion/Misc/WinAPI.cs index 55a93edc0..b90694d8f 100644 --- a/HandheldCompanion/Misc/WinAPI.cs +++ b/HandheldCompanion/Misc/WinAPI.cs @@ -1,8 +1,6 @@ using System; using System.Runtime.InteropServices; using static PInvoke.Kernel32; -using BOOL = System.Int32; -using DWORD = System.Int32; using HANDLE = System.IntPtr; using LPVOID = System.IntPtr; diff --git a/HandheldCompanion/Platforms/GOGGalaxy.cs b/HandheldCompanion/Platforms/GOGGalaxy.cs index 273ba3d75..ef929dc08 100644 --- a/HandheldCompanion/Platforms/GOGGalaxy.cs +++ b/HandheldCompanion/Platforms/GOGGalaxy.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; -using HandheldCompanion.Platforms; using HandheldCompanion.Utils; namespace HandheldCompanion.Platforms; diff --git a/HandheldCompanion/Platforms/HWiNFO.cs b/HandheldCompanion/Platforms/HWiNFO.cs index 276c2a92a..636db428e 100644 --- a/HandheldCompanion/Platforms/HWiNFO.cs +++ b/HandheldCompanion/Platforms/HWiNFO.cs @@ -269,157 +269,157 @@ public void PopulateSensors() switch (element.tReading) { case SENSOR_READING_TYPE.SENSOR_TYPE_TEMP: - { - switch (element.szLabelOrig) { - case "CPU Package": - case "CPU (Tctl/Tdie)": - MonitoredSensors[SensorElementType.CPUTemperature] = element; - break; - - case "CPU GT Cores (Graphics)": - case "GPU Temperature": - MonitoredSensors[SensorElementType.GPUTemperature] = element; - break; + switch (element.szLabelOrig) + { + case "CPU Package": + case "CPU (Tctl/Tdie)": + MonitoredSensors[SensorElementType.CPUTemperature] = element; + break; + + case "CPU GT Cores (Graphics)": + case "GPU Temperature": + MonitoredSensors[SensorElementType.GPUTemperature] = element; + break; + } } - } break; case SENSOR_READING_TYPE.SENSOR_TYPE_POWER: - { - switch (element.szLabelOrig) { - case "CPU Package Power": - case "CPU PPT": - MonitoredSensors[SensorElementType.CPUPower] = element; - break; - - case "PL1 Power Limit": - // case "PL1 Power Limit (Static)": - case "PL1 Power Limit (Dynamic)": - { - var reading = (int)Math.Ceiling(element.Value); - if (reading != MonitoredSensors[SensorElementType.PL1].Value) - PowerLimitChanged?.Invoke(PowerType.Slow, reading); - - element.Value = reading; - MonitoredSensors[SensorElementType.PL1] = element; - } - break; - case "PL2 Power Limit": - // case "PL2 Power Limit (Static)": - case "PL2 Power Limit (Dynamic)": + switch (element.szLabelOrig) { - var reading = (int)Math.Ceiling(element.Value); - if (reading != MonitoredSensors[SensorElementType.PL2].Value) - PowerLimitChanged?.Invoke(PowerType.Fast, reading); - - element.Value = reading; - MonitoredSensors[SensorElementType.PL2] = element; + case "CPU Package Power": + case "CPU PPT": + MonitoredSensors[SensorElementType.CPUPower] = element; + break; + + case "PL1 Power Limit": + // case "PL1 Power Limit (Static)": + case "PL1 Power Limit (Dynamic)": + { + var reading = (int)Math.Ceiling(element.Value); + if (reading != MonitoredSensors[SensorElementType.PL1].Value) + PowerLimitChanged?.Invoke(PowerType.Slow, reading); + + element.Value = reading; + MonitoredSensors[SensorElementType.PL1] = element; + } + break; + case "PL2 Power Limit": + // case "PL2 Power Limit (Static)": + case "PL2 Power Limit (Dynamic)": + { + var reading = (int)Math.Ceiling(element.Value); + if (reading != MonitoredSensors[SensorElementType.PL2].Value) + PowerLimitChanged?.Invoke(PowerType.Fast, reading); + + element.Value = reading; + MonitoredSensors[SensorElementType.PL2] = element; + } + break; + + case "GPU ASIC Power": + case "GT Cores Power": + case "GPU SoC Power (VDDCR_SOC)": + case "GPU PPT": + MonitoredSensors[SensorElementType.GPUPower] = element; + break; } - break; - - case "GPU ASIC Power": - case "GT Cores Power": - case "GPU SoC Power (VDDCR_SOC)": - case "GPU PPT": - MonitoredSensors[SensorElementType.GPUPower] = element; - break; } - } break; case SENSOR_READING_TYPE.SENSOR_TYPE_USAGE: - { - switch (element.szLabelOrig) { - case "GPU Utilization": - case "GPU D3D Usage": - MonitoredSensors[SensorElementType.GPUUsage] = element; - break; - - case "Total CPU Usage": - MonitoredSensors[SensorElementType.CPUUsage] = element; - break; - - case "CPU PPT SLOW Limit": + switch (element.szLabelOrig) { - var reading = (int)Math.Floor(MonitoredSensors[SensorElementType.CPUPower].Value / - element.Value * 100.0d); - if (reading != MonitoredSensors[SensorElementType.PL1].Value) - PowerLimitChanged?.Invoke(PowerType.Slow, reading); - - element.Value = reading; - MonitoredSensors[SensorElementType.PL1] = element; + case "GPU Utilization": + case "GPU D3D Usage": + MonitoredSensors[SensorElementType.GPUUsage] = element; + break; + + case "Total CPU Usage": + MonitoredSensors[SensorElementType.CPUUsage] = element; + break; + + case "CPU PPT SLOW Limit": + { + var reading = (int)Math.Floor(MonitoredSensors[SensorElementType.CPUPower].Value / + element.Value * 100.0d); + if (reading != MonitoredSensors[SensorElementType.PL1].Value) + PowerLimitChanged?.Invoke(PowerType.Slow, reading); + + element.Value = reading; + MonitoredSensors[SensorElementType.PL1] = element; + } + break; + case "CPU PPT FAST Limit": + { + var reading = (int)Math.Floor(MonitoredSensors[SensorElementType.CPUPower].Value / + element.Value * 100.0d); + if (reading != MonitoredSensors[SensorElementType.PL2].Value) + PowerLimitChanged?.Invoke(PowerType.Fast, reading); + + element.Value = reading; + MonitoredSensors[SensorElementType.PL2] = element; + } + break; } - break; - case "CPU PPT FAST Limit": - { - var reading = (int)Math.Floor(MonitoredSensors[SensorElementType.CPUPower].Value / - element.Value * 100.0d); - if (reading != MonitoredSensors[SensorElementType.PL2].Value) - PowerLimitChanged?.Invoke(PowerType.Fast, reading); - - element.Value = reading; - MonitoredSensors[SensorElementType.PL2] = element; - } - break; } - } break; case SENSOR_READING_TYPE.SENSOR_TYPE_CLOCK: - { - switch (element.szLabelOrig) { - case "GPU Clock": - case "GPU SoC Clock": // keep me ? - { - var reading = element.Value; - if (reading != MonitoredSensors[SensorElementType.GPUFrequency].Value) - GPUFrequencyChanged?.Invoke(reading); - - MonitoredSensors[SensorElementType.GPUFrequency] = element; - } - break; - - case "Core 0 Clock": - case "Core 1 Clock": - case "Core 2 Clock": - case "Core 3 Clock": - case "Core 4 Clock": - case "Core 5 Clock": - case "Core 6 Clock": - case "Core 7 Clock": - case "Core 8 Clock": - case "Core 9 Clock": - case "Core 10 Clock": - case "Core 11 Clock": - case "Core 12 Clock": - case "Core 13 Clock": - case "Core 14 Clock": - case "Core 15 Clock": - case "Core 16 Clock": - case "Core 17 Clock": - case "Core 18 Clock": // improve me (lol) + switch (element.szLabelOrig) { - // we'll keep the highest known frequency right now - if (element.Value > MonitoredSensors[SensorElementType.CPUFrequency].Value) - MonitoredSensors[SensorElementType.CPUFrequency] = element; + case "GPU Clock": + case "GPU SoC Clock": // keep me ? + { + var reading = element.Value; + if (reading != MonitoredSensors[SensorElementType.GPUFrequency].Value) + GPUFrequencyChanged?.Invoke(reading); + + MonitoredSensors[SensorElementType.GPUFrequency] = element; + } + break; + + case "Core 0 Clock": + case "Core 1 Clock": + case "Core 2 Clock": + case "Core 3 Clock": + case "Core 4 Clock": + case "Core 5 Clock": + case "Core 6 Clock": + case "Core 7 Clock": + case "Core 8 Clock": + case "Core 9 Clock": + case "Core 10 Clock": + case "Core 11 Clock": + case "Core 12 Clock": + case "Core 13 Clock": + case "Core 14 Clock": + case "Core 15 Clock": + case "Core 16 Clock": + case "Core 17 Clock": + case "Core 18 Clock": // improve me (lol) + { + // we'll keep the highest known frequency right now + if (element.Value > MonitoredSensors[SensorElementType.CPUFrequency].Value) + MonitoredSensors[SensorElementType.CPUFrequency] = element; + } + break; } - break; } - } break; case SENSOR_READING_TYPE.SENSOR_TYPE_VOLT: - { - } + { + } break; case SENSOR_READING_TYPE.SENSOR_TYPE_OTHER: - { - } + { + } break; } diff --git a/HandheldCompanion/Platforms/RTSS.cs b/HandheldCompanion/Platforms/RTSS.cs index c477e2856..6f073e9fb 100644 --- a/HandheldCompanion/Platforms/RTSS.cs +++ b/HandheldCompanion/Platforms/RTSS.cs @@ -7,12 +7,9 @@ using System.Threading; using System.Threading.Tasks; using System.Timers; -using HandheldCompanion; using HandheldCompanion.Managers; -using HandheldCompanion.Platforms; using HandheldCompanion.Utils; using HandheldCompanion.Controls; -using HandheldCompanion.Managers; using HandheldCompanion.Managers.Desktop; using RTSSSharedMemoryNET; using Timer = System.Timers.Timer; @@ -188,7 +185,7 @@ private async void ProcessManager_ForegroundChanged(ProcessEx processEx, Process { return; } - catch {} + catch { } await Task.Delay(1000); } while (appEntry is null && ProcessManager.HasProcess(ProcessId) && KeepAlive); diff --git a/HandheldCompanion/Platforms/SteamPlatform.cs b/HandheldCompanion/Platforms/SteamPlatform.cs index f4ec42c31..6d445c621 100644 --- a/HandheldCompanion/Platforms/SteamPlatform.cs +++ b/HandheldCompanion/Platforms/SteamPlatform.cs @@ -6,10 +6,8 @@ using System.Text.RegularExpressions; using System.Threading.Tasks; using HandheldCompanion.Managers; -using HandheldCompanion.Platforms; using HandheldCompanion.Utils; using HandheldCompanion.Controls; -using HandheldCompanion.Managers; using HandheldCompanion.Properties; namespace HandheldCompanion.Platforms; @@ -34,7 +32,7 @@ public SteamPlatform() Name = "Steam"; ExecutableName = "steam.exe"; - + // this is for detecting steam start/stop, for some reason steam.exe often doesn't work RunningName = "steamwebhelper.exe"; diff --git a/HandheldCompanion/Platforms/UbisoftConnect.cs b/HandheldCompanion/Platforms/UbisoftConnect.cs index f7aa36140..dbe1cb9d0 100644 --- a/HandheldCompanion/Platforms/UbisoftConnect.cs +++ b/HandheldCompanion/Platforms/UbisoftConnect.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; -using HandheldCompanion.Platforms; using HandheldCompanion.Utils; namespace HandheldCompanion.Platforms; diff --git a/HandheldCompanion/Sensors/IMUAccelerometer.cs b/HandheldCompanion/Sensors/IMUAccelerometer.cs index ef466ec37..e46b551d3 100644 --- a/HandheldCompanion/Sensors/IMUAccelerometer.cs +++ b/HandheldCompanion/Sensors/IMUAccelerometer.cs @@ -1,4 +1,3 @@ -using HandheldCompanion.Devices; using HandheldCompanion.Managers; using HandheldCompanion.Utils; using HandheldCompanion.Views; @@ -108,13 +107,13 @@ private void ReadingChanged(float GyroAccelX, float GyroAccelY, float GyroAccelZ switch (sensorFamily) { case SensorFamily.Controller: - { - reading.X = reading_fixed.X = GyroAccelX; - reading.Y = reading_fixed.Y = GyroAccelY; - reading.Z = reading_fixed.Z = GyroAccelZ; + { + reading.X = reading_fixed.X = GyroAccelX; + reading.Y = reading_fixed.Y = GyroAccelY; + reading.Z = reading_fixed.Z = GyroAccelZ; - base.ReadingChanged(); - } + base.ReadingChanged(); + } break; } } diff --git a/HandheldCompanion/Sensors/IMUGyrometer.cs b/HandheldCompanion/Sensors/IMUGyrometer.cs index 6df8646d2..cee11224c 100644 --- a/HandheldCompanion/Sensors/IMUGyrometer.cs +++ b/HandheldCompanion/Sensors/IMUGyrometer.cs @@ -50,12 +50,12 @@ public void UpdateSensor() switch (sensorFamily) { case SensorFamily.Windows: - { - ((Gyrometer)sensor).ReportInterval = (uint)updateInterval; + { + ((Gyrometer)sensor).ReportInterval = (uint)updateInterval; - LogManager.LogInformation("{0} initialised as a {1}. Report interval set to {2}ms", ToString(), - sensorFamily.ToString(), updateInterval); - } + LogManager.LogInformation("{0} initialised as a {1}. Report interval set to {2}ms", ToString(), + sensorFamily.ToString(), updateInterval); + } break; case SensorFamily.SerialUSBIMU: LogManager.LogInformation("{0} initialised as a {1}. Baud rate set to {2}", ToString(), @@ -107,13 +107,13 @@ private void ReadingChanged(float GyroRoll, float GyroPitch, float GyroYaw) switch (sensorFamily) { case SensorFamily.Controller: - { - reading.X = reading_fixed.X = GyroRoll; - reading.Y = reading_fixed.Y = GyroPitch; - reading.Z = reading_fixed.Z = GyroYaw; + { + reading.X = reading_fixed.X = GyroRoll; + reading.Y = reading_fixed.Y = GyroPitch; + reading.Z = reading_fixed.Z = GyroYaw; - base.ReadingChanged(); - } + base.ReadingChanged(); + } break; } } diff --git a/HandheldCompanion/Sensors/IMUSensor.cs b/HandheldCompanion/Sensors/IMUSensor.cs index 8082e7afa..2cc06fa21 100644 --- a/HandheldCompanion/Sensors/IMUSensor.cs +++ b/HandheldCompanion/Sensors/IMUSensor.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Numerics; using System.Timers; -using static HandheldCompanion.Sensors.SerialUSBIMU; using static HandheldCompanion.Utils.DeviceUtils; namespace HandheldCompanion.Sensors; diff --git a/HandheldCompanion/Sensors/SerialUSBIMU.cs b/HandheldCompanion/Sensors/SerialUSBIMU.cs index cb8b8cb4f..ea48a1998 100644 --- a/HandheldCompanion/Sensors/SerialUSBIMU.cs +++ b/HandheldCompanion/Sensors/SerialUSBIMU.cs @@ -286,71 +286,71 @@ public void PlacementTransformation(SerialPlacement SensorPlacement, bool isUpsi switch (SensorPlacement) { case SerialPlacement.Top: - { - AccelerationG.X = -AccTemp.X; - - if (isUpsideDown) { - AccelerationG.X = AccTemp.X; // Intentionally undo previous - AccelerationG.Y = -AccTemp.Y; + AccelerationG.X = -AccTemp.X; - AngularVelocityDeg.X = -AngVelTemp.X; - AngularVelocityDeg.Y = -AngVelTemp.Y; + if (isUpsideDown) + { + AccelerationG.X = AccTemp.X; // Intentionally undo previous + AccelerationG.Y = -AccTemp.Y; + + AngularVelocityDeg.X = -AngVelTemp.X; + AngularVelocityDeg.Y = -AngVelTemp.Y; + } } - } break; case SerialPlacement.Right: - { - AccelerationG.X = AccTemp.Z; - AccelerationG.Z = AccTemp.X; + { + AccelerationG.X = AccTemp.Z; + AccelerationG.Z = AccTemp.X; - AngularVelocityDeg.X = -AngVelTemp.Z; - AngularVelocityDeg.Z = AngVelTemp.X; + AngularVelocityDeg.X = -AngVelTemp.Z; + AngularVelocityDeg.Z = AngVelTemp.X; - if (isUpsideDown) - { - AccelerationG.Y = -AccTemp.Y; - AccelerationG.Z = -AccTemp.X; + if (isUpsideDown) + { + AccelerationG.Y = -AccTemp.Y; + AccelerationG.Z = -AccTemp.X; - AngularVelocityDeg.Y = -AngVelTemp.Y; - AngularVelocityDeg.Z = -AngVelTemp.X; + AngularVelocityDeg.Y = -AngVelTemp.Y; + AngularVelocityDeg.Z = -AngVelTemp.X; + } } - } break; case SerialPlacement.Bottom: - { - AccelerationG.Z = -AccTemp.Z; + { + AccelerationG.Z = -AccTemp.Z; - AngularVelocityDeg.X = -AngVelTemp.X; - AngularVelocityDeg.Z = -AngVelTemp.Z; + AngularVelocityDeg.X = -AngVelTemp.X; + AngularVelocityDeg.Z = -AngVelTemp.Z; - if (isUpsideDown) - { - AccelerationG.X = -AccTemp.X; - AccelerationG.Y = -AccTemp.Y; + if (isUpsideDown) + { + AccelerationG.X = -AccTemp.X; + AccelerationG.Y = -AccTemp.Y; - AngularVelocityDeg.X = AngVelTemp.X; // Intentionally undo previous - AngularVelocityDeg.Y = -AngVelTemp.Y; + AngularVelocityDeg.X = AngVelTemp.X; // Intentionally undo previous + AngularVelocityDeg.Y = -AngVelTemp.Y; + } } - } break; case SerialPlacement.Left: - { - AccelerationG.X = -AccTemp.Z; - AccelerationG.Z = -AccTemp.X; + { + AccelerationG.X = -AccTemp.Z; + AccelerationG.Z = -AccTemp.X; - AngularVelocityDeg.X = AngVelTemp.Z; - AngularVelocityDeg.Z = -AngVelTemp.X; + AngularVelocityDeg.X = AngVelTemp.Z; + AngularVelocityDeg.Z = -AngVelTemp.X; - if (isUpsideDown) - { - AccelerationG.Y = -AccTemp.Y; - AccelerationG.Z = AccTemp.X; + if (isUpsideDown) + { + AccelerationG.Y = -AccTemp.Y; + AccelerationG.Z = AccTemp.X; - AngularVelocityDeg.Y = -AngVelTemp.Y; - AngularVelocityDeg.Z = AngVelTemp.X; + AngularVelocityDeg.Y = -AngVelTemp.Y; + AngularVelocityDeg.Z = AngVelTemp.X; + } } - } break; } } diff --git a/HandheldCompanion/Simulators/KeyboardSimulator.cs b/HandheldCompanion/Simulators/KeyboardSimulator.cs index d62ebb682..007d21eb0 100644 --- a/HandheldCompanion/Simulators/KeyboardSimulator.cs +++ b/HandheldCompanion/Simulators/KeyboardSimulator.cs @@ -1,6 +1,5 @@ using System; using System.Runtime.InteropServices; -using System.Windows.Forms; using Gma.System.MouseKeyHook; using GregsStack.InputSimulatorStandard; using GregsStack.InputSimulatorStandard.Native; @@ -87,7 +86,7 @@ public static void KeyUp(KeyEventArgsExt e) keybd_event(modifierVk, modifierScan, KEYEVENTF_KEYUP, UIntPtr.Zero); } } - + public static void KeyDown(VirtualKeyCode key) { try diff --git a/HandheldCompanion/Utils/WPFUtils.cs b/HandheldCompanion/Utils/WPFUtils.cs index 62e411068..f016c231d 100644 --- a/HandheldCompanion/Utils/WPFUtils.cs +++ b/HandheldCompanion/Utils/WPFUtils.cs @@ -7,7 +7,6 @@ using System.Windows.Controls; using System.Windows.Interop; using System.Windows.Media; -using Button = System.Windows.Controls.Button; using Control = System.Windows.Controls.Control; namespace HandheldCompanion.Utils; diff --git a/HandheldCompanion/Utils/XInputPlusUtils.cs b/HandheldCompanion/Utils/XInputPlusUtils.cs index 492d66adc..02e2797fb 100644 --- a/HandheldCompanion/Utils/XInputPlusUtils.cs +++ b/HandheldCompanion/Utils/XInputPlusUtils.cs @@ -1,11 +1,4 @@ -using HandheldCompanion.Properties; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace HandheldCompanion.Utils +namespace HandheldCompanion.Utils { public static class XInputPlusUtils { diff --git a/HandheldCompanion/Views/Classes/GamepadWindow.cs b/HandheldCompanion/Views/Classes/GamepadWindow.cs index 42ecb5c3c..9cbd87172 100644 --- a/HandheldCompanion/Views/Classes/GamepadWindow.cs +++ b/HandheldCompanion/Views/Classes/GamepadWindow.cs @@ -44,12 +44,12 @@ protected void InvokeLostGamepadWindowFocus() LostGamepadWindowFocus?.Invoke(); } -#region events + #region events public event GotGamepadWindowFocusEventHandler GotGamepadWindowFocus; public delegate void GotGamepadWindowFocusEventHandler(); public event LostGamepadWindowFocusEventHandler LostGamepadWindowFocus; public delegate void LostGamepadWindowFocusEventHandler(); -#endregion + #endregion } } diff --git a/HandheldCompanion/Views/Classes/OverlayWindow.cs b/HandheldCompanion/Views/Classes/OverlayWindow.cs index 16d0d6711..d7c7e2145 100644 --- a/HandheldCompanion/Views/Classes/OverlayWindow.cs +++ b/HandheldCompanion/Views/Classes/OverlayWindow.cs @@ -1,7 +1,5 @@ using HandheldCompanion.Managers; using System; -using System.Linq; -using System.Linq.Expressions; using System.Runtime.InteropServices; using System.Windows; using System.Windows.Input; @@ -42,7 +40,7 @@ private void OverlayWindow_IsVisibleChanged(object sender, DependencyPropertyCha { if (_hotkeyId == 0) return; - + if (HotkeysManager.Hotkeys.TryGetValue(_hotkeyId, out Hotkey hotkey)) hotkey.SetToggle(this.Visibility == Visibility.Visible ? true : false); } @@ -68,7 +66,7 @@ private void OverlayWindow_IsVisibleChanged(object sender, DependencyPropertyCha UpdatePosition(); } } - + private void OverlayWindow_Loaded(object sender, RoutedEventArgs e) { var source = PresentationSource.FromVisual(this) as HwndSource; @@ -78,7 +76,7 @@ private void OverlayWindow_Loaded(object sender, RoutedEventArgs e) var helper = new WindowInteropHelper(this); SetWindowLong(helper.Handle, GWL_EXSTYLE, GetWindowLong(helper.Handle, GWL_EXSTYLE) | WS_EX_NOACTIVATE); } - + private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { if (msg == WM_MOUSEACTIVATE) diff --git a/HandheldCompanion/Views/Pages/ControllerPage.xaml.cs b/HandheldCompanion/Views/Pages/ControllerPage.xaml.cs index 557835488..6d999e283 100644 --- a/HandheldCompanion/Views/Pages/ControllerPage.xaml.cs +++ b/HandheldCompanion/Views/Pages/ControllerPage.xaml.cs @@ -1,8 +1,5 @@ using System; -using System.Collections.Generic; using System.Linq; -using System.Threading; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Media; @@ -129,7 +126,7 @@ private void ControllerUnplugged(IController Controller) private void ControllerPlugged(IController Controller, bool isHCVirtualController) { // we assume this is HC virtual controller - if(Controller.IsVirtual() && isHCVirtualController) + if (Controller.IsVirtual() && isHCVirtualController) { if (SettingsManager.GetBoolean("VirtualControllerForceOrder")) { diff --git a/HandheldCompanion/Views/Pages/Layout/ILayoutPage.cs b/HandheldCompanion/Views/Pages/Layout/ILayoutPage.cs index fe98a54d2..9572f47a8 100644 --- a/HandheldCompanion/Views/Pages/Layout/ILayoutPage.cs +++ b/HandheldCompanion/Views/Pages/Layout/ILayoutPage.cs @@ -1,13 +1,11 @@ using System.Collections.Generic; using System.Windows; -using HandheldCompanion; using HandheldCompanion.Actions; using HandheldCompanion.Controllers; using HandheldCompanion.Controls; using HandheldCompanion.Inputs; using Inkore.UI.WPF.Modern.Controls; -using Layout = HandheldCompanion.Layout; using Page = System.Windows.Controls.Page; namespace HandheldCompanion.Views.Pages; @@ -73,7 +71,7 @@ public virtual void UpdateController(IController controller) bool isVisible = false; // update mapping visibility - switch(flags) + switch (flags) { default: if (controller.HasSourceAxis(flags)) diff --git a/HandheldCompanion/Views/Pages/LayoutPage.xaml.cs b/HandheldCompanion/Views/Pages/LayoutPage.xaml.cs index 3535ec49b..ae7c3cc46 100644 --- a/HandheldCompanion/Views/Pages/LayoutPage.xaml.cs +++ b/HandheldCompanion/Views/Pages/LayoutPage.xaml.cs @@ -1,21 +1,17 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Threading; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Navigation; using HandheldCompanion.Actions; using HandheldCompanion.Controllers; -using HandheldCompanion.Devices; using HandheldCompanion.Utils; using HandheldCompanion.Controls; using HandheldCompanion.Managers; using HandheldCompanion.Misc; using Inkore.UI.WPF.Modern.Controls; -using Layout = HandheldCompanion.Layout; using Page = System.Windows.Controls.Page; using HandheldCompanion.Inputs; using Nefarius.Utilities.DeviceManagement.PnP; @@ -32,7 +28,7 @@ public partial class LayoutPage : Page // page vars private Dictionary pages; - private readonly ButtonsPage buttonsPage = new(); + private readonly ButtonsPage buttonsPage = new(); private readonly DpadPage dpadPage = new(); private readonly GyroPage gyroPage = new(); private readonly JoysticksPage joysticksPage = new(); @@ -355,22 +351,22 @@ private async void ButtonApplyLayout_Click(object sender, RoutedEventArgs e) switch (result.Result) { case ContentDialogResult.Primary: - { - // do not overwrite currentTemplate and currentTemplate.Layout as a whole - // because they both have important Update notifitications set - var newLayout = layoutTemplate.Layout.Clone() as Layout; - currentTemplate.Layout.AxisLayout = newLayout.AxisLayout; - currentTemplate.Layout.ButtonLayout = newLayout.ButtonLayout; - currentTemplate.Name = layoutTemplate.Name; - currentTemplate.Description = layoutTemplate.Description; - currentTemplate.Guid = layoutTemplate.Guid; // not needed - - UpdatePages(); - - // the whole layout has been updated without notification, trigger one - currentTemplate.Layout.UpdateLayout(); - UpdatePages(); - } + { + // do not overwrite currentTemplate and currentTemplate.Layout as a whole + // because they both have important Update notifitications set + var newLayout = layoutTemplate.Layout.Clone() as Layout; + currentTemplate.Layout.AxisLayout = newLayout.AxisLayout; + currentTemplate.Layout.ButtonLayout = newLayout.ButtonLayout; + currentTemplate.Name = layoutTemplate.Name; + currentTemplate.Description = layoutTemplate.Description; + currentTemplate.Guid = layoutTemplate.Guid; // not needed + + UpdatePages(); + + // the whole layout has been updated without notification, trigger one + currentTemplate.Layout.UpdateLayout(); + UpdatePages(); + } break; } } diff --git a/HandheldCompanion/Views/Pages/OverlayPage.xaml.cs b/HandheldCompanion/Views/Pages/OverlayPage.xaml.cs index 1374706a7..fb694c4ab 100644 --- a/HandheldCompanion/Views/Pages/OverlayPage.xaml.cs +++ b/HandheldCompanion/Views/Pages/OverlayPage.xaml.cs @@ -132,11 +132,11 @@ private void UpdateUI_TrackpadsPosition(int trackpadsAlignment) private void UpdateUI_ControllerPosition(int controllerAlignment) { foreach (SimpleStackPanel panel in OverlayControllerAlignment.Children) - foreach (Button button in panel.Children) - if (int.Parse((string)button.Tag) == controllerAlignment) - button.Style = Application.Current.FindResource("AccentButtonStyle") as Style; - else - button.Style = Application.Current.FindResource("DefaultButtonStyle") as Style; + foreach (Button button in panel.Children) + if (int.Parse((string)button.Tag) == controllerAlignment) + button.Style = Application.Current.FindResource("AccentButtonStyle") as Style; + else + button.Style = Application.Current.FindResource("DefaultButtonStyle") as Style; switch (controllerAlignment) { diff --git a/HandheldCompanion/Views/Pages/Profiles/SettingsMode0.xaml.cs b/HandheldCompanion/Views/Pages/Profiles/SettingsMode0.xaml.cs index 1133acd71..2c3cd98a7 100644 --- a/HandheldCompanion/Views/Pages/Profiles/SettingsMode0.xaml.cs +++ b/HandheldCompanion/Views/Pages/Profiles/SettingsMode0.xaml.cs @@ -274,18 +274,18 @@ private void TriggerCreated(Hotkey hotkey) switch (hotkey.inputsHotkey.Listener) { case "shortcutProfilesSettingsMode0": - { - // pull hotkey - ProfilesPageHotkey = hotkey; + { + // pull hotkey + ProfilesPageHotkey = hotkey; - // add to UI - var hotkeyBorder = ProfilesPageHotkey.GetControl(); - if (hotkeyBorder is null || hotkeyBorder.Parent is not null) - return; + // add to UI + var hotkeyBorder = ProfilesPageHotkey.GetControl(); + if (hotkeyBorder is null || hotkeyBorder.Parent is not null) + return; - if (UMC_Activator.Children.Count == 0) - UMC_Activator.Children.Add(hotkeyBorder); - } + if (UMC_Activator.Children.Count == 0) + UMC_Activator.Children.Add(hotkeyBorder); + } break; } } diff --git a/HandheldCompanion/Views/Pages/Profiles/SettingsMode1.xaml.cs b/HandheldCompanion/Views/Pages/Profiles/SettingsMode1.xaml.cs index 5252fd3cc..307d3bdc0 100644 --- a/HandheldCompanion/Views/Pages/Profiles/SettingsMode1.xaml.cs +++ b/HandheldCompanion/Views/Pages/Profiles/SettingsMode1.xaml.cs @@ -84,7 +84,7 @@ private void SliderSteeringAngle_ValueChanged(object sender, RoutedPropertyChang if (updateLock) return; - + ProfilesPage.currentProfile.SteeringMaxAngle = (float)SliderSteeringAngle.Value; ProfilesPage.RequestUpdate(); } diff --git a/HandheldCompanion/Views/Pages/ProfilesPage.xaml.cs b/HandheldCompanion/Views/Pages/ProfilesPage.xaml.cs index c020bddcf..c4a05f73c 100644 --- a/HandheldCompanion/Views/Pages/ProfilesPage.xaml.cs +++ b/HandheldCompanion/Views/Pages/ProfilesPage.xaml.cs @@ -72,7 +72,7 @@ public ProfilesPage(string Tag) : this() { // create panel var panel = new SimpleStackPanel - { Spacing = 6, Orientation = Orientation.Horizontal, VerticalAlignment = VerticalAlignment.Center }; + { Spacing = 6, Orientation = Orientation.Horizontal, VerticalAlignment = VerticalAlignment.Center }; // create icon var icon = new FontIcon { Glyph = "" }; @@ -110,7 +110,7 @@ public ProfilesPage(string Tag) : this() { // create panel var panel = new SimpleStackPanel - { Spacing = 6, Orientation = Orientation.Horizontal, VerticalAlignment = VerticalAlignment.Center }; + { Spacing = 6, Orientation = Orientation.Horizontal, VerticalAlignment = VerticalAlignment.Center }; // create icon var icon = new FontIcon { Glyph = "" }; @@ -576,7 +576,7 @@ private void cB_Wrapper_SelectionChanged(object sender, RoutedEventArgs e) if (updateLock) return; - currentProfile.XInputPlus = (XInputPlusMethod)cB_Wrapper.SelectedIndex; + currentProfile.XInputPlus = (XInputPlusMethod)cB_Wrapper.SelectedIndex; RequestUpdate(); } @@ -792,16 +792,16 @@ private void TriggerCreated(Hotkey hotkey) switch (hotkey.inputsHotkey.Listener) { case "shortcutProfilesPage@": - { - var hotkeyBorder = hotkey.GetControl(); - if (hotkeyBorder is null || hotkeyBorder.Parent is not null) - return; + { + var hotkeyBorder = hotkey.GetControl(); + if (hotkeyBorder is null || hotkeyBorder.Parent is not null) + return; - // pull hotkey - ProfilesPageHotkey = hotkey; + // pull hotkey + ProfilesPageHotkey = hotkey; - UMC_Activator.Children.Add(hotkeyBorder); - } + UMC_Activator.Children.Add(hotkeyBorder); + } break; } } @@ -1066,7 +1066,7 @@ private void Toggle_ControllerLayout_Toggled(object sender, RoutedEventArgs e) public static void RequestUpdate() { - if(UpdateTimer is not null) + if (UpdateTimer is not null) { UpdateTimer.Stop(); UpdateTimer.Start(); diff --git a/HandheldCompanion/Views/Pages/SettingsPage.xaml.cs b/HandheldCompanion/Views/Pages/SettingsPage.xaml.cs index 84d2f1a2e..cb2b5b268 100644 --- a/HandheldCompanion/Views/Pages/SettingsPage.xaml.cs +++ b/HandheldCompanion/Views/Pages/SettingsPage.xaml.cs @@ -116,39 +116,39 @@ private void SettingsManager_SettingValueChanged(string? name, object value) switch (name) { case "MainWindowTheme": - { - cB_Theme.SelectedIndex = Convert.ToInt32(value); + { + cB_Theme.SelectedIndex = Convert.ToInt32(value); - // bug: SelectionChanged not triggered when control isn't loaded - if (!IsLoaded) - cB_Theme_SelectionChanged(this, null); - } + // bug: SelectionChanged not triggered when control isn't loaded + if (!IsLoaded) + cB_Theme_SelectionChanged(this, null); + } break; case "MainWindowBackdrop": - { - cB_Backdrop.SelectedIndex = Convert.ToInt32(value); + { + cB_Backdrop.SelectedIndex = Convert.ToInt32(value); - // bug: SelectionChanged not triggered when control isn't loaded - if (!IsLoaded) - cB_Backdrop_SelectionChanged(this, null); - } + // bug: SelectionChanged not triggered when control isn't loaded + if (!IsLoaded) + cB_Backdrop_SelectionChanged(this, null); + } break; case "QuicktoolsBackdrop": - { - cB_QuickToolsBackdrop.SelectedIndex = Convert.ToInt32(value); + { + cB_QuickToolsBackdrop.SelectedIndex = Convert.ToInt32(value); - // bug: SelectionChanged not triggered when control isn't loaded - if (!IsLoaded) - cB_QuickToolsBackdrop_SelectionChanged(this, null); - } + // bug: SelectionChanged not triggered when control isn't loaded + if (!IsLoaded) + cB_QuickToolsBackdrop_SelectionChanged(this, null); + } break; case "SensorSelection": - { - var idx = Convert.ToInt32(value); - - // default value - if (idx == -1) { + var idx = Convert.ToInt32(value); + + // default value + if (idx == -1) + { if (MainWindow.CurrentDevice.Capabilities.HasFlag(DeviceCapabilities.InternalSensor)) { SettingsManager.SetProperty(name, cB_SensorSelection.Items.IndexOf(SensorInternal)); @@ -162,15 +162,15 @@ private void SettingsManager_SettingValueChanged(string? name, object value) SettingsManager.SetProperty(name, cB_SensorSelection.Items.IndexOf(SensorNone)); } - return; - } + return; + } - cB_SensorSelection.SelectedIndex = idx; + cB_SensorSelection.SelectedIndex = idx; - // bug: SelectionChanged not triggered when control isn't loaded - if (!IsLoaded) - cB_SensorSelection_SelectionChanged(this, null); - } + // bug: SelectionChanged not triggered when control isn't loaded + if (!IsLoaded) + cB_SensorSelection_SelectionChanged(this, null); + } break; case "RunAtStartup": Toggle_AutoStart.IsOn = Convert.ToBoolean(value); @@ -287,7 +287,7 @@ private async void Toggle_AutoStart_Toggled(object? sender, RoutedEventArgs? e) await result; - switch(result.Result) + switch (result.Result) { case ContentDialogResult.Primary: SettingsManager.SetProperty("VirtualControllerForceOrder", false); @@ -371,7 +371,7 @@ private async void Toggle_ForceVirtualControllerOrder_Toggled(object sender, Rou { SettingsManager.SetProperty("RunAtStartup", true); } - + SettingsManager.SetProperty("VirtualControllerForceOrder", Toggle_ForceVirtualControllerOrder.IsOn); } @@ -396,96 +396,96 @@ private void UpdateManager_Updated(UpdateStatus status, UpdateFile updateFile, o case UpdateStatus.Failed: // lazy ? case UpdateStatus.Updated: case UpdateStatus.Initialized: - { - if (updateFile is not null) { - updateFile.updateDownload.Visibility = Visibility.Visible; - - updateFile.updatePercentage.Visibility = Visibility.Collapsed; - updateFile.updateInstall.Visibility = Visibility.Collapsed; - } - else - { - LabelUpdate.Text = Properties.Resources.SettingsPage_UpToDate; - LabelUpdateDate.Text = Properties.Resources.SettingsPage_LastChecked + - MainWindow.updateManager.GetTime(); + if (updateFile is not null) + { + updateFile.updateDownload.Visibility = Visibility.Visible; - LabelUpdateDate.Visibility = Visibility.Visible; - GridUpdateSymbol.Visibility = Visibility.Visible; - ProgressBarUpdate.Visibility = Visibility.Collapsed; - B_CheckUpdate.IsEnabled = true; + updateFile.updatePercentage.Visibility = Visibility.Collapsed; + updateFile.updateInstall.Visibility = Visibility.Collapsed; + } + else + { + LabelUpdate.Text = Properties.Resources.SettingsPage_UpToDate; + LabelUpdateDate.Text = Properties.Resources.SettingsPage_LastChecked + + MainWindow.updateManager.GetTime(); + + LabelUpdateDate.Visibility = Visibility.Visible; + GridUpdateSymbol.Visibility = Visibility.Visible; + ProgressBarUpdate.Visibility = Visibility.Collapsed; + B_CheckUpdate.IsEnabled = true; + } } - } break; case UpdateStatus.Checking: - { - LabelUpdate.Text = Properties.Resources.SettingsPage_UpdateCheck; + { + LabelUpdate.Text = Properties.Resources.SettingsPage_UpdateCheck; - GridUpdateSymbol.Visibility = Visibility.Collapsed; - LabelUpdateDate.Visibility = Visibility.Collapsed; - ProgressBarUpdate.Visibility = Visibility.Visible; - B_CheckUpdate.IsEnabled = false; - } + GridUpdateSymbol.Visibility = Visibility.Collapsed; + LabelUpdateDate.Visibility = Visibility.Collapsed; + ProgressBarUpdate.Visibility = Visibility.Visible; + B_CheckUpdate.IsEnabled = false; + } break; case UpdateStatus.Ready: - { - ProgressBarUpdate.Visibility = Visibility.Collapsed; - - var updateFiles = (Dictionary)value; - LabelUpdate.Text = Properties.Resources.SettingsPage_UpdateAvailable; - - foreach (var update in updateFiles.Values) { - var border = update.Draw(); + ProgressBarUpdate.Visibility = Visibility.Collapsed; - // Set download button action - update.updateDownload.Click += (sender, e) => - { - MainWindow.updateManager.DownloadUpdateFile(update); - }; + var updateFiles = (Dictionary)value; + LabelUpdate.Text = Properties.Resources.SettingsPage_UpdateAvailable; - // Set button action - update.updateInstall.Click += (sender, e) => + foreach (var update in updateFiles.Values) { - MainWindow.updateManager.InstallUpdate(update); - }; + var border = update.Draw(); + + // Set download button action + update.updateDownload.Click += (sender, e) => + { + MainWindow.updateManager.DownloadUpdateFile(update); + }; - CurrentUpdates.Children.Add(border); + // Set button action + update.updateInstall.Click += (sender, e) => + { + MainWindow.updateManager.InstallUpdate(update); + }; + + CurrentUpdates.Children.Add(border); + } } - } break; case UpdateStatus.Changelog: - { - CurrentChangelog.Visibility = Visibility.Visible; - CurrentChangelog.AppendText((string)value); - } + { + CurrentChangelog.Visibility = Visibility.Visible; + CurrentChangelog.AppendText((string)value); + } break; case UpdateStatus.Download: - { - updateFile.updateDownload.Visibility = Visibility.Collapsed; - updateFile.updatePercentage.Visibility = Visibility.Visible; - } + { + updateFile.updateDownload.Visibility = Visibility.Collapsed; + updateFile.updatePercentage.Visibility = Visibility.Visible; + } break; case UpdateStatus.Downloading: - { - var progress = (int)value; - updateFile.updatePercentage.Text = - Properties.Resources.SettingsPage_DownloadingPercentage + $"{value} %"; - } + { + var progress = (int)value; + updateFile.updatePercentage.Text = + Properties.Resources.SettingsPage_DownloadingPercentage + $"{value} %"; + } break; case UpdateStatus.Downloaded: - { - updateFile.updateInstall.Visibility = Visibility.Visible; + { + updateFile.updateInstall.Visibility = Visibility.Visible; - updateFile.updateDownload.Visibility = Visibility.Collapsed; - updateFile.updatePercentage.Visibility = Visibility.Collapsed; - } + updateFile.updateDownload.Visibility = Visibility.Collapsed; + updateFile.updatePercentage.Visibility = Visibility.Collapsed; + } break; } }); @@ -705,11 +705,11 @@ private void SensorPlacement_Click(object sender, RoutedEventArgs? e) private void UpdateUI_SensorPlacement(int? SensorPlacement) { foreach (SimpleStackPanel panel in Grid_SensorPlacementVisualisation.Children) - foreach (Button button in panel.Children) - if (int.Parse((string)button.Tag) == SensorPlacement) - button.Background = (Brush)Application.Current.Resources["SystemControlForegroundAccentBrush"]; - else - button.Background = (Brush)Application.Current.Resources["SystemControlHighlightAltBaseLowBrush"]; + foreach (Button button in panel.Children) + if (int.Parse((string)button.Tag) == SensorPlacement) + button.Background = (Brush)Application.Current.Resources["SystemControlForegroundAccentBrush"]; + else + button.Background = (Brush)Application.Current.Resources["SystemControlHighlightAltBaseLowBrush"]; } private void Toggle_SensorPlacementUpsideDown_Toggled(object? sender, RoutedEventArgs? e) diff --git a/HandheldCompanion/Views/QuickPages/QuickProfilesPage.xaml.cs b/HandheldCompanion/Views/QuickPages/QuickProfilesPage.xaml.cs index 7a4553acb..e1dc65fad 100644 --- a/HandheldCompanion/Views/QuickPages/QuickProfilesPage.xaml.cs +++ b/HandheldCompanion/Views/QuickPages/QuickProfilesPage.xaml.cs @@ -59,7 +59,7 @@ public QuickProfilesPage() { // create panel var panel = new SimpleStackPanel - { Spacing = 6, Orientation = Orientation.Horizontal, VerticalAlignment = VerticalAlignment.Center }; + { Spacing = 6, Orientation = Orientation.Horizontal, VerticalAlignment = VerticalAlignment.Center }; // create icon var icon = new FontIcon { Glyph = "" }; @@ -96,7 +96,7 @@ public QuickProfilesPage() { // create panel var panel = new SimpleStackPanel - { Spacing = 6, Orientation = Orientation.Horizontal, VerticalAlignment = VerticalAlignment.Center }; + { Spacing = 6, Orientation = Orientation.Horizontal, VerticalAlignment = VerticalAlignment.Center }; // create icon var icon = new FontIcon { Glyph = "" }; @@ -232,20 +232,20 @@ private void HotkeysManager_CommandExecuted(string listener) switch (listener) { case "increaseTDP": - { - if (currentProfile is null || !currentProfile.TDPOverrideEnabled) - return; + { + if (currentProfile is null || !currentProfile.TDPOverrideEnabled) + return; - TDPSlider.Value++; - } + TDPSlider.Value++; + } break; case "decreaseTDP": - { - if (currentProfile is null || !currentProfile.TDPOverrideEnabled) - return; + { + if (currentProfile is null || !currentProfile.TDPOverrideEnabled) + return; - TDPSlider.Value--; - } + TDPSlider.Value--; + } break; } }); @@ -602,16 +602,16 @@ private void TriggerCreated(Hotkey hotkey) switch (hotkey.inputsHotkey.Listener) { case "shortcutProfilesPage@@": - { - var hotkeyBorder = hotkey.GetControl(); - if (hotkeyBorder is null || hotkeyBorder.Parent is not null) - return; + { + var hotkeyBorder = hotkey.GetControl(); + if (hotkeyBorder is null || hotkeyBorder.Parent is not null) + return; - // pull hotkey - ProfilesPageHotkey = hotkey; + // pull hotkey + ProfilesPageHotkey = hotkey; - UMC_Activator.Children.Add(hotkeyBorder); - } + UMC_Activator.Children.Add(hotkeyBorder); + } break; } } diff --git a/HandheldCompanion/Views/SplashScreen.xaml.cs b/HandheldCompanion/Views/SplashScreen.xaml.cs index a2116b3a0..e73a29053 100644 --- a/HandheldCompanion/Views/SplashScreen.xaml.cs +++ b/HandheldCompanion/Views/SplashScreen.xaml.cs @@ -1,17 +1,5 @@ using HandheldCompanion.Views.Classes; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; namespace HandheldCompanion.Views { diff --git a/HandheldCompanion/Views/Windows/MainWindow.xaml.cs b/HandheldCompanion/Views/Windows/MainWindow.xaml.cs index 119328708..0dca402bd 100644 --- a/HandheldCompanion/Views/Windows/MainWindow.xaml.cs +++ b/HandheldCompanion/Views/Windows/MainWindow.xaml.cs @@ -687,7 +687,7 @@ private async void Window_Closing(object sender, CancelEventArgs e) return; } - if(SettingsManager.GetBoolean("VirtualControllerForceOrder") && !CloseOverride) + if (SettingsManager.GetBoolean("VirtualControllerForceOrder") && !CloseOverride) { // we have to cancel closing the window to be able to prompt the user e.Cancel = true; diff --git a/HandheldCompanion/Views/Windows/OverlayModel.xaml.cs b/HandheldCompanion/Views/Windows/OverlayModel.xaml.cs index 5934f0f73..8ecaede7c 100644 --- a/HandheldCompanion/Views/Windows/OverlayModel.xaml.cs +++ b/HandheldCompanion/Views/Windows/OverlayModel.xaml.cs @@ -35,7 +35,7 @@ public partial class OverlayModel : OverlayWindow private HIDmode HIDmode; private ControllerState Inputs = new(); - + private OverlayModelMode Modelmode; public bool MotionActivated = true; diff --git a/HandheldCompanion/Views/Windows/OverlayQuickTools.xaml.cs b/HandheldCompanion/Views/Windows/OverlayQuickTools.xaml.cs index 583b21916..7c39eb924 100644 --- a/HandheldCompanion/Views/Windows/OverlayQuickTools.xaml.cs +++ b/HandheldCompanion/Views/Windows/OverlayQuickTools.xaml.cs @@ -2,12 +2,10 @@ using System.Collections.Generic; using System.ComponentModel; using System.Linq; -using System.Threading.Tasks; using System.Windows; using System.Windows.Forms; using System.Windows.Input; using System.Windows.Interop; -using System.Windows.Media; using System.Windows.Navigation; using Windows.System.Power; using HandheldCompanion.Utils; @@ -25,10 +23,7 @@ using Screen = WpfScreenHelper.Screen; using SystemInformation = System.Windows.Forms.SystemInformation; using SystemPowerManager = Windows.System.Power.PowerManager; -using Control = System.Windows.Controls.Control; using HandheldCompanion.Views.Classes; -using HandheldCompanion; -using System.Diagnostics; namespace HandheldCompanion.Views.Windows; @@ -118,15 +113,15 @@ private void SettingsManager_SettingValueChanged(string name, object value) switch (name) { case "QuickToolsLocation": - { - var QuickToolsLocation = Convert.ToInt32(value); - UpdateLocation(QuickToolsLocation); - } + { + var QuickToolsLocation = Convert.ToInt32(value); + UpdateLocation(QuickToolsLocation); + } break; case "QuickToolsAutoHide": - { - AutoHide = Convert.ToBoolean(value); - } + { + AutoHide = Convert.ToBoolean(value); + } break; } }); @@ -144,39 +139,39 @@ private void UpdateLocation(int QuickToolsLocation) { // top, left case 0: - { - this.SetWindowPosition(WindowPositions.TopLeft, Screen.PrimaryScreen); - Top += Margin.Top; - Left += Margin.Left; - } + { + this.SetWindowPosition(WindowPositions.TopLeft, Screen.PrimaryScreen); + Top += Margin.Top; + Left += Margin.Left; + } break; // top, right case 1: - { - this.SetWindowPosition(WindowPositions.TopRight, Screen.PrimaryScreen); - Top += Margin.Top; - Left -= Margin.Left; - } + { + this.SetWindowPosition(WindowPositions.TopRight, Screen.PrimaryScreen); + Top += Margin.Top; + Left -= Margin.Left; + } break; // bottom, left case 2: - { - this.SetWindowPosition(WindowPositions.BottomLeft, Screen.PrimaryScreen); - Top -= Margin.Top; - Left += Margin.Left; - } + { + this.SetWindowPosition(WindowPositions.BottomLeft, Screen.PrimaryScreen); + Top -= Margin.Top; + Left += Margin.Left; + } break; // bottom, right default: case 3: - { - this.SetWindowPosition(WindowPositions.BottomRight, Screen.PrimaryScreen); - Top -= Margin.Top; - Left -= Margin.Left; - } + { + this.SetWindowPosition(WindowPositions.BottomRight, Screen.PrimaryScreen); + Top -= Margin.Top; + Left -= Margin.Left; + } break; } @@ -202,15 +197,15 @@ private void PowerManager_PowerStatusChanged(PowerStatus status) KeyStatus = "Charging"; break; default: - { - var energy = SystemPowerManager.EnergySaverStatus; - switch (energy) { - case EnergySaverStatus.On: - KeyStatus = "Saver"; - break; + var energy = SystemPowerManager.EnergySaverStatus; + switch (energy) + { + case EnergySaverStatus.On: + KeyStatus = "Saver"; + break; + } } - } break; } diff --git a/HandheldCompanion/Views/Windows/OverlayTrackpad.xaml.cs b/HandheldCompanion/Views/Windows/OverlayTrackpad.xaml.cs index 8cae94dc5..f19552a1e 100644 --- a/HandheldCompanion/Views/Windows/OverlayTrackpad.xaml.cs +++ b/HandheldCompanion/Views/Windows/OverlayTrackpad.xaml.cs @@ -45,37 +45,37 @@ private void SettingsManager_SettingValueChanged(string name, object value) switch (name) { case "OverlayTrackpadsSize": - { - var size = Convert.ToInt32(value); - LeftTrackpad.Width = size; - RightTrackpad.Width = size; - Height = size; - HorizontalAlignment = HorizontalAlignment.Stretch; - } + { + var size = Convert.ToInt32(value); + LeftTrackpad.Width = size; + RightTrackpad.Width = size; + Height = size; + HorizontalAlignment = HorizontalAlignment.Stretch; + } break; case "OverlayTrackpadsAlignment": - { - var trackpadsAlignment = Convert.ToInt32(value); - switch (trackpadsAlignment) { - case 0: - VerticalAlignment = VerticalAlignment.Top; - break; - case 1: - VerticalAlignment = VerticalAlignment.Center; - break; - case 2: - VerticalAlignment = VerticalAlignment.Bottom; - break; + var trackpadsAlignment = Convert.ToInt32(value); + switch (trackpadsAlignment) + { + case 0: + VerticalAlignment = VerticalAlignment.Top; + break; + case 1: + VerticalAlignment = VerticalAlignment.Center; + break; + case 2: + VerticalAlignment = VerticalAlignment.Bottom; + break; + } } - } break; case "OverlayTrackpadsOpacity": - { - TrackpadOpacity = Convert.ToDouble(value); - LeftTrackpad.Opacity = TrackpadOpacity; - RightTrackpad.Opacity = TrackpadOpacity; - } + { + TrackpadOpacity = Convert.ToDouble(value); + LeftTrackpad.Opacity = TrackpadOpacity; + RightTrackpad.Opacity = TrackpadOpacity; + } break; } }); @@ -101,20 +101,20 @@ private void Trackpad_TouchInput(TouchEventArgs e, CursorAction action, CursorBu { default: case CursorButton.TouchLeft: - { - point = args.GetTouchPoint(LeftTrackpad); - flags = leftInput.Flags; + { + point = args.GetTouchPoint(LeftTrackpad); + flags = leftInput.Flags; - leftInput.Timestamp = e.Timestamp; - } + leftInput.Timestamp = e.Timestamp; + } break; case CursorButton.TouchRight: - { - point = args.GetTouchPoint(RightTrackpad); - flags = rightInput.Flags; + { + point = args.GetTouchPoint(RightTrackpad); + flags = rightInput.Flags; - rightInput.Timestamp = e.Timestamp; - } + rightInput.Timestamp = e.Timestamp; + } break; } @@ -141,14 +141,14 @@ private void Trackpad_PreviewTouchMove(object sender, TouchEventArgs e) switch (name) { case "LeftTrackpad": - { - Trackpad_TouchInput(e, CursorAction.CursorMove, CursorButton.TouchLeft); - } + { + Trackpad_TouchInput(e, CursorAction.CursorMove, CursorButton.TouchLeft); + } break; case "RightTrackpad": - { - Trackpad_TouchInput(e, CursorAction.CursorMove, CursorButton.TouchRight); - } + { + Trackpad_TouchInput(e, CursorAction.CursorMove, CursorButton.TouchRight); + } break; } @@ -162,32 +162,32 @@ private void Trackpad_PreviewTouchDown(object sender, TouchEventArgs e) switch (name) { case "LeftTrackpad": - { - var elapsed = e.Timestamp - leftInput.Timestamp; - if (elapsed < 200) - leftInput.Flags = 30; + { + var elapsed = e.Timestamp - leftInput.Timestamp; + if (elapsed < 200) + leftInput.Flags = 30; - Trackpad_TouchInput(e, CursorAction.CursorDown, CursorButton.TouchLeft); + Trackpad_TouchInput(e, CursorAction.CursorDown, CursorButton.TouchLeft); - LeftTrackpad.Opacity = TrackpadOpacity + TrackpadOpacityTouched; + LeftTrackpad.Opacity = TrackpadOpacity + TrackpadOpacityTouched; - // send vibration (todo: make it a setting) - ControllerManager.GetTargetController()?.Rumble(); // (1, 25, 0, 60); - } + // send vibration (todo: make it a setting) + ControllerManager.GetTargetController()?.Rumble(); // (1, 25, 0, 60); + } break; case "RightTrackpad": - { - var elapsed = e.Timestamp - rightInput.Timestamp; - if (elapsed < 200) - rightInput.Flags = 30; + { + var elapsed = e.Timestamp - rightInput.Timestamp; + if (elapsed < 200) + rightInput.Flags = 30; - Trackpad_TouchInput(e, CursorAction.CursorDown, CursorButton.TouchRight); + Trackpad_TouchInput(e, CursorAction.CursorDown, CursorButton.TouchRight); - RightTrackpad.Opacity = TrackpadOpacity + TrackpadOpacityTouched; + RightTrackpad.Opacity = TrackpadOpacity + TrackpadOpacityTouched; - // send vibration (todo: make it a setting) - ControllerManager.GetTargetController()?.Rumble(); // (1, 25, 0, 60); - } + // send vibration (todo: make it a setting) + ControllerManager.GetTargetController()?.Rumble(); // (1, 25, 0, 60); + } break; } @@ -201,18 +201,18 @@ private void Trackpad_PreviewTouchUp(object sender, TouchEventArgs e) switch (name) { case "LeftTrackpad": - { - leftInput.Flags = 0; - Trackpad_TouchInput(e, CursorAction.CursorUp, CursorButton.TouchLeft); - LeftTrackpad.Opacity = TrackpadOpacity - TrackpadOpacityTouched; - } + { + leftInput.Flags = 0; + Trackpad_TouchInput(e, CursorAction.CursorUp, CursorButton.TouchLeft); + LeftTrackpad.Opacity = TrackpadOpacity - TrackpadOpacityTouched; + } break; case "RightTrackpad": - { - rightInput.Flags = 0; - Trackpad_TouchInput(e, CursorAction.CursorUp, CursorButton.TouchRight); - RightTrackpad.Opacity = TrackpadOpacity - TrackpadOpacityTouched; - } + { + rightInput.Flags = 0; + Trackpad_TouchInput(e, CursorAction.CursorUp, CursorButton.TouchRight); + RightTrackpad.Opacity = TrackpadOpacity - TrackpadOpacityTouched; + } break; } diff --git a/HandheldCompanion/XInputPlus/XInputPlus.cs b/HandheldCompanion/XInputPlus/XInputPlus.cs index c52c2553b..a731a59e8 100644 --- a/HandheldCompanion/XInputPlus/XInputPlus.cs +++ b/HandheldCompanion/XInputPlus/XInputPlus.cs @@ -3,12 +3,10 @@ using System.Diagnostics; using System.IO; using System.Linq; -using HandheldCompanion; using HandheldCompanion.Managers; using HandheldCompanion.Utils; using Force.Crc32; using HandheldCompanion.Controllers; -using HandheldCompanion.Managers; using HandheldCompanion.Properties; using static HandheldCompanion.Utils.ProcessUtils; using System.IO.MemoryMappedFiles; @@ -18,7 +16,6 @@ using System.ComponentModel; using System.Threading; using HandheldCompanion.Controls; -using System.Threading.Tasks; namespace HandheldCompanion; @@ -103,19 +100,19 @@ static XInputPlus() // this should be handled by the installer at some point. public static void ExtractXInputPlusLibraries() { - if(!Directory.Exists(XInputPlusDir)) + if (!Directory.Exists(XInputPlusDir)) Directory.CreateDirectory(XInputPlusDir); if (!Directory.Exists(XInputPlus_InjectorDir)) Directory.CreateDirectory(XInputPlus_InjectorDir); - if(!Directory.Exists(XInputPlus_x86Dir)) - Directory.CreateDirectory (XInputPlus_x86Dir); + if (!Directory.Exists(XInputPlus_x86Dir)) + Directory.CreateDirectory(XInputPlus_x86Dir); if (!Directory.Exists(XInputPlus_x64Dir)) Directory.CreateDirectory(XInputPlus_x64Dir); - if(!File.Exists(XInputPlus_Injectorx86)) + if (!File.Exists(XInputPlus_Injectorx86)) File.WriteAllBytes(XInputPlus_Injectorx86, Resources.XInputPlusInjector); if (!File.Exists(XInputPlus_Injectorx64)) @@ -146,7 +143,7 @@ private static void ProcessManager_ProcessStarted(ProcessEx processEx, bool OnSt WriteXInputPlusINI(XInputPlus_InjectorDir); InjectXInputPlus(processEx.Process); } - catch(Exception ex) + catch (Exception ex) { LogManager.LogError("Error when injecting XInputPlus to {0}: {1}", processEx.Name, ex.Message); } @@ -301,13 +298,13 @@ public static void UnregisterApplication(Profile profile) else { // clean up XInputPlus files - if(dllexist) + if (dllexist) File.Delete(XInputPlusDLLTargetPath); } } // remove XInputPlus INI file - if(File.Exists(IniPath)) + if (File.Exists(IniPath)) File.Delete(IniPath); } diff --git a/HandheldCompanion/models/ModelToyController.cs b/HandheldCompanion/models/ModelToyController.cs index 0e02cf0b4..7589f5021 100644 --- a/HandheldCompanion/models/ModelToyController.cs +++ b/HandheldCompanion/models/ModelToyController.cs @@ -18,7 +18,7 @@ internal class ModelToyController : IModel private readonly Model3DGroup B4Letter; private readonly Model3DGroup B4LetterInside1; private readonly Model3DGroup B4LetterInside2; - + private readonly Model3DGroup DPadDown4; private readonly Model3DGroup DPadLeft1; private readonly Model3DGroup DPadRight3; diff --git a/hidapi.net/HidDevice.cs b/hidapi.net/HidDevice.cs index 397bb7a0f..474608e10 100644 --- a/hidapi.net/HidDevice.cs +++ b/hidapi.net/HidDevice.cs @@ -64,7 +64,7 @@ public bool OpenDevice() if (_deviceHandle != IntPtr.Zero) break; - next: + next: deviceInfo = hidDeviceInfo.NextDevicePtr; } diff --git a/steam-hidapi.net/Hid/HidEnums.cs b/steam-hidapi.net/Hid/HidEnums.cs index 1eeff19aa..72119a1bc 100644 --- a/steam-hidapi.net/Hid/HidEnums.cs +++ b/steam-hidapi.net/Hid/HidEnums.cs @@ -5,61 +5,61 @@ namespace steam_hidapi.net.Hid { internal enum SCPid : ushort { - WIRED = 0x1102, - WIRELESS = 0x1142, + WIRED = 0x1102, + WIRELESS = 0x1142, STEAMDECK = 0x1205, } internal enum SCEventType : byte { - INPUT_DATA = 0x01, - CONNECT = 0x03, - BATTERY = 0x04, + INPUT_DATA = 0x01, + CONNECT = 0x03, + BATTERY = 0x04, DECK_INPUT_DATA = 0x09, } internal enum SCPacketType : byte { // linux kernel - CLEAR_MAPPINGS = 0x81, - GET_MAPPINGS = 0x82, - GET_ATTRIB = 0x83, - GET_ATTRIB_LABEL = 0x84, - DEFAULT_MAPPINGS = 0x85, - FACTORY_RESET = 0x86, - WRITE_REGISTER = 0x87, - CLEAR_REGISTER = 0x88, - READ_REGISTER = 0x89, - GET_REGISTER_LABEL = 0x8a, - GET_REGISTER_MAX = 0x8b, + CLEAR_MAPPINGS = 0x81, + GET_MAPPINGS = 0x82, + GET_ATTRIB = 0x83, + GET_ATTRIB_LABEL = 0x84, + DEFAULT_MAPPINGS = 0x85, + FACTORY_RESET = 0x86, + WRITE_REGISTER = 0x87, + CLEAR_REGISTER = 0x88, + READ_REGISTER = 0x89, + GET_REGISTER_LABEL = 0x8a, + GET_REGISTER_MAX = 0x8b, GET_REGISTER_DEFAULT = 0x8c, - SET_MODE = 0x8d, - DEFAULT_MOUSE = 0x8e, - SET_HAPTIC = 0x8f, - GET_SERIAL = 0xae, - REQUEST_COMM_STATUS = 0xb4, - HAPTIC_RUMBLE = 0xeb, + SET_MODE = 0x8d, + DEFAULT_MOUSE = 0x8e, + SET_HAPTIC = 0x8f, + GET_SERIAL = 0xae, + REQUEST_COMM_STATUS = 0xb4, + HAPTIC_RUMBLE = 0xeb, // other sources - RESET = 0x95, - OFF = 0x9f, - CALIBRATE_TRACKPAD = 0xa7, - AUDIO = 0xb6, - CALIBRATE_JOYSTICK = 0xbf, - SET_AUDIO_INDICES = 0xc1, - SET_HAPTIC2 = 0xea, + RESET = 0x95, + OFF = 0x9f, + CALIBRATE_TRACKPAD = 0xa7, + AUDIO = 0xb6, + CALIBRATE_JOYSTICK = 0xbf, + SET_AUDIO_INDICES = 0xc1, + SET_HAPTIC2 = 0xea, } internal enum SCRegister : byte { - LPAD_MODE = 0x07, // cursor keys, haptic on SD - RPAD_MODE = 0x08, // mouse - RPAD_MARGIN = 0x18, // dead margin, eliminating small movements, noise, on by default - LED_INTENSITY = 0x2d, // 0 - 100 - UNKNOWN1 = 0x2e, // seen in scc config packet, set to 0x00 - GYRO_MODE = 0x30, // Gordon - UNKNOWN2 = 0x31, // seen in scc config packet, set to 0x02 - IDLE_TIMEOUT = 0x32, // in seconds + LPAD_MODE = 0x07, // cursor keys, haptic on SD + RPAD_MODE = 0x08, // mouse + RPAD_MARGIN = 0x18, // dead margin, eliminating small movements, noise, on by default + LED_INTENSITY = 0x2d, // 0 - 100 + UNKNOWN1 = 0x2e, // seen in scc config packet, set to 0x00 + GYRO_MODE = 0x30, // Gordon + UNKNOWN2 = 0x31, // seen in scc config packet, set to 0x02 + IDLE_TIMEOUT = 0x32, // in seconds LPAD_CLICK_PRESSURE = 0x34, // Neptune RPAD_CLICK_PRESSURE = 0x35, // Neptune } @@ -72,7 +72,7 @@ internal enum SCRegisterValue : byte internal enum SCLizardMode : byte { - ON = 0x00, + ON = 0x00, OFF = 0x07, } @@ -97,47 +97,47 @@ internal struct SCHapticPacket internal enum GCGyroMode : byte { - NONE = 0x00, - TILT_X = 0x01, - TILT_Y = 0x02, - Q = 0x04, - ACCEL = 0x08, - GYRO = 0x10, + NONE = 0x00, + TILT_X = 0x01, + TILT_Y = 0x02, + Q = 0x04, + ACCEL = 0x08, + GYRO = 0x10, } internal enum GCButton0 { - BTN_R2 = 0b00000001, - BTN_L2 = 0b00000010, - BTN_R1 = 0b00000100, - BTN_L1 = 0b00001000, - BTN_Y = 0b00010000, - BTN_B = 0b00100000, - BTN_X = 0b01000000, - BTN_A = 0b10000000, + BTN_R2 = 0b00000001, + BTN_L2 = 0b00000010, + BTN_R1 = 0b00000100, + BTN_L1 = 0b00001000, + BTN_Y = 0b00010000, + BTN_B = 0b00100000, + BTN_X = 0b01000000, + BTN_A = 0b10000000, } internal enum GCButton1 { - BTN_DPAD_UP = 0b00000001, - BTN_DPAD_RIGHT = 0b00000010, - BTN_DPAD_LEFT = 0b00000100, - BTN_DPAD_DOWN = 0b00001000, - BTN_MENU = 0b00010000, - BTN_STEAM = 0b00100000, - BTN_OPTIONS = 0b01000000, - BTN_L4 = 0b10000000, + BTN_DPAD_UP = 0b00000001, + BTN_DPAD_RIGHT = 0b00000010, + BTN_DPAD_LEFT = 0b00000100, + BTN_DPAD_DOWN = 0b00001000, + BTN_MENU = 0b00010000, + BTN_STEAM = 0b00100000, + BTN_OPTIONS = 0b01000000, + BTN_L4 = 0b10000000, } internal enum GCButton2 { - BTN_R4 = 0b00000001, - BTN_LPAD_PRESS = 0b00000010, - BTN_RPAD_PRESS = 0b00000100, - BTN_LPAD_TOUCH = 0b00001000, - BTN_RPAD_TOUCH = 0b00010000, - BTN_LSTICK_PRESS = 0b01000000, - BTN_LPAD_AND_JOY = 0b10000000, + BTN_R4 = 0b00000001, + BTN_LPAD_PRESS = 0b00000010, + BTN_RPAD_PRESS = 0b00000100, + BTN_LPAD_TOUCH = 0b00001000, + BTN_RPAD_TOUCH = 0b00010000, + BTN_LSTICK_PRESS = 0b01000000, + BTN_LPAD_AND_JOY = 0b10000000, } [StructLayout(LayoutKind.Sequential, Pack = 1)] @@ -186,54 +186,54 @@ internal struct GCInput internal enum NCButton0 { - BTN_R2 = 0b00000001, - BTN_L2 = 0b00000010, - BTN_R1 = 0b00000100, - BTN_L1 = 0b00001000, - BTN_Y = 0b00010000, - BTN_B = 0b00100000, - BTN_X = 0b01000000, - BTN_A = 0b10000000, + BTN_R2 = 0b00000001, + BTN_L2 = 0b00000010, + BTN_R1 = 0b00000100, + BTN_L1 = 0b00001000, + BTN_Y = 0b00010000, + BTN_B = 0b00100000, + BTN_X = 0b01000000, + BTN_A = 0b10000000, } internal enum NCButton1 { - BTN_DPAD_UP = 0b00000001, - BTN_DPAD_RIGHT = 0b00000010, - BTN_DPAD_LEFT = 0b00000100, - BTN_DPAD_DOWN = 0b00001000, - BTN_MENU = 0b00010000, - BTN_STEAM = 0b00100000, - BTN_OPTIONS = 0b01000000, - BTN_L5 = 0b10000000, + BTN_DPAD_UP = 0b00000001, + BTN_DPAD_RIGHT = 0b00000010, + BTN_DPAD_LEFT = 0b00000100, + BTN_DPAD_DOWN = 0b00001000, + BTN_MENU = 0b00010000, + BTN_STEAM = 0b00100000, + BTN_OPTIONS = 0b01000000, + BTN_L5 = 0b10000000, } internal enum NCButton2 { - BTN_R5 = 0b00000001, - BTN_LPAD_PRESS = 0b00000010, - BTN_RPAD_PRESS = 0b00000100, - BTN_LPAD_TOUCH = 0b00001000, - BTN_RPAD_TOUCH = 0b00010000, - BTN_LSTICK_PRESS = 0b01000000, + BTN_R5 = 0b00000001, + BTN_LPAD_PRESS = 0b00000010, + BTN_RPAD_PRESS = 0b00000100, + BTN_LPAD_TOUCH = 0b00001000, + BTN_RPAD_TOUCH = 0b00010000, + BTN_LSTICK_PRESS = 0b01000000, } internal enum NCButton3 { - BTN_RSTICK_PRESS = 0b00000100, + BTN_RSTICK_PRESS = 0b00000100, } internal enum NCButton5 { - BTN_L4 = 0b00000010, - BTN_R4 = 0b00000100, - BTN_LSTICK_TOUCH = 0b01000000, - BTN_RSTICK_TOUCH = 0b10000000, + BTN_L4 = 0b00000010, + BTN_R4 = 0b00000100, + BTN_LSTICK_TOUCH = 0b01000000, + BTN_RSTICK_TOUCH = 0b10000000, } internal enum NCButton6 { - BTN_QUICK_ACCESS = 0b00000100, + BTN_QUICK_ACCESS = 0b00000100, } [StructLayout(LayoutKind.Sequential, Pack = 1)]