sdl2-compat: GetIndexFromJoystickInstance: if jid==0, return -1 without searching list.

From ddaf7dcff77f21215a51b01c8766059fa3291901 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Sat, 13 Apr 2024 14:13:46 -0400
Subject: [PATCH] GetIndexFromJoystickInstance: if jid==0, return -1 without
 searching list.

---
 src/sdl2_compat.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index 2ae2086..88f0440 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -6931,10 +6931,12 @@ SDL_NumJoysticks(void)
 
 static int
 GetIndexFromJoystickInstance(SDL_JoystickID jid) {
-    int i;
-    for (i = 0; i < num_joysticks; i++) {
-        if (joystick_list[i] == jid) {
-            return i;
+    if (jid != 0) {
+        int i;
+        for (i = 0; i < num_joysticks; i++) {
+            if (joystick_list[i] == jid) {
+                return i;
+            }
         }
     }
     return -1;