SDL: testevdev: include SDL_internal.h first, and fixup SDL_main.h

From a65982e15dca1820a1a0c50652bb8ec3b910e3ca Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Mon, 25 Mar 2024 19:55:22 +0100
Subject: [PATCH] testevdev: include SDL_internal.h first, and fixup SDL_main.h

---
 test/testevdev.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/test/testevdev.c b/test/testevdev.c
index d086e45457b7a..f231b12eb85e8 100644
--- a/test/testevdev.c
+++ b/test/testevdev.c
@@ -11,11 +11,10 @@
   freely.
 */
 
-#include <SDL3/SDL.h>
-#include <SDL3/SDL_main.h>
-#include <SDL3/SDL_test.h>
+/* Hack #1: avoid inclusion of SDL_main.h by SDL_internal.h */
+#define SDL_main_h_
 
-/* Hack to avoid dynapi renaming */
+/* Hack #2: avoid dynapi renaming (must be done before #include <SDL3/SDL.h>) */
 #include "../src/dynapi/SDL_dynapi.h"
 #ifdef SDL_DYNAMIC_API
 #undef SDL_DYNAMIC_API
@@ -26,6 +25,18 @@
 #include "../src/SDL_internal.h"
 #endif
 
+/* Hack #3: undo Hack #1 */
+#ifdef SDL_main_h_
+#undef SDL_main_h_
+#endif
+#ifdef SDL_MAIN_NOIMPL
+#undef SDL_MAIN_NOIMPL
+#endif
+
+#include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
+#include <SDL3/SDL_test.h>
+
 #include <stdio.h>
 #include <string.h>