SDL: evdev: fixed devices not being removed on disconnect

From ba1412cb9f46461070f798701e202678328cb0fa Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 23 Oct 2024 10:52:00 -0700
Subject: [PATCH] evdev: fixed devices not being removed on disconnect

---
 src/core/linux/SDL_udev.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/core/linux/SDL_udev.c b/src/core/linux/SDL_udev.c
index ada5a26b74f67..bcd910bb8afbc 100644
--- a/src/core/linux/SDL_udev.c
+++ b/src/core/linux/SDL_udev.c
@@ -487,9 +487,13 @@ static void device_event(SDL_UDEV_deviceevent type, struct udev_device *dev)
         return;
     }
 
-    devclass = device_class(dev);
-    if (!devclass) {
-         return;
+    if (type == SDL_UDEV_DEVICEADDED) {
+        devclass = device_class(dev);
+        if (!devclass) {
+            return;
+        }
+    } else {
+        // The device has been removed, the class isn't available
     }
 
     // Process callbacks