Skip to content

Commit

Permalink
check for empty gamepad list
Browse files Browse the repository at this point in the history
  • Loading branch information
nkast committed Sep 14, 2024
1 parent 74a9272 commit 40ab96b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Wasm.Dom/Dom/Navigator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace nkast.Wasm.Dom
public class Navigator : JSObject
{
private readonly Window _window;
static Gamepad[] _emptyGamepadArray = new Gamepad[0];

private Dictionary<int,Gamepad> _gamepadMap = new Dictionary<int, Gamepad>();

Expand All @@ -32,6 +33,9 @@ public Gamepad[] GetGamepads()
{
string str = InvokeRet<string>("nkNavigator.GetGamepads");

if (str == String.Empty)
return _emptyGamepadArray;

string[] strs = str.Split(',');
Gamepad[] gamepads = new Gamepad[strs.Length];

Expand Down

0 comments on commit 40ab96b

Please sign in to comment.