SDL: Show the existing mapping when a controller is connected

From 1934417b4d6db0117a8438e099ea63d8f7cf3d74 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 8 Nov 2023 12:38:54 -0800
Subject: [PATCH] Show the existing mapping when a controller is connected

---
 test/testcontroller.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/test/testcontroller.c b/test/testcontroller.c
index dd4b9819d95f..4fd5627ab096 100644
--- a/test/testcontroller.c
+++ b/test/testcontroller.c
@@ -981,6 +981,14 @@ static void HandleGamepadAdded(SDL_JoystickID id, SDL_bool verbose)
                 SDL_SetGamepadSensorEnabled(gamepad, sensor, SDL_TRUE);
             }
         }
+
+        if (verbose) {
+            char *mapping = SDL_GetGamepadMapping(gamepad);
+            if (mapping) {
+                SDL_Log("Mapping: %s\n", mapping);
+                SDL_free(mapping);
+            }
+        }
     } else {
         SDL_Log("Couldn't open gamepad: %s", SDL_GetError());
     }