diff --git a/src/rcore.c b/src/rcore.c index 7455e3597..12de4141e 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -3934,7 +3934,11 @@ bool IsGamepadAvailable(int gamepad) // Get gamepad internal name id const char *GetGamepadName(int gamepad) { - return CORE.Input.Gamepad.name[gamepad]; + const char *name = NULL; + + if ((gamepad >= 0) && (gamepad < MAX_GAMEPADS)) name = CORE.Input.Gamepad.name[gamepad]; + + return name; } // Check if gamepad button has been pressed once @@ -3999,7 +4003,11 @@ int GetGamepadButtonPressed(void) // Get gamepad axis count int GetGamepadAxisCount(int gamepad) { - return CORE.Input.Gamepad.axisCount[gamepad]; + int result = 0; + + if ((gamepad >= 0) && (gamepad < MAX_GAMEPADS)) result = CORE.Input.Gamepad.axisCount[gamepad]; + + return result; } // Get axis movement vector for a gamepad