Skip to content

Commit

Permalink
Fixed crash when no gamepad is connected
Browse files Browse the repository at this point in the history
  • Loading branch information
Axadiw committed Jan 17, 2016
1 parent d4bd29f commit de13c62
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
27 changes: 20 additions & 7 deletions MFIGamepadFeeder/Gamepads/GamepadManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,16 @@ public void Refresh()
public void SetupGamepad(HidDeviceRepresentation hidDeviceRepresentation, uint gamePadId,
GamepadConfiguration config)
{
var device =
_hidDeviceLoader.GetDevices(
hidDeviceRepresentation.VendorId,
hidDeviceRepresentation.ProductId,
hidDeviceRepresentation.ProductVersion,
hidDeviceRepresentation.SerialNumber
).First();
try
{
var device =
_hidDeviceLoader.GetDevices(
hidDeviceRepresentation.VendorId,
hidDeviceRepresentation.ProductId,
hidDeviceRepresentation.ProductVersion,
hidDeviceRepresentation.SerialNumber
).First();


if (device == null)
{
Expand Down Expand Up @@ -139,13 +142,23 @@ public void SetupGamepad(HidDeviceRepresentation hidDeviceRepresentation, uint g
{
continue;
}
catch (Exception ex)
{
Log(ex.Message);
break;
}

if (count > 0)
{
gamepad.UpdateState(bytes);
}
}
}
}
catch (Exception ex)
{
Log(ex.Message);
}
}

private async Task<GamepadConfiguration> GetConfigFromFilePath(string filePath)
Expand Down
4 changes: 2 additions & 2 deletions MFIGamepadFeeder/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.1.0")]
[assembly: AssemblyFileVersion("1.0.1.0")]

0 comments on commit de13c62

Please sign in to comment.