sanity checks in controller shit (#611)

This commit is contained in:
minenice55 2024-01-06 22:56:02 -05:00 committed by GitHub
parent 522f603412
commit 84d766bb7e

View file

@ -47,7 +47,7 @@ namespace HeavenStudio
public static InputController.ControlStyles CurrentControlStyle = InputController.ControlStyles.Pad; public static InputController.ControlStyles CurrentControlStyle = InputController.ControlStyles.Pad;
static List<InputController> inputDevices; static List<InputController> inputDevices = new List<InputController>();
public delegate InputController[] InputControllerInitializer(); public delegate InputController[] InputControllerInitializer();
@ -126,6 +126,7 @@ namespace HeavenStudio
//so such controllers should have a reference to the other controller in the pair //so such controllers should have a reference to the other controller in the pair
foreach (InputController i in inputDevices) foreach (InputController i in inputDevices)
{ {
if (i == null) continue;
if (i.GetPlayer() == player) if (i.GetPlayer() == player)
{ {
return i; return i;
@ -142,6 +143,7 @@ namespace HeavenStudio
//controller IDs are determined by connection order (the Keyboard is always first) //controller IDs are determined by connection order (the Keyboard is always first)
for (int i = 0; i < inputDevices.Count; i++) for (int i = 0; i < inputDevices.Count; i++)
{ {
if (inputDevices[i] == null) continue;
if (inputDevices[i].GetPlayer() == player) if (inputDevices[i].GetPlayer() == player)
{ {
return i; return i;
@ -152,8 +154,10 @@ namespace HeavenStudio
public static void UpdateInputControllers() public static void UpdateInputControllers()
{ {
if (inputDevices == null) return;
foreach (InputController i in inputDevices) foreach (InputController i in inputDevices)
{ {
if (i == null) continue;
i.UpdateState(); i.UpdateState();
} }
} }