mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2026-03-06 13:03:52 +01:00
Improve exception handling for X360 controller
This commit is contained in:
parent
147ef53a7f
commit
9f1288cfb0
|
|
@ -45,6 +45,7 @@ namespace SteamController.Devices
|
|||
}
|
||||
catch (VigemBusNotFoundException)
|
||||
{
|
||||
// ViGem is not installed
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -54,6 +55,7 @@ namespace SteamController.Devices
|
|||
var client = this.client;
|
||||
|
||||
// unset current device
|
||||
this.isConnected = false;
|
||||
this.client = null;
|
||||
this.device = null;
|
||||
|
||||
|
|
@ -91,6 +93,13 @@ namespace SteamController.Devices
|
|||
device?.Connect();
|
||||
TraceLine("Connected X360 Controller.");
|
||||
}
|
||||
catch (System.ComponentModel.Win32Exception e)
|
||||
{
|
||||
// This is expected exception (as sometimes device will fail to connect)
|
||||
TraceException("X360", "ConnectExpected", e);
|
||||
Fail();
|
||||
return;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
TraceException("X360", "Connect", e);
|
||||
|
|
@ -105,6 +114,10 @@ namespace SteamController.Devices
|
|||
device?.Disconnect();
|
||||
TraceLine("Disconnected X360 Controller.");
|
||||
}
|
||||
catch (VigemTargetNotPluggedInException)
|
||||
{
|
||||
// everything fine
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
TraceException("X360", "Disconnect", e);
|
||||
|
|
@ -149,11 +162,14 @@ namespace SteamController.Devices
|
|||
{
|
||||
device?.SubmitReport();
|
||||
}
|
||||
catch (VigemInvalidTargetException e)
|
||||
catch (VigemInvalidTargetException)
|
||||
{
|
||||
// Device was lost
|
||||
lock (this) { Fail(); }
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
TraceException("X360", "SubmitReport", e);
|
||||
device?.Disconnect();
|
||||
isConnected = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue