From 03b259893a8a8df80d0b1a35e619d708bef45380 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 6 Oct 2024 14:17:57 -0700 Subject: [PATCH] Fixed return value of SDL_AddGamepadMapping() Fixes https://github.com/libsdl-org/SDL/issues/11095 --- src/joystick/SDL_gamepad.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/joystick/SDL_gamepad.c b/src/joystick/SDL_gamepad.c index e4ad40d80b..bb7904c867 100644 --- a/src/joystick/SDL_gamepad.c +++ b/src/joystick/SDL_gamepad.c @@ -1935,12 +1935,13 @@ static int SDL_PrivateAddGamepadMapping(const char *mappingString, SDL_GamepadMa bool is_xinput_mapping = false; bool existing = false; GamepadMapping_t *pGamepadMapping; - int result = false; + int result = -1; SDL_AssertJoysticksLocked(); if (!mappingString) { - return SDL_InvalidParamError("mappingString"); + SDL_InvalidParamError("mappingString"); + return -1; } { // Extract and verify the hint field @@ -1992,7 +1993,7 @@ static int SDL_PrivateAddGamepadMapping(const char *mappingString, SDL_GamepadMa value = !value; } if (!value) { - result = true; + result = 0; goto done; } } @@ -2041,7 +2042,7 @@ static int SDL_PrivateAddGamepadMapping(const char *mappingString, SDL_GamepadMa } if (existing) { - result = true; + result = 0; } else { if (is_default_mapping) { s_pDefaultMapping = pGamepadMapping;