diff --git a/src/Engine/Imp/Graphics/Desktop/InputImp.cs b/src/Engine/Imp/Graphics/Desktop/InputImp.cs index 941340e050..6a6ac6fd0d 100644 --- a/src/Engine/Imp/Graphics/Desktop/InputImp.cs +++ b/src/Engine/Imp/Graphics/Desktop/InputImp.cs @@ -300,7 +300,14 @@ public string Id get { - return GLFW.GetGamepadName(DeviceID); + try + { + return GLFW.GetGamepadName(DeviceID); + } + catch + { + return "No gamepad connected"; + } } } /// @@ -479,11 +486,17 @@ public float GetAxis(int iAxisId) { JoystickState state = _gameWindow.JoystickStates[DeviceID]; if (state != null) - return state.GetAxis(iAxisId); - + { + try + { + return state.GetAxis(iAxisId); + } + catch + { + return 0; + } + } return 0; - - //throw new InvalidOperationException($"Unknown axis {iAxisId}. Cannot get value for unknown axis."); } /// @@ -493,11 +506,17 @@ public bool GetButton(int iButtonId) { JoystickState state = _gameWindow.JoystickStates[DeviceID]; if (state != null) - return state.IsButtonDown(iButtonId); - + { + try + { + return state.IsButtonDown(iButtonId); + } + catch + { + return false; + } + } return false; - - //throw new InvalidOperationException($"Unknown button {iButtonId}. Cannot get value for unknown button."); } }