Browse Source

Fixed return value of SDL_AddGamepadMapping()

Fixes https://github.com/libsdl-org/SDL/issues/11095
Sam Lantinga 10 months ago
parent
commit
03b259893a
1 changed files with 5 additions and 4 deletions
  1. 5 4
      src/joystick/SDL_gamepad.c

+ 5 - 4
src/joystick/SDL_gamepad.c

@@ -1935,12 +1935,13 @@ static int SDL_PrivateAddGamepadMapping(const char *mappingString, SDL_GamepadMa
     bool is_xinput_mapping = false;
     bool is_xinput_mapping = false;
     bool existing = false;
     bool existing = false;
     GamepadMapping_t *pGamepadMapping;
     GamepadMapping_t *pGamepadMapping;
-    int result = false;
+    int result = -1;
 
 
     SDL_AssertJoysticksLocked();
     SDL_AssertJoysticksLocked();
 
 
     if (!mappingString) {
     if (!mappingString) {
-        return SDL_InvalidParamError("mappingString");
+        SDL_InvalidParamError("mappingString");
+        return -1;
     }
     }
 
 
     { // Extract and verify the hint field
     { // Extract and verify the hint field
@@ -1992,7 +1993,7 @@ static int SDL_PrivateAddGamepadMapping(const char *mappingString, SDL_GamepadMa
                     value = !value;
                     value = !value;
                 }
                 }
                 if (!value) {
                 if (!value) {
-                    result = true;
+                    result = 0;
                     goto done;
                     goto done;
                 }
                 }
             }
             }
@@ -2041,7 +2042,7 @@ static int SDL_PrivateAddGamepadMapping(const char *mappingString, SDL_GamepadMa
     }
     }
 
 
     if (existing) {
     if (existing) {
-        result = true;
+        result = 0;
     } else {
     } else {
         if (is_default_mapping) {
         if (is_default_mapping) {
             s_pDefaultMapping = pGamepadMapping;
             s_pDefaultMapping = pGamepadMapping;