Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Valkirie authored and CasperH2O committed Apr 8, 2024
1 parent 2aeca9c commit 2e4a8d1
Show file tree
Hide file tree
Showing 74 changed files with 171 additions and 238 deletions.
2 changes: 1 addition & 1 deletion HandheldCompanion/ADLX/ADLXBackend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public enum ADLX_RESULT
[DllImport(ADLX_Wrapper, CallingConvention = CallingConvention.Cdecl)] public static extern bool CloseAdlx();

[DllImport(ADLX_Wrapper, CallingConvention = CallingConvention.Cdecl)] public static extern ADLX_RESULT GetNumberOfDisplays(ref int displayNum);

[DllImport(ADLX_Wrapper, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
public static extern ADLX_RESULT GetDisplayName(int idx, StringBuilder dispName, int nameLength);

Expand Down
2 changes: 1 addition & 1 deletion HandheldCompanion/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private void Application_ThreadException(object sender, ThreadExceptionEventArgs
{
var ex = default(Exception);
ex = (Exception)e.Exception;
if(ex.InnerException != null)
if (ex.InnerException != null)
{
LogManager.LogCritical(ex.InnerException.Message + "\t" + ex.InnerException.StackTrace);
}
Expand Down
1 change: 0 additions & 1 deletion HandheldCompanion/Controllers/DS4Controller.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using HandheldCompanion.Inputs;
using HandheldCompanion.Managers;
using HandheldCompanion.Utils;
using System.Windows;
using System.Windows.Media;
using static JSL;

Expand Down
1 change: 0 additions & 1 deletion HandheldCompanion/Controllers/DualSenseController.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using HandheldCompanion.Inputs;
using HandheldCompanion.Managers;
using HandheldCompanion.Utils;
using System.Windows;
using System.Windows.Media;
using static JSL;

Expand Down
1 change: 0 additions & 1 deletion HandheldCompanion/Controllers/GordonController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Windows.Media;
using static JSL;

namespace HandheldCompanion.Controllers
{
Expand Down
1 change: 0 additions & 1 deletion HandheldCompanion/Controllers/IController.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using HandheldCompanion.Inputs;
using HandheldCompanion.Managers;
using HandheldCompanion.Misc;
using HandheldCompanion.Sensors;
using HandheldCompanion.Utils;
using iNKORE.UI.WPF.Modern.Controls;
using System;
Expand Down
7 changes: 2 additions & 5 deletions HandheldCompanion/Controllers/JSController.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using HandheldCompanion.Helpers;
using HandheldCompanion.Inputs;
using HandheldCompanion.Inputs;
using HandheldCompanion.Utils;
using Nefarius.Utilities.DeviceManagement.PnP;
using System;
using System.Threading.Tasks;
using System.Windows;
using static JSL;
using Timer = System.Timers.Timer;

namespace HandheldCompanion.Controllers;

Expand Down Expand Up @@ -121,7 +118,7 @@ public virtual void UpdateState(float delta)
// store motion
Inputs.GyroState.SetGyroscope(iMU_STATE.gyroX, iMU_STATE.gyroY, iMU_STATE.gyroZ);
Inputs.GyroState.SetAccelerometer(iMU_STATE.accelX, iMU_STATE.accelY, iMU_STATE.accelZ);

// process motion
gamepadMotion.ProcessMotion(iMU_STATE.gyroX, iMU_STATE.gyroY, iMU_STATE.gyroZ, iMU_STATE.accelX, iMU_STATE.accelY, iMU_STATE.accelZ, delta);
}
Expand Down
12 changes: 5 additions & 7 deletions HandheldCompanion/Controllers/LegionController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using HandheldCompanion.Managers;
using HandheldCompanion.Utils;
using HidLibrary;
using SharpDX.XInput;
using System;
using System.Collections.Generic;
using System.Numerics;
Expand All @@ -13,15 +12,14 @@
using System.Windows;
using System.Windows.Forms;
using static HandheldCompanion.Devices.Lenovo.SapientiaUsb;
using static JSL;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrackBar;

namespace HandheldCompanion.Controllers
{
public class LegionController : XInputController
{
// Import the user32.dll library
[DllImport("user32.dll", SetLastError = true)][return: MarshalAs(UnmanagedType.Bool)]
[DllImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool SystemParametersInfo(uint uiAction, uint uiParam, ref uint pvParam, uint fWinIni);

[Flags]
Expand Down Expand Up @@ -58,7 +56,7 @@ private enum ControllerState
private const byte LCONTROLLER_STATE_IDX = 11;
private const byte RCONTROLLER_STATE_IDX = 12;

private HashSet<int> READY_STATES = new HashSet<int>() {25, 60};
private HashSet<int> READY_STATES = new HashSet<int>() { 25, 60 };

private Thread dataThread;
private bool dataThreadRunning;
Expand All @@ -84,7 +82,7 @@ public override bool IsWireless
}

private bool IsPassthrough = false;
private int GyroIndex = LegionGo.RightJoyconIndex;
private int GyroIndex = LegionGo.RightJoyconIndex;

private uint LongPressTime = 1000; // The minimum time in milliseconds for a long press
private const int MaxDistance = 40; // Maximum distance tolerance between touch and untouch in pixels
Expand Down Expand Up @@ -384,7 +382,7 @@ public override string GetGlyph(ButtonFlags button)
case ButtonFlags.B8:
return "\u27F1"; // Scroll down
}

return base.GetGlyph(button);
}

Expand Down
3 changes: 1 addition & 2 deletions HandheldCompanion/Controllers/NeptuneController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using static JSL;

namespace HandheldCompanion.Controllers;

Expand Down Expand Up @@ -277,7 +276,7 @@ private void Close()

// remove handler
Controller.OnControllerInputReceived = null;

Controller.Close();
isConnected = false;
}
Expand Down
1 change: 0 additions & 1 deletion HandheldCompanion/Controllers/ProController.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using HandheldCompanion.Inputs;
using HandheldCompanion.Managers;
using HandheldCompanion.Utils;
using System.Collections.Generic;
using static JSL;

namespace HandheldCompanion.Controllers;
Expand Down
1 change: 0 additions & 1 deletion HandheldCompanion/Controllers/SteamController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using HandheldCompanion.Inputs;
using HandheldCompanion.Managers;
using SharpDX.XInput;
using steam_hidapi.net.Hid;
using System;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using HandheldCompanion.Devices;
using HandheldCompanion.Utils;
using HandheldCompanion.Views;
using System;
using System.Collections.Generic;
using System.Diagnostics;
Expand Down
8 changes: 1 addition & 7 deletions HandheldCompanion/Controls/Hints/Hint_MSIClawCenter.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
using HandheldCompanion.Devices;
using HandheldCompanion.Utils;
using HandheldCompanion.Views;
using Microsoft.Win32.TaskScheduler;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Threading.Tasks;
using System.Timers;
using System.Windows;
using static Microsoft.WindowsAPICodePack.Shell.PropertySystem.SystemProperties.System;
using Task = System.Threading.Tasks.Task;
using TaskScheduled = Microsoft.Win32.TaskScheduler.Task;

namespace HandheldCompanion.Controls.Hints
Expand Down Expand Up @@ -63,7 +57,7 @@ private bool HasTask()
TaskScheduled task = GetTask();
if (task is null)
return false;

return task.Enabled;
}

Expand Down
3 changes: 1 addition & 2 deletions HandheldCompanion/Controls/Hints/Hint_RogAllyServiceCheck.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using HandheldCompanion.Devices;
using HandheldCompanion.Utils;
using HandheldCompanion.Views;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -60,7 +59,7 @@ public Hint_RogAllyServiceCheck() : base()

private void ServiceTimer_Elapsed(object? sender, ElapsedEventArgs e)
{
if(!serviceControllers.Any())
if (!serviceControllers.Any())
return;

// Check if any of the services in the list exist and are running
Expand Down
3 changes: 0 additions & 3 deletions HandheldCompanion/Devices/AYANEO/AYANEO2.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using HandheldCompanion.Inputs;
using System.Collections.Generic;
using WindowsInput.Events;
namespace HandheldCompanion.Devices;

public class AYANEO2 : AYANEO.AYANEODeviceCEc
Expand Down
2 changes: 1 addition & 1 deletion HandheldCompanion/Devices/AYANEO/AYANEOKUN.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public AYANEOKUN()

protected override byte[] MapColorValues(int zone, Color color)
{
switch(zone)
switch (zone)
{
case 1:
return [color.G, color.R, color.B];
Expand Down
4 changes: 1 addition & 3 deletions HandheldCompanion/Devices/IDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;
using System.Threading;
using System.Windows.Media;
using Windows.Devices.Sensors;
using WindowsInput.Events;
using static HandheldCompanion.OneEuroFilter;
using static HandheldCompanion.OpenLibSys;
using static HandheldCompanion.Utils.DeviceUtils;

Expand Down Expand Up @@ -757,7 +755,7 @@ protected virtual void SendECData(byte data)
protected bool IsECReady()
{
DateTime timeout = DateTime.Now.AddMilliseconds(250);
while(DateTime.Now < timeout)
while (DateTime.Now < timeout)
{
if ((ECRamReadByte(EC_SC) & EC_IBF) == 0x0)
{
Expand Down
6 changes: 3 additions & 3 deletions HandheldCompanion/Devices/Lenovo/LegionGo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ public LegionGo()
DynamicLightingCapabilities |= LEDLevel.Wheel;

// Legion Go - Quiet
DevicePowerProfiles.Add(new(Properties.Resources.PowerProfileLegionGoBetterBattery, Properties.Resources.PowerProfileLegionGoBetterBatteryDesc)
DevicePowerProfiles.Add(new(Properties.Resources.PowerProfileLegionGoBetterBattery, Properties.Resources.PowerProfileLegionGoBetterBatteryDesc)
{
Default = true,
DeviceDefault = true,
OSPowerMode = OSPowerMode.BetterBattery,
CPUBoostLevel = CPUBoostLevel.Disabled,
OEMPowerMode = (int) LegionMode.Quiet,
OEMPowerMode = (int)LegionMode.Quiet,
Guid = new("961cc777-2547-4f9d-8174-7d86181b8a7a"),
TDPOverrideEnabled = true,
TDPOverrideValues = new[] { 8.0d, 8.0d, 8.0d }
Expand Down Expand Up @@ -202,7 +202,7 @@ public LegionGo()
));

// device specific layout
DefaultLayout.AxisLayout[AxisLayoutFlags.RightPad] = new MouseActions {MouseType = MouseActionsType.Move, Filtering = true, Sensivity = 15 };
DefaultLayout.AxisLayout[AxisLayoutFlags.RightPad] = new MouseActions { MouseType = MouseActionsType.Move, Filtering = true, Sensivity = 15 };

DefaultLayout.ButtonLayout[ButtonFlags.RightPadClick] = new List<IActions>() { new MouseActions { MouseType = MouseActionsType.LeftButton, HapticMode = HapticMode.Down, HapticStrength = HapticStrength.Low } };
DefaultLayout.ButtonLayout[ButtonFlags.RightPadClickDown] = new List<IActions>() { new MouseActions { MouseType = MouseActionsType.RightButton, HapticMode = HapticMode.Down, HapticStrength = HapticStrength.High } };
Expand Down
2 changes: 1 addition & 1 deletion HandheldCompanion/Devices/MSI/ClawA1M.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using HandheldCompanion.Inputs;
using HandheldCompanion.Managers;
using HandheldCompanion.Utils;
using System;
using HidLibrary;
using System;
using System.Collections.Generic;
using System.Management;
using System.Numerics;
Expand Down
2 changes: 1 addition & 1 deletion HandheldCompanion/Devices/OneXPlayer/OneXPlayerOneXFly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public override bool SetLedBrightness(int brightness)

// Define the HID message for setting brightness.
byte[] msg = { 0x00, 0x07, 0xFF, 0xFD, 0x01, 0x05, (byte)brightness };

// Write the HID message to set the LED brightness.
hidDevice.Write(msg);

Expand Down
8 changes: 4 additions & 4 deletions HandheldCompanion/Extensions/GlyphExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ public static string ToGlyph(this MotionInput motionInput)
return "\uF119";
case MotionInput.WorldSpace:
return "\uE714";
/*
case MotionInput.AutoRollYawSwap:
return "\uE7F8";
*/
/*
case MotionInput.AutoRollYawSwap:
return "\uE7F8";
*/
case MotionInput.JoystickSteering:
return "\uEC47";
}
Expand Down
3 changes: 1 addition & 2 deletions HandheldCompanion/GraphicsProcessingUnit/AMDGPU.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using SharpDX.Direct3D9;
using System;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Timers;
using static HandheldCompanion.ADLX.ADLXBackend;
Expand All @@ -29,7 +28,7 @@ public bool HasRSRSupport()

return Execute(ADLXBackend.HasRSRSupport, false);
}

public override bool HasIntegerScalingSupport()
{
if (!IsInitialized)
Expand Down
1 change: 0 additions & 1 deletion HandheldCompanion/GraphicsProcessingUnit/GPU.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using SharpDX.Direct3D9;
using System;
using System.Management;
using System.Threading;
using System.Threading.Tasks;
using Task = System.Threading.Tasks.Task;
using Timer = System.Timers.Timer;
Expand Down
8 changes: 4 additions & 4 deletions HandheldCompanion/IGCL/IGCLBackend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ internal static bool GetGPUScaling(nint deviceIdx, uint displayIdx)
{
handle = device
};

Result = GetScalingSettings(hDevice, displayIdx, ref ScalingSettings);
if (Result != ctl_result_t.CTL_RESULT_SUCCESS)
return false;
Expand All @@ -600,7 +600,7 @@ internal static bool SetGPUScaling(nint deviceIdx, uint displayIdx, bool enabled
{
handle = device
};

Result = GetScalingSettings(hDevice, displayIdx, ref ScalingSettings);
if (Result != ctl_result_t.CTL_RESULT_SUCCESS)
return false;
Expand Down Expand Up @@ -686,7 +686,7 @@ internal static bool SetScalingMode(nint deviceIdx, uint displayIdx, int mode)
{
handle = device
};

Result = GetScalingSettings(hDevice, displayIdx, ref ScalingSettings);
if (Result != ctl_result_t.CTL_RESULT_SUCCESS)
return false;
Expand Down Expand Up @@ -875,7 +875,7 @@ internal static bool SetIntegerScaling(nint deviceIdx, bool enabled, byte type)
// fill custom scaling details
RetroScalingSettings.Enable = enabled;
RetroScalingSettings.RetroScalingType = RetroScalingType;

Result = SetRetroScalingSettings(hDevice, RetroScalingSettings);
if (Result != ctl_result_t.CTL_RESULT_SUCCESS)
return false;
Expand Down
3 changes: 1 addition & 2 deletions HandheldCompanion/Inputs/GyroState.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using HandheldCompanion.Devices;
using System;
using System;
using System.Collections.Generic;
using System.Numerics;

Expand Down
Loading

0 comments on commit 2e4a8d1

Please sign in to comment.