Fixed SDL_GetNumGamepadTouchpads() returning 1 for a NULL gamepad

This commit is contained in:
Sam Lantinga
2025-02-12 10:04:22 -08:00
parent ca29304ce1
commit d2b7a84651

View File

@@ -3054,7 +3054,7 @@ SDL_GamepadButtonLabel SDL_GetGamepadButtonLabel(SDL_Gamepad *gamepad, SDL_Gamep
*/
int SDL_GetNumGamepadTouchpads(SDL_Gamepad *gamepad)
{
int result = true;
int result = 0;
SDL_LockJoysticks();
{
@@ -3073,7 +3073,7 @@ int SDL_GetNumGamepadTouchpads(SDL_Gamepad *gamepad)
*/
int SDL_GetNumGamepadTouchpadFingers(SDL_Gamepad *gamepad, int touchpad)
{
int result = true;
int result = 0;
SDL_LockJoysticks();
{
@@ -3081,8 +3081,6 @@ int SDL_GetNumGamepadTouchpadFingers(SDL_Gamepad *gamepad, int touchpad)
if (joystick) {
if (touchpad >= 0 && touchpad < joystick->ntouchpads) {
result = joystick->touchpads[touchpad].nfingers;
} else {
result = SDL_InvalidParamError("touchpad");
}
}
}
@@ -3326,7 +3324,7 @@ SDL_JoystickID SDL_GetGamepadID(SDL_Gamepad *gamepad)
SDL_PropertiesID SDL_GetGamepadProperties(SDL_Gamepad *gamepad)
{
SDL_PropertiesID result = true;
SDL_PropertiesID result = 0;
SDL_LockJoysticks();
{