mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2026-04-04 13:57:39 +00:00
Recreate X360 device on fatal failure (might happen after resume)
This commit is contained in:
parent
fdb94c42ed
commit
8ff22739c5
2 changed files with 35 additions and 4 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue