SDL: testmouse: Create the window on the touch screen when building for the 3DS (723cb)

From 723cbf4b8eb415e7bba354fbc33a6d3f13ebf210 Mon Sep 17 00:00:00 2001
From: Cameron Cawley <[EMAIL REDACTED]>
Date: Sat, 13 Apr 2024 23:23:18 +0100
Subject: [PATCH] testmouse: Create the window on the touch screen when
 building for the 3DS

---
 test/testmouse.c | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/test/testmouse.c b/test/testmouse.c
index 496bb5eac02cd..d5954231919f6 100644
--- a/test/testmouse.c
+++ b/test/testmouse.c
@@ -20,9 +20,15 @@
 
 #include <stdlib.h> /* exit() */
 
-#ifdef SDL_PLATFORM_IOS
-#define SCREEN_WIDTH  320
-#define SCREEN_HEIGHT 480
+#ifdef SDL_PLATFORM_3DS
+/* For mouse-based tests, we want to have the window on the touch screen */
+#define SCREEN_X 40
+#define SCREEN_Y 240
+#define SCREEN_WIDTH    320
+#define SCREEN_HEIGHT   240
+#elif defined(SDL_PLATFORM_IOS)
+#define SCREEN_WIDTH    320
+#define SCREEN_HEIGHT   480
 #else
 #define SCREEN_WIDTH  640
 #define SCREEN_HEIGHT 480
@@ -258,6 +264,9 @@ int main(int argc, char *argv[])
 {
     struct mouse_loop_data loop_data;
     SDLTest_CommonState *state;
+#ifdef SDL_PLATFORM_3DS
+    SDL_PropertiesID props;
+#endif
 
     /* Initialize test framework */
     state = SDLTest_CommonCreateState(argv, 0);
@@ -280,7 +289,18 @@ int main(int argc, char *argv[])
     }
 
     /* Create a window to display joystick axis position */
+#ifdef SDL_PLATFORM_3DS
+    props = SDL_CreateProperties();
+    SDL_SetStringProperty(props, SDL_PROP_WINDOW_CREATE_TITLE_STRING, "Mouse Test");
+    SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_X_NUMBER, SCREEN_X);
+    SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_Y_NUMBER, SCREEN_Y);
+    SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER, SCREEN_WIDTH);
+    SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_HEIGHT_NUMBER, SCREEN_HEIGHT);
+    SDL_SetNumberProperty(props, "flags", 0);
+    window = SDL_CreateWindowWithProperties(props);
+#else
     window = SDL_CreateWindow("Mouse Test", SCREEN_WIDTH, SCREEN_HEIGHT, 0);
+#endif
     if (!window) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError());
         return 0;