From 36a88afe52d8151f94c7b1d424eefc9a07459a30 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Tue, 14 Nov 2023 11:19:21 -0800 Subject: [PATCH] add no-op delegate to gamepad connect events --- src/Input/Input.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Input/Input.cs b/src/Input/Input.cs index 4700d2cb..e6c1d2d0 100644 --- a/src/Input/Input.cs +++ b/src/Input/Input.cs @@ -41,7 +41,7 @@ namespace MoonWorks.Input /// Called when a gamepad has been connected. /// /// The slot where the connection occurred. - public OnGamepadConnectedFunc OnGamepadConnected; + public OnGamepadConnectedFunc OnGamepadConnected = delegate { }; public delegate void OnGamepadDisconnectedFunc(int slot); @@ -49,7 +49,7 @@ namespace MoonWorks.Input /// Called when a gamepad has been disconnected. /// /// The slot where the disconnection occurred. - public OnGamepadDisconnectedFunc OnGamepadDisconnected; + public OnGamepadDisconnectedFunc OnGamepadDisconnected = delegate { }; internal Inputs() { @@ -142,7 +142,11 @@ namespace MoonWorks.Input { Gamepads[slot].Register(openResult); Logger.LogInfo($"Gamepad added to slot {slot}!"); - OnGamepadConnected(slot); + + if (OnGamepadConnected != null) + { + OnGamepadConnected(slot); + } } return;