sdl2-compat: - fix check "count == 0"

From 2aac4ba34c59effa1570cbcb0e4db8cc61ed6efd Mon Sep 17 00:00:00 2001
From: Sylvain <[EMAIL REDACTED]>
Date: Tue, 31 Jan 2023 20:20:15 +0100
Subject: [PATCH] - fix check "count == 0" - return invalid displaIndex/ID on
 error

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

diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index ee36be2..fbcc961 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -3248,16 +3248,16 @@ static SDL_DisplayID Display_IndexToID(int displayIndex)
 
     list = SDL3_GetDisplays(&count);
 
-    if (list == NULL || list == 0) {
+    if (list == NULL || count == 0) {
         SDL3_SetError("no displays");
         SDL_free(list);
-        return SDL3_GetPrimaryDisplay();
+        return 0;
     }
 
     if (displayIndex < 0 || displayIndex >= count) {
         SDL3_SetError("invalid displayIndex");
         SDL_free(list);
-        return SDL3_GetPrimaryDisplay();
+        return 0;
     }
 
     displayID = list[displayIndex];
@@ -3305,15 +3305,15 @@ Display_IDToIndex(SDL_DisplayID displayID)
 
     if (displayID == 0) {
         SDL3_SetError("invalid displayID");
-        return 0;
+        return -1;
     }
 
     list = SDL3_GetDisplays(&count);
 
-    if (list == NULL || list == 0) {
+    if (list == NULL || count == 0) {
         SDL3_SetError("no displays");
         SDL_free(list);
-        return 0;
+        return -1;
     }
 
     for (i = 0; i < count; i++) {