Skip to content

Commit

Permalink
Merge branch 'main' into pr/936
Browse files Browse the repository at this point in the history
  • Loading branch information
CasperH2O committed Jan 12, 2024
2 parents ce45fef + a93ddab commit 5ebcf59
Show file tree
Hide file tree
Showing 12 changed files with 413 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ labels: bug
- [ ] GPD
- [ ] ONEXPLAYER
- [ ] VALVE
- [ ] LENOVO

**Device model**
Your device model
Expand Down
5 changes: 5 additions & 0 deletions HandheldCompanion/Controllers/NeptuneController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,11 @@ public override void Unplug()
base.Unplug();
}

public override void Cleanup()

Check failure on line 349 in HandheldCompanion/Controllers/NeptuneController.cs

View workflow job for this annotation

GitHub Actions / Build and Release

'NeptuneController.Cleanup()': no suitable method found to override

Check failure on line 349 in HandheldCompanion/Controllers/NeptuneController.cs

View workflow job for this annotation

GitHub Actions / Build and Release

'NeptuneController.Cleanup()': no suitable method found to override
{
TimerManager.Tick -= UpdateInputs;
}

public bool GetHapticIntensity(byte? input, sbyte minIntensity, sbyte maxIntensity, out sbyte output)
{
output = default;
Expand Down
60 changes: 60 additions & 0 deletions HandheldCompanion/Controls/Hints/Hint_HWiNFO12hLimitPassed.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using HandheldCompanion.Managers;
using HandheldCompanion.Platforms;
using System;
using System.Windows;

namespace HandheldCompanion.Controls.Hints
{
public class Hint_HWiNFO12hLimitPassed : IHint
{
public Hint_HWiNFO12hLimitPassed() : base()
{
PlatformManager.HWiNFO.Updated += HWiNFO_Updated;
PlatformManager.HWiNFO.SettingValueChanged += HWiNFO_SettingValueChanged;

PlatformManager.Initialized += PlatformManager_Initialized;

// default state
this.HintActionButton.Visibility = Visibility.Collapsed;

this.HintTitle.Text = Properties.Resources.Hint_HWiNFO12hLimitPassed;
this.HintDescription.Text = Properties.Resources.Hint_HWiNFO12hLimitPassedDesc;
this.HintReadMe.Text = Properties.Resources.Hint_HWiNFO12hLimitPassedReadme;
}

private void HWiNFO_Updated(PlatformStatus status)
{
CheckSettings();
}

private void HWiNFO_SettingValueChanged(string name, object value)
{
// UI thread (async)
Application.Current.Dispatcher.BeginInvoke(() =>
{
switch(name)
{
case "SensorsSM":
this.Visibility = Convert.ToBoolean(value) ? Visibility.Collapsed : Visibility.Visible;
break;
}
});
}

private void PlatformManager_Initialized()
{
CheckSettings();
}

private void CheckSettings()
{
bool SensorsSM = PlatformManager.HWiNFO.GetProperty("SensorsSM");
HWiNFO_SettingValueChanged("SensorsSM", SensorsSM);
}

public override void Stop()
{
base.Stop();
}
}
}
81 changes: 81 additions & 0 deletions HandheldCompanion/Controls/Hints/Hint_LegionGoDaemon.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
using HandheldCompanion.Devices;
using HandheldCompanion.Views;
using Microsoft.Win32.TaskScheduler;
using System.Diagnostics;
using System.Linq;
using System.Timers;
using System.Windows;
using Task = System.Threading.Tasks.Task;

namespace HandheldCompanion.Controls.Hints
{
public class Hint_LegionGoDaemon : IHint
{
private Process process;
private const string taskName = "LSDaemon";
private Timer taskTimer;

public Hint_LegionGoDaemon() : base()
{
if (MainWindow.CurrentDevice is not LegionGo)
return;

taskTimer = new Timer(4000);
taskTimer.Elapsed += TaskTimer_Elapsed;
taskTimer.Start();

// default state
this.HintActionButton.Visibility = Visibility.Visible;

this.HintTitle.Text = Properties.Resources.Hint_LegionGoDaemon;
this.HintDescription.Text = Properties.Resources.Hint_LegionGoDaemonDesc;
this.HintReadMe.Text = Properties.Resources.Hint_LegionGoDaemonReadme;

this.HintActionButton.Content = Properties.Resources.Hint_LegionGoDaemonAction;
}

private void TaskTimer_Elapsed(object? sender, ElapsedEventArgs e)
{
// Get all the processes with the given name
process = Process.GetProcessesByName(taskName).FirstOrDefault();

// If there is at least one process, return true
// UI thread (async)
Application.Current.Dispatcher.BeginInvoke(() =>
{
if (process is not null && !process.HasExited)
this.Visibility = Visibility.Visible;
else
this.Visibility = Visibility.Collapsed;
});
}

protected override void HintActionButton_Click(object sender, RoutedEventArgs e)
{
Task.Run(async () =>
{
// Get the task service instance
using (TaskService ts = new TaskService())
{
// Get the task by name
Microsoft.Win32.TaskScheduler.Task task = ts.GetTask(taskName);
if (task != null && task.State == TaskState.Running)
{
task.Stop();
task.Enabled = false;
}
}
});

// If the process exists and is running, kill it
if (process != null && !process.HasExited)
process.Kill();
}

public override void Stop()
{
taskTimer.Stop();
base.Stop();
}
}
}
107 changes: 107 additions & 0 deletions HandheldCompanion/Controls/Hints/Hint_LegionGoServices.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
using HandheldCompanion.Devices;
using HandheldCompanion.Utils;
using HandheldCompanion.Views;
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceProcess;
using System.Threading.Tasks;
using System.Timers;
using System.Windows;

namespace HandheldCompanion.Controls.Hints
{
public class Hint_LegionGoServices : IHint
{
private List<string> serviceNames = new()
{
"DAService",
};

private List<ServiceController> serviceControllers = new();
private Timer serviceTimer;

public Hint_LegionGoServices() : base()
{
if (MainWindow.CurrentDevice is not LegionGo)
return;

// Get all the services installed on the local computer
ServiceController[] services = ServiceController.GetServices();
foreach (string serviceName in serviceNames)
{
if (services.Any(s => serviceNames.Contains(s.ServiceName)))
{
// Create a service controller object for the specified service
ServiceController serviceController = new ServiceController(serviceName);
serviceControllers.Add(serviceController);
}
}

// Check if any of the services in the list exist
if (!serviceControllers.Any())
return;

serviceTimer = new Timer(4000);
serviceTimer.Elapsed += ServiceTimer_Elapsed;
serviceTimer.Start();

// default state
this.HintActionButton.Visibility = Visibility.Visible;

this.HintTitle.Text = Properties.Resources.Hint_LegionGoServices;
this.HintDescription.Text = Properties.Resources.Hint_LegionGoServicesDesc;
this.HintReadMe.Text = Properties.Resources.Hint_LegionGoServicesReadme;

this.HintActionButton.Content = Properties.Resources.Hint_LegionGoServicesAction;
}

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

// Check if any of the services in the list exist and are running
bool anyRunning = false;

foreach (ServiceController serviceController in serviceControllers)
{
serviceController.Refresh();
if (serviceController.Status == ServiceControllerStatus.Running)
{
anyRunning = true;
break;
}
}

// UI thread (async)
Application.Current.Dispatcher.BeginInvoke(() =>
{
this.Visibility = anyRunning ? Visibility.Visible : Visibility.Collapsed;
});
}

protected override void HintActionButton_Click(object sender, RoutedEventArgs e)
{
if (!serviceControllers.Any())
return;

Task.Run(async () =>
{
foreach (ServiceController serviceController in serviceControllers)
{
if (serviceController.Status == ServiceControllerStatus.Running)
serviceController.Stop();
serviceController.WaitForStatus(ServiceControllerStatus.Stopped);
ServiceUtils.ChangeStartMode(serviceController, ServiceStartMode.Disabled, out _);
}
});
}

public override void Stop()
{
serviceTimer.Stop();
base.Stop();
}
}
}
15 changes: 15 additions & 0 deletions HandheldCompanion/Devices/AOKZOE/AOKZOEA1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,19 @@ public override string GetGlyph(ButtonFlags button)

return defaultGlyph;
}

public override string GetGlyph(ButtonFlags button)

Check failure on line 132 in HandheldCompanion/Devices/AOKZOE/AOKZOEA1.cs

View workflow job for this annotation

GitHub Actions / Build and Release

Type 'AOKZOEA1' already defines a member called 'GetGlyph' with the same parameter types

Check failure on line 132 in HandheldCompanion/Devices/AOKZOE/AOKZOEA1.cs

View workflow job for this annotation

GitHub Actions / Build and Release

Type 'AOKZOEA1' already defines a member called 'GetGlyph' with the same parameter types
{
switch (button)
{
case ButtonFlags.OEM1:
return "\u220C";
case ButtonFlags.OEM2:
return "\u2210";
case ButtonFlags.OEM3:
return "\u2211";
}

return defaultGlyph;
}
}
15 changes: 15 additions & 0 deletions HandheldCompanion/Devices/AYANEO/AYANEO2021.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,19 @@ public override string GetGlyph(ButtonFlags button)

return defaultGlyph;
}

public override string GetGlyph(ButtonFlags button)

Check failure on line 73 in HandheldCompanion/Devices/AYANEO/AYANEO2021.cs

View workflow job for this annotation

GitHub Actions / Build and Release

Type 'AYANEO2021' already defines a member called 'GetGlyph' with the same parameter types

Check failure on line 73 in HandheldCompanion/Devices/AYANEO/AYANEO2021.cs

View workflow job for this annotation

GitHub Actions / Build and Release

Type 'AYANEO2021' already defines a member called 'GetGlyph' with the same parameter types
{
switch (button)
{
case ButtonFlags.OEM1:
return "\uE008";
case ButtonFlags.OEM2:
return "\u242F";
case ButtonFlags.OEM3:
return "\u243D";
}

return defaultGlyph;
}
}
13 changes: 13 additions & 0 deletions HandheldCompanion/Devices/GPD/GPDWinMax2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,17 @@ public override string GetGlyph(ButtonFlags button)

return defaultGlyph;
}

public override string GetGlyph(ButtonFlags button)

Check failure on line 61 in HandheldCompanion/Devices/GPD/GPDWinMax2.cs

View workflow job for this annotation

GitHub Actions / Build and Release

Type 'GPDWinMax2' already defines a member called 'GetGlyph' with the same parameter types

Check failure on line 61 in HandheldCompanion/Devices/GPD/GPDWinMax2.cs

View workflow job for this annotation

GitHub Actions / Build and Release

Type 'GPDWinMax2' already defines a member called 'GetGlyph' with the same parameter types
{
switch (button)
{
case ButtonFlags.OEM2:
return "\u220E";
case ButtonFlags.OEM3:
return "\u220F";
}

return defaultGlyph;
}
}
14 changes: 14 additions & 0 deletions HandheldCompanion/Devices/OneXPlayer/OneXPlayerMini.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,20 @@ public override string GetGlyph(ButtonFlags button)

return defaultGlyph;
}
public override string GetGlyph(ButtonFlags button)

Check failure on line 75 in HandheldCompanion/Devices/OneXPlayer/OneXPlayerMini.cs

View workflow job for this annotation

GitHub Actions / Build and Release

Type 'OneXPlayerMini' already defines a member called 'GetGlyph' with the same parameter types

Check failure on line 75 in HandheldCompanion/Devices/OneXPlayer/OneXPlayerMini.cs

View workflow job for this annotation

GitHub Actions / Build and Release

Type 'OneXPlayerMini' already defines a member called 'GetGlyph' with the same parameter types
{
switch (button)
{
case ButtonFlags.OEM1:
return "\u2219";
case ButtonFlags.OEM2:
return "\u2210";
case ButtonFlags.OEM3:
return "\u2218";
}

return defaultGlyph;
}

public override bool Open()
{
Expand Down
Binary file added HandheldCompanion/GraphSettings.dll
Binary file not shown.
Binary file added HandheldCompanion/PerformanceMetrics.dll
Binary file not shown.
Loading

0 comments on commit 5ebcf59

Please sign in to comment.