Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Valkirie committed Jun 22, 2022
1 parent 26d5b1b commit c623348
Show file tree
Hide file tree
Showing 24 changed files with 54 additions and 115 deletions.
3 changes: 1 addition & 2 deletions ControllerCommon/Devices/AYANEO2021.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using static ControllerCommon.OneEuroFilter;
using WindowsInput.Events;
using WindowsInput.Events;

namespace ControllerCommon.Devices
{
Expand Down
1 change: 0 additions & 1 deletion ControllerCommon/Devices/AYANEONEXT.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using WindowsInput.Events;
using static ControllerCommon.OneEuroFilter;

namespace ControllerCommon.Devices
{
Expand Down
61 changes: 30 additions & 31 deletions ControllerCommon/Devices/Device.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Numerics;
using Windows.Devices.Sensors;
using WindowsInput.Events;
using WindowsInput.Events.Sources;
using static ControllerCommon.OneEuroFilter;
using static ControllerCommon.Utils.DeviceUtils;

Expand Down Expand Up @@ -66,45 +65,45 @@ public static Device GetDefault()
switch (ManufacturerName)
{
case "AYANEO":
{
switch (ProductName)
{
case "AYANEO 2021":
case "AYANEO 2021 Pro":
case "AYANEO 2021 Pro Retro Power":
device = new AYANEO2021();
break;
case "NEXT Pro":
case "NEXT Advance":
case "NEXT":
device = new AYANEONEXT();
break;
switch (ProductName)
{
case "AYANEO 2021":
case "AYANEO 2021 Pro":
case "AYANEO 2021 Pro Retro Power":
device = new AYANEO2021();
break;
case "NEXT Pro":
case "NEXT Advance":
case "NEXT":
device = new AYANEONEXT();
break;
}
}
}
break;
break;

case "ONE-NETBOOK TECHNOLOGY CO., LTD.":
{
switch (ProductName)
{
case "ONE XPLAYER":
{
switch (Version)
switch (ProductName)
{
case "ONE XPLAYER":
{
default:
case "V01":
device = new OneXPlayerMiniAMD();
break;
case "1002-C":
device = new OneXPlayerMiniIntel();
break;
switch (Version)
{
default:
case "V01":
device = new OneXPlayerMiniAMD();
break;
case "1002-C":
device = new OneXPlayerMiniIntel();
break;
}
break;
}
break;
}
break;
}
}
}
break;
break;
}

if (device is null)
Expand Down
1 change: 0 additions & 1 deletion ControllerCommon/Devices/OneXPlayerMiniAMD.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Numerics;
using WindowsInput.Events;
using static ControllerCommon.OneEuroFilter;

namespace ControllerCommon.Devices
{
Expand Down
1 change: 0 additions & 1 deletion ControllerCommon/Devices/OneXPlayerMiniIntel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Numerics;
using WindowsInput.Events;
using static ControllerCommon.OneEuroFilter;

namespace ControllerCommon.Devices
{
Expand Down
2 changes: 1 addition & 1 deletion ControllerCommon/Managers/ServiceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public bool Exists()
string output = process.StandardOutput.ReadToEnd();
string error = CommonUtils.Between(output, "FAILED ", ":");

switch(error)
switch (error)
{
case "1060":
return false;
Expand Down
2 changes: 1 addition & 1 deletion ControllerCommon/Managers/SystemManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private PnPDeviceEx GetDeviceEx(PnPDevice owner)

return deviceEx;
}

public List<PnPDeviceEx> GetDeviceExs()
{
devices.Clear();
Expand Down
10 changes: 2 additions & 8 deletions ControllerCommon/TriggerInputs.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
using SharpDX.XInput;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WindowsInput.Events;
using WindowsInput.Events.Sources;

namespace ControllerCommon
{
Expand All @@ -28,7 +22,7 @@ public TriggerInputs(TriggerInputsType type, string value)
this.type = type;
this.raw = value;

switch(type)
switch (type)
{
default:
case TriggerInputsType.Gamepad:
Expand All @@ -52,7 +46,7 @@ public TriggerInputs(TriggerInputsType type, string value, string name) : this(t

public string GetValue()
{
switch(type)
switch (type)
{
default:
case TriggerInputsType.Gamepad:
Expand Down
1 change: 0 additions & 1 deletion ControllerService/ControllerService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using ControllerCommon;
using ControllerCommon.Devices;
using ControllerCommon.Managers;
using ControllerCommon.Sensors;
using ControllerCommon.Utils;
Expand Down
1 change: 0 additions & 1 deletion ControllerService/Sensors/XInputAccelerometer.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using ControllerCommon.Managers;
using ControllerCommon.Sensors;
using ControllerCommon.Utils;
using System.Collections.Generic;
using System.Numerics;
using Windows.Devices.Sensors;
using static ControllerCommon.Utils.DeviceUtils;
Expand Down
1 change: 0 additions & 1 deletion ControllerService/Sensors/XInputGirometer.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using ControllerCommon.Managers;
using ControllerCommon.Sensors;
using ControllerCommon.Utils;
using System.Collections.Generic;
using System.Numerics;
using Windows.Devices.Sensors;
using static ControllerCommon.Utils.DeviceUtils;
Expand Down
1 change: 0 additions & 1 deletion ControllerService/Sensors/XInputInclinometer.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using ControllerCommon.Managers;
using ControllerCommon.Sensors;
using System;
using System.Collections.Generic;
using System.Numerics;
using Windows.Devices.Sensors;
using static ControllerCommon.Utils.DeviceUtils;
Expand Down
1 change: 0 additions & 1 deletion ControllerService/Targets/ViGEmTarget.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using ControllerCommon;
using ControllerCommon.Devices;
using ControllerCommon.Managers;
using ControllerCommon.Utils;
using ControllerService.Sensors;
Expand Down
1 change: 0 additions & 1 deletion HandheldCompanion/Managers/ControllerManager.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using ControllerCommon;
using ControllerCommon.Managers;
using HandheldCompanion.Views;
using SharpDX.XInput;
using System.Collections.Generic;
Expand Down
12 changes: 2 additions & 10 deletions HandheldCompanion/Managers/InputsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,10 @@
using HandheldCompanion.Views;
using SharpDX.XInput;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using WindowsInput;
using WindowsInput.Events;
using WindowsInput.Events.Sources;
using static ControllerCommon.TriggerInputs;
using Timer = System.Timers.Timer;

namespace HandheldCompanion.Managers
{
Expand Down Expand Up @@ -158,7 +149,8 @@ private void M_GlobalHook_KeyEvent(object? sender, KeyEventArgs e)
{
TriggerBuffer.AddRange(Intercepted);
break;
}else if (args.IsKeyUp)
}
else if (args.IsKeyUp)
TriggerRaised?.Invoke(trigger, Triggers[trigger]);
}
else
Expand Down
12 changes: 4 additions & 8 deletions HandheldCompanion/Managers/ProcessManager.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using ControllerCommon;
using ControllerCommon.Managers;
using ControllerCommon.Managers;
using ControllerCommon.Utils;
using ModernWpf.Controls;
using System;
Expand All @@ -11,11 +10,8 @@
using System.Management;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using System.Timers;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Threading;
using Windows.System.Diagnostics;
using Brush = System.Windows.Media.Brush;
Expand Down Expand Up @@ -252,7 +248,7 @@ private void ProcessResume_Click(object sender, RoutedEventArgs e)
{
processResume.IsEnabled = false;
}));

NtResumeProcess(Process.Handle);
Thread.Sleep(500); // breathing
ShowWindow(Process.MainWindowHandle, 9);
Expand Down Expand Up @@ -322,7 +318,7 @@ public void Stop()
if (!isRunning)
return;

foreach(ProcessEx processEx in CurrentProcesses.Values)
foreach (ProcessEx processEx in CurrentProcesses.Values)
processEx.Stop();

// stop processes monitor
Expand Down Expand Up @@ -408,7 +404,7 @@ void ProcessCreated(object sender, EventArrivedEventArgs e)
Process proc = Process.GetProcessById((int)processId);
ProcessCreated(proc);
}
catch(Exception) { }
catch (Exception) { }
}

void ProcessCreated(Process proc)
Expand Down
3 changes: 0 additions & 3 deletions HandheldCompanion/Views/Pages/AboutPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using ControllerCommon;
using ControllerCommon.Devices;
using ControllerCommon.Managers;
using Nefarius.Utilities.DeviceManagement.PnP;
using System;
using System.Windows;
Expand Down
1 change: 0 additions & 1 deletion HandheldCompanion/Views/Pages/ControllerPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using ControllerCommon;
using ControllerCommon.Managers;
using ControllerCommon.Utils;
using HandheldCompanion.Managers;
using System;
Expand Down
8 changes: 2 additions & 6 deletions HandheldCompanion/Views/Pages/OverlayPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
using ControllerCommon;
using ControllerCommon.Utils;
using HandheldCompanion.Managers;
using HandheldCompanion.Models;
using HandheldCompanion.Views.Windows;
using ModernWpf.Controls;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using GamepadButtonFlags = SharpDX.XInput.GamepadButtonFlags;
using Page = System.Windows.Controls.Page;

namespace HandheldCompanion.Views.Pages
Expand Down Expand Up @@ -304,8 +300,8 @@ private void TriggerUpdated(string listener, TriggerInputs input)
Properties.Settings.Default.OverlayTrackpadsTriggerType = (int)input.type;
break;
}
});
});

Properties.Settings.Default.Save();
}

Expand Down
1 change: 0 additions & 1 deletion HandheldCompanion/Views/Pages/SettingsPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using ControllerCommon;
using ControllerCommon.Managers;
using ControllerCommon.Utils;
using HandheldCompanion.Managers;
using ModernWpf;
Expand Down
8 changes: 3 additions & 5 deletions HandheldCompanion/Views/Windows/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
using ControllerCommon.Managers;
using ControllerCommon.Utils;
using HandheldCompanion.Managers;
using HandheldCompanion.Models;
using HandheldCompanion.Views.Pages;
using HandheldCompanion.Views.Windows;
using ModernWpf.Controls;
using Nefarius.Utilities.DeviceManagement.PnP;
using SharpDX.XInput;
using System;
using System.Collections.Generic;
using System.ComponentModel;
Expand Down Expand Up @@ -296,13 +294,13 @@ private void InputsManager_TriggerRaised(string listener, TriggerInputs input)
switch (listener)
{
case "suspender":
suspender.UpdateVisibility();
suspender.UpdateVisibility();
break;
case "overlayGamepad":
overlay.UpdateControllerVisibility();
overlay.UpdateControllerVisibility();
break;
case "overlayTrackpads":
overlay.UpdateTrackpadsVisibility();
overlay.UpdateTrackpadsVisibility();
break;
}
});
Expand Down
9 changes: 3 additions & 6 deletions HandheldCompanion/Views/Windows/Overlay.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using ControllerCommon;
using ControllerCommon.Devices;
using ControllerCommon.Utils;
using HandheldCompanion.Managers;
using HandheldCompanion.Models;
using SharpDX.XInput;
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows;
Expand Down Expand Up @@ -164,7 +161,7 @@ public void UpdateModel()
break;
case OverlayModelMode.Virtual:
{
switch(HIDmode)
switch (HIDmode)
{
default:
case HIDmode.DualShock4Controller:
Expand Down Expand Up @@ -317,7 +314,7 @@ public void UpdateTrackpadsVisibility()
visibility = Visibility.Collapsed;
break;
case Visibility.Collapsed:
case Visibility.Hidden:
case Visibility.Hidden:
visibility = Visibility.Visible;
break;
}
Expand Down Expand Up @@ -668,7 +665,7 @@ private void UpdateModelVisual3D()

// Correction amount for camera, increase slowly
FaceCameraObjectAlignment += DiffAngle * 0.0006; // 0.0015 = ~90 degrees in 30 seconds

// Devices rotates (slowly) towards a default position facing the camara
// Calculation above is done to:
// - "quickly" move to the correct pose when enabled as it's calculated in the background
Expand Down
Loading

0 comments on commit c623348

Please sign in to comment.