SDL: Return the touch device name for SDL_TOUCH_MOUSEID (9848c)

From 9848c32d9a87153947dac73e0c69eb54c89049c9 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 13 May 2026 09:07:36 -0700
Subject: [PATCH] Return the touch device name for SDL_TOUCH_MOUSEID

(cherry picked from commit 3dbd3e43e293931cfa7b356e09fca8e89aac5e53)
---
 src/events/SDL_mouse.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c
index 96641495ae59b..eaf1f2cdfdfb0 100644
--- a/src/events/SDL_mouse.c
+++ b/src/events/SDL_mouse.c
@@ -428,7 +428,17 @@ const char *SDL_GetMouseNameForID(SDL_MouseID instance_id)
         name = "Mouse";
         break;
     case SDL_TOUCH_MOUSEID:
-        name = "Touch";
+        // We can't tell which touch device it was, just use the first one
+        {
+            SDL_TouchID *devices = SDL_GetTouchDevices(NULL);
+            if (devices) {
+                name = SDL_GetTouchDeviceName(devices[0]);
+                SDL_free(devices);
+            }
+        }
+        if (!name) {
+            name = "Touch";
+        }
         break;
     case SDL_PEN_MOUSEID:
         name = "Pen";