mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2026-01-03 15:20:05 +01:00
SteamController: Force to reconnect X360 controller on Resume
This commit is contained in:
parent
561138beb3
commit
82a9f63358
|
|
@ -23,3 +23,4 @@
|
|||
- GPU detection will log errors to `Sentry.io`
|
||||
- Support SMU of Vangogh GPU shipped with BIOS 113
|
||||
- Fix Steam Game detection when in X360 controller mode
|
||||
- Force to reconnect X360 controller on Resume
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using Microsoft.Win32;
|
||||
using Nefarius.ViGEm.Client;
|
||||
using Nefarius.ViGEm.Client.Exceptions;
|
||||
using Nefarius.ViGEm.Client.Targets;
|
||||
|
|
@ -21,13 +22,30 @@ namespace SteamController.Devices
|
|||
|
||||
public Xbox360Controller()
|
||||
{
|
||||
Microsoft.Win32.SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
|
||||
}
|
||||
|
||||
~Xbox360Controller()
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
Microsoft.Win32.SystemEvents.PowerModeChanged -= SystemEvents_PowerModeChanged;
|
||||
using (client) { }
|
||||
}
|
||||
|
||||
private void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
|
||||
{
|
||||
if (e.Mode == Microsoft.Win32.PowerModes.Resume)
|
||||
{
|
||||
// Force to reconnect device on resume
|
||||
lock (this) { Fail(); }
|
||||
}
|
||||
}
|
||||
|
||||
internal bool Tick()
|
||||
{
|
||||
if (this.device is not null)
|
||||
|
|
|
|||
Loading…
Reference in a new issue