Jelajahi Sumber

Fixed test programs for joystick not exiting on events after first disconnect.

Exit was broken since the main loop extraction needed for Emscripten support
because the former local but now global variables were not reset correctly.
Philipp Wiesemann 11 tahun lalu
induk
melakukan
d1932834e2
2 mengubah file dengan 11 tambahan dan 0 penghapusan
  1. 8 0
      test/testgamecontroller.c
  2. 3 0
      test/testjoystick.c

+ 8 - 0
test/testgamecontroller.c

@@ -163,6 +163,10 @@ WatchGameController(SDL_GameController * gamecontroller)
     const size_t titlelen = SDL_strlen(basetitle) + SDL_strlen(name) + 1;
     const size_t titlelen = SDL_strlen(basetitle) + SDL_strlen(name) + 1;
     char *title = (char *)SDL_malloc(titlelen);
     char *title = (char *)SDL_malloc(titlelen);
     SDL_Window *window = NULL;
     SDL_Window *window = NULL;
+
+    retval = SDL_FALSE;
+    done = SDL_FALSE;
+
     if (title) {
     if (title) {
         SDL_snprintf(title, titlelen, "%s%s", basetitle, name);
         SDL_snprintf(title, titlelen, "%s%s", basetitle, name);
     }
     }
@@ -219,6 +223,10 @@ WatchGameController(SDL_GameController * gamecontroller)
 #endif
 #endif
 
 
     SDL_DestroyRenderer(screen);
     SDL_DestroyRenderer(screen);
+    screen = NULL;
+    background = NULL;
+    button = NULL;
+    axis = NULL;
     SDL_DestroyWindow(window);
     SDL_DestroyWindow(window);
     return retval;
     return retval;
 }
 }

+ 3 - 0
test/testjoystick.c

@@ -176,6 +176,8 @@ WatchJoystick(SDL_Joystick * joystick)
 {
 {
     SDL_Window *window = NULL;
     SDL_Window *window = NULL;
     const char *name = NULL;
     const char *name = NULL;
+
+    retval = SDL_FALSE;
     done = SDL_FALSE;
     done = SDL_FALSE;
 
 
     /* Create a window to display joystick axis position */
     /* Create a window to display joystick axis position */
@@ -217,6 +219,7 @@ WatchJoystick(SDL_Joystick * joystick)
 #endif
 #endif
 
 
     SDL_DestroyRenderer(screen);
     SDL_DestroyRenderer(screen);
+    screen = NULL;
     SDL_DestroyWindow(window);
     SDL_DestroyWindow(window);
     return retval;
     return retval;
 }
 }