mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2026-01-10 02:30:59 +01:00
Recreate X360 device on fatal failure (might happen after resume)
This commit is contained in:
parent
fdb94c42ed
commit
8ff22739c5
|
|
@ -19,3 +19,4 @@
|
|||
- Allow to assign BackPanel keys to X360 controller (breaks all current configs to set mappings)
|
||||
- All SteamDeckTools settings are stored in `.ini` file in root folder
|
||||
- Detect SAS (Secure Attention Sequence) in a way that does not prevent screen sleep
|
||||
- Recreate X360 device on fatal failure (might happen after resume)
|
||||
|
|
|
|||
|
|
@ -66,6 +66,18 @@ namespace SteamController.Devices
|
|||
}
|
||||
}
|
||||
|
||||
private void Fail()
|
||||
{
|
||||
var client = this.client;
|
||||
|
||||
// unset current device
|
||||
this.client = null;
|
||||
this.device = null;
|
||||
|
||||
try { using (client) { } }
|
||||
catch (Exception) { }
|
||||
}
|
||||
|
||||
internal void BeforeUpdate()
|
||||
{
|
||||
device?.ResetReport();
|
||||
|
|
@ -89,13 +101,31 @@ namespace SteamController.Devices
|
|||
|
||||
if (wantsConnected)
|
||||
{
|
||||
device?.Connect();
|
||||
TraceLine("Connected X360 Controller.");
|
||||
try
|
||||
{
|
||||
device?.Connect();
|
||||
TraceLine("Connected X360 Controller.");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
TraceLine("X360: Connect: {0}", e);
|
||||
Fail();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
device?.Disconnect();
|
||||
TraceLine("Disconnected X360 Controller.");
|
||||
try
|
||||
{
|
||||
device?.Disconnect();
|
||||
TraceLine("Disconnected X360 Controller.");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
TraceLine("X360: Disconnect: {0}", e);
|
||||
Fail();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
isConnected = wantsConnected;
|
||||
|
|
|
|||
Loading…
Reference in a new issue